Chromium Code Reviews| 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 | |
| 13 /* | 15 /* |
| 14 * This base class encapsulates the functionality which the GP uses to build fra gment shaders | 16 * This base class encapsulates the functionality which the GP uses to build fra gment shaders |
| 15 */ | 17 */ |
| 16 class GrGLGPFragmentBuilder : public GrGLShaderBuilder { | 18 class GrGLGPFragmentBuilder : public GrGLShaderBuilder { |
| 17 public: | 19 public: |
| 18 GrGLGPFragmentBuilder(GrGLProgramBuilder* program) : INHERITED(program) {} | 20 GrGLGPFragmentBuilder(GrGLProgramBuilder* program) : INHERITED(program) {} |
| 19 virtual ~GrGLGPFragmentBuilder() {} | 21 virtual ~GrGLGPFragmentBuilder() {} |
| 20 /** | 22 /** |
| 21 * Use of these features may require a GLSL extension to be enabled. Shaders may not compile | 23 * Use of these features may require a GLSL extension to be enabled. Shaders may not compile |
| 22 * if code is added that uses one of these features without calling enableFe ature() | 24 * 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... | |
| 84 | 86 |
| 85 GrGLFragmentShaderBuilder(GrGLProgramBuilder* program, const GrGLProgramDesc & desc); | 87 GrGLFragmentShaderBuilder(GrGLProgramBuilder* program, const GrGLProgramDesc & desc); |
| 86 | 88 |
| 87 // true public interface, defined explicitly in the abstract interfaces abov e | 89 // true public interface, defined explicitly in the abstract interfaces abov e |
| 88 virtual bool enableFeature(GLSLFeature) SK_OVERRIDE; | 90 virtual bool enableFeature(GLSLFeature) SK_OVERRIDE; |
| 89 virtual SkString ensureFSCoords2D(const GrGLProcessor::TransformedCoordsArra y& coords, | 91 virtual SkString ensureFSCoords2D(const GrGLProcessor::TransformedCoordsArra y& coords, |
| 90 int index) SK_OVERRIDE; | 92 int index) SK_OVERRIDE; |
| 91 virtual const char* fragmentPosition() SK_OVERRIDE; | 93 virtual const char* fragmentPosition() SK_OVERRIDE; |
| 92 virtual const char* dstColor() SK_OVERRIDE; | 94 virtual const char* dstColor() SK_OVERRIDE; |
| 93 | 95 |
| 96 // As GLProcessors emit code, there are some conditions we need to verify. We use the below | |
| 97 // state to track this. The reset call is called per processor emitted. | |
| 98 bool hasReadDstColor() const { return fHasReadDstColor; } | |
| 99 bool hasReadFragmentPosition() const { return fHasReadFragmentPosition; } | |
| 100 void reset() { | |
| 101 fHasReadDstColor = false; | |
| 102 fHasReadFragmentPosition = false; | |
| 103 } | |
| 104 | |
|
joshualitt
2014/10/23 20:08:22
whoops, I'll make this private
| |
| 105 private: | |
| 94 // Private public interface, used by GrGLProgramBuilder to build a fragment shader | 106 // Private public interface, used by GrGLProgramBuilder to build a fragment shader |
| 95 void emitCodeToReadDstTexture(); | 107 void emitCodeToReadDstTexture(); |
| 96 void enableCustomOutput(); | 108 void enableCustomOutput(); |
| 97 void enableSecondaryOutput(); | 109 void enableSecondaryOutput(); |
| 98 const char* getPrimaryColorOutputName() const; | 110 const char* getPrimaryColorOutputName() const; |
| 99 const char* getSecondaryColorOutputName() const; | 111 const char* getSecondaryColorOutputName() const; |
| 100 void enableSecondaryOutput(const GrGLSLExpr4& inputColor, const GrGLSLExpr4& inputCoverage); | 112 void enableSecondaryOutput(const GrGLSLExpr4& inputColor, const GrGLSLExpr4& inputCoverage); |
| 101 void combineColorAndCoverage(const GrGLSLExpr4& inputColor, const GrGLSLExpr 4& inputCoverage); | 113 void combineColorAndCoverage(const GrGLSLExpr4& inputColor, const GrGLSLExpr 4& inputCoverage); |
| 102 bool compileAndAttachShaders(GrGLuint programId, SkTDArray<GrGLuint>* shader Ids) const; | 114 bool compileAndAttachShaders(GrGLuint programId, SkTDArray<GrGLuint>* shader Ids) const; |
| 103 void bindFragmentShaderLocations(GrGLuint programID); | 115 void bindFragmentShaderLocations(GrGLuint programID); |
| 104 | 116 |
| 105 /* | 117 /* |
| 106 * An internal call for GrGLProgramBuilder to use to add varyings to the ver tex shader | 118 * An internal call for GrGLProgramBuilder to use to add varyings to the ver tex shader |
| 107 */ | 119 */ |
| 108 void addVarying(GrSLType type, | 120 void addVarying(GrGLVarying* v, |
| 109 const char* name, | 121 GrGLShaderVar::Precision fsPrec = GrGLShaderVar::kDefault_Pr ecision); |
| 110 const char** fsInName, | |
| 111 GrGLShaderVar::Precision fsPrecision = GrGLShaderVar::kDefaul t_Precision); | |
| 112 | 122 |
| 113 // As GLProcessors emit code, there are some conditions we need to verify. We use the below | |
| 114 // state to track this. The reset call is called per processor emitted. | |
| 115 bool hasReadDstColor() const { return fHasReadDstColor; } | |
| 116 bool hasReadFragmentPosition() const { return fHasReadFragmentPosition; } | |
| 117 void reset() { | |
| 118 fHasReadDstColor = false; | |
| 119 fHasReadFragmentPosition = false; | |
| 120 } | |
| 121 | |
| 122 private: | |
| 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 |