Panda3D
|
00001 // Filename: textureContext.h 00002 // Created by: drose (07Oct99) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #ifndef TEXTURECONTEXT_H 00016 #define TEXTURECONTEXT_H 00017 00018 #include "pandabase.h" 00019 00020 #include "bufferContext.h" 00021 #include "texture.h" 00022 #include "preparedGraphicsObjects.h" 00023 #include "adaptiveLru.h" 00024 00025 //////////////////////////////////////////////////////////////////// 00026 // Class : TextureContext 00027 // Description : This is a special class object that holds all the 00028 // information returned by a particular GSG to indicate 00029 // the texture's internal context identifier. 00030 // 00031 // Textures typically have an immediate-mode and a 00032 // retained-mode operation. When using textures in 00033 // retained-mode (in response to Texture::prepare()), 00034 // the GSG will create some internal handle for the 00035 // texture and store it here. The texture stores all of 00036 // these handles internally. 00037 //////////////////////////////////////////////////////////////////// 00038 class EXPCL_PANDA_GOBJ TextureContext : public BufferContext, public AdaptiveLruPage { 00039 public: 00040 INLINE TextureContext(PreparedGraphicsObjects *pgo, Texture *tex); 00041 00042 PUBLISHED: 00043 INLINE Texture *get_texture() const; 00044 00045 INLINE bool was_modified() const; 00046 INLINE bool was_properties_modified() const; 00047 INLINE bool was_image_modified() const; 00048 INLINE bool was_simple_image_modified() const; 00049 00050 public: 00051 INLINE void update_data_size_bytes(size_t new_data_size_bytes); 00052 INLINE void mark_loaded(); 00053 INLINE void mark_simple_loaded(); 00054 INLINE void mark_unloaded(); 00055 INLINE void mark_needs_reload(); 00056 00057 virtual void output(ostream &out) const; 00058 virtual void write(ostream &out, int indent_level) const; 00059 00060 private: 00061 // This cannot be a PT(Texture), because the texture and the GSG 00062 // both own their TextureContexts! That would create a circular 00063 // reference count. 00064 Texture *_texture; 00065 UpdateSeq _properties_modified; 00066 UpdateSeq _image_modified; 00067 UpdateSeq _simple_image_modified; 00068 00069 public: 00070 static TypeHandle get_class_type() { 00071 return _type_handle; 00072 } 00073 static void init_type() { 00074 BufferContext::init_type(); 00075 register_type(_type_handle, "TextureContext", 00076 BufferContext::get_class_type()); 00077 } 00078 virtual TypeHandle get_type() const { 00079 return get_class_type(); 00080 } 00081 virtual TypeHandle force_init_type() {init_type(); return get_class_type();} 00082 00083 private: 00084 static TypeHandle _type_handle; 00085 00086 friend class PreparedGraphicsObjects; 00087 }; 00088 00089 inline ostream &operator << (ostream &out, const TextureContext &context) { 00090 context.output(out); 00091 return out; 00092 } 00093 00094 #include "textureContext.I" 00095 00096 #endif 00097