Panda3D
bufferContextChain.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 bufferContextChain.cxx
10  * @author drose
11  * @date 2006-03-16
12  */
13 
14 #include "bufferContextChain.h"
15 #include "bufferContext.h"
16 #include "indent.h"
17 
18 /**
19  * Returns the first BufferContext object stored in the tracker. You can walk
20  * through the entire list of objects stored on the tracker by calling
21  * get_next() on each returned object, until the return value is NULL.
22  */
25  // This method is declared non-inline so we can include bufferContext.h,
26  // which is necessary for proper downcasting of the _next pointer.
27  if (_next == this) {
28  return nullptr;
29  }
30  return (BufferContext *)_next;
31 }
32 
33 /**
34  * Moves all of the BufferContexts from the other tracker onto this one.
35  */
38  _total_size += other._total_size;
39  _count += other._count;
40  other._total_size = 0;
41  other._count = 0;
42 
43  LinkedListNode *llnode = other._next;
44  while (llnode != &other) {
45  nassertv(((BufferContext *)llnode)->_owning_chain == &other);
46  ((BufferContext *)llnode)->_owning_chain = this;
47  llnode = ((BufferContext *)llnode)->_next;
48  }
49 
50  take_list_from(&other);
51 }
52 
53 /**
54  *
55  */
56 void BufferContextChain::
57 write(std::ostream &out, int indent_level) const {
58  indent(out, indent_level)
59  << _count << " objects, consuming " << _total_size << " bytes:\n";
60 
61  LinkedListNode *llnode = _next;
62  while (llnode != this) {
63  ((BufferContext *)llnode)->write(out, indent_level + 2);
64  llnode = ((BufferContext *)llnode)->_next;
65  }
66 }
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is a base class for those kinds of SavedContexts that occupy an easily-measured (and substantial...
Definition: bufferContext.h:38
This just stores the pointers to implement a doubly-linked list of some kind of object.
This class maintains a linked list of BufferContexts that might be allocated on the graphics card in ...
BufferContext * get_first()
Returns the first BufferContext object stored in the tracker.
std::ostream & indent(std::ostream &out, int indent_level)
A handy function for doing text formatting.
Definition: indent.cxx:20
void take_from(BufferContextChain &other)
Moves all of the BufferContexts from the other tracker onto this one.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.