mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-07 04:11:51 -04:00
75 lines
2.1 KiB
C++
75 lines
2.1 KiB
C++
// Filename: textureMemoryCounter.h
|
|
// Created by: drose (19Dec00)
|
|
//
|
|
////////////////////////////////////////////////////////////////////
|
|
//
|
|
// PANDA 3D SOFTWARE
|
|
// Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved
|
|
//
|
|
// All use of this software is subject to the terms of the Panda 3d
|
|
// Software license. You should have received a copy of this license
|
|
// along with this source code; you will also find a current copy of
|
|
// the license at http://www.panda3d.org/license.txt .
|
|
//
|
|
// To contact the maintainers of this program write to
|
|
// panda3d@yahoogroups.com .
|
|
//
|
|
////////////////////////////////////////////////////////////////////
|
|
|
|
#ifndef TEXTUREMEMORYCOUNTER_H
|
|
#define TEXTUREMEMORYCOUNTER_H
|
|
|
|
#include <pandatoolbase.h>
|
|
|
|
class ImageFile;
|
|
class PaletteImage;
|
|
class TextureImage;
|
|
class DestTextureImage;
|
|
class TexturePlacement;
|
|
|
|
#include "pmap.h"
|
|
#include "pset.h"
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
// Class : TextureMemoryCounter
|
|
// Description : This class is used to gather statistics on texture
|
|
// memory usage, etc. It adds up the total texture
|
|
// memory required by a number of image files, and
|
|
// reports it at the end.
|
|
////////////////////////////////////////////////////////////////////
|
|
class TextureMemoryCounter {
|
|
public:
|
|
TextureMemoryCounter();
|
|
|
|
void reset();
|
|
void add_placement(TexturePlacement *placement);
|
|
|
|
void report(ostream &out, int indent_level);
|
|
|
|
private:
|
|
static ostream &format_memory_fraction(ostream &out, int fraction_bytes,
|
|
int palette_bytes);
|
|
void add_palette(PaletteImage *image);
|
|
void add_texture(TextureImage *texture, int bytes);
|
|
int count_bytes(ImageFile *image);
|
|
int count_bytes(ImageFile *image, int x_size, int y_size);
|
|
|
|
int _num_textures;
|
|
int _num_placed;
|
|
int _num_unplaced;
|
|
int _num_palettes;
|
|
|
|
int _bytes;
|
|
int _unused_bytes;
|
|
int _duplicate_bytes;
|
|
int _coverage_bytes;
|
|
|
|
typedef pmap<TextureImage *, int> Textures;
|
|
Textures _textures;
|
|
|
|
typedef pset<PaletteImage *> Palettes;
|
|
Palettes _palettes;
|
|
};
|
|
|
|
#endif
|