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