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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 typedef GrTAllocator<SeparableVaryingInfo> SeparableVaryingInfoArray; | 79 typedef GrTAllocator<SeparableVaryingInfo> SeparableVaryingInfoArray; |
80 | 80 |
81 /** Generates a shader program. | 81 /** Generates a shader program. |
82 * | 82 * |
83 * The program implements what is specified in the stages given as input. | 83 * The program implements what is specified in the stages given as input. |
84 * After successful generation, the builder result objects are available | 84 * After successful generation, the builder result objects are available |
85 * to be used. | 85 * to be used. |
86 * @return true if generation was successful. | 86 * @return true if generation was successful. |
87 */ | 87 */ |
88 | 88 |
89 bool genProgram(const GrGeometryStage* inGeometryProcessor, | 89 bool genProgram(const GrOptDrawState& optstate, |
| 90 const GrGeometryStage* inGeometryProcessor, |
90 const GrFragmentStage* inColorStages[], | 91 const GrFragmentStage* inColorStages[], |
91 const GrFragmentStage* inCoverageStages[]); | 92 const GrFragmentStage* inCoverageStages[]); |
92 | 93 |
93 GrGLProgramEffects* getGeometryProcessor() const { | 94 GrGLProgramEffects* getGeometryProcessor() const { |
94 SkASSERT(fProgramID); return fGeometryProcessor.get(); | 95 SkASSERT(fProgramID); return fGeometryProcessor.get(); |
95 } | 96 } |
96 GrGLProgramEffects* getColorEffects() const { SkASSERT(fProgramID); return f
ColorEffects.get(); } | 97 GrGLProgramEffects* getColorEffects() const { SkASSERT(fProgramID); return f
ColorEffects.get(); } |
97 GrGLProgramEffects* getCoverageEffects() const { SkASSERT(fProgramID); retur
n fCoverageEffects.get(); } | 98 GrGLProgramEffects* getCoverageEffects() const { SkASSERT(fProgramID); retur
n fCoverageEffects.get(); } |
98 const BuiltinUniformHandles& getBuiltinUniformHandles() const { | 99 const BuiltinUniformHandles& getBuiltinUniformHandles() const { |
99 SkASSERT(fProgramID); | 100 SkASSERT(fProgramID); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 void emitSamplers(const GrProcessor& effect, | 174 void emitSamplers(const GrProcessor& effect, |
174 GrGLProcessor::TextureSamplerArray* outSamplers); | 175 GrGLProcessor::TextureSamplerArray* outSamplers); |
175 | 176 |
176 // Generates a name for a variable. The generated string will be name prefix
ed by the prefix | 177 // Generates a name for a variable. The generated string will be name prefix
ed by the prefix |
177 // char (unless the prefix is '\0'). It also mangles the name to be stage-sp
ecific if we're | 178 // char (unless the prefix is '\0'). It also mangles the name to be stage-sp
ecific if we're |
178 // generating stage code. | 179 // generating stage code. |
179 void nameVariable(SkString* out, char prefix, const char* name); | 180 void nameVariable(SkString* out, char prefix, const char* name); |
180 | 181 |
181 virtual bool compileAndAttachShaders(GrGLuint programId, SkTDArray<GrGLuint>
* shaderIds) const; | 182 virtual bool compileAndAttachShaders(GrGLuint programId, SkTDArray<GrGLuint>
* shaderIds) const; |
182 | 183 |
183 virtual void bindProgramLocations(GrGLuint programId); | 184 virtual void bindProgramLocations(const GrOptDrawState&, GrGLuint programId)
; |
184 void resolveProgramLocations(GrGLuint programId); | 185 void resolveProgramLocations(GrGLuint programId); |
185 | 186 |
186 void appendDecls(const VarArray&, SkString*) const; | 187 void appendDecls(const VarArray&, SkString*) const; |
187 void appendUniformDecls(ShaderVisibility, SkString*) const; | 188 void appendUniformDecls(ShaderVisibility, SkString*) const; |
188 | 189 |
189 class CodeStage : SkNoncopyable { | 190 class CodeStage : SkNoncopyable { |
190 public: | 191 public: |
191 CodeStage() : fNextIndex(0), fCurrentIndex(-1), fEffectStage(NULL) {} | 192 CodeStage() : fNextIndex(0), fCurrentIndex(-1), fEffectStage(NULL) {} |
192 | 193 |
193 bool inStageCode() const { | 194 bool inStageCode() const { |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 /* | 316 /* |
316 * Because we have fragment only builders, and those builders need to implem
ent a subclass | 317 * Because we have fragment only builders, and those builders need to implem
ent a subclass |
317 * of program effects, we have to have base classes overload the program eff
ects here | 318 * of program effects, we have to have base classes overload the program eff
ects here |
318 */ | 319 */ |
319 virtual GrGLProgramEffects* getProgramEffects() = 0; | 320 virtual GrGLProgramEffects* getProgramEffects() = 0; |
320 | 321 |
321 /** | 322 /** |
322 * Compiles all the shaders, links them into a program, and writes the progr
am id to the output | 323 * Compiles all the shaders, links them into a program, and writes the progr
am id to the output |
323 * struct. | 324 * struct. |
324 **/ | 325 **/ |
325 bool finish(); | 326 bool finish(const GrOptDrawState&); |
326 | 327 |
327 GrGLFragmentProcessorEmitter fGrProcessorEmitter; | 328 GrGLFragmentProcessorEmitter fGrProcessorEmitter; |
328 | 329 |
329 const GrGLProgramDesc& fDesc; | 330 const GrGLProgramDesc& fDesc; |
330 GrGpuGL* fGpu; | 331 GrGpuGL* fGpu; |
331 UniformInfoArray fUniforms; | 332 UniformInfoArray fUniforms; |
332 | 333 |
333 friend class GrGLShaderBuilder; | 334 friend class GrGLShaderBuilder; |
334 friend class GrGLVertexShaderBuilder; | 335 friend class GrGLVertexShaderBuilder; |
335 friend class GrGLFragmentShaderBuilder; | 336 friend class GrGLFragmentShaderBuilder; |
336 friend class GrGLGeometryShaderBuilder; | 337 friend class GrGLGeometryShaderBuilder; |
337 }; | 338 }; |
338 | 339 |
339 #endif | 340 #endif |
OLD | NEW |