| 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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 class GrGLProgramBuilder : public GrGLGPBuilder, | 112 class GrGLProgramBuilder : public GrGLGPBuilder, |
| 113 public GrGLFPBuilder { | 113 public GrGLFPBuilder { |
| 114 public: | 114 public: |
| 115 /** Generates a shader program. | 115 /** Generates a shader program. |
| 116 * | 116 * |
| 117 * The program implements what is specified in the stages given as input. | 117 * The program implements what is specified in the stages given as input. |
| 118 * After successful generation, the builder result objects are available | 118 * After successful generation, the builder result objects are available |
| 119 * to be used. | 119 * to be used. |
| 120 * @return true if generation was successful. | 120 * @return true if generation was successful. |
| 121 */ | 121 */ |
| 122 static GrGLProgram* CreateProgram(const GrOptDrawState&, | 122 static GrGLProgram* CreateProgram(const GrOptDrawState&, GrGpu::DrawType, Gr
GpuGL*); |
| 123 const GrGLProgramDesc&, | |
| 124 GrGpu::DrawType, | |
| 125 GrGpuGL* gpu); | |
| 126 | 123 |
| 127 virtual UniformHandle addUniform(uint32_t visibility, | 124 virtual UniformHandle addUniform(uint32_t visibility, |
| 128 GrSLType type, | 125 GrSLType type, |
| 129 const char* name, | 126 const char* name, |
| 130 const char** outName = NULL) SK_OVERRIDE { | 127 const char** outName = NULL) SK_OVERRIDE { |
| 131 return this->addUniformArray(visibility, type, name, GrGLShaderVar::kNon
Array, outName); | 128 return this->addUniformArray(visibility, type, name, GrGLShaderVar::kNon
Array, outName); |
| 132 } | 129 } |
| 133 virtual UniformHandle addUniformArray(uint32_t visibility, | 130 virtual UniformHandle addUniformArray(uint32_t visibility, |
| 134 GrSLType type, | 131 GrSLType type, |
| 135 const char* name, | 132 const char* name, |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 // origin_upper_left is not supported. | 166 // origin_upper_left is not supported. |
| 170 UniformHandle fRTHeightUni; | 167 UniformHandle fRTHeightUni; |
| 171 | 168 |
| 172 // Uniforms for computing texture coords to do the dst-copy lookup | 169 // Uniforms for computing texture coords to do the dst-copy lookup |
| 173 UniformHandle fDstCopyTopLeftUni; | 170 UniformHandle fDstCopyTopLeftUni; |
| 174 UniformHandle fDstCopyScaleUni; | 171 UniformHandle fDstCopyScaleUni; |
| 175 UniformHandle fDstCopySamplerUni; | 172 UniformHandle fDstCopySamplerUni; |
| 176 }; | 173 }; |
| 177 | 174 |
| 178 protected: | 175 protected: |
| 179 typedef GrGLProgramDesc::ProcKeyProvider ProcKeyProvider; | 176 typedef GrProgramDesc::ProcKeyProvider ProcKeyProvider; |
| 180 typedef GrGLProgramDataManager::UniformInfo UniformInfo; | 177 typedef GrGLProgramDataManager::UniformInfo UniformInfo; |
| 181 typedef GrGLProgramDataManager::UniformInfoArray UniformInfoArray; | 178 typedef GrGLProgramDataManager::UniformInfoArray UniformInfoArray; |
| 182 | 179 |
| 183 static GrGLProgramBuilder* CreateProgramBuilder(const GrGLProgramDesc&, | 180 static GrGLProgramBuilder* CreateProgramBuilder(const GrOptDrawState&, |
| 184 const GrOptDrawState&, | |
| 185 GrGpu::DrawType, | 181 GrGpu::DrawType, |
| 186 bool hasGeometryProcessor, | 182 bool hasGeometryProcessor, |
| 187 GrGpuGL*); | 183 GrGpuGL*); |
| 188 | 184 |
| 189 GrGLProgramBuilder(GrGpuGL*, const GrOptDrawState&, const GrGLProgramDesc&); | 185 GrGLProgramBuilder(GrGpuGL*, const GrOptDrawState&); |
| 190 | 186 |
| 191 const GrOptDrawState& optState() const { return fOptState; } | 187 const GrOptDrawState& optState() const { return fOptState; } |
| 192 const GrGLProgramDesc& desc() const { return fDesc; } | 188 const GrProgramDesc& desc() const { return fDesc; } |
| 193 const GrGLProgramDesc::KeyHeader& header() const { return fDesc.getHeader();
} | 189 const GrProgramDesc::KeyHeader& header() const { return fDesc.header(); } |
| 194 | 190 |
| 195 // Generates a name for a variable. The generated string will be name prefix
ed by the prefix | 191 // Generates a name for a variable. The generated string will be name prefix
ed by the prefix |
| 196 // char (unless the prefix is '\0'). It also mangles the name to be stage-sp
ecific if we're | 192 // char (unless the prefix is '\0'). It also mangles the name to be stage-sp
ecific if we're |
| 197 // generating stage code. | 193 // generating stage code. |
| 198 void nameVariable(SkString* out, char prefix, const char* name); | 194 void nameVariable(SkString* out, char prefix, const char* name); |
| 199 void setupUniformColorAndCoverageIfNeeded(GrGLSLExpr4* inputColor, GrGLSLExp
r4* inputCoverage); | 195 void setupUniformColorAndCoverageIfNeeded(GrGLSLExpr4* inputColor, GrGLSLExp
r4* inputCoverage); |
| 200 void emitAndInstallProcs(const GrOptDrawState& optState, | 196 void emitAndInstallProcs(const GrOptDrawState& optState, |
| 201 GrGLSLExpr4* inputColor, | 197 GrGLSLExpr4* inputColor, |
| 202 GrGLSLExpr4* inputCoverage); | 198 GrGLSLExpr4* inputCoverage); |
| 203 void emitAndInstallFragProcs(int procOffset, int numProcs, GrGLSLExpr4* inOu
t); | 199 void emitAndInstallFragProcs(int procOffset, int numProcs, GrGLSLExpr4* inOu
t); |
| 204 template <class Proc> | 200 template <class Proc> |
| 205 void emitAndInstallProc(const Proc&, | 201 void emitAndInstallProc(const Proc&, |
| 206 int index, | 202 int index, |
| 207 const ProcKeyProvider, | 203 const ProcKeyProvider&, |
| 208 const GrGLSLExpr4& input, | 204 const GrGLSLExpr4& input, |
| 209 GrGLSLExpr4* output); | 205 GrGLSLExpr4* output); |
| 210 | 206 |
| 211 // these emit functions help to keep the createAndEmitProcessors template ge
neral | 207 // these emit functions help to keep the createAndEmitProcessors template ge
neral |
| 212 void emitAndInstallProc(const GrFragmentStage&, | 208 void emitAndInstallProc(const GrFragmentStage&, |
| 213 const GrProcessorKey&, | 209 const GrProcessorKey&, |
| 214 const char* outColor, | 210 const char* outColor, |
| 215 const char* inColor); | 211 const char* inColor); |
| 216 void emitAndInstallProc(const GrGeometryProcessor&, | 212 void emitAndInstallProc(const GrGeometryProcessor&, |
| 217 const GrProcessorKey&, | 213 const GrProcessorKey&, |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 GrGLVertexBuilder fVS; | 273 GrGLVertexBuilder fVS; |
| 278 GrGLGeometryBuilder fGS; | 274 GrGLGeometryBuilder fGS; |
| 279 GrGLFragmentShaderBuilder fFS; | 275 GrGLFragmentShaderBuilder fFS; |
| 280 bool fOutOfStage; | 276 bool fOutOfStage; |
| 281 int fStageIndex; | 277 int fStageIndex; |
| 282 | 278 |
| 283 GrGLInstalledGeoProc* fGeometryProcessor; | 279 GrGLInstalledGeoProc* fGeometryProcessor; |
| 284 SkAutoTUnref<GrGLInstalledFragProcs> fFragmentProcessors; | 280 SkAutoTUnref<GrGLInstalledFragProcs> fFragmentProcessors; |
| 285 | 281 |
| 286 const GrOptDrawState& fOptState; | 282 const GrOptDrawState& fOptState; |
| 287 const GrGLProgramDesc& fDesc; | 283 const GrProgramDesc& fDesc; |
| 288 GrGpuGL* fGpu; | 284 GrGpuGL* fGpu; |
| 289 UniformInfoArray fUniforms; | 285 UniformInfoArray fUniforms; |
| 290 | 286 |
| 291 friend class GrGLShaderBuilder; | 287 friend class GrGLShaderBuilder; |
| 292 friend class GrGLVertexBuilder; | 288 friend class GrGLVertexBuilder; |
| 293 friend class GrGLFragmentShaderBuilder; | 289 friend class GrGLFragmentShaderBuilder; |
| 294 friend class GrGLGeometryBuilder; | 290 friend class GrGLGeometryBuilder; |
| 295 }; | 291 }; |
| 296 | 292 |
| 297 /** | 293 /** |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 SkSTArray<2, Transform, true> fTransforms; | 337 SkSTArray<2, Transform, true> fTransforms; |
| 342 bool fLocalCoordAttrib; | 338 bool fLocalCoordAttrib; |
| 343 }; | 339 }; |
| 344 | 340 |
| 345 struct GrGLInstalledFragProcs : public SkRefCnt { | 341 struct GrGLInstalledFragProcs : public SkRefCnt { |
| 346 virtual ~GrGLInstalledFragProcs(); | 342 virtual ~GrGLInstalledFragProcs(); |
| 347 SkSTArray<8, GrGLInstalledFragProc*, true> fProcs; | 343 SkSTArray<8, GrGLInstalledFragProc*, true> fProcs; |
| 348 }; | 344 }; |
| 349 | 345 |
| 350 #endif | 346 #endif |
| OLD | NEW |