| 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 GrGLSLFragmentShaderBuilder_DEFINED | 8 #ifndef GrGLSLFragmentShaderBuilder_DEFINED |
| 9 #define GrGLSLFragmentShaderBuilder_DEFINED | 9 #define GrGLSLFragmentShaderBuilder_DEFINED |
| 10 | 10 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 , fHasCustomColorOutput(false) | 25 , fHasCustomColorOutput(false) |
| 26 , fHasSecondaryOutput(false) { | 26 , fHasSecondaryOutput(false) { |
| 27 fSubstageIndices.push_back(0); | 27 fSubstageIndices.push_back(0); |
| 28 } | 28 } |
| 29 virtual ~GrGLSLFragmentBuilder() {} | 29 virtual ~GrGLSLFragmentBuilder() {} |
| 30 /** | 30 /** |
| 31 * Use of these features may require a GLSL extension to be enabled. Shaders
may not compile | 31 * Use of these features may require a GLSL extension to be enabled. Shaders
may not compile |
| 32 * if code is added that uses one of these features without calling enableFe
ature() | 32 * if code is added that uses one of these features without calling enableFe
ature() |
| 33 */ | 33 */ |
| 34 enum GLSLFeature { | 34 enum GLSLFeature { |
| 35 kStandardDerivatives_GLSLFeature = 0, | 35 kStandardDerivatives_GLSLFeature = kLastGLSLPrivateFeature + 1, |
| 36 kPixelLocalStorage_GLSLFeature = 1, | 36 kPixelLocalStorage_GLSLFeature |
| 37 kLastGLSLFeature = kPixelLocalStorage_GLSLFeature | |
| 38 }; | 37 }; |
| 39 | 38 |
| 40 /** | 39 /** |
| 41 * If the feature is supported then true is returned and any necessary #exte
nsion declarations | 40 * If the feature is supported then true is returned and any necessary #exte
nsion declarations |
| 42 * are added to the shaders. If the feature is not supported then false will
be returned. | 41 * are added to the shaders. If the feature is not supported then false will
be returned. |
| 43 */ | 42 */ |
| 44 virtual bool enableFeature(GLSLFeature) = 0; | 43 virtual bool enableFeature(GLSLFeature) = 0; |
| 45 | 44 |
| 46 /** | 45 /** |
| 47 * This returns a variable name to access the 2D, perspective correct versio
n of the coords in | 46 * This returns a variable name to access the 2D, perspective correct versio
n of the coords in |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 static const char* DeclaredColorOutputName() { return "fsColorOut"; } | 160 static const char* DeclaredColorOutputName() { return "fsColorOut"; } |
| 162 static const char* DeclaredSecondaryColorOutputName() { return "fsSecondaryC
olorOut"; } | 161 static const char* DeclaredSecondaryColorOutputName() { return "fsSecondaryC
olorOut"; } |
| 163 | 162 |
| 164 /* | 163 /* |
| 165 * An internal call for GrGLProgramBuilder to use to add varyings to the ver
tex shader | 164 * An internal call for GrGLProgramBuilder to use to add varyings to the ver
tex shader |
| 166 */ | 165 */ |
| 167 void addVarying(GrGLSLVarying*, GrSLPrecision); | 166 void addVarying(GrGLSLVarying*, GrSLPrecision); |
| 168 | 167 |
| 169 void onFinalize() override; | 168 void onFinalize() override; |
| 170 | 169 |
| 171 /** | |
| 172 * Features that should only be enabled by GrGLSLFragmentShaderBuilder itsel
f. | |
| 173 */ | |
| 174 enum GLSLPrivateFeature { | |
| 175 kFragCoordConventions_GLSLPrivateFeature = kLastGLSLFeature + 1, | |
| 176 kBlendEquationAdvanced_GLSLPrivateFeature, | |
| 177 kBlendFuncExtended_GLSLPrivateFeature, | |
| 178 kExternalTexture_GLSLPrivateFeature, | |
| 179 kLastGLSLPrivateFeature = kBlendFuncExtended_GLSLPrivateFeature | |
| 180 }; | |
| 181 | |
| 182 // Interpretation of FragPosKey when generating code | 170 // Interpretation of FragPosKey when generating code |
| 183 enum { | 171 enum { |
| 184 kNoFragPosRead_FragPosKey = 0, // The fragment positition wil
l not be needed. | 172 kNoFragPosRead_FragPosKey = 0, // The fragment positition wil
l not be needed. |
| 185 kTopLeftFragPosRead_FragPosKey = 0x1,// Read frag pos relative to t
op-left. | 173 kTopLeftFragPosRead_FragPosKey = 0x1,// Read frag pos relative to t
op-left. |
| 186 kBottomLeftFragPosRead_FragPosKey = 0x2,// Read frag pos relative to b
ottom-left. | 174 kBottomLeftFragPosRead_FragPosKey = 0x2,// Read frag pos relative to b
ottom-left. |
| 187 }; | 175 }; |
| 188 | 176 |
| 189 static const char* kDstTextureColorName; | 177 static const char* kDstTextureColorName; |
| 190 | 178 |
| 191 bool fSetupFragPosition; | 179 bool fSetupFragPosition; |
| 192 bool fTopLeftFragPosRead; | 180 bool fTopLeftFragPosRead; |
| 193 int fCustomColorOutputIndex; | 181 int fCustomColorOutputIndex; |
| 194 | 182 |
| 195 // some state to verify shaders and effects are consistent, this is reset be
tween effects by | 183 // some state to verify shaders and effects are consistent, this is reset be
tween effects by |
| 196 // the program creator | 184 // the program creator |
| 197 bool fHasReadDstColor; | 185 bool fHasReadDstColor; |
| 198 bool fHasReadFragmentPosition; | 186 bool fHasReadFragmentPosition; |
| 199 | 187 |
| 200 friend class GrGLSLProgramBuilder; | 188 friend class GrGLSLProgramBuilder; |
| 201 friend class GrGLProgramBuilder; | 189 friend class GrGLProgramBuilder; |
| 202 | 190 |
| 203 typedef GrGLSLXPFragmentBuilder INHERITED; | 191 typedef GrGLSLXPFragmentBuilder INHERITED; |
| 204 }; | 192 }; |
| 205 | 193 |
| 206 #endif | 194 #endif |
| OLD | NEW |