add set_keep_ram_image

This commit is contained in:
David Rose 2002-02-11 19:21:27 +00:00
parent 8a0a089baf
commit d53603f85b
3 changed files with 41 additions and 5 deletions

View File

@ -87,16 +87,48 @@ uses_mipmaps() const {
////////////////////////////////////////////////////////////////////
// Function: Texture::has_ram_image
// Access: Public
// Description: Returns true if the Texture keeps has its image
// contents available in main RAM, false if it exists
// only in texture memory or in the prepared GSG
// context.
// Description: Returns true if the Texture has its image contents
// available in main RAM, false if it exists only in
// texture memory or in the prepared GSG context.
////////////////////////////////////////////////////////////////////
INLINE bool Texture::
has_ram_image() const {
return !_pbuffer->_image.empty();
}
////////////////////////////////////////////////////////////////////
// Function: Texture::set_keep_ram_image
// Access: Public
// Description: Sets the flag that indicates whether this Texture is
// eligible to have its main RAM copy of the texture
// memory dumped when the texture is prepared for
// rendering.
//
// This will be true for most textures, which can reload
// their images if needed by rereading the input file.
// However, textures that were generated dynamically and
// cannot be easily reloaded will want to set this flag
// to true, so that the _pbuffer member will always keep
// its image copy around.
////////////////////////////////////////////////////////////////////
INLINE void Texture::
set_keep_ram_image(bool keep_ram_image) {
_keep_ram_image = keep_ram_image;
}
////////////////////////////////////////////////////////////////////
// Function: Texture::get_keep_ram_image
// Access: Public
// Description: Returns the flag that indicates whether this Texture
// is eligible to have its main RAM copy of the texture
// memory dumped when the texture is prepared for
// rendering. See set_keep_ram_image().
////////////////////////////////////////////////////////////////////
INLINE bool Texture::
get_keep_ram_image() const {
return _keep_ram_image;
}
////////////////////////////////////////////////////////////////////
// Function: Texture::apply
// Access: Public

View File

@ -121,6 +121,7 @@ Texture() : ImageBuffer() {
_wrapu = WM_repeat;
_wrapv = WM_repeat;
_anisotropic_degree = 1;
_keep_ram_image = false;
_pbuffer = new PixelBuffer;
_has_requested_size = false;
_all_dirty_flags = 0;
@ -366,7 +367,7 @@ prepare(GraphicsStateGuardianBase *gsg) {
// context isn't.
_all_dirty_flags = 0;
if (!keep_texture_ram) {
if (!keep_texture_ram && !_keep_ram_image) {
// Once we have prepared the texture, we can generally safely
// remove the pixels from main RAM. The GSG is now responsible
// for remembering what it looks like.

View File

@ -105,6 +105,8 @@ public:
INLINE bool has_ram_image() const;
PixelBuffer *get_ram_image();
INLINE void set_keep_ram_image(bool keep_ram_image);
INLINE bool get_keep_ram_image() const;
INLINE void apply(GraphicsStateGuardianBase *gsg);
@ -134,6 +136,7 @@ private:
FilterType _minfilter;
FilterType _magfilter;
int _anisotropic_degree;
bool _keep_ram_image;
// A Texture keeps a list (actually, a map) of all the GSG's that it
// has been prepared into. Each GSG conversely keeps a list (a set)