Panda3D
 All Classes Functions Variables Enumerations
bufferContext.cxx
1 // Filename: bufferContext.cxx
2 // Created by: drose (16Mar06)
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 "bufferContext.h"
16 
17 TypeHandle BufferContext::_type_handle;
18 
19 ////////////////////////////////////////////////////////////////////
20 // Function: BufferContext::Constructor
21 // Access: Public
22 // Description:
23 ////////////////////////////////////////////////////////////////////
24 BufferContext::
25 BufferContext(BufferResidencyTracker *residency) :
26  _residency(residency),
27  _residency_state(0),
28  _data_size_bytes(0),
29  _owning_chain(NULL)
30 {
31  set_owning_chain(&residency->_chains[0]);
32 }
33 
34 ////////////////////////////////////////////////////////////////////
35 // Function: BufferContext::Destructor
36 // Access: Public, Virtual
37 // Description:
38 ////////////////////////////////////////////////////////////////////
39 BufferContext::
40 ~BufferContext() {
41  set_owning_chain(NULL);
42 }
43 
44 ////////////////////////////////////////////////////////////////////
45 // Function: BufferContext::set_owning_chain
46 // Access: Private
47 // Description: Moves this object to a different BufferContextChain.
48 ////////////////////////////////////////////////////////////////////
49 void BufferContext::
50 set_owning_chain(BufferContextChain *chain) {
51  if (chain != _owning_chain) {
52  if (_owning_chain != (BufferContextChain *)NULL){
53  --(_owning_chain->_count);
54  _owning_chain->adjust_bytes(-(int)_data_size_bytes);
55  remove_from_list();
56  }
57 
58  _owning_chain = chain;
59 
60  if (_owning_chain != (BufferContextChain *)NULL) {
61  ++(_owning_chain->_count);
62  _owning_chain->adjust_bytes((int)_data_size_bytes);
63  insert_before(_owning_chain);
64  }
65  }
66 }
This class is used to keep track of the current state of all the BufferContexts for a particular grap...
This class maintains a linked list of BufferContexts that might be allocated on the graphics card in ...
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85