Panda3D
Loading...
Searching...
No Matches
textureContext.I
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 textureContext.I
10 * @author drose
11 * @date 1999-10-07
12 */
13
14/**
15 *
16 */
17INLINE TextureContext::
18TextureContext(PreparedGraphicsObjects *pgo, Texture *tex, int view) :
19 BufferContext(&pgo->_texture_residency, tex),
21 _view(view)
22{
23}
24
25/**
26 * Returns the pointer to the associated Texture object.
27 */
29get_texture() const {
30 return (Texture *)_object;
31}
32
33/**
34 * Returns the specific view of a multiview texture this context represents.
35 * In the usual case, with a non-multiview texture, this will be 0.
36 */
38get_view() const {
39 return _view;
40}
41
42
43/**
44 * Returns true if the texture properties or image have been modified since
45 * the last time mark_loaded() was called.
46 */
48was_modified() const {
50}
51
52/**
53 * Returns true if the texture properties (unrelated to the image) have been
54 * modified since the last time mark_loaded() was called.
55 */
58 return _properties_modified != get_texture()->get_properties_modified();
59}
60
61/**
62 * Returns true if the texture image has been modified since the last time
63 * mark_loaded() was called.
64 */
66was_image_modified() const {
67 return _image_modified != get_texture()->get_image_modified();
68}
69
70/**
71 * Returns true if the texture's "simple" image has been modified since the
72 * last time mark_simple_loaded() was called.
73 */
76 return _simple_image_modified != get_texture()->get_simple_image_modified();
77}
78
79/**
80 * Returns a sequence number which is guaranteed to change at least every time
81 * the texture properties (unrelated to the image) are modified.
82 */
85 return _properties_modified;
86}
87
88/**
89 * Returns a sequence number which is guaranteed to change at least every time
90 * the texture image data (including mipmap levels) are modified.
91 */
93get_image_modified() const {
94 return _image_modified;
95}
96
97/**
98 * Returns a sequence number which is guaranteed to change at least every time
99 * the texture's "simple" image data is modified.
100 */
103 return _simple_image_modified;
104}
105
106/**
107 * Should be called (usually by a derived class) when the on-card size of this
108 * object has changed.
109 */
111update_data_size_bytes(size_t new_data_size_bytes) {
112 BufferContext::update_data_size_bytes(new_data_size_bytes);
113 AdaptiveLruPage::set_lru_size(new_data_size_bytes);
114}
115
116/**
117 * Should be called after the texture has been loaded into graphics memory,
118 * this updates the internal flags for changed_size() and modified().
119 */
121mark_loaded() {
122 // _data_size_bytes = _data->get_texture_size_bytes();
123 _properties_modified = get_texture()->get_properties_modified();
124 _image_modified = get_texture()->get_image_modified();
125 update_modified((std::max)(_properties_modified, _image_modified));
126
127 // Assume the texture is now resident.
128 set_resident(true);
129}
130
131/**
132 * Should be called after the texture's "simple" image has been loaded into
133 * graphics memory.
134 */
137 _properties_modified = get_texture()->get_properties_modified();
138 _simple_image_modified = get_texture()->get_simple_image_modified();
139 update_modified((std::max)(_properties_modified, _simple_image_modified));
140
141 // The texture's not exactly resident now, but some part of it is.
142 set_resident(true);
143}
144
145/**
146 * Should be called after the texture has been forced out of texture memory.
147 */
150 _properties_modified = UpdateSeq::old();
151 _image_modified = UpdateSeq::old();
152 _simple_image_modified = UpdateSeq::old();
153 update_modified(UpdateSeq::old());
154
155 set_resident(false);
156}
157
158/**
159 * Should be called to indicate the texture should be reloaded at the nearest
160 * opportunity.
161 */
164 _image_modified = UpdateSeq::old();
165}
One atomic piece that may be managed by a AdaptiveLru chain.
void set_lru_size(size_t lru_size)
Specifies the size of this page, presumably in bytes, although any unit is possible.
This is a base class for those kinds of SavedContexts that occupy an easily-measured (and substantial...
void update_data_size_bytes(size_t new_data_size_bytes)
Should be called (usually by a derived class) when the on-card size of this object has changed.
void set_resident(bool flag)
Changes the resident flag associated with this object.
void update_modified(UpdateSeq new_modified)
Should be called (usually by a derived class) when the modified counter for this object has changed.
A table of objects that are saved within the graphics context for reference by handle later.
void mark_needs_reload()
Should be called to indicate the texture should be reloaded at the nearest opportunity.
bool was_simple_image_modified() const
Returns true if the texture's "simple" image has been modified since the last time mark_simple_loaded...
void update_data_size_bytes(size_t new_data_size_bytes)
Should be called (usually by a derived class) when the on-card size of this object has changed.
Texture * get_texture() const
Returns the pointer to the associated Texture object.
bool was_properties_modified() const
Returns true if the texture properties (unrelated to the image) have been modified since the last tim...
bool was_modified() const
Returns true if the texture properties or image have been modified since the last time mark_loaded() ...
void mark_simple_loaded()
Should be called after the texture's "simple" image has been loaded into graphics memory.
void mark_unloaded()
Should be called after the texture has been forced out of texture memory.
UpdateSeq get_simple_image_modified() const
Returns a sequence number which is guaranteed to change at least every time the texture's "simple" im...
UpdateSeq get_image_modified() const
Returns a sequence number which is guaranteed to change at least every time the texture image data (i...
void mark_loaded()
Should be called after the texture has been loaded into graphics memory, this updates the internal fl...
int get_view() const
Returns the specific view of a multiview texture this context represents.
UpdateSeq get_properties_modified() const
Returns a sequence number which is guaranteed to change at least every time the texture properties (u...
bool was_image_modified() const
Returns true if the texture image has been modified since the last time mark_loaded() was called.
Represents a texture object, which is typically a single 2-d image but may also represent a 1-d or 3-...
Definition texture.h:72
get_properties_modified
Returns a sequence number which is guaranteed to change at least every time the texture properties (u...
Definition texture.h:527
get_image_modified
Returns a sequence number which is guaranteed to change at least every time the texture image data (i...
Definition texture.h:528
get_simple_image_modified
Returns a sequence number which is guaranteed to change at least every time the texture's "simple" im...
Definition texture.h:529
This is a sequence number that increments monotonically.
Definition updateSeq.h:37