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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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: |
168 // Private public interface, used by GrGLProgramBuilder to build a fragment
shader | 169 // Private public interface, used by GrGLProgramBuilder to build a fragment
shader |
169 void enableCustomOutput(); | 170 void enableCustomOutput(); |
170 void enableSecondaryOutput(); | 171 void enableSecondaryOutput(); |
171 const char* getPrimaryColorOutputName() const; | 172 const char* getPrimaryColorOutputName() const; |
172 const char* getSecondaryColorOutputName() const; | 173 const char* getSecondaryColorOutputName() const; |
173 | 174 |
| 175 #ifdef SK_DEBUG |
174 // As GLSLProcessors emit code, there are some conditions we need to verify.
We use the below | 176 // 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. | 177 // state to track this. The reset call is called per processor emitted. |
| 178 bool usedBuiltInState() const { return fUsedBuiltInState; } |
176 bool hasReadDstColor() const { return fHasReadDstColor; } | 179 bool hasReadDstColor() const { return fHasReadDstColor; } |
177 bool hasReadFragmentPosition() const { return fHasReadFragmentPosition; } | 180 void resetVerification() { |
178 void reset() { | 181 fUsedBuiltInState = GrProcessor::kNone_BuiltInState; |
179 fHasReadDstColor = false; | 182 fHasReadDstColor = false; |
180 fHasReadFragmentPosition = false; | |
181 } | 183 } |
| 184 #endif |
182 | 185 |
183 static const char* DeclaredColorOutputName() { return "fsColorOut"; } | 186 static const char* DeclaredColorOutputName() { return "fsColorOut"; } |
184 static const char* DeclaredSecondaryColorOutputName() { return "fsSecondaryC
olorOut"; } | 187 static const char* DeclaredSecondaryColorOutputName() { return "fsSecondaryC
olorOut"; } |
185 | 188 |
186 /* | 189 /* |
187 * An internal call for GrGLProgramBuilder to use to add varyings to the ver
tex shader | 190 * An internal call for GrGLProgramBuilder to use to add varyings to the ver
tex shader |
188 */ | 191 */ |
189 void addVarying(GrGLSLVarying*, GrSLPrecision); | 192 void addVarying(GrGLSLVarying*, GrSLPrecision); |
190 | 193 |
191 void onFinalize() override; | 194 void onFinalize() override; |
(...skipping 27 matching lines...) Expand all Loading... |
219 */ | 222 */ |
220 SkString fMangleString; | 223 SkString fMangleString; |
221 | 224 |
222 bool fSetupFragPosition; | 225 bool fSetupFragPosition; |
223 bool fTopLeftFragPosRead; | 226 bool fTopLeftFragPosRead; |
224 bool fHasCustomColorOutput; | 227 bool fHasCustomColorOutput; |
225 int fCustomColorOutputIndex; | 228 int fCustomColorOutputIndex; |
226 bool fHasSecondaryOutput; | 229 bool fHasSecondaryOutput; |
227 bool fHasInitializedSampleMask; | 230 bool fHasInitializedSampleMask; |
228 | 231 |
| 232 #ifdef SK_DEBUG |
229 // some state to verify shaders and effects are consistent, this is reset be
tween effects by | 233 // some state to verify shaders and effects are consistent, this is reset be
tween effects by |
230 // the program creator | 234 // the program creator |
| 235 GrProcessor::BuiltInState fUsedBuiltInState; |
231 bool fHasReadDstColor; | 236 bool fHasReadDstColor; |
232 bool fHasReadFragmentPosition; | 237 #endif |
233 | 238 |
234 friend class GrGLSLProgramBuilder; | 239 friend class GrGLSLProgramBuilder; |
235 friend class GrGLProgramBuilder; | 240 friend class GrGLProgramBuilder; |
236 }; | 241 }; |
237 | 242 |
238 #endif | 243 #endif |
OLD | NEW |