textureContext.h
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.h
10  * @author drose
11  * @date 1999-10-07
12  */
13 
14 #ifndef TEXTURECONTEXT_H
15 #define TEXTURECONTEXT_H
16 
17 #include "pandabase.h"
18 
19 #include "bufferContext.h"
20 #include "texture.h"
22 #include "adaptiveLru.h"
23 
24 /**
25  * This is a special class object that holds all the information returned by a
26  * particular GSG to indicate the texture's internal context identifier.
27  *
28  * Textures typically have an immediate-mode and a retained-mode operation.
29  * When using textures in retained-mode (in response to Texture::prepare()),
30  * the GSG will create some internal handle for the texture and store it here.
31  * The texture stores all of these handles internally.
32  */
33 class EXPCL_PANDA_GOBJ TextureContext : public BufferContext, public AdaptiveLruPage {
34 public:
35  INLINE TextureContext(PreparedGraphicsObjects *pgo, Texture *tex, int view);
36 
37 PUBLISHED:
38  INLINE Texture *get_texture() const;
39  INLINE int get_view() const;
40 
41  INLINE bool was_modified() const;
42  INLINE bool was_properties_modified() const;
43  INLINE bool was_image_modified() const;
44  INLINE bool was_simple_image_modified() const;
45 
46  INLINE UpdateSeq get_properties_modified() const;
47  INLINE UpdateSeq get_image_modified() const;
48  INLINE UpdateSeq get_simple_image_modified() const;
49 
50 public:
51  INLINE void update_data_size_bytes(size_t new_data_size_bytes);
52  INLINE void mark_loaded();
53  INLINE void mark_simple_loaded();
54  INLINE void mark_unloaded();
55  INLINE void mark_needs_reload();
56 
57  virtual void output(ostream &out) const;
58  virtual void write(ostream &out, int indent_level) const;
59 
60 private:
61  // This cannot be a PT(Texture), because the texture and the GSG both own
62  // their TextureContexts! That would create a circular reference count.
63  Texture *_texture;
64  int _view;
65  UpdateSeq _properties_modified;
66  UpdateSeq _image_modified;
67  UpdateSeq _simple_image_modified;
68 
69 public:
70  static TypeHandle get_class_type() {
71  return _type_handle;
72  }
73  static void init_type() {
74  BufferContext::init_type();
75  register_type(_type_handle, "TextureContext",
76  BufferContext::get_class_type());
77  }
78  virtual TypeHandle get_type() const {
79  return get_class_type();
80  }
81  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
82 
83 private:
84  static TypeHandle _type_handle;
85 
86  friend class PreparedGraphicsObjects;
87 };
88 
89 inline ostream &operator << (ostream &out, const TextureContext &context) {
90  context.output(out);
91  return out;
92 }
93 
94 #include "textureContext.I"
95 
96 #endif
void register_type(TypeHandle &type_handle, const string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(), along with zero to four record_derivation()s.
Definition: register_type.I:22
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A table of objects that are saved within the graphics context for reference by handle later...
This is a base class for those kinds of SavedContexts that occupy an easily-measured (and substantial...
Definition: bufferContext.h:37
This is a special class object that holds all the information returned by a particular GSG to indicat...
Represents a texture object, which is typically a single 2-d image but may also represent a 1-d or 3-...
Definition: texture.h:70
This is a sequence number that increments monotonically.
Definition: updateSeq.h:37
One atomic piece that may be managed by a AdaptiveLru chain.
Definition: adaptiveLru.h:135
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.