Panda3D

textureMemoryCounter.h
Go to the documentation of this file.
1 /**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file textureMemoryCounter.h
10 * @author drose
11 * @date 2000-12-19
12 */
13
14 #ifndef TEXTUREMEMORYCOUNTER_H
15 #define TEXTUREMEMORYCOUNTER_H
16
17 #include "pandatoolbase.h"
18
19 class ImageFile;
20 class PaletteImage;
21 class TextureImage;
22 class DestTextureImage;
23 class TexturePlacement;
24
25 #include "pmap.h"
26 #include "pset.h"
27
28 /**
29 * This class is used to gather statistics on texture memory usage, etc. It
30 * adds up the total texture memory required by a number of image files, and
31 * reports it at the end.
32 */
33 class TextureMemoryCounter {
34 public:
35 TextureMemoryCounter();
36
37 void reset();
38 void add_placement(TexturePlacement *placement);
39
40 void report(std::ostream &out, int indent_level);
41
42 private:
43 static std::ostream &format_memory_fraction(std::ostream &out, int fraction_bytes,
44 int palette_bytes);
45 void add_palette(PaletteImage *image);
46 void add_texture(TextureImage *texture, int bytes);
47 int count_bytes(ImageFile *image);
48 int count_bytes(ImageFile *image, int x_size, int y_size);
49
50 int _num_textures;
51 int _num_placed;
52 int _num_unplaced;
53 int _num_palettes;
54
55 int _bytes;
56 int _unused_bytes;
57 int _duplicate_bytes;
58 int _coverage_bytes;
59
60 typedef pmap<TextureImage *, int> Textures;
61 Textures _textures;
62
63 typedef pset<PaletteImage *> Palettes;
64 Palettes _palettes;
65 };
66
67 #endif
DestTextureImage
This represents a texture filename as it has been resized and copied to the map directory (e....
Definition: destTextureImage.h:28
ImageFile
This is the base class of both TextureImage and PaletteImage.
Definition: imageFile.h:33
PaletteImage
This is a single palette image, one of several within a PalettePage, which is in turn one of several ...
Definition: paletteImage.h:32
TextureImage
This represents a single source texture that is referenced by one or more egg files.
Definition: textureImage.h:46
TextureMemoryCounter
This class is used to gather statistics on texture memory usage, etc.
Definition: textureMemoryCounter.h:33
TextureMemoryCounter::add_placement
void add_placement(TexturePlacement *placement)
Adds the indicated TexturePlacement to the counter.
Definition: textureMemoryCounter.cxx:54
TextureMemoryCounter::report
void report(std::ostream &out, int indent_level)
Reports the measured texture memory usage.
Definition: textureMemoryCounter.cxx:84
TextureMemoryCounter::reset
void reset()
Resets the count to zero.
Definition: textureMemoryCounter.cxx:36
TexturePlacement
This corresponds to a particular assignment of a TextureImage with a PaletteGroup,...
Definition: texturePlacement.h:41
pmap< TextureImage *, int >
pset< PaletteImage * >
pandatoolbase.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pmap.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pset.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.