Răsfoiți Sursa

fix get_uncompressed_ram_image() with implicit reload

David Rose 17 ani în urmă
părinte
comite
9b9528097e
2 a modificat fișierele cu 15 adăugiri și 6 ștergeri
  1. 6 6
      panda/src/gobj/texture.I
  2. 9 0
      panda/src/gobj/texture.cxx

+ 6 - 6
panda/src/gobj/texture.I

@@ -1201,12 +1201,12 @@ clear_ram_image() {
 //               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 texture will always keep its
-//               image copy around.
+//               This will be false 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 texture will
+//               always keep its image copy around.
 ////////////////////////////////////////////////////////////////////
 INLINE void Texture::
 set_keep_ram_image(bool keep_ram_image) {

+ 9 - 0
panda/src/gobj/texture.cxx

@@ -3874,6 +3874,15 @@ do_get_uncompressed_ram_image() {
     do_unlock_and_reload_ram_image(false);
   }
 
+  if (!_ram_images.empty() && _ram_image_compression != CM_off) {
+    // Great, now we have an image.
+    if (do_uncompress_ram_image()) {
+      gobj_cat.info()
+        << "Uncompressed " << get_name() << "\n";
+      return _ram_images[0]._image;
+    }
+  }
+
   if (_ram_images.empty() || _ram_image_compression != CM_off) {
     return CPTA_uchar(get_class_type());
   }