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 */
23 BufferContext *BufferContextChain::
24 get_first() {
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 */
36 void BufferContextChain::
37 take_from(BufferContextChain &other) {
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 }
bufferContextChain.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
bufferContext.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
BufferContextChain
This class maintains a linked list of BufferContexts that might be allocated on the graphics card in ...
Definition: bufferContextChain.h:31
BufferContextChain::get_first
BufferContext * get_first()
Returns the first BufferContext object stored in the tracker.
Definition: bufferContextChain.cxx:24
BufferContextChain::take_from
void take_from(BufferContextChain &other)
Moves all of the BufferContexts from the other tracker onto this one.
Definition: bufferContextChain.cxx:37
BufferContext
This is a base class for those kinds of SavedContexts that occupy an easily-measured (and substantial...
Definition: bufferContext.h:38
LinkedListNode
This just stores the pointers to implement a doubly-linked list of some kind of object.
Definition: linkedListNode.h:31
indent
std::ostream & indent(std::ostream &out, int indent_level)
A handy function for doing text formatting.
Definition: indent.cxx:20
indent.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.