Panda3D
|
00001 // Filename: textureMemoryCounter.h 00002 // Created by: drose (19Dec00) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #ifndef TEXTUREMEMORYCOUNTER_H 00016 #define TEXTUREMEMORYCOUNTER_H 00017 00018 #include "pandatoolbase.h" 00019 00020 class ImageFile; 00021 class PaletteImage; 00022 class TextureImage; 00023 class DestTextureImage; 00024 class TexturePlacement; 00025 00026 #include "pmap.h" 00027 #include "pset.h" 00028 00029 //////////////////////////////////////////////////////////////////// 00030 // Class : TextureMemoryCounter 00031 // Description : This class is used to gather statistics on texture 00032 // memory usage, etc. It adds up the total texture 00033 // memory required by a number of image files, and 00034 // reports it at the end. 00035 //////////////////////////////////////////////////////////////////// 00036 class TextureMemoryCounter { 00037 public: 00038 TextureMemoryCounter(); 00039 00040 void reset(); 00041 void add_placement(TexturePlacement *placement); 00042 00043 void report(ostream &out, int indent_level); 00044 00045 private: 00046 static ostream &format_memory_fraction(ostream &out, int fraction_bytes, 00047 int palette_bytes); 00048 void add_palette(PaletteImage *image); 00049 void add_texture(TextureImage *texture, int bytes); 00050 int count_bytes(ImageFile *image); 00051 int count_bytes(ImageFile *image, int x_size, int y_size); 00052 00053 int _num_textures; 00054 int _num_placed; 00055 int _num_unplaced; 00056 int _num_palettes; 00057 00058 int _bytes; 00059 int _unused_bytes; 00060 int _duplicate_bytes; 00061 int _coverage_bytes; 00062 00063 typedef pmap<TextureImage *, int> Textures; 00064 Textures _textures; 00065 00066 typedef pset<PaletteImage *> Palettes; 00067 Palettes _palettes; 00068 }; 00069 00070 #endif