OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 | 8 |
9 #ifndef GrGLProgram_DEFINED | 9 #ifndef GrGLProgram_DEFINED |
10 #define GrGLProgram_DEFINED | 10 #define GrGLProgram_DEFINED |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 // per-vertex colors. | 149 // per-vertex colors. |
150 void setColor(const GrDrawState&, GrColor color, SharedGLState*); | 150 void setColor(const GrDrawState&, GrColor color, SharedGLState*); |
151 | 151 |
152 // Helper for setData(). Makes GL calls to specify the initial coverage when
there is not | 152 // Helper for setData(). Makes GL calls to specify the initial coverage when
there is not |
153 // per-vertex coverages. | 153 // per-vertex coverages. |
154 void setCoverage(const GrDrawState&, GrColor coverage, SharedGLState*); | 154 void setCoverage(const GrDrawState&, GrColor coverage, SharedGLState*); |
155 | 155 |
156 // Helper for setData() that sets the view matrix and loads the render targe
t height uniform | 156 // Helper for setData() that sets the view matrix and loads the render targe
t height uniform |
157 void setMatrixAndRenderTargetHeight(const GrDrawState&); | 157 void setMatrixAndRenderTargetHeight(const GrDrawState&); |
158 | 158 |
159 typedef SkSTArray<4, UniformHandle, true> SamplerUniSArray; | 159 // handles for uniforms (aside from per-effect samplers) |
160 | |
161 struct UniformHandles { | 160 struct UniformHandles { |
162 UniformHandle fViewMatrixUni; | 161 UniformHandle fViewMatrixUni; |
163 UniformHandle fColorUni; | 162 UniformHandle fColorUni; |
164 UniformHandle fCoverageUni; | 163 UniformHandle fCoverageUni; |
165 UniformHandle fColorFilterUni; | 164 UniformHandle fColorFilterUni; |
166 | 165 |
167 // We use the render target height to provide a y-down frag coord when s
pecifying | 166 // We use the render target height to provide a y-down frag coord when s
pecifying |
168 // origin_upper_left is not supported. | 167 // origin_upper_left is not supported. |
169 UniformHandle fRTHeightUni; | 168 UniformHandle fRTHeightUni; |
170 | 169 |
171 // Uniforms for computing texture coords to do the dst-copy lookup | 170 // Uniforms for computing texture coords to do the dst-copy lookup |
172 UniformHandle fDstCopyTopLeftUni; | 171 UniformHandle fDstCopyTopLeftUni; |
173 UniformHandle fDstCopyScaleUni; | 172 UniformHandle fDstCopyScaleUni; |
174 UniformHandle fDstCopySamplerUni; | 173 UniformHandle fDstCopySamplerUni; |
175 | 174 |
176 // An array of sampler uniform handles for each effect. | |
177 SamplerUniSArray fEffectSamplerUnis[GrDrawState::kNumStages]; | |
178 | |
179 UniformHandles() { | 175 UniformHandles() { |
180 fViewMatrixUni = GrGLUniformManager::kInvalidUniformHandle; | 176 fViewMatrixUni = GrGLUniformManager::kInvalidUniformHandle; |
181 fColorUni = GrGLUniformManager::kInvalidUniformHandle; | 177 fColorUni = GrGLUniformManager::kInvalidUniformHandle; |
182 fCoverageUni = GrGLUniformManager::kInvalidUniformHandle; | 178 fCoverageUni = GrGLUniformManager::kInvalidUniformHandle; |
183 fColorFilterUni = GrGLUniformManager::kInvalidUniformHandle; | 179 fColorFilterUni = GrGLUniformManager::kInvalidUniformHandle; |
184 fRTHeightUni = GrGLUniformManager::kInvalidUniformHandle; | 180 fRTHeightUni = GrGLUniformManager::kInvalidUniformHandle; |
185 fDstCopyTopLeftUni = GrGLUniformManager::kInvalidUniformHandle; | 181 fDstCopyTopLeftUni = GrGLUniformManager::kInvalidUniformHandle; |
186 fDstCopyScaleUni = GrGLUniformManager::kInvalidUniformHandle; | 182 fDstCopyScaleUni = GrGLUniformManager::kInvalidUniformHandle; |
187 fDstCopySamplerUni = GrGLUniformManager::kInvalidUniformHandle; | 183 fDstCopySamplerUni = GrGLUniformManager::kInvalidUniformHandle; |
188 } | 184 } |
189 }; | 185 }; |
190 | 186 |
| 187 typedef SkSTArray<4, UniformHandle, true> SamplerUniSArray; |
| 188 typedef SkSTArray<4, int, true> TextureUnitSArray; |
| 189 |
| 190 struct EffectAndSamplers { |
| 191 EffectAndSamplers() : fGLEffect(NULL) {} |
| 192 ~EffectAndSamplers() { delete fGLEffect; } |
| 193 GrGLEffect* fGLEffect; |
| 194 SamplerUniSArray fSamplerUnis; // sampler uni handles for effect's G
rTextureAccess |
| 195 TextureUnitSArray fTextureUnits; // texture unit used for each entry o
f fSamplerUnis |
| 196 }; |
| 197 |
191 // GL IDs | 198 // GL IDs |
192 GrGLuint fVShaderID; | 199 GrGLuint fVShaderID; |
193 GrGLuint fGShaderID; | 200 GrGLuint fGShaderID; |
194 GrGLuint fFShaderID; | 201 GrGLuint fFShaderID; |
195 GrGLuint fProgramID; | 202 GrGLuint fProgramID; |
196 | 203 |
197 // these reflect the current values of uniforms (GL uniform values travel wi
th program) | 204 // these reflect the current values of uniforms (GL uniform values travel wi
th program) |
198 MatrixState fMatrixState; | 205 MatrixState fMatrixState; |
199 GrColor fColor; | 206 GrColor fColor; |
200 GrColor fCoverage; | 207 GrColor fCoverage; |
201 GrColor fColorFilterColor; | 208 GrColor fColorFilterColor; |
| 209 int fDstCopyTexUnit; |
202 | 210 |
203 GrGLEffect* fEffects[GrDrawState::kNumStages]; | 211 SkTArray<EffectAndSamplers> fEffectStates; |
204 | 212 |
205 GrGLProgramDesc fDesc; | 213 GrGLProgramDesc fDesc; |
206 const GrGLContext& fContext; | 214 const GrGLContext& fContext; |
207 | 215 |
208 GrGLUniformManager fUniformManager; | 216 GrGLUniformManager fUniformManager; |
209 UniformHandles fUniformHandles; | 217 UniformHandles fUniformHandles; |
210 | 218 |
211 typedef GrRefCnt INHERITED; | 219 typedef GrRefCnt INHERITED; |
212 }; | 220 }; |
213 | 221 |
214 #endif | 222 #endif |
OLD | NEW |