| 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 GrGLFullProgramBuilder_DEFINED | 8 #ifndef GrGLFullProgramBuilder_DEFINED |
| 9 #define GrGLFullProgramBuilder_DEFINED | 9 #define GrGLFullProgramBuilder_DEFINED |
| 10 | 10 |
| 11 #include "GrGLProgramBuilder.h" | 11 #include "GrGLProgramBuilder.h" |
| 12 | 12 |
| 13 class GrGLVertexProgramEffects; |
| 14 |
| 13 class GrGLFullProgramBuilder : public GrGLProgramBuilder { | 15 class GrGLFullProgramBuilder : public GrGLProgramBuilder { |
| 14 public: | 16 public: |
| 15 GrGLFullProgramBuilder(GrGpuGL*, const GrGLProgramDesc&); | 17 GrGLFullProgramBuilder(GrGpuGL*, const GrGLProgramDesc&); |
| 16 | 18 |
| 17 /** Add a varying variable to the current program to pass values between vert
ex and fragment | 19 /** Add a varying variable to the current program to pass values between vert
ex and fragment |
| 18 shaders. If the last two parameters are non-NULL, they are filled in wit
h the name | 20 shaders. If the last two parameters are non-NULL, they are filled in wit
h the name |
| 19 generated. */ | 21 generated. */ |
| 20 void addVarying(GrSLType type, | 22 void addVarying(GrSLType type, |
| 21 const char* name, | 23 const char* name, |
| 22 const char** vsOutName = NULL, | 24 const char** vsOutName = NULL, |
| 23 const char** fsInName = NULL, | 25 const char** fsInName = NULL, |
| 24 GrGLShaderVar::Precision fsPrecision=GrGLShaderVar::kDefault
_Precision); | 26 GrGLShaderVar::Precision fsPrecision=GrGLShaderVar::kDefault
_Precision); |
| 25 | 27 |
| 26 /** Add a separable varying input variable to the current program. | 28 /** Add a separable varying input variable to the current program. |
| 27 * A separable varying (fragment shader input) is a varying that can be used
also when vertex | 29 * A separable varying (fragment shader input) is a varying that can be used
also when vertex |
| 28 * shaders are not used. With a vertex shader, the operation is same as with
other | 30 * shaders are not used. With a vertex shader, the operation is same as with
other |
| 29 * varyings. Without a vertex shader, such as with NV_path_rendering, GL API
s are used to | 31 * varyings. Without a vertex shader, such as with NV_path_rendering, GL API
s are used to |
| 30 * populate the variable. The APIs can refer to the variable through the ret
urned handle. | 32 * populate the variable. The APIs can refer to the variable through the ret
urned handle. |
| 31 */ | 33 */ |
| 32 VaryingHandle addSeparableVarying(GrSLType type, | 34 VaryingHandle addSeparableVarying(GrSLType type, |
| 33 const char* name, | 35 const char* name, |
| 34 const char** vsOutName, | 36 const char** vsOutName, |
| 35 const char** fsInName); | 37 const char** fsInName); |
| 36 | 38 |
| 37 GrGLVertexShaderBuilder* getVertexShaderBuilder() { return &fVS; } | 39 GrGLVertexShaderBuilder* getVertexShaderBuilder() { return &fVS; } |
| 38 | 40 |
| 39 private: | 41 private: |
| 40 virtual void emitCodeBeforeEffects(GrGLSLExpr4* color, | 42 virtual void createAndEmitEffects(const GrEffectStage* geometryProcessor, |
| 41 GrGLSLExpr4* coverage) SK_OVERRIDE; | 43 const GrEffectStage* colorStages[], |
| 44 const GrEffectStage* coverageStages[], |
| 45 GrGLSLExpr4* inputColor, |
| 46 GrGLSLExpr4* inputCoverage) SK_OVERRIDE; |
| 42 | 47 |
| 43 virtual void emitGeometryProcessor(const GrEffectStage* geometryProcessor, | 48 GrGLProgramEffects* onCreateAndEmitEffects(const GrEffectStage* effectStages
[], |
| 44 GrGLSLExpr4* coverage) SK_OVERRIDE; | 49 int effectCnt, |
| 50 const GrGLProgramDesc::EffectKeyP
rovider&, |
| 51 GrGLSLExpr4* inOutFSColor); |
| 45 | 52 |
| 46 virtual GrGLProgramEffects* createAndEmitEffects(const GrEffectStage* effect
Stages[], | 53 virtual void emitEffect(const GrEffectStage& stage, |
| 47 int effectCnt, | 54 const GrEffectKey& key, |
| 48 const GrGLProgramDesc::Effe
ctKeyProvider&, | 55 const char* outColor, |
| 49 GrGLSLExpr4* inOutFSColor)
SK_OVERRIDE; | 56 const char* inColor, |
| 57 int stageIndex) SK_OVERRIDE; |
| 50 | 58 |
| 51 /* | 59 /** |
| 52 * These functions are temporary and will eventually operate not on effects
but on | 60 * Helper for emitEffect(). Emits code to implement an effect's coord transf
orms in the VS. |
| 53 * geometry processors | 61 * Varyings are added as an outputs of the VS and inputs to the FS. The vary
ings may be either a |
| 62 * vec2f or vec3f depending upon whether perspective interpolation is requir
ed or not. The names |
| 63 * of the varyings in the VS and FS as well their types are appended to the |
| 64 * TransformedCoordsArray* object, which is in turn passed to the effect's e
mitCode() function. |
| 54 */ | 65 */ |
| 55 void createAndEmitEffect(GrGLProgramEffectsBuilder*, | 66 void emitTransforms(const GrEffectStage& effectStage, |
| 56 const GrEffectStage* effectStage, | 67 GrGLEffect::TransformedCoordsArray* outCoords); |
| 57 const GrGLProgramDesc::EffectKeyProvider&, | |
| 58 GrGLSLExpr4* inOutFSColor); | |
| 59 | |
| 60 GrGLProgramEffects* createAndEmitEffect(const GrEffectStage* geometryProcess
or, | |
| 61 const GrGLProgramDesc::EffectKeyProv
ider&, | |
| 62 GrGLSLExpr4* inOutFSColor); | |
| 63 | |
| 64 virtual void emitCodeAfterEffects() SK_OVERRIDE; | |
| 65 | 68 |
| 66 virtual bool compileAndAttachShaders(GrGLuint programId, | 69 virtual bool compileAndAttachShaders(GrGLuint programId, |
| 67 SkTDArray<GrGLuint>* shaderIds) const S
K_OVERRIDE; | 70 SkTDArray<GrGLuint>* shaderIds) const S
K_OVERRIDE; |
| 68 | 71 |
| 69 virtual void bindProgramLocations(GrGLuint programId) SK_OVERRIDE; | 72 virtual void bindProgramLocations(GrGLuint programId) SK_OVERRIDE; |
| 70 | 73 |
| 74 virtual GrGLProgramEffects* getProgramEffects() SK_OVERRIDE { return fProgra
mEffects.get(); } |
| 75 |
| 76 typedef GrGLProgramDesc::EffectKeyProvider EffectKeyProvider; |
| 77 |
| 71 GrGLGeometryShaderBuilder fGS; | 78 GrGLGeometryShaderBuilder fGS; |
| 72 GrGLVertexShaderBuilder fVS; | 79 GrGLVertexShaderBuilder fVS; |
| 80 SkAutoTDelete<GrGLVertexProgramEffects> fProgramEffects; |
| 73 | 81 |
| 74 typedef GrGLProgramBuilder INHERITED; | 82 typedef GrGLProgramBuilder INHERITED; |
| 75 }; | 83 }; |
| 76 | 84 |
| 77 #endif | 85 #endif |
| OLD | NEW |