| 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 | 64 |
| 65 virtual const GrGLShaderVar& getUniformVariable(UniformHandle u) const = 0; | 65 virtual const GrGLShaderVar& getUniformVariable(UniformHandle u) const = 0; |
| 66 | 66 |
| 67 /** | 67 /** |
| 68 * Shortcut for getUniformVariable(u).c_str() | 68 * Shortcut for getUniformVariable(u).c_str() |
| 69 */ | 69 */ |
| 70 virtual const char* getUniformCStr(UniformHandle u) const = 0; | 70 virtual const char* getUniformCStr(UniformHandle u) const = 0; |
| 71 | 71 |
| 72 virtual const GrGLContextInfo& ctxInfo() const = 0; | 72 virtual const GrGLContextInfo& ctxInfo() const = 0; |
| 73 | 73 |
| 74 virtual GrGpuGL* gpu() const = 0; | 74 virtual GrGLGpu* gpu() const = 0; |
| 75 | 75 |
| 76 /* | 76 /* |
| 77 * *NOTE* NO MEMBERS ALLOWED, MULTIPLE INHERITANCE | 77 * *NOTE* NO MEMBERS ALLOWED, MULTIPLE INHERITANCE |
| 78 */ | 78 */ |
| 79 }; | 79 }; |
| 80 | 80 |
| 81 // TODO move this into GrGLGPBuilder and move them both out of this file | 81 // TODO move this into GrGLGPBuilder and move them both out of this file |
| 82 class GrGLVarying { | 82 class GrGLVarying { |
| 83 public: | 83 public: |
| 84 bool vsVarying() const { return kVertToFrag_Varying == fVarying || | 84 bool vsVarying() const { return kVertToFrag_Varying == fVarying || |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 public GrGLFPBuilder, | 198 public GrGLFPBuilder, |
| 199 public GrGLXPBuilder { | 199 public GrGLXPBuilder { |
| 200 public: | 200 public: |
| 201 /** Generates a shader program. | 201 /** Generates a shader program. |
| 202 * | 202 * |
| 203 * The program implements what is specified in the stages given as input. | 203 * The program implements what is specified in the stages given as input. |
| 204 * After successful generation, the builder result objects are available | 204 * After successful generation, the builder result objects are available |
| 205 * to be used. | 205 * to be used. |
| 206 * @return true if generation was successful. | 206 * @return true if generation was successful. |
| 207 */ | 207 */ |
| 208 static GrGLProgram* CreateProgram(const GrOptDrawState&, GrGpuGL*); | 208 static GrGLProgram* CreateProgram(const GrOptDrawState&, GrGLGpu*); |
| 209 | 209 |
| 210 UniformHandle addUniformArray(uint32_t visibility, | 210 UniformHandle addUniformArray(uint32_t visibility, |
| 211 GrSLType type, | 211 GrSLType type, |
| 212 GrSLPrecision precision, | 212 GrSLPrecision precision, |
| 213 const char* name, | 213 const char* name, |
| 214 int arrayCount, | 214 int arrayCount, |
| 215 const char** outName) SK_OVERRIDE; | 215 const char** outName) SK_OVERRIDE; |
| 216 | 216 |
| 217 const GrGLShaderVar& getUniformVariable(UniformHandle u) const SK_OVERRIDE { | 217 const GrGLShaderVar& getUniformVariable(UniformHandle u) const SK_OVERRIDE { |
| 218 return fUniforms[u.toShaderBuilderIndex()].fVariable; | 218 return fUniforms[u.toShaderBuilderIndex()].fVariable; |
| 219 } | 219 } |
| 220 | 220 |
| 221 const char* getUniformCStr(UniformHandle u) const SK_OVERRIDE { | 221 const char* getUniformCStr(UniformHandle u) const SK_OVERRIDE { |
| 222 return this->getUniformVariable(u).c_str(); | 222 return this->getUniformVariable(u).c_str(); |
| 223 } | 223 } |
| 224 | 224 |
| 225 const GrGLContextInfo& ctxInfo() const SK_OVERRIDE; | 225 const GrGLContextInfo& ctxInfo() const SK_OVERRIDE; |
| 226 | 226 |
| 227 GrGpuGL* gpu() const SK_OVERRIDE { return fGpu; } | 227 GrGLGpu* gpu() const SK_OVERRIDE { return fGpu; } |
| 228 | 228 |
| 229 GrGLFPFragmentBuilder* getFragmentShaderBuilder() SK_OVERRIDE { return &fFS;
} | 229 GrGLFPFragmentBuilder* getFragmentShaderBuilder() SK_OVERRIDE { return &fFS;
} |
| 230 GrGLVertexBuilder* getVertexShaderBuilder() SK_OVERRIDE { return &fVS; } | 230 GrGLVertexBuilder* getVertexShaderBuilder() SK_OVERRIDE { return &fVS; } |
| 231 | 231 |
| 232 void addVarying( | 232 void addVarying( |
| 233 const char* name, | 233 const char* name, |
| 234 GrGLVarying*, | 234 GrGLVarying*, |
| 235 GrSLPrecision fsPrecision = kDefault_GrSLPrecision) SK_OVERRIDE; | 235 GrSLPrecision fsPrecision = kDefault_GrSLPrecision) SK_OVERRIDE; |
| 236 | 236 |
| 237 void addPassThroughAttribute(const GrGeometryProcessor::GrAttribute*, | 237 void addPassThroughAttribute(const GrGeometryProcessor::GrAttribute*, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 252 UniformHandle fDstCopyScaleUni; | 252 UniformHandle fDstCopyScaleUni; |
| 253 UniformHandle fDstCopySamplerUni; | 253 UniformHandle fDstCopySamplerUni; |
| 254 }; | 254 }; |
| 255 | 255 |
| 256 protected: | 256 protected: |
| 257 typedef GrGLProgramDataManager::UniformInfo UniformInfo; | 257 typedef GrGLProgramDataManager::UniformInfo UniformInfo; |
| 258 typedef GrGLProgramDataManager::UniformInfoArray UniformInfoArray; | 258 typedef GrGLProgramDataManager::UniformInfoArray UniformInfoArray; |
| 259 | 259 |
| 260 static GrGLProgramBuilder* CreateProgramBuilder(const GrOptDrawState&, | 260 static GrGLProgramBuilder* CreateProgramBuilder(const GrOptDrawState&, |
| 261 bool hasGeometryProcessor, | 261 bool hasGeometryProcessor, |
| 262 GrGpuGL*); | 262 GrGLGpu*); |
| 263 | 263 |
| 264 GrGLProgramBuilder(GrGpuGL*, const GrOptDrawState&); | 264 GrGLProgramBuilder(GrGLGpu*, const GrOptDrawState&); |
| 265 | 265 |
| 266 const GrOptDrawState& optState() const { return fOptState; } | 266 const GrOptDrawState& optState() const { return fOptState; } |
| 267 const GrProgramDesc& desc() const { return fDesc; } | 267 const GrProgramDesc& desc() const { return fDesc; } |
| 268 const GrProgramDesc::KeyHeader& header() const { return fDesc.header(); } | 268 const GrProgramDesc::KeyHeader& header() const { return fDesc.header(); } |
| 269 | 269 |
| 270 // Generates a name for a variable. The generated string will be name prefix
ed by the prefix | 270 // Generates a name for a variable. The generated string will be name prefix
ed by the prefix |
| 271 // char (unless the prefix is '\0'). It also mangles the name to be stage-sp
ecific if we're | 271 // char (unless the prefix is '\0'). It also mangles the name to be stage-sp
ecific if we're |
| 272 // generating stage code. | 272 // generating stage code. |
| 273 void nameVariable(SkString* out, char prefix, const char* name); | 273 void nameVariable(SkString* out, char prefix, const char* name); |
| 274 // Generates a possibly mangled name for a stage variable and writes it to t
he fragment shader. | 274 // Generates a possibly mangled name for a stage variable and writes it to t
he fragment shader. |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 GrGLFragmentShaderBuilder fFS; | 370 GrGLFragmentShaderBuilder fFS; |
| 371 bool fOutOfStage; | 371 bool fOutOfStage; |
| 372 int fStageIndex; | 372 int fStageIndex; |
| 373 | 373 |
| 374 GrGLInstalledGeoProc* fGeometryProcessor; | 374 GrGLInstalledGeoProc* fGeometryProcessor; |
| 375 GrGLInstalledXferProc* fXferProcessor; | 375 GrGLInstalledXferProc* fXferProcessor; |
| 376 SkAutoTUnref<GrGLInstalledFragProcs> fFragmentProcessors; | 376 SkAutoTUnref<GrGLInstalledFragProcs> fFragmentProcessors; |
| 377 | 377 |
| 378 const GrOptDrawState& fOptState; | 378 const GrOptDrawState& fOptState; |
| 379 const GrProgramDesc& fDesc; | 379 const GrProgramDesc& fDesc; |
| 380 GrGpuGL* fGpu; | 380 GrGLGpu* fGpu; |
| 381 UniformInfoArray fUniforms; | 381 UniformInfoArray fUniforms; |
| 382 SkSTArray<16, TransformVarying, true> fCoordVaryings; | 382 SkSTArray<16, TransformVarying, true> fCoordVaryings; |
| 383 | 383 |
| 384 friend class GrGLShaderBuilder; | 384 friend class GrGLShaderBuilder; |
| 385 friend class GrGLVertexBuilder; | 385 friend class GrGLVertexBuilder; |
| 386 friend class GrGLFragmentShaderBuilder; | 386 friend class GrGLFragmentShaderBuilder; |
| 387 friend class GrGLGeometryBuilder; | 387 friend class GrGLGeometryBuilder; |
| 388 }; | 388 }; |
| 389 | 389 |
| 390 /** | 390 /** |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 437 SkAutoTDelete<GrGLFragmentProcessor> fGLProc; | 437 SkAutoTDelete<GrGLFragmentProcessor> fGLProc; |
| 438 SkSTArray<2, Transform, true> fTransforms; | 438 SkSTArray<2, Transform, true> fTransforms; |
| 439 }; | 439 }; |
| 440 | 440 |
| 441 struct GrGLInstalledFragProcs : public SkRefCnt { | 441 struct GrGLInstalledFragProcs : public SkRefCnt { |
| 442 virtual ~GrGLInstalledFragProcs(); | 442 virtual ~GrGLInstalledFragProcs(); |
| 443 SkSTArray<8, GrGLInstalledFragProc*, true> fProcs; | 443 SkSTArray<8, GrGLInstalledFragProc*, true> fProcs; |
| 444 }; | 444 }; |
| 445 | 445 |
| 446 #endif | 446 #endif |
| OLD | NEW |