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