Panda3D
 All Classes Functions Variables Enumerations
tinyTextureContext.cxx
1 // Filename: tinyTextureContext.cxx
2 // Created by: drose (30Apr08)
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 "tinyTextureContext.h"
16 #include "zgl.h"
17 
18 TypeHandle TinyTextureContext::_type_handle;
19 
20 ////////////////////////////////////////////////////////////////////
21 // Function: TinyTextureContext::evict_lru
22 // Access: Public, Virtual
23 // Description: Evicts the page from the LRU. Called internally when
24 // the LRU determines that it is full. May also be
25 // called externally when necessary to explicitly evict
26 // the page.
27 //
28 // It is legal for this method to either evict the page
29 // as requested, do nothing (in which case the eviction
30 // will be requested again at the next epoch), or
31 // requeue itself on the tail of the queue (in which
32 // case the eviction will be requested again much
33 // later).
34 ////////////////////////////////////////////////////////////////////
37  dequeue_lru();
38 
39  GLTexture *gltex = &_gltex;
40  if (gltex->allocated_buffer != NULL) {
41  nassertv(gltex->num_levels != 0);
42  TinyTextureContext::get_class_type().dec_memory_usage(TypeHandle::MC_array, gltex->total_bytecount);
43  PANDA_FREE_ARRAY(gltex->allocated_buffer);
44  gltex->allocated_buffer = NULL;
45  gltex->total_bytecount = 0;
46  gltex->num_levels = 0;
47  } else {
48  nassertv(gltex->num_levels == 0);
49  }
50 
52  mark_unloaded();
53 }
virtual void evict_lru()
Evicts the page from the LRU.
void dequeue_lru()
Removes the page from its AdaptiveLru.
Definition: adaptiveLru.I:171
Definition: zgl.h:123
void update_data_size_bytes(size_t new_data_size_bytes)
Should be called (usually by a derived class) when the on-card size of this object has changed...
void mark_unloaded()
Should be called after the texture has been forced out of texture memory.
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85