diff --git a/panda/src/gobj/texture.cxx b/panda/src/gobj/texture.cxx index a764051946..63989bb349 100644 --- a/panda/src/gobj/texture.cxx +++ b/panda/src/gobj/texture.cxx @@ -1128,6 +1128,66 @@ was_image_modified(PreparedGraphicsObjects *prepared_objects) const { return true; } +//////////////////////////////////////////////////////////////////// +// Function: Texture::get_data_size_bytes +// Access: Public +// Description: Returns the number of bytes which the texture is +// reported to consume within graphics memory, for the +// indicated GSG. This may return a nonzero value even +// if the texture is not currently resident; you should +// also check get_resident() if you want to know how +// much space the texture is actually consuming right +// now. +//////////////////////////////////////////////////////////////////// +size_t Texture:: +get_data_size_bytes(PreparedGraphicsObjects *prepared_objects) const { + MutexHolder holder(_lock); + Contexts::const_iterator ci; + ci = _contexts.find(prepared_objects); + if (ci != _contexts.end()) { + TextureContext *tc = (*ci).second; + return tc->get_data_size_bytes(); + } + return 0; +} + +//////////////////////////////////////////////////////////////////// +// Function: Texture::get_active +// Access: Public +// Description: Returns true if this Texture was rendered in the most +// recent frame within the indicated GSG. +//////////////////////////////////////////////////////////////////// +bool Texture:: +get_active(PreparedGraphicsObjects *prepared_objects) const { + MutexHolder holder(_lock); + Contexts::const_iterator ci; + ci = _contexts.find(prepared_objects); + if (ci != _contexts.end()) { + TextureContext *tc = (*ci).second; + return tc->get_active(); + } + return false; +} + +//////////////////////////////////////////////////////////////////// +// Function: Texture::get_resident +// Access: Public +// Description: Returns true if this Texture is reported to be +// resident within graphics memory for the indicated +// GSG. +//////////////////////////////////////////////////////////////////// +bool Texture:: +get_resident(PreparedGraphicsObjects *prepared_objects) const { + MutexHolder holder(_lock); + Contexts::const_iterator ci; + ci = _contexts.find(prepared_objects); + if (ci != _contexts.end()) { + TextureContext *tc = (*ci).second; + return tc->get_resident(); + } + return false; +} + //////////////////////////////////////////////////////////////////// // Function: Texture::release // Access: Published diff --git a/panda/src/gobj/texture.h b/panda/src/gobj/texture.h index 59a2d2f7c1..a026d6fd63 100644 --- a/panda/src/gobj/texture.h +++ b/panda/src/gobj/texture.h @@ -355,6 +355,10 @@ PUBLISHED: void prepare(PreparedGraphicsObjects *prepared_objects); bool is_prepared(PreparedGraphicsObjects *prepared_objects) const; bool was_image_modified(PreparedGraphicsObjects *prepared_objects) const; + size_t get_data_size_bytes(PreparedGraphicsObjects *prepared_objects) const; + bool get_active(PreparedGraphicsObjects *prepared_objects) const; + bool get_resident(PreparedGraphicsObjects *prepared_objects) const; + bool release(PreparedGraphicsObjects *prepared_objects); int release_all();