00001 // Filename: bufferContext.cxx 00002 // Created by: drose (16Mar06) 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 "bufferContext.h" 00016 00017 TypeHandle BufferContext::_type_handle; 00018 00019 //////////////////////////////////////////////////////////////////// 00020 // Function: BufferContext::Constructor 00021 // Access: Public 00022 // Description: 00023 //////////////////////////////////////////////////////////////////// 00024 BufferContext:: 00025 BufferContext(BufferResidencyTracker *residency) : 00026 _residency(residency), 00027 _residency_state(0), 00028 _data_size_bytes(0), 00029 _owning_chain(NULL) 00030 { 00031 set_owning_chain(&residency->_chains[0]); 00032 } 00033 00034 //////////////////////////////////////////////////////////////////// 00035 // Function: BufferContext::Destructor 00036 // Access: Public, Virtual 00037 // Description: 00038 //////////////////////////////////////////////////////////////////// 00039 BufferContext:: 00040 ~BufferContext() { 00041 set_owning_chain(NULL); 00042 } 00043 00044 //////////////////////////////////////////////////////////////////// 00045 // Function: BufferContext::set_owning_chain 00046 // Access: Private 00047 // Description: Moves this object to a different BufferContextChain. 00048 //////////////////////////////////////////////////////////////////// 00049 void BufferContext:: 00050 set_owning_chain(BufferContextChain *chain) { 00051 if (chain != _owning_chain) { 00052 if (_owning_chain != (BufferContextChain *)NULL){ 00053 --(_owning_chain->_count); 00054 _owning_chain->adjust_bytes(-(int)_data_size_bytes); 00055 remove_from_list(); 00056 } 00057 00058 _owning_chain = chain; 00059 00060 if (_owning_chain != (BufferContextChain *)NULL) { 00061 ++(_owning_chain->_count); 00062 _owning_chain->adjust_bytes((int)_data_size_bytes); 00063 insert_before(_owning_chain); 00064 } 00065 } 00066 }