Panda3D
 All Classes Functions Variables Enumerations
textureReloadRequest.cxx
1 // Filename: textureReloadRequest.cxx
2 // Created by: drose (12Aug08)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #include "textureReloadRequest.h"
16 #include "textureContext.h"
17 
18 TypeHandle TextureReloadRequest::_type_handle;
19 
20 ////////////////////////////////////////////////////////////////////
21 // Function: TextureReloadRequest::do_task
22 // Access: Protected, Virtual
23 // Description: Performs the task: that is, loads the one model.
24 ////////////////////////////////////////////////////////////////////
25 AsyncTask::DoneStatus TextureReloadRequest::
26 do_task() {
27  // Don't reload the texture if it doesn't need it.
28  if (_texture->was_image_modified(_pgo)) {
29  double delay = async_load_delay;
30  if (delay != 0.0) {
31  Thread::sleep(delay);
32  }
33 
34  if (_texture->was_image_modified(_pgo)) {
35  if (_allow_compressed) {
36  _texture->get_ram_image();
37  } else {
38  _texture->get_uncompressed_ram_image();
39  }
40 
41  // Now that we've loaded the texture, we should ensure it
42  // actually gets prepared--even if it's no longer visible in the
43  // frame--or it may become a kind of a leak (if the texture is
44  // never rendered again on this GSG, we'll just end up carrying
45  // the texture memory in RAM forever, instead of dumping it as
46  // soon as it gets prepared).
47  _texture->prepare(_pgo);
48  }
49  }
50  _is_ready = true;
51 
52  // Don't continue the task; we're done.
53  return DS_done;
54 }
static void sleep(double seconds)
Suspends the current thread for at least the indicated amount of time.
Definition: thread.I:236
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85