Panda3D
bufferContext.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 bufferContext.cxx
10  * @author drose
11  * @date 2006-03-16
12  */
13 
14 #include "bufferContext.h"
15 
16 TypeHandle BufferContext::_type_handle;
17 
18 /**
19  *
20  */
21 BufferContext::
22 BufferContext(BufferResidencyTracker *residency, TypedWritableReferenceCount *object) :
23  _object(object),
24  _residency(residency),
25  _residency_state(0),
26  _data_size_bytes(0),
27  _owning_chain(nullptr)
28 {
29  set_owning_chain(&residency->_chains[0]);
30 }
31 
32 /**
33  *
34  */
35 BufferContext::
36 ~BufferContext() {
37  set_owning_chain(nullptr);
38 }
39 
40 /**
41  * Moves this object to a different BufferContextChain.
42  */
43 void BufferContext::
44 set_owning_chain(BufferContextChain *chain) {
45  if (chain != _owning_chain) {
46  if (_owning_chain != nullptr){
47  --(_owning_chain->_count);
48  _owning_chain->adjust_bytes(-(int)_data_size_bytes);
49  remove_from_list();
50  }
51 
52  _owning_chain = chain;
53 
54  if (_owning_chain != nullptr) {
55  ++(_owning_chain->_count);
56  _owning_chain->adjust_bytes((int)_data_size_bytes);
57  insert_before(_owning_chain);
58  }
59  }
60 }
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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 ...
A base class for things which need to inherit from both TypedWritable and from ReferenceCount.
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81