diff options
Diffstat (limited to 'linden/indra/llrender/llimagegl.h')
-rw-r--r-- | linden/indra/llrender/llimagegl.h | 49 |
1 files changed, 30 insertions, 19 deletions
diff --git a/linden/indra/llrender/llimagegl.h b/linden/indra/llrender/llimagegl.h index 3f231ee..1965495 100644 --- a/linden/indra/llrender/llimagegl.h +++ b/linden/indra/llrender/llimagegl.h | |||
@@ -4,7 +4,7 @@ | |||
4 | * | 4 | * |
5 | * $LicenseInfo:firstyear=2001&license=viewergpl$ | 5 | * $LicenseInfo:firstyear=2001&license=viewergpl$ |
6 | * | 6 | * |
7 | * Copyright (c) 2001-2008, Linden Research, Inc. | 7 | * Copyright (c) 2001-2009, Linden Research, Inc. |
8 | * | 8 | * |
9 | * Second Life Viewer Source Code | 9 | * Second Life Viewer Source Code |
10 | * The source code in this file ("Source Code") is provided by Linden Lab | 10 | * The source code in this file ("Source Code") is provided by Linden Lab |
@@ -37,6 +37,9 @@ | |||
37 | 37 | ||
38 | #include "llgltypes.h" | 38 | #include "llgltypes.h" |
39 | #include "llmemory.h" | 39 | #include "llmemory.h" |
40 | #include "v2math.h" | ||
41 | |||
42 | #include "llrender.h" | ||
40 | 43 | ||
41 | //============================================================================ | 44 | //============================================================================ |
42 | 45 | ||
@@ -48,11 +51,7 @@ public: | |||
48 | static S32 dataFormatBytes(S32 dataformat, S32 width, S32 height); | 51 | static S32 dataFormatBytes(S32 dataformat, S32 width, S32 height); |
49 | static S32 dataFormatComponents(S32 dataformat); | 52 | static S32 dataFormatComponents(S32 dataformat); |
50 | 53 | ||
51 | // Wrapper for glBindTexture that keeps LLImageGL in sync. | 54 | void updateBindStats(void) const; |
52 | // Usually you want stage = 0 and bind_target = GL_TEXTURE_2D | ||
53 | static void bindExternalTexture( LLGLuint gl_name, S32 stage, LLGLenum bind_target); | ||
54 | static void unbindTexture(S32 stage, LLGLenum target); | ||
55 | static void unbindTexture(S32 stage); // Uses GL_TEXTURE_2D (not a default arg to avoid gl.h dependency) | ||
56 | 55 | ||
57 | // needs to be called every frame | 56 | // needs to be called every frame |
58 | static void updateStats(F32 current_time); | 57 | static void updateStats(F32 current_time); |
@@ -79,7 +78,6 @@ public: | |||
79 | 78 | ||
80 | protected: | 79 | protected: |
81 | virtual ~LLImageGL(); | 80 | virtual ~LLImageGL(); |
82 | BOOL bindTextureInternal(const S32 stage = 0) const; | ||
83 | 81 | ||
84 | private: | 82 | private: |
85 | void glClamp (BOOL clamps, BOOL clampt); | 83 | void glClamp (BOOL clamps, BOOL clampt); |
@@ -87,10 +85,12 @@ private: | |||
87 | 85 | ||
88 | public: | 86 | public: |
89 | virtual void dump(); // debugging info to llinfos | 87 | virtual void dump(); // debugging info to llinfos |
90 | virtual BOOL bind(const S32 stage = 0) const; | 88 | virtual bool bindError(const S32 stage = 0) const; |
89 | virtual bool bindDefaultImage(const S32 stage = 0) const; | ||
91 | 90 | ||
92 | void setSize(S32 width, S32 height, S32 ncomponents); | 91 | void setSize(S32 width, S32 height, S32 ncomponents); |
93 | 92 | ||
93 | BOOL createGLTexture() ; | ||
94 | BOOL createGLTexture(S32 discard_level, const LLImageRaw* imageraw, S32 usename = 0); | 94 | 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); | 95 | BOOL createGLTexture(S32 discard_level, const U8* data, BOOL data_hasmips = FALSE, S32 usename = 0); |
96 | void setImage(const LLImageRaw* imageraw); | 96 | void setImage(const LLImageRaw* imageraw); |
@@ -114,6 +114,8 @@ public: | |||
114 | S32 getDiscardLevel() const { return mCurrentDiscardLevel; } | 114 | S32 getDiscardLevel() const { return mCurrentDiscardLevel; } |
115 | S32 getMaxDiscardLevel() const { return mMaxDiscardLevel; } | 115 | S32 getMaxDiscardLevel() const { return mMaxDiscardLevel; } |
116 | 116 | ||
117 | S32 getCurrentWidth() const { return mWidth ;} | ||
118 | S32 getCurrentHeight() const { return mHeight ;} | ||
117 | S32 getWidth(S32 discard_level = -1) const; | 119 | S32 getWidth(S32 discard_level = -1) const; |
118 | S32 getHeight(S32 discard_level = -1) const; | 120 | S32 getHeight(S32 discard_level = -1) const; |
119 | U8 getComponents() const { return mComponents; } | 121 | U8 getComponents() const { return mComponents; } |
@@ -132,7 +134,11 @@ public: | |||
132 | 134 | ||
133 | BOOL getIsResident(BOOL test_now = FALSE); // not const | 135 | BOOL getIsResident(BOOL test_now = FALSE); // not const |
134 | 136 | ||
135 | void setTarget(const LLGLenum target, const LLGLenum bind_target); | 137 | void setTarget(const LLGLenum target, const LLTexUnit::eTextureType bind_target); |
138 | |||
139 | LLTexUnit::eTextureType getTarget(void) const { return mBindTarget; } | ||
140 | bool isGLTextureCreated(void) const { return mGLTextureCreated ; } | ||
141 | void setGLTextureCreated (bool initialized) { mGLTextureCreated = initialized; } | ||
136 | 142 | ||
137 | BOOL getUseMipMaps() const { return mUseMipMaps; } | 143 | BOOL getUseMipMaps() const { return mUseMipMaps; } |
138 | void setUseMipMaps(BOOL usemips) { mUseMipMaps = usemips; } | 144 | void setUseMipMaps(BOOL usemips) { mUseMipMaps = usemips; } |
@@ -141,6 +147,11 @@ public: | |||
141 | 147 | ||
142 | BOOL isValidForSculpt(S32 discard_level, S32 image_width, S32 image_height, S32 ncomponents) ; | 148 | BOOL isValidForSculpt(S32 discard_level, S32 image_width, S32 image_height, S32 ncomponents) ; |
143 | 149 | ||
150 | void updatePickMask(S32 width, S32 height, const U8* data_in); | ||
151 | BOOL getMask(const LLVector2 &tc); | ||
152 | |||
153 | void checkTexSize() const ; | ||
154 | |||
144 | protected: | 155 | protected: |
145 | void init(BOOL usemipmaps); | 156 | void init(BOOL usemipmaps); |
146 | virtual void cleanup(); // Clean up the LLImageGL so it can be reinitialized. Be careful when using this in derived class destructors | 157 | virtual void cleanup(); // Clean up the LLImageGL so it can be reinitialized. Be careful when using this in derived class destructors |
@@ -152,25 +163,26 @@ public: | |||
152 | 163 | ||
153 | private: | 164 | private: |
154 | LLPointer<LLImageRaw> mSaveData; // used for destroyGL/restoreGL | 165 | LLPointer<LLImageRaw> mSaveData; // used for destroyGL/restoreGL |
166 | U8* mPickMask; //downsampled bitmap approximation of alpha channel. NULL if no alpha channel | ||
155 | S8 mUseMipMaps; | 167 | S8 mUseMipMaps; |
156 | S8 mHasMipMaps; | 168 | S8 mHasMipMaps; |
157 | S8 mHasExplicitFormat; // If false (default), GL format is f(mComponents) | 169 | S8 mHasExplicitFormat; // If false (default), GL format is f(mComponents) |
158 | S8 mAutoGenMips; | 170 | S8 mAutoGenMips; |
159 | 171 | ||
160 | protected: | 172 | bool mGLTextureCreated ; |
161 | LLGLenum mTarget; // Normally GL_TEXTURE2D, sometimes something else (ex. cube maps) | ||
162 | LLGLenum mBindTarget; // NOrmally GL_TEXTURE2D, sometimes something else (ex. cube maps) | ||
163 | |||
164 | LLGLuint mTexName; | 173 | LLGLuint mTexName; |
174 | U16 mWidth; | ||
175 | U16 mHeight; | ||
176 | S8 mCurrentDiscardLevel; | ||
165 | 177 | ||
178 | protected: | ||
179 | LLGLenum mTarget; // Normally GL_TEXTURE2D, sometimes something else (ex. cube maps) | ||
180 | LLTexUnit::eTextureType mBindTarget; // Normally TT_TEXTURE, sometimes something else (ex. cube maps) | ||
181 | |||
166 | LLGLboolean mIsResident; | 182 | LLGLboolean mIsResident; |
167 | |||
168 | U16 mWidth; | ||
169 | U16 mHeight; | ||
170 | 183 | ||
171 | S8 mComponents; | 184 | S8 mComponents; |
172 | S8 mMaxDiscardLevel; | 185 | S8 mMaxDiscardLevel; |
173 | S8 mCurrentDiscardLevel; | ||
174 | S8 mDontDiscard; // Keep full res version of this image (for UI, etc) | 186 | S8 mDontDiscard; // Keep full res version of this image (for UI, etc) |
175 | 187 | ||
176 | S8 mClampS; // Need to save clamp state | 188 | S8 mClampS; // Need to save clamp state |
@@ -200,7 +212,6 @@ public: | |||
200 | static U32 sBindCount; // Tracks number of texture binds for current frame | 212 | static U32 sBindCount; // Tracks number of texture binds for current frame |
201 | static U32 sUniqueCount; // Tracks number of unique texture binds for current frame | 213 | static U32 sUniqueCount; // Tracks number of unique texture binds for current frame |
202 | static BOOL sGlobalUseAnisotropic; | 214 | static BOOL sGlobalUseAnisotropic; |
203 | |||
204 | #if DEBUG_MISS | 215 | #if DEBUG_MISS |
205 | BOOL mMissed; // Missed on last bind? | 216 | BOOL mMissed; // Missed on last bind? |
206 | BOOL getMissed() const { return mMissed; }; | 217 | BOOL getMissed() const { return mMissed; }; |