| 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 "GrGLFragmentShaderBuilder.h" | 8 #include "GrGLFragmentShaderBuilder.h" |
| 9 #include "GrGLShaderStringBuilder.h" | 9 #include "GrGLShaderStringBuilder.h" |
| 10 #include "GrGLProgramBuilder.h" | 10 #include "GrGLProgramBuilder.h" |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 static const char* kCoordName = "fragCoordYDown"; | 140 static const char* kCoordName = "fragCoordYDown"; |
| 141 if (!fSetupFragPosition) { | 141 if (!fSetupFragPosition) { |
| 142 // temporarily change the stage index because we're inserting non-st
age code. | 142 // temporarily change the stage index because we're inserting non-st
age code. |
| 143 GrGLProgramBuilder::AutoStageRestore asr(fProgramBuilder); | 143 GrGLProgramBuilder::AutoStageRestore asr(fProgramBuilder); |
| 144 SkASSERT(!fProgramBuilder->fUniformHandles.fRTHeightUni.isValid()); | 144 SkASSERT(!fProgramBuilder->fUniformHandles.fRTHeightUni.isValid()); |
| 145 const char* rtHeightName; | 145 const char* rtHeightName; |
| 146 | 146 |
| 147 fProgramBuilder->fUniformHandles.fRTHeightUni = | 147 fProgramBuilder->fUniformHandles.fRTHeightUni = |
| 148 fProgramBuilder->addUniform(GrGLProgramBuilder::kFragment_Vi
sibility, | 148 fProgramBuilder->addUniform(GrGLProgramBuilder::kFragment_Vi
sibility, |
| 149 kFloat_GrSLType, | 149 kFloat_GrSLType, |
| 150 kDefault_GrSLPrecision, |
| 150 "RTHeight", | 151 "RTHeight", |
| 151 &rtHeightName); | 152 &rtHeightName); |
| 152 | 153 |
| 153 // Using glFragCoord.zw for the last two components tickles an Adren
o driver bug that | 154 // Using glFragCoord.zw for the last two components tickles an Adren
o driver bug that |
| 154 // causes programs to fail to link. Making this function return a ve
c2() didn't fix the | 155 // causes programs to fail to link. Making this function return a ve
c2() didn't fix the |
| 155 // problem but using 1.0 for the last two components does. | 156 // problem but using 1.0 for the last two components does. |
| 156 this->codePrependf("\tvec4 %s = vec4(gl_FragCoord.x, %s - gl_FragCoo
rd.y, 1.0, " | 157 this->codePrependf("\tvec4 %s = vec4(gl_FragCoord.x, %s - gl_FragCoo
rd.y, 1.0, " |
| 157 "1.0);\n", kCoordName, rtHeightName); | 158 "1.0);\n", kCoordName, rtHeightName); |
| 158 fSetupFragPosition = true; | 159 fSetupFragPosition = true; |
| 159 } | 160 } |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 const char* dstCopySamplerName; | 193 const char* dstCopySamplerName; |
| 193 uint32_t configMask; | 194 uint32_t configMask; |
| 194 if (SkToBool(kUseAlphaConfig_DstReadKeyBit & fProgramBuilder->header().fDstR
eadKey)) { | 195 if (SkToBool(kUseAlphaConfig_DstReadKeyBit & fProgramBuilder->header().fDstR
eadKey)) { |
| 195 configMask = kA_GrColorComponentFlag; | 196 configMask = kA_GrColorComponentFlag; |
| 196 } else { | 197 } else { |
| 197 configMask = kRGBA_GrColorComponentFlags; | 198 configMask = kRGBA_GrColorComponentFlags; |
| 198 } | 199 } |
| 199 fProgramBuilder->fUniformHandles.fDstCopySamplerUni = | 200 fProgramBuilder->fUniformHandles.fDstCopySamplerUni = |
| 200 fProgramBuilder->addUniform(GrGLProgramBuilder::kFragment_Visibility
, | 201 fProgramBuilder->addUniform(GrGLProgramBuilder::kFragment_Visibility
, |
| 201 kSampler2D_GrSLType, | 202 kSampler2D_GrSLType, |
| 203 kDefault_GrSLPrecision, |
| 202 "DstCopySampler", | 204 "DstCopySampler", |
| 203 &dstCopySamplerName); | 205 &dstCopySamplerName); |
| 204 fProgramBuilder->fUniformHandles.fDstCopyTopLeftUni = | 206 fProgramBuilder->fUniformHandles.fDstCopyTopLeftUni = |
| 205 fProgramBuilder->addUniform(GrGLProgramBuilder::kFragment_Visibility
, | 207 fProgramBuilder->addUniform(GrGLProgramBuilder::kFragment_Visibility
, |
| 206 kVec2f_GrSLType, | 208 kVec2f_GrSLType, |
| 209 kDefault_GrSLPrecision, |
| 207 "DstCopyUpperLeft", | 210 "DstCopyUpperLeft", |
| 208 &dstCopyTopLeftName); | 211 &dstCopyTopLeftName); |
| 209 fProgramBuilder->fUniformHandles.fDstCopyScaleUni = | 212 fProgramBuilder->fUniformHandles.fDstCopyScaleUni = |
| 210 fProgramBuilder->addUniform(GrGLProgramBuilder::kFragment_Visibility
, | 213 fProgramBuilder->addUniform(GrGLProgramBuilder::kFragment_Visibility
, |
| 211 kVec2f_GrSLType, | 214 kVec2f_GrSLType, |
| 215 kDefault_GrSLPrecision, |
| 212 "DstCopyCoordScale", | 216 "DstCopyCoordScale", |
| 213 &dstCopyCoordScaleName); | 217 &dstCopyCoordScaleName); |
| 214 const char* fragPos = this->fragmentPosition(); | 218 const char* fragPos = this->fragmentPosition(); |
| 215 | 219 |
| 216 this->codeAppend("// Read color from copy of the destination.\n"); | 220 this->codeAppend("// Read color from copy of the destination.\n"); |
| 217 this->codeAppendf("vec2 _dstTexCoord = (%s.xy - %s) * %s;", | 221 this->codeAppendf("vec2 _dstTexCoord = (%s.xy - %s) * %s;", |
| 218 fragPos, dstCopyTopLeftName, dstCopyCoordScaleName); | 222 fragPos, dstCopyTopLeftName, dstCopyCoordScaleName); |
| 219 if (!topDown) { | 223 if (!topDown) { |
| 220 this->codeAppend("_dstTexCoord.y = 1.0 - _dstTexCoord.y;"); | 224 this->codeAppend("_dstTexCoord.y = 1.0 - _dstTexCoord.y;"); |
| 221 } | 225 } |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 } | 346 } |
| 343 } | 347 } |
| 344 | 348 |
| 345 void GrGLFragmentShaderBuilder::addVarying(GrGLVarying* v, GrSLPrecision fsPrec)
{ | 349 void GrGLFragmentShaderBuilder::addVarying(GrGLVarying* v, GrSLPrecision fsPrec)
{ |
| 346 v->fFsIn = v->fVsOut; | 350 v->fFsIn = v->fVsOut; |
| 347 if (v->fGsOut) { | 351 if (v->fGsOut) { |
| 348 v->fFsIn = v->fGsOut; | 352 v->fFsIn = v->fGsOut; |
| 349 } | 353 } |
| 350 fInputs.push_back().set(v->fType, GrGLShaderVar::kVaryingIn_TypeModifier, v-
>fFsIn, fsPrec); | 354 fInputs.push_back().set(v->fType, GrGLShaderVar::kVaryingIn_TypeModifier, v-
>fFsIn, fsPrec); |
| 351 } | 355 } |
| OLD | NEW |