| 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 GrGLFragmentShaderBuilder_DEFINED | 8 #ifndef GrGLFragmentShaderBuilder_DEFINED |
| 9 #define GrGLFragmentShaderBuilder_DEFINED | 9 #define GrGLFragmentShaderBuilder_DEFINED |
| 10 | 10 |
| 11 #include "GrGLShaderBuilder.h" | 11 #include "GrGLShaderBuilder.h" |
| 12 | 12 |
| 13 class GrGLVarying; | |
| 14 | |
| 15 /* | 13 /* |
| 16 * This base class encapsulates the functionality which the GP uses to build fra
gment shaders | 14 * This base class encapsulates the functionality which the GP uses to build fra
gment shaders |
| 17 */ | 15 */ |
| 18 class GrGLGPFragmentBuilder : public GrGLShaderBuilder { | 16 class GrGLGPFragmentBuilder : public GrGLShaderBuilder { |
| 19 public: | 17 public: |
| 20 GrGLGPFragmentBuilder(GrGLProgramBuilder* program) : INHERITED(program) {} | 18 GrGLGPFragmentBuilder(GrGLProgramBuilder* program) : INHERITED(program) {} |
| 21 virtual ~GrGLGPFragmentBuilder() {} | 19 virtual ~GrGLGPFragmentBuilder() {} |
| 22 /** | 20 /** |
| 23 * Use of these features may require a GLSL extension to be enabled. Shaders
may not compile | 21 * Use of these features may require a GLSL extension to be enabled. Shaders
may not compile |
| 24 * if code is added that uses one of these features without calling enableFe
ature() | 22 * if code is added that uses one of these features without calling enableFe
ature() |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 | 84 |
| 87 GrGLFragmentShaderBuilder(GrGLProgramBuilder* program, const GrGLProgramDesc
& desc); | 85 GrGLFragmentShaderBuilder(GrGLProgramBuilder* program, const GrGLProgramDesc
& desc); |
| 88 | 86 |
| 89 // true public interface, defined explicitly in the abstract interfaces abov
e | 87 // true public interface, defined explicitly in the abstract interfaces abov
e |
| 90 virtual bool enableFeature(GLSLFeature) SK_OVERRIDE; | 88 virtual bool enableFeature(GLSLFeature) SK_OVERRIDE; |
| 91 virtual SkString ensureFSCoords2D(const GrGLProcessor::TransformedCoordsArra
y& coords, | 89 virtual SkString ensureFSCoords2D(const GrGLProcessor::TransformedCoordsArra
y& coords, |
| 92 int index) SK_OVERRIDE; | 90 int index) SK_OVERRIDE; |
| 93 virtual const char* fragmentPosition() SK_OVERRIDE; | 91 virtual const char* fragmentPosition() SK_OVERRIDE; |
| 94 virtual const char* dstColor() SK_OVERRIDE; | 92 virtual const char* dstColor() SK_OVERRIDE; |
| 95 | 93 |
| 96 private: | |
| 97 // Private public interface, used by GrGLProgramBuilder to build a fragment
shader | 94 // Private public interface, used by GrGLProgramBuilder to build a fragment
shader |
| 98 void emitCodeToReadDstTexture(); | 95 void emitCodeToReadDstTexture(); |
| 99 void enableCustomOutput(); | 96 void enableCustomOutput(); |
| 100 void enableSecondaryOutput(); | 97 void enableSecondaryOutput(); |
| 101 const char* getPrimaryColorOutputName() const; | 98 const char* getPrimaryColorOutputName() const; |
| 102 const char* getSecondaryColorOutputName() const; | 99 const char* getSecondaryColorOutputName() const; |
| 103 void enableSecondaryOutput(const GrGLSLExpr4& inputColor, const GrGLSLExpr4&
inputCoverage); | 100 void enableSecondaryOutput(const GrGLSLExpr4& inputColor, const GrGLSLExpr4&
inputCoverage); |
| 104 void combineColorAndCoverage(const GrGLSLExpr4& inputColor, const GrGLSLExpr
4& inputCoverage); | 101 void combineColorAndCoverage(const GrGLSLExpr4& inputColor, const GrGLSLExpr
4& inputCoverage); |
| 105 bool compileAndAttachShaders(GrGLuint programId, SkTDArray<GrGLuint>* shader
Ids) const; | 102 bool compileAndAttachShaders(GrGLuint programId, SkTDArray<GrGLuint>* shader
Ids) const; |
| 106 void bindFragmentShaderLocations(GrGLuint programID); | 103 void bindFragmentShaderLocations(GrGLuint programID); |
| 107 | 104 |
| 105 /* |
| 106 * An internal call for GrGLProgramBuilder to use to add varyings to the ver
tex shader |
| 107 */ |
| 108 void addVarying(GrSLType type, |
| 109 const char* name, |
| 110 const char** fsInName, |
| 111 GrGLShaderVar::Precision fsPrecision = GrGLShaderVar::kDefaul
t_Precision); |
| 112 |
| 108 // As GLProcessors emit code, there are some conditions we need to verify.
We use the below | 113 // As GLProcessors emit code, there are some conditions we need to verify.
We use the below |
| 109 // state to track this. The reset call is called per processor emitted. | 114 // state to track this. The reset call is called per processor emitted. |
| 110 bool hasReadDstColor() const { return fHasReadDstColor; } | 115 bool hasReadDstColor() const { return fHasReadDstColor; } |
| 111 bool hasReadFragmentPosition() const { return fHasReadFragmentPosition; } | 116 bool hasReadFragmentPosition() const { return fHasReadFragmentPosition; } |
| 112 void reset() { | 117 void reset() { |
| 113 fHasReadDstColor = false; | 118 fHasReadDstColor = false; |
| 114 fHasReadFragmentPosition = false; | 119 fHasReadFragmentPosition = false; |
| 115 } | 120 } |
| 116 | 121 |
| 117 /* | 122 private: |
| 118 * An internal call for GrGLProgramBuilder to use to add varyings to the ver
tex shader | |
| 119 */ | |
| 120 void addVarying(GrGLVarying* v, | |
| 121 GrGLShaderVar::Precision fsPrec = GrGLShaderVar::kDefault_Pr
ecision); | |
| 122 | |
| 123 /** | 123 /** |
| 124 * Features that should only be enabled by GrGLFragmentShaderBuilder itself. | 124 * Features that should only be enabled by GrGLFragmentShaderBuilder itself. |
| 125 */ | 125 */ |
| 126 enum GLSLPrivateFeature { | 126 enum GLSLPrivateFeature { |
| 127 kFragCoordConventions_GLSLPrivateFeature = kLastGLSLFeature + 1, | 127 kFragCoordConventions_GLSLPrivateFeature = kLastGLSLFeature + 1, |
| 128 kLastGLSLPrivateFeature = kFragCoordConventions_GLSLPrivateFeature | 128 kLastGLSLPrivateFeature = kFragCoordConventions_GLSLPrivateFeature |
| 129 }; | 129 }; |
| 130 | 130 |
| 131 // Interpretation of DstReadKey when generating code | 131 // Interpretation of DstReadKey when generating code |
| 132 enum { | 132 enum { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 156 bool fHasReadDstColor; | 156 bool fHasReadDstColor; |
| 157 bool fHasReadFragmentPosition; | 157 bool fHasReadFragmentPosition; |
| 158 | 158 |
| 159 friend class GrGLNvprProgramBuilder; | 159 friend class GrGLNvprProgramBuilder; |
| 160 friend class GrGLProgramBuilder; | 160 friend class GrGLProgramBuilder; |
| 161 | 161 |
| 162 typedef GrGLFPFragmentBuilder INHERITED; | 162 typedef GrGLFPFragmentBuilder INHERITED; |
| 163 }; | 163 }; |
| 164 | 164 |
| 165 #endif | 165 #endif |
| OLD | NEW |