00001 // Filename: textureReloadRequest.cxx 00002 // Created by: drose (12Aug08) 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 #include "textureReloadRequest.h" 00016 #include "textureContext.h" 00017 00018 TypeHandle TextureReloadRequest::_type_handle; 00019 00020 //////////////////////////////////////////////////////////////////// 00021 // Function: TextureReloadRequest::do_task 00022 // Access: Protected, Virtual 00023 // Description: Performs the task: that is, loads the one model. 00024 //////////////////////////////////////////////////////////////////// 00025 AsyncTask::DoneStatus TextureReloadRequest:: 00026 do_task() { 00027 // Don't reload the texture if it doesn't need it. 00028 if (_texture->was_image_modified(_pgo)) { 00029 double delay = async_load_delay; 00030 if (delay != 0.0) { 00031 Thread::sleep(delay); 00032 } 00033 00034 if (_texture->was_image_modified(_pgo)) { 00035 if (_allow_compressed) { 00036 _texture->get_ram_image(); 00037 } else { 00038 _texture->get_uncompressed_ram_image(); 00039 } 00040 00041 // Now that we've loaded the texture, we should ensure it 00042 // actually gets prepared--even if it's no longer visible in the 00043 // frame--or it may become a kind of a leak (if the texture is 00044 // never rendered again on this GSG, we'll just end up carrying 00045 // the texture memory in RAM forever, instead of dumping it as 00046 // soon as it gets prepared). 00047 _texture->prepare(_pgo); 00048 } 00049 } 00050 _is_ready = true; 00051 00052 // Don't continue the task; we're done. 00053 return DS_done; 00054 }