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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
145 }; | 145 }; |
146 | 146 |
147 /** | 147 /** |
148 * This function uploads uniforms and calls each GrGLProcessor's setData. It is called before a | 148 * This function uploads uniforms and calls each GrGLProcessor's setData. It is called before a |
149 * draw occurs using the program after the program has already been bound. I t also uses the | 149 * draw occurs using the program after the program has already been bound. I t also uses the |
150 * GrGpuGL object to bind the textures required by the GrGLProcessors. The c olor and coverage | 150 * GrGpuGL object to bind the textures required by the GrGLProcessors. The c olor and coverage |
151 * stages come from GrGLProgramDesc::Build(). | 151 * stages come from GrGLProgramDesc::Build(). |
152 */ | 152 */ |
153 void setData(const GrOptDrawState&, | 153 void setData(const GrOptDrawState&, |
154 GrGpu::DrawType, | 154 GrGpu::DrawType, |
155 const GrGeometryStage* geometryProcessor, | |
156 const GrFragmentStage* colorStages[], | |
157 const GrFragmentStage* coverageStages[], | |
158 const GrDeviceCoordTexture* dstCopy, // can be NULL | 155 const GrDeviceCoordTexture* dstCopy, // can be NULL |
159 SharedGLState*); | 156 SharedGLState*); |
160 | 157 |
161 protected: | 158 protected: |
162 typedef GrGLProgramDataManager::UniformHandle UniformHandle; | 159 typedef GrGLProgramDataManager::UniformHandle UniformHandle; |
163 typedef GrGLProgramDataManager::UniformInfoArray UniformInfoArray; | 160 typedef GrGLProgramDataManager::UniformInfoArray UniformInfoArray; |
164 | 161 |
165 GrGLProgram(GrGpuGL*, | 162 GrGLProgram(GrGpuGL*, |
166 const GrGLProgramDesc&, | 163 const GrGLProgramDesc&, |
167 const BuiltinUniformHandles&, | 164 const BuiltinUniformHandles&, |
168 GrGLuint programID, | 165 GrGLuint programID, |
169 const UniformInfoArray&, | 166 const UniformInfoArray&, |
170 GrGLInstalledProcessors* geometryProcessor, | 167 GrGLInstalledProcessors* geometryProcessor, |
171 GrGLInstalledProcessors* colorProcessors, | 168 GrGLInstalledProcessors* colorProcessors, |
172 GrGLInstalledProcessors* coverageProcessors); | 169 GrGLInstalledProcessors* coverageProcessors); |
173 | 170 |
174 // Sets the texture units for samplers. | 171 // Sets the texture units for samplers. |
175 void initSamplerUniforms(); | 172 void initSamplerUniforms(); |
176 void initSamplers(GrGLInstalledProcessors* processors, int* texUnitIdx); | 173 void initSamplers(GrGLInstalledProcessors* processors, int* texUnitIdx); |
177 | 174 |
178 // Helper for setData(). Makes GL calls to specify the initial color when th ere is not | 175 // Helper for setData(). Makes GL calls to specify the initial color when th ere is not |
179 // per-vertex colors. | 176 // per-vertex colors. |
180 void setColor(const GrOptDrawState&, GrColor color, SharedGLState*); | 177 void setColor(const GrOptDrawState&, GrColor color, SharedGLState*); |
181 | 178 |
182 // Helper for setData(). Makes GL calls to specify the initial coverage when there is not | 179 // Helper for setData(). Makes GL calls to specify the initial coverage when there is not |
183 // per-vertex coverages. | 180 // per-vertex coverages. |
184 void setCoverage(const GrOptDrawState&, GrColor coverage, SharedGLState*); | 181 void setCoverage(const GrOptDrawState&, GrColor coverage, SharedGLState*); |
185 | 182 |
186 // A templated helper to loop over effects, set the transforms(via subclass) and bind textures | 183 // A templated helper to loop over effects, set the transforms(via subclass) and bind textures |
187 template <class ProcessorStage> | 184 template <class StageMapper> |
188 void setData(const ProcessorStage* effectStages[], | 185 void setData(const GrOptDrawState& optState, GrGLInstalledProcessors* instal ledProcessors) { |
bsalomon
2014/10/09 18:35:45
Is it useful that this operates on an array? It's
egdaniel
2014/10/09 18:52:04
I can definitely make GrODS have a single FP array
| |
189 GrGLInstalledProcessors* installedProcessors) { | |
190 int numEffects = installedProcessors->fGLProcessors.count(); | 186 int numEffects = installedProcessors->fGLProcessors.count(); |
191 SkASSERT(numEffects == installedProcessors->fTransforms.count()); | 187 SkASSERT(numEffects == installedProcessors->fTransforms.count()); |
192 SkASSERT(numEffects == installedProcessors->fSamplers.count()); | 188 SkASSERT(numEffects == installedProcessors->fSamplers.count()); |
193 for (int e = 0; e < numEffects; ++e) { | 189 for (int e = 0; e < numEffects; ++e) { |
194 const GrProcessor& effect = *effectStages[e]->getProcessor(); | 190 const GrFragmentStage& stage = StageMapper::GetStage(optState, e); |
191 SkASSERT(stage.getProcessor()); | |
192 const GrProcessor& effect = *stage.getProcessor(); | |
195 installedProcessors->fGLProcessors[e]->setData(fProgramDataManager, effect); | 193 installedProcessors->fGLProcessors[e]->setData(fProgramDataManager, effect); |
196 this->setTransformData(*effectStages[e], e, installedProcessors); | 194 this->setTransformData(stage, e, installedProcessors); |
197 this->bindTextures(installedProcessors, effect, e); | 195 this->bindTextures(*installedProcessors, effect, e); |
198 } | 196 } |
199 } | 197 } |
200 virtual void setTransformData(const GrProcessorStage& effectStage, | 198 virtual void setTransformData(const GrFragmentStage& effectStage, |
201 int effectIdx, | 199 int effectIdx, |
202 GrGLInstalledProcessors* pe); | 200 GrGLInstalledProcessors* pe); |
203 void bindTextures(const GrGLInstalledProcessors*, const GrProcessor&, int ef fectIdx); | 201 void bindTextures(const GrGLInstalledProcessors&, const GrProcessor&, int ef fectIdx); |
204 | 202 |
205 /* | 203 /* |
206 * Legacy NVPR needs a hook here to flush path tex gen settings. | 204 * Legacy NVPR needs a hook here to flush path tex gen settings. |
207 * TODO when legacy nvpr is removed, remove this call. | 205 * TODO when legacy nvpr is removed, remove this call. |
208 */ | 206 */ |
209 virtual void didSetData(GrGpu::DrawType); | 207 virtual void didSetData(GrGpu::DrawType); |
210 | 208 |
211 // Helper for setData() that sets the view matrix and loads the render targe t height uniform | 209 // Helper for setData() that sets the view matrix and loads the render targe t height uniform |
212 void setMatrixAndRenderTargetHeight(GrGpu::DrawType, const GrOptDrawState&); | 210 void setMatrixAndRenderTargetHeight(GrGpu::DrawType, const GrOptDrawState&); |
213 virtual void onSetMatrixAndRenderTargetHeight(GrGpu::DrawType, const GrOptDr awState&); | 211 virtual void onSetMatrixAndRenderTargetHeight(GrGpu::DrawType, const GrOptDr awState&); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
264 typedef GrGLNvprProgramBuilder::SeparableVaryingInfoArray SeparableVaryingIn foArray; | 262 typedef GrGLNvprProgramBuilder::SeparableVaryingInfoArray SeparableVaryingIn foArray; |
265 GrGLNvprProgram(GrGpuGL*, | 263 GrGLNvprProgram(GrGpuGL*, |
266 const GrGLProgramDesc&, | 264 const GrGLProgramDesc&, |
267 const BuiltinUniformHandles&, | 265 const BuiltinUniformHandles&, |
268 GrGLuint programID, | 266 GrGLuint programID, |
269 const UniformInfoArray&, | 267 const UniformInfoArray&, |
270 GrGLInstalledProcessors* colorProcessors, | 268 GrGLInstalledProcessors* colorProcessors, |
271 GrGLInstalledProcessors* coverageProcessors, | 269 GrGLInstalledProcessors* coverageProcessors, |
272 const SeparableVaryingInfoArray& separableVaryings); | 270 const SeparableVaryingInfoArray& separableVaryings); |
273 virtual void didSetData(GrGpu::DrawType) SK_OVERRIDE; | 271 virtual void didSetData(GrGpu::DrawType) SK_OVERRIDE; |
274 virtual void setTransformData(const GrProcessorStage&, | 272 virtual void setTransformData(const GrFragmentStage&, |
275 int effectIdx, | 273 int effectIdx, |
276 GrGLInstalledProcessors*) SK_OVERRIDE; | 274 GrGLInstalledProcessors*) SK_OVERRIDE; |
277 | 275 |
278 struct Varying { | 276 struct Varying { |
279 GrGLint fLocation; | 277 GrGLint fLocation; |
280 SkDEBUGCODE( | 278 SkDEBUGCODE( |
281 GrSLType fType; | 279 GrSLType fType; |
282 ); | 280 ); |
283 }; | 281 }; |
284 SkTArray<Varying, true> fVaryings; | 282 SkTArray<Varying, true> fVaryings; |
(...skipping 10 matching lines...) Expand all Loading... | |
295 private: | 293 private: |
296 GrGLLegacyNvprProgram(GrGpuGL* gpu, | 294 GrGLLegacyNvprProgram(GrGpuGL* gpu, |
297 const GrGLProgramDesc& desc, | 295 const GrGLProgramDesc& desc, |
298 const BuiltinUniformHandles&, | 296 const BuiltinUniformHandles&, |
299 GrGLuint programID, | 297 GrGLuint programID, |
300 const UniformInfoArray&, | 298 const UniformInfoArray&, |
301 GrGLInstalledProcessors* colorProcessors, | 299 GrGLInstalledProcessors* colorProcessors, |
302 GrGLInstalledProcessors* coverageProcessors, | 300 GrGLInstalledProcessors* coverageProcessors, |
303 int texCoordSetCnt); | 301 int texCoordSetCnt); |
304 virtual void didSetData(GrGpu::DrawType) SK_OVERRIDE; | 302 virtual void didSetData(GrGpu::DrawType) SK_OVERRIDE; |
305 virtual void setTransformData(const GrProcessorStage&, | 303 virtual void setTransformData(const GrFragmentStage&, |
306 int effectIdx, | 304 int effectIdx, |
307 GrGLInstalledProcessors*) SK_OVERRIDE; | 305 GrGLInstalledProcessors*) SK_OVERRIDE; |
308 | 306 |
309 int fTexCoordSetCnt; | 307 int fTexCoordSetCnt; |
310 | 308 |
311 friend class GrGLLegacyNvprProgramBuilder; | 309 friend class GrGLLegacyNvprProgramBuilder; |
312 | 310 |
313 typedef GrGLNvprProgramBase INHERITED; | 311 typedef GrGLNvprProgramBase INHERITED; |
314 }; | 312 }; |
315 | 313 |
316 #endif | 314 #endif |
OLD | NEW |