aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llrender/llimagegl.h
diff options
context:
space:
mode:
authorJacek Antonelli2009-04-30 13:04:20 -0500
committerJacek Antonelli2009-04-30 13:07:16 -0500
commitca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e (patch)
tree8348301d0ac44a524f1819b777686bf086907d76 /linden/indra/llrender/llimagegl.h
parentSecond Life viewer sources 1.22.11 (diff)
downloadmeta-impy-ca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e.zip
meta-impy-ca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e.tar.gz
meta-impy-ca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e.tar.bz2
meta-impy-ca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e.tar.xz
Second Life viewer sources 1.23.0-RC
Diffstat (limited to 'linden/indra/llrender/llimagegl.h')
-rw-r--r--linden/indra/llrender/llimagegl.h78
1 files changed, 55 insertions, 23 deletions
diff --git a/linden/indra/llrender/llimagegl.h b/linden/indra/llrender/llimagegl.h
index 1965495..4f737bc 100644
--- a/linden/indra/llrender/llimagegl.h
+++ b/linden/indra/llrender/llimagegl.h
@@ -17,7 +17,8 @@
17 * There are special exceptions to the terms and conditions of the GPL as 17 * There are special exceptions to the terms and conditions of the GPL as
18 * it is applied to this Source Code. View the full text of the exception 18 * it is applied to this Source Code. View the full text of the exception
19 * in the file doc/FLOSS-exception.txt in this software distribution, or 19 * in the file doc/FLOSS-exception.txt in this software distribution, or
20 * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception 20 * online at
21 * http://secondlifegrid.net/programs/open_source/licensing/flossexception
21 * 22 *
22 * By copying, modifying or distributing this software, you acknowledge 23 * By copying, modifying or distributing this software, you acknowledge
23 * that you have read and understood your obligations described above, 24 * that you have read and understood your obligations described above,
@@ -45,6 +46,7 @@
45 46
46class LLImageGL : public LLRefCount 47class LLImageGL : public LLRefCount
47{ 48{
49 friend class LLTexUnit;
48public: 50public:
49 // Size calculation 51 // Size calculation
50 static S32 dataFormatBits(S32 dataformat); 52 static S32 dataFormatBits(S32 dataformat);
@@ -79,17 +81,22 @@ public:
79protected: 81protected:
80 virtual ~LLImageGL(); 82 virtual ~LLImageGL();
81 83
82private: 84 void analyzeAlpha(const void* data_in, S32 w, S32 h);
83 void glClamp (BOOL clamps, BOOL clampt);
84 void glClampCubemap (BOOL clamps, BOOL clampt, BOOL clampr = FALSE);
85 85
86public: 86public:
87 virtual void dump(); // debugging info to llinfos 87 virtual void dump(); // debugging info to llinfos
88 virtual bool bindError(const S32 stage = 0) const; 88 virtual bool bindError(const S32 stage = 0) const;
89 virtual bool bindDefaultImage(const S32 stage = 0) const; 89 virtual bool bindDefaultImage(const S32 stage = 0) const;
90 virtual void forceImmediateUpdate() ;
90 91
91 void setSize(S32 width, S32 height, S32 ncomponents); 92 void setSize(S32 width, S32 height, S32 ncomponents);
92 93
94 // These 3 functions currently wrap glGenTextures(), glDeleteTextures(), and glTexImage2D()
95 // for tracking purposes and will be deprecated in the future
96 static void generateTextures(S32 numTextures, U32 *textures);
97 static void deleteTextures(S32 numTextures, U32 *textures);
98 static void setManualImage(U32 target, S32 miplevel, S32 intformat, S32 width, S32 height, U32 pixformat, U32 pixtype, const void *pixels);
99
93 BOOL createGLTexture() ; 100 BOOL createGLTexture() ;
94 BOOL createGLTexture(S32 discard_level, const LLImageRaw* imageraw, S32 usename = 0); 101 BOOL createGLTexture(S32 discard_level, const LLImageRaw* imageraw, S32 usename = 0);
95 BOOL createGLTexture(S32 discard_level, const U8* data, BOOL data_hasmips = FALSE, S32 usename = 0); 102 BOOL createGLTexture(S32 discard_level, const U8* data, BOOL data_hasmips = FALSE, S32 usename = 0);
@@ -102,14 +109,9 @@ public:
102 // Read back a raw image for this discard level, if it exists 109 // Read back a raw image for this discard level, if it exists
103 BOOL readBackRaw(S32 discard_level, LLImageRaw* imageraw, bool compressed_ok); 110 BOOL readBackRaw(S32 discard_level, LLImageRaw* imageraw, bool compressed_ok);
104 void destroyGLTexture(); 111 void destroyGLTexture();
105 112
106 void setClampCubemap (BOOL clamps, BOOL clampt, BOOL clampr = FALSE);
107 void setClamp(BOOL clamps, BOOL clampt);
108 void overrideClamp (BOOL clamps, BOOL clampt);
109 void restoreClamp (void);
110 void setMipFilterNearest(BOOL mag_nearest, BOOL min_nearest = FALSE);
111 void setExplicitFormat(LLGLint internal_format, LLGLenum primary_format, LLGLenum type_format = 0, BOOL swap_bytes = FALSE); 113 void setExplicitFormat(LLGLint internal_format, LLGLenum primary_format, LLGLenum type_format = 0, BOOL swap_bytes = FALSE);
112 void dontDiscard() { mDontDiscard = 1; } 114 void dontDiscard() { mDontDiscard = 1; mTextureState = NO_DELETE; }
113 115
114 S32 getDiscardLevel() const { return mCurrentDiscardLevel; } 116 S32 getDiscardLevel() const { return mCurrentDiscardLevel; }
115 S32 getMaxDiscardLevel() const { return mMaxDiscardLevel; } 117 S32 getMaxDiscardLevel() const { return mMaxDiscardLevel; }
@@ -123,15 +125,12 @@ public:
123 S32 getMipBytes(S32 discard_level = -1) const; 125 S32 getMipBytes(S32 discard_level = -1) const;
124 BOOL getBoundRecently() const; 126 BOOL getBoundRecently() const;
125 LLGLenum getPrimaryFormat() const { return mFormatPrimary; } 127 LLGLenum getPrimaryFormat() const { return mFormatPrimary; }
126 128
127 BOOL getClampS() const { return mClampS; }
128 BOOL getClampT() const { return mClampT; }
129 BOOL getClampR() const { return mClampR; }
130 BOOL getMipFilterNearest() const { return mMagFilterNearest; }
131
132 BOOL getHasGLTexture() const { return mTexName != 0; } 129 BOOL getHasGLTexture() const { return mTexName != 0; }
133 LLGLuint getTexName() const { return mTexName; } 130 LLGLuint getTexName() const { return mTexName; }
134 131
132 BOOL getIsAlphaMask() const { return mIsMask; }
133
135 BOOL getIsResident(BOOL test_now = FALSE); // not const 134 BOOL getIsResident(BOOL test_now = FALSE); // not const
136 135
137 void setTarget(const LLGLenum target, const LLTexUnit::eTextureType bind_target); 136 void setTarget(const LLGLenum target, const LLTexUnit::eTextureType bind_target);
@@ -151,6 +150,27 @@ public:
151 BOOL getMask(const LLVector2 &tc); 150 BOOL getMask(const LLVector2 &tc);
152 151
153 void checkTexSize() const ; 152 void checkTexSize() const ;
153
154 // Sets the addressing mode used to sample the texture
155 // (such as wrapping, mirrored wrapping, and clamp)
156 // Note: this actually gets set the next time the texture is bound.
157 void setAddressMode(LLTexUnit::eTextureAddressMode mode);
158 LLTexUnit::eTextureAddressMode getAddressMode(void) const { return mAddressMode; }
159
160 // Sets the filtering options used to sample the texture
161 // (such as point sampling, bilinear interpolation, mipmapping, and anisotropic filtering)
162 // Note: this actually gets set the next time the texture is bound.
163 void setFilteringOption(LLTexUnit::eTextureFilterOptions option);
164 LLTexUnit::eTextureFilterOptions getFilteringOption(void) const { return mFilterOption; }
165
166 BOOL isDeleted() ;
167 BOOL isInactive() ;
168 BOOL isDeletionCandidate();
169 void setDeletionCandidate() ;
170 void setInactive() ;
171 void setActive() ;
172 void forceActive() ;
173 void setNoDelete() ;
154 174
155protected: 175protected:
156 void init(BOOL usemipmaps); 176 void init(BOOL usemipmaps);
@@ -165,9 +185,10 @@ private:
165 LLPointer<LLImageRaw> mSaveData; // used for destroyGL/restoreGL 185 LLPointer<LLImageRaw> mSaveData; // used for destroyGL/restoreGL
166 U8* mPickMask; //downsampled bitmap approximation of alpha channel. NULL if no alpha channel 186 U8* mPickMask; //downsampled bitmap approximation of alpha channel. NULL if no alpha channel
167 S8 mUseMipMaps; 187 S8 mUseMipMaps;
168 S8 mHasMipMaps;
169 S8 mHasExplicitFormat; // If false (default), GL format is f(mComponents) 188 S8 mHasExplicitFormat; // If false (default), GL format is f(mComponents)
170 S8 mAutoGenMips; 189 S8 mAutoGenMips;
190
191 BOOL mIsMask;
171 192
172 bool mGLTextureCreated ; 193 bool mGLTextureCreated ;
173 LLGLuint mTexName; 194 LLGLuint mTexName;
@@ -178,6 +199,7 @@ private:
178protected: 199protected:
179 LLGLenum mTarget; // Normally GL_TEXTURE2D, sometimes something else (ex. cube maps) 200 LLGLenum mTarget; // Normally GL_TEXTURE2D, sometimes something else (ex. cube maps)
180 LLTexUnit::eTextureType mBindTarget; // Normally TT_TEXTURE, sometimes something else (ex. cube maps) 201 LLTexUnit::eTextureType mBindTarget; // Normally TT_TEXTURE, sometimes something else (ex. cube maps)
202 bool mHasMipMaps;
181 203
182 LLGLboolean mIsResident; 204 LLGLboolean mIsResident;
183 205
@@ -185,17 +207,27 @@ protected:
185 S8 mMaxDiscardLevel; 207 S8 mMaxDiscardLevel;
186 S8 mDontDiscard; // Keep full res version of this image (for UI, etc) 208 S8 mDontDiscard; // Keep full res version of this image (for UI, etc)
187 209
188 S8 mClampS; // Need to save clamp state 210 bool mTexOptionsDirty;
189 S8 mClampT; 211 LLTexUnit::eTextureAddressMode mAddressMode; // Defaults to TAM_WRAP
190 S8 mClampR; 212 LLTexUnit::eTextureFilterOptions mFilterOption; // Defaults to TFO_TRILINEAR
191 S8 mMagFilterNearest; // if TRUE, set magfilter to GL_NEAREST 213
192 S8 mMinFilterNearest; // if TRUE, set minfilter to GL_NEAREST
193 214
194 LLGLint mFormatInternal; // = GL internalformat 215 LLGLint mFormatInternal; // = GL internalformat
195 LLGLenum mFormatPrimary; // = GL format (pixel data format) 216 LLGLenum mFormatPrimary; // = GL format (pixel data format)
196 LLGLenum mFormatType; 217 LLGLenum mFormatType;
197 BOOL mFormatSwapBytes;// if true, use glPixelStorei(GL_UNPACK_SWAP_BYTES, 1) 218 BOOL mFormatSwapBytes;// if true, use glPixelStorei(GL_UNPACK_SWAP_BYTES, 1)
198 219
220protected:
221 typedef enum
222 {
223 DELETED = 0, //removed from memory
224 DELETION_CANDIDATE, //ready to be removed from memory
225 INACTIVE, //not be used for the last certain period (i.e., 30 seconds).
226 ACTIVE, //just being used, can become inactive if not being used for a certain time (10 seconds).
227 NO_DELETE = 99 //stay in memory, can not be removed.
228 } LLGLTexureState;
229 LLGLTexureState mTextureState ;
230
199 // STATICS 231 // STATICS
200public: 232public:
201 static std::set<LLImageGL*> sImageList; 233 static std::set<LLImageGL*> sImageList;