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 #include "GrGLSLFragmentShaderBuilder.h" | 8 #include "GrGLSLFragmentShaderBuilder.h" |
9 #include "GrRenderTarget.h" | 9 #include "GrRenderTarget.h" |
10 #include "gl/GrGLGpu.h" | 10 #include "gl/GrGLGpu.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 GrGLSLFragmentShaderBuilder::KeyForFragmentPosition(const GrRenderTarget* dst) { | 61 GrGLSLFragmentShaderBuilder::KeyForFragmentPosition(const GrRenderTarget* dst) { |
62 if (kTopLeft_GrSurfaceOrigin == dst->origin()) { | 62 if (kTopLeft_GrSurfaceOrigin == dst->origin()) { |
63 return kTopLeftFragPosRead_FragPosKey; | 63 return kTopLeftFragPosRead_FragPosKey; |
64 } else { | 64 } else { |
65 return kBottomLeftFragPosRead_FragPosKey; | 65 return kBottomLeftFragPosRead_FragPosKey; |
66 } | 66 } |
67 } | 67 } |
68 | 68 |
69 GrGLSLFragmentShaderBuilder::GrGLSLFragmentShaderBuilder(GrGLSLProgramBuilder* p
rogram, | 69 GrGLSLFragmentShaderBuilder::GrGLSLFragmentShaderBuilder(GrGLSLProgramBuilder* p
rogram, |
70 uint8_t fragPosKey) | 70 uint8_t fragPosKey) |
71 : INHERITED(program) | 71 : GrGLSLFragmentBuilder(program) |
72 , fSetupFragPosition(false) | 72 , fSetupFragPosition(false) |
73 , fTopLeftFragPosRead(kTopLeftFragPosRead_FragPosKey == fragPosKey) | 73 , fTopLeftFragPosRead(kTopLeftFragPosRead_FragPosKey == fragPosKey) |
| 74 , fHasCustomColorOutput(false) |
74 , fCustomColorOutputIndex(-1) | 75 , fCustomColorOutputIndex(-1) |
| 76 , fHasSecondaryOutput(false) |
75 , fHasReadDstColor(false) | 77 , fHasReadDstColor(false) |
76 , fHasReadFragmentPosition(false) { | 78 , fHasReadFragmentPosition(false) { |
| 79 fSubstageIndices.push_back(0); |
77 } | 80 } |
78 | 81 |
79 bool GrGLSLFragmentShaderBuilder::enableFeature(GLSLFeature feature) { | 82 bool GrGLSLFragmentShaderBuilder::enableFeature(GLSLFeature feature) { |
80 switch (feature) { | 83 switch (feature) { |
81 case kStandardDerivatives_GLSLFeature: { | 84 case kStandardDerivatives_GLSLFeature: { |
82 if (!fProgramBuilder->glslCaps()->shaderDerivativeSupport()) { | 85 if (!fProgramBuilder->glslCaps()->shaderDerivativeSupport()) { |
83 return false; | 86 return false; |
84 } | 87 } |
85 const char* extension = fProgramBuilder->glslCaps()->shaderDerivativ
eExtensionString(); | 88 const char* extension = fProgramBuilder->glslCaps()->shaderDerivativ
eExtensionString(); |
86 if (extension) { | 89 if (extension) { |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 : "gl_SecondaryFragColorEXT"; | 259 : "gl_SecondaryFragColorEXT"; |
257 } | 260 } |
258 | 261 |
259 void GrGLSLFragmentShaderBuilder::onFinalize() { | 262 void GrGLSLFragmentShaderBuilder::onFinalize() { |
260 fProgramBuilder->varyingHandler()->getFragDecls(&this->inputs(), &this->outp
uts()); | 263 fProgramBuilder->varyingHandler()->getFragDecls(&this->inputs(), &this->outp
uts()); |
261 GrGLSLAppendDefaultFloatPrecisionDeclaration(kDefault_GrSLPrecision, | 264 GrGLSLAppendDefaultFloatPrecisionDeclaration(kDefault_GrSLPrecision, |
262 *fProgramBuilder->glslCaps(), | 265 *fProgramBuilder->glslCaps(), |
263 &this->precisionQualifier()); | 266 &this->precisionQualifier()); |
264 } | 267 } |
265 | 268 |
266 void GrGLSLFragmentBuilder::onBeforeChildProcEmitCode() { | 269 void GrGLSLFragmentShaderBuilder::onBeforeChildProcEmitCode() { |
267 SkASSERT(fSubstageIndices.count() >= 1); | 270 SkASSERT(fSubstageIndices.count() >= 1); |
268 fSubstageIndices.push_back(0); | 271 fSubstageIndices.push_back(0); |
269 // second-to-last value in the fSubstageIndices stack is the index of the ch
ild proc | 272 // second-to-last value in the fSubstageIndices stack is the index of the ch
ild proc |
270 // at that level which is currently emitting code. | 273 // at that level which is currently emitting code. |
271 fMangleString.appendf("_c%d", fSubstageIndices[fSubstageIndices.count() - 2]
); | 274 fMangleString.appendf("_c%d", fSubstageIndices[fSubstageIndices.count() - 2]
); |
272 } | 275 } |
273 | 276 |
274 void GrGLSLFragmentBuilder::onAfterChildProcEmitCode() { | 277 void GrGLSLFragmentShaderBuilder::onAfterChildProcEmitCode() { |
275 SkASSERT(fSubstageIndices.count() >= 2); | 278 SkASSERT(fSubstageIndices.count() >= 2); |
276 fSubstageIndices.pop_back(); | 279 fSubstageIndices.pop_back(); |
277 fSubstageIndices.back()++; | 280 fSubstageIndices.back()++; |
278 int removeAt = fMangleString.findLastOf('_'); | 281 int removeAt = fMangleString.findLastOf('_'); |
279 fMangleString.remove(removeAt, fMangleString.size() - removeAt); | 282 fMangleString.remove(removeAt, fMangleString.size() - removeAt); |
280 } | 283 } |
281 | 284 |
OLD | NEW |