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, int view); 00041 00042 PUBLISHED: 00043 INLINE Texture *get_texture() const; 00044 INLINE int get_view() const; 00045 00046 INLINE bool was_modified() const; 00047 INLINE bool was_properties_modified() const; 00048 INLINE bool was_image_modified() const; 00049 INLINE bool was_simple_image_modified() const; 00050 00051 public: 00052 INLINE void update_data_size_bytes(size_t new_data_size_bytes); 00053 INLINE void mark_loaded(); 00054 INLINE void mark_simple_loaded(); 00055 INLINE void mark_unloaded(); 00056 INLINE void mark_needs_reload(); 00057 00058 virtual void output(ostream &out) const; 00059 virtual void write(ostream &out, int indent_level) const; 00060 00061 private: 00062 // This cannot be a PT(Texture), because the texture and the GSG 00063 // both own their TextureContexts! That would create a circular 00064 // reference count. 00065 Texture *_texture; 00066 int _view; 00067 UpdateSeq _properties_modified; 00068 UpdateSeq _image_modified; 00069 UpdateSeq _simple_image_modified; 00070 00071 public: 00072 static TypeHandle get_class_type() { 00073 return _type_handle; 00074 } 00075 static void init_type() { 00076 BufferContext::init_type(); 00077 register_type(_type_handle, "TextureContext", 00078 BufferContext::get_class_type()); 00079 } 00080 virtual TypeHandle get_type() const { 00081 return get_class_type(); 00082 } 00083 virtual TypeHandle force_init_type() {init_type(); return get_class_type();} 00084 00085 private: 00086 static TypeHandle _type_handle; 00087 00088 friend class PreparedGraphicsObjects; 00089 }; 00090 00091 inline ostream &operator << (ostream &out, const TextureContext &context) { 00092 context.output(out); 00093 return out; 00094 } 00095 00096 #include "textureContext.I" 00097 00098 #endif 00099