OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 #ifndef GrGLProgramBuilder_DEFINED | 8 #ifndef GrGLProgramBuilder_DEFINED |
9 #define GrGLProgramBuilder_DEFINED | 9 #define GrGLProgramBuilder_DEFINED |
10 | 10 |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 * Please note - no diamond problems because of virtual inheritance. Also, both
base classes | 212 * Please note - no diamond problems because of virtual inheritance. Also, both
base classes |
213 * are pure virtual with no data members. This is the base class for program bu
ilding. | 213 * are pure virtual with no data members. This is the base class for program bu
ilding. |
214 * Subclasses are nearly identical but each has their own way of emitting transf
orms. State for | 214 * Subclasses are nearly identical but each has their own way of emitting transf
orms. State for |
215 * each of the elements of the shader pipeline, ie vertex, fragment, geometry, e
tc, lives in those | 215 * each of the elements of the shader pipeline, ie vertex, fragment, geometry, e
tc, lives in those |
216 * respective builders | 216 * respective builders |
217 */ | 217 */ |
218 class GrGLProgramBuilder : public GrGLGPBuilder, | 218 class GrGLProgramBuilder : public GrGLGPBuilder, |
219 public GrGLFPBuilder, | 219 public GrGLFPBuilder, |
220 public GrGLXPBuilder { | 220 public GrGLXPBuilder { |
221 public: | 221 public: |
| 222 typedef GrGpu::DrawArgs DrawArgs; |
222 /** Generates a shader program. | 223 /** Generates a shader program. |
223 * | 224 * |
224 * The program implements what is specified in the stages given as input. | 225 * The program implements what is specified in the stages given as input. |
225 * After successful generation, the builder result objects are available | 226 * After successful generation, the builder result objects are available |
226 * to be used. | 227 * to be used. |
227 * @return true if generation was successful. | 228 * @return true if generation was successful. |
228 */ | 229 */ |
229 static GrGLProgram* CreateProgram(const GrOptDrawState&, GrGLGpu*); | 230 static GrGLProgram* CreateProgram(const DrawArgs&, GrGLGpu*); |
230 | 231 |
231 UniformHandle addUniformArray(uint32_t visibility, | 232 UniformHandle addUniformArray(uint32_t visibility, |
232 GrSLType type, | 233 GrSLType type, |
233 GrSLPrecision precision, | 234 GrSLPrecision precision, |
234 const char* name, | 235 const char* name, |
235 int arrayCount, | 236 int arrayCount, |
236 const char** outName) SK_OVERRIDE; | 237 const char** outName) SK_OVERRIDE; |
237 | 238 |
238 const GrGLShaderVar& getUniformVariable(UniformHandle u) const SK_OVERRIDE { | 239 const GrGLShaderVar& getUniformVariable(UniformHandle u) const SK_OVERRIDE { |
239 return fUniforms[u.toShaderBuilderIndex()].fVariable; | 240 return fUniforms[u.toShaderBuilderIndex()].fVariable; |
(...skipping 30 matching lines...) Expand all Loading... |
270 // Uniforms for computing texture coords to do the dst-copy lookup | 271 // Uniforms for computing texture coords to do the dst-copy lookup |
271 UniformHandle fDstCopyTopLeftUni; | 272 UniformHandle fDstCopyTopLeftUni; |
272 UniformHandle fDstCopyScaleUni; | 273 UniformHandle fDstCopyScaleUni; |
273 UniformHandle fDstCopySamplerUni; | 274 UniformHandle fDstCopySamplerUni; |
274 }; | 275 }; |
275 | 276 |
276 protected: | 277 protected: |
277 typedef GrGLProgramDataManager::UniformInfo UniformInfo; | 278 typedef GrGLProgramDataManager::UniformInfo UniformInfo; |
278 typedef GrGLProgramDataManager::UniformInfoArray UniformInfoArray; | 279 typedef GrGLProgramDataManager::UniformInfoArray UniformInfoArray; |
279 | 280 |
280 static GrGLProgramBuilder* CreateProgramBuilder(const GrOptDrawState&, GrGLG
pu*); | 281 static GrGLProgramBuilder* CreateProgramBuilder(const DrawArgs&, GrGLGpu*); |
281 | 282 |
282 GrGLProgramBuilder(GrGLGpu*, const GrOptDrawState&); | 283 GrGLProgramBuilder(GrGLGpu*, const DrawArgs&); |
283 | 284 |
284 const GrOptDrawState& optState() const { return fOptState; } | 285 const GrPrimitiveProcessor& primitiveProcessor() const { return *fArgs.fPrim
itiveProcessor; } |
285 const GrProgramDesc& desc() const { return fDesc; } | 286 const GrOptDrawState& optState() const { return *fArgs.fOptState; } |
286 const GrProgramDesc::KeyHeader& header() const { return fDesc.header(); } | 287 const GrProgramDesc& desc() const { return *fArgs.fDesc; } |
| 288 const GrBatchTracker& batchTracker() const { return *fArgs.fBatchTracker; } |
| 289 const GrProgramDesc::KeyHeader& header() const { return fArgs.fDesc->header(
); } |
287 | 290 |
288 // Generates a name for a variable. The generated string will be name prefix
ed by the prefix | 291 // Generates a name for a variable. The generated string will be name prefix
ed by the prefix |
289 // char (unless the prefix is '\0'). It also mangles the name to be stage-sp
ecific if we're | 292 // char (unless the prefix is '\0'). It also mangles the name to be stage-sp
ecific if we're |
290 // generating stage code. | 293 // generating stage code. |
291 void nameVariable(SkString* out, char prefix, const char* name); | 294 void nameVariable(SkString* out, char prefix, const char* name); |
292 // Generates a possibly mangled name for a stage variable and writes it to t
he fragment shader. | 295 // Generates a possibly mangled name for a stage variable and writes it to t
he fragment shader. |
293 // If GrGLSLExpr4 has a valid name then it will use that instead | 296 // If GrGLSLExpr4 has a valid name then it will use that instead |
294 void nameExpression(GrGLSLExpr4*, const char* baseName); | 297 void nameExpression(GrGLSLExpr4*, const char* baseName); |
295 void emitAndInstallProcs(GrGLSLExpr4* inputColor, | 298 void emitAndInstallProcs(GrGLSLExpr4* inputColor, |
296 GrGLSLExpr4* inputCoverage); | 299 GrGLSLExpr4* inputCoverage); |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
376 GrGLVertexBuilder fVS; | 379 GrGLVertexBuilder fVS; |
377 GrGLGeometryBuilder fGS; | 380 GrGLGeometryBuilder fGS; |
378 GrGLFragmentShaderBuilder fFS; | 381 GrGLFragmentShaderBuilder fFS; |
379 bool fOutOfStage; | 382 bool fOutOfStage; |
380 int fStageIndex; | 383 int fStageIndex; |
381 | 384 |
382 GrGLInstalledGeoProc* fGeometryProcessor; | 385 GrGLInstalledGeoProc* fGeometryProcessor; |
383 GrGLInstalledXferProc* fXferProcessor; | 386 GrGLInstalledXferProc* fXferProcessor; |
384 SkAutoTUnref<GrGLInstalledFragProcs> fFragmentProcessors; | 387 SkAutoTUnref<GrGLInstalledFragProcs> fFragmentProcessors; |
385 | 388 |
386 const GrOptDrawState& fOptState; | 389 const DrawArgs& fArgs; |
387 const GrProgramDesc& fDesc; | |
388 GrGLGpu* fGpu; | 390 GrGLGpu* fGpu; |
389 UniformInfoArray fUniforms; | 391 UniformInfoArray fUniforms; |
390 GrGLPrimitiveProcessor::TransformsIn fCoordTransforms; | 392 GrGLPrimitiveProcessor::TransformsIn fCoordTransforms; |
391 GrGLPrimitiveProcessor::TransformsOut fOutCoords; | 393 GrGLPrimitiveProcessor::TransformsOut fOutCoords; |
392 | 394 |
393 friend class GrGLShaderBuilder; | 395 friend class GrGLShaderBuilder; |
394 friend class GrGLVertexBuilder; | 396 friend class GrGLVertexBuilder; |
395 friend class GrGLFragmentShaderBuilder; | 397 friend class GrGLFragmentShaderBuilder; |
396 friend class GrGLGeometryBuilder; | 398 friend class GrGLGeometryBuilder; |
397 }; | 399 }; |
398 #endif | 400 #endif |
OLD | NEW |