| 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 |
| 11 #include "GrGLSLShaderBuilder.h" | 11 #include "GrGLSLShaderBuilder.h" |
| 12 | 12 |
| 13 #include "GrProcessor.h" |
| 13 #include "glsl/GrGLSLProcessorTypes.h" | 14 #include "glsl/GrGLSLProcessorTypes.h" |
| 14 | 15 |
| 15 class GrRenderTarget; | 16 class GrRenderTarget; |
| 16 class GrGLSLVarying; | 17 class GrGLSLVarying; |
| 17 | 18 |
| 18 /* | 19 /* |
| 19 * This base class encapsulates the common functionality which all processors us
e to build fragment | 20 * This base class encapsulates the common functionality which all processors us
e to build fragment |
| 20 * shaders. | 21 * shaders. |
| 21 */ | 22 */ |
| 22 class GrGLSLFragmentBuilder : public GrGLSLShaderBuilder { | 23 class GrGLSLFragmentBuilder : public GrGLSLShaderBuilder { |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 void onBeforeChildProcEmitCode() override; | 159 void onBeforeChildProcEmitCode() override; |
| 159 void onAfterChildProcEmitCode() override; | 160 void onAfterChildProcEmitCode() override; |
| 160 | 161 |
| 161 // GrGLSLXPFragmentBuilder interface. | 162 // GrGLSLXPFragmentBuilder interface. |
| 162 bool hasCustomColorOutput() const override { return fHasCustomColorOutput; } | 163 bool hasCustomColorOutput() const override { return fHasCustomColorOutput; } |
| 163 bool hasSecondaryOutput() const override { return fHasSecondaryOutput; } | 164 bool hasSecondaryOutput() const override { return fHasSecondaryOutput; } |
| 164 const char* dstColor() override; | 165 const char* dstColor() override; |
| 165 void enableAdvancedBlendEquationIfNeeded(GrBlendEquation) override; | 166 void enableAdvancedBlendEquationIfNeeded(GrBlendEquation) override; |
| 166 | 167 |
| 167 private: | 168 private: |
| 169 bool hasFragmentPosition() const; |
| 170 |
| 168 // Private public interface, used by GrGLProgramBuilder to build a fragment
shader | 171 // Private public interface, used by GrGLProgramBuilder to build a fragment
shader |
| 169 void enableCustomOutput(); | 172 void enableCustomOutput(); |
| 170 void enableSecondaryOutput(); | 173 void enableSecondaryOutput(); |
| 171 const char* getPrimaryColorOutputName() const; | 174 const char* getPrimaryColorOutputName() const; |
| 172 const char* getSecondaryColorOutputName() const; | 175 const char* getSecondaryColorOutputName() const; |
| 173 | 176 |
| 177 #ifdef SK_DEBUG |
| 174 // As GLSLProcessors emit code, there are some conditions we need to verify.
We use the below | 178 // As GLSLProcessors emit code, there are some conditions we need to verify.
We use the below |
| 175 // state to track this. The reset call is called per processor emitted. | 179 // state to track this. The reset call is called per processor emitted. |
| 180 GrProcessor::RequiredFeatures usedProcessorFeatures() const { return fUsedPr
ocessorFeatures; } |
| 176 bool hasReadDstColor() const { return fHasReadDstColor; } | 181 bool hasReadDstColor() const { return fHasReadDstColor; } |
| 177 bool hasReadFragmentPosition() const { return fHasReadFragmentPosition; } | 182 void resetVerification() { |
| 178 void reset() { | 183 fUsedProcessorFeatures = GrProcessor::kNone_RequiredFeatures; |
| 179 fHasReadDstColor = false; | 184 fHasReadDstColor = false; |
| 180 fHasReadFragmentPosition = false; | |
| 181 } | 185 } |
| 186 #endif |
| 182 | 187 |
| 183 static const char* DeclaredColorOutputName() { return "fsColorOut"; } | 188 static const char* DeclaredColorOutputName() { return "fsColorOut"; } |
| 184 static const char* DeclaredSecondaryColorOutputName() { return "fsSecondaryC
olorOut"; } | 189 static const char* DeclaredSecondaryColorOutputName() { return "fsSecondaryC
olorOut"; } |
| 185 | 190 |
| 186 /* | 191 /* |
| 187 * An internal call for GrGLProgramBuilder to use to add varyings to the ver
tex shader | 192 * An internal call for GrGLProgramBuilder to use to add varyings to the ver
tex shader |
| 188 */ | 193 */ |
| 189 void addVarying(GrGLSLVarying*, GrSLPrecision); | 194 void addVarying(GrGLSLVarying*, GrSLPrecision); |
| 190 | 195 |
| 191 void onFinalize() override; | 196 void onFinalize() override; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 219 */ | 224 */ |
| 220 SkString fMangleString; | 225 SkString fMangleString; |
| 221 | 226 |
| 222 bool fSetupFragPosition; | 227 bool fSetupFragPosition; |
| 223 bool fTopLeftFragPosRead; | 228 bool fTopLeftFragPosRead; |
| 224 bool fHasCustomColorOutput; | 229 bool fHasCustomColorOutput; |
| 225 int fCustomColorOutputIndex; | 230 int fCustomColorOutputIndex; |
| 226 bool fHasSecondaryOutput; | 231 bool fHasSecondaryOutput; |
| 227 bool fHasInitializedSampleMask; | 232 bool fHasInitializedSampleMask; |
| 228 | 233 |
| 234 #ifdef SK_DEBUG |
| 229 // some state to verify shaders and effects are consistent, this is reset be
tween effects by | 235 // some state to verify shaders and effects are consistent, this is reset be
tween effects by |
| 230 // the program creator | 236 // the program creator |
| 237 GrProcessor::RequiredFeatures fUsedProcessorFeatures; |
| 231 bool fHasReadDstColor; | 238 bool fHasReadDstColor; |
| 232 bool fHasReadFragmentPosition; | 239 #endif |
| 233 | 240 |
| 234 friend class GrGLSLProgramBuilder; | 241 friend class GrGLSLProgramBuilder; |
| 235 friend class GrGLProgramBuilder; | 242 friend class GrGLProgramBuilder; |
| 236 }; | 243 }; |
| 237 | 244 |
| 238 #endif | 245 #endif |
| OLD | NEW |