00001 // Filename: tinyTextureContext.cxx 00002 // Created by: drose (30Apr08) 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 "tinyTextureContext.h" 00016 #include "zgl.h" 00017 00018 TypeHandle TinyTextureContext::_type_handle; 00019 00020 //////////////////////////////////////////////////////////////////// 00021 // Function: TinyTextureContext::evict_lru 00022 // Access: Public, Virtual 00023 // Description: Evicts the page from the LRU. Called internally when 00024 // the LRU determines that it is full. May also be 00025 // called externally when necessary to explicitly evict 00026 // the page. 00027 // 00028 // It is legal for this method to either evict the page 00029 // as requested, do nothing (in which case the eviction 00030 // will be requested again at the next epoch), or 00031 // requeue itself on the tail of the queue (in which 00032 // case the eviction will be requested again much 00033 // later). 00034 //////////////////////////////////////////////////////////////////// 00035 void TinyTextureContext:: 00036 evict_lru() { 00037 dequeue_lru(); 00038 00039 GLTexture *gltex = &_gltex; 00040 if (gltex->allocated_buffer != NULL) { 00041 nassertv(gltex->num_levels != 0); 00042 TinyTextureContext::get_class_type().dec_memory_usage(TypeHandle::MC_array, gltex->total_bytecount); 00043 PANDA_FREE_ARRAY(gltex->allocated_buffer); 00044 gltex->allocated_buffer = NULL; 00045 gltex->total_bytecount = 0; 00046 gltex->num_levels = 0; 00047 } else { 00048 nassertv(gltex->num_levels == 0); 00049 } 00050 00051 update_data_size_bytes(0); 00052 mark_unloaded(); 00053 }