| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "GrDistanceFieldTextureEffect.h" | 8 #include "GrDistanceFieldTextureEffect.h" |
| 9 #include "GrInvariantOutput.h" | 9 #include "GrInvariantOutput.h" |
| 10 #include "GrTexture.h" | 10 #include "GrTexture.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 public: | 28 public: |
| 29 GrGLDistanceFieldTextureEffect(const GrGeometryProcessor&, | 29 GrGLDistanceFieldTextureEffect(const GrGeometryProcessor&, |
| 30 const GrBatchTracker&) | 30 const GrBatchTracker&) |
| 31 : fColor(GrColor_ILLEGAL) | 31 : fColor(GrColor_ILLEGAL) |
| 32 , fTextureSize(SkISize::Make(-1,-1)) | 32 , fTextureSize(SkISize::Make(-1,-1)) |
| 33 #ifdef SK_GAMMA_APPLY_TO_A8 | 33 #ifdef SK_GAMMA_APPLY_TO_A8 |
| 34 , fLuminance(-1.0f) | 34 , fLuminance(-1.0f) |
| 35 #endif | 35 #endif |
| 36 {} | 36 {} |
| 37 | 37 |
| 38 void onEmitCode(EmitArgs& args) SK_OVERRIDE { | 38 void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) SK_OVERRIDE{ |
| 39 const GrDistanceFieldTextureEffect& dfTexEffect = | 39 const GrDistanceFieldTextureEffect& dfTexEffect = |
| 40 args.fGP.cast<GrDistanceFieldTextureEffect>(); | 40 args.fGP.cast<GrDistanceFieldTextureEffect>(); |
| 41 const DistanceFieldBatchTracker& local = args.fBT.cast<DistanceFieldBatc
hTracker>(); | 41 const DistanceFieldBatchTracker& local = args.fBT.cast<DistanceFieldBatc
hTracker>(); |
| 42 GrGLGPBuilder* pb = args.fPB; | 42 GrGLGPBuilder* pb = args.fPB; |
| 43 GrGLGPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder(); | 43 GrGLGPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder(); |
| 44 SkAssertResult(fsBuilder->enableFeature( | 44 SkAssertResult(fsBuilder->enableFeature( |
| 45 GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature)); | 45 GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature)); |
| 46 | 46 |
| 47 GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder(); | 47 GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder(); |
| 48 | 48 |
| 49 // emit attributes | 49 // emit attributes |
| 50 vsBuilder->emitAttributes(dfTexEffect); | 50 vsBuilder->emitAttributes(dfTexEffect); |
| 51 | 51 |
| 52 GrGLVertToFrag v(kVec2f_GrSLType); | 52 GrGLVertToFrag v(kVec2f_GrSLType); |
| 53 args.fPB->addVarying("TextureCoords", &v); | 53 args.fPB->addVarying("TextureCoords", &v); |
| 54 vsBuilder->codeAppendf("%s = %s;", v.vsOut(), dfTexEffect.inTextureCoord
s()->fName); | 54 vsBuilder->codeAppendf("%s = %s;", v.vsOut(), dfTexEffect.inTextureCoord
s()->fName); |
| 55 | 55 |
| 56 // Setup pass through color | 56 // Setup pass through color |
| 57 this->setupColorPassThrough(pb, local.fInputColorType, args.fOutputColor
, | 57 this->setupColorPassThrough(pb, local.fInputColorType, args.fOutputColor
, |
| 58 dfTexEffect.inColor(), &fColorUniform); | 58 dfTexEffect.inColor(), &fColorUniform); |
| 59 | 59 |
| 60 // setup uniform viewMatrix | 60 // setup uniform viewMatrix |
| 61 this->addUniformViewMatrix(pb); | 61 this->addUniformViewMatrix(pb); |
| 62 | 62 |
| 63 // Setup position | 63 // Setup position |
| 64 vsBuilder->codeAppendf("%s = %s * vec3(%s, 1);", this->position(), this
->uViewM(), | 64 SetupPosition(vsBuilder, gpArgs, dfTexEffect.inPosition()->fName, |
| 65 dfTexEffect.inPosition()->fName); | 65 dfTexEffect.viewMatrix(), this->uViewM()); |
| 66 | 66 |
| 67 // emit transforms | 67 // emit transforms |
| 68 this->emitTransforms(args.fPB, this->position(), dfTexEffect.inPosition
()->fName, | 68 this->emitTransforms(args.fPB, gpArgs->fPositionVar, dfTexEffect.inPosit
ion()->fName, |
| 69 dfTexEffect.localMatrix(), args.fTransformsIn, args
.fTransformsOut); | 69 dfTexEffect.localMatrix(), args.fTransformsIn, args
.fTransformsOut); |
| 70 | 70 |
| 71 const char* textureSizeUniName = NULL; | 71 const char* textureSizeUniName = NULL; |
| 72 fTextureSizeUni = args.fPB->addUniform(GrGLProgramBuilder::kFragment_Vis
ibility, | 72 fTextureSizeUni = args.fPB->addUniform(GrGLProgramBuilder::kFragment_Vis
ibility, |
| 73 kVec2f_GrSLType, kDefault_GrSLPre
cision, | 73 kVec2f_GrSLType, kDefault_GrSLPre
cision, |
| 74 "TextureSize", &textureSizeUniNam
e); | 74 "TextureSize", &textureSizeUniNam
e); |
| 75 | 75 |
| 76 fsBuilder->codeAppend("\tvec4 texColor = "); | 76 fsBuilder->codeAppend("\tvec4 texColor = "); |
| 77 fsBuilder->appendTextureLookup(args.fSamplers[0], | 77 fsBuilder->appendTextureLookup(args.fSamplers[0], |
| 78 v.fsIn(), | 78 v.fsIn(), |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 | 159 |
| 160 const DistanceFieldBatchTracker& local = bt.cast<DistanceFieldBatchTrack
er>(); | 160 const DistanceFieldBatchTracker& local = bt.cast<DistanceFieldBatchTrack
er>(); |
| 161 if (kUniform_GrGPInput == local.fInputColorType && local.fColor != fColo
r) { | 161 if (kUniform_GrGPInput == local.fInputColorType && local.fColor != fColo
r) { |
| 162 GrGLfloat c[4]; | 162 GrGLfloat c[4]; |
| 163 GrColorToRGBAFloat(local.fColor, c); | 163 GrColorToRGBAFloat(local.fColor, c); |
| 164 pdman.set4fv(fColorUniform, 1, c); | 164 pdman.set4fv(fColorUniform, 1, c); |
| 165 fColor = local.fColor; | 165 fColor = local.fColor; |
| 166 } | 166 } |
| 167 } | 167 } |
| 168 | 168 |
| 169 static inline void GenKey(const GrGeometryProcessor& processor, | 169 static inline void GenKey(const GrGeometryProcessor& gp, |
| 170 const GrBatchTracker& bt, | 170 const GrBatchTracker& bt, |
| 171 const GrGLCaps&, | 171 const GrGLCaps&, |
| 172 GrProcessorKeyBuilder* b) { | 172 GrProcessorKeyBuilder* b) { |
| 173 const GrDistanceFieldTextureEffect& dfTexEffect = | 173 const GrDistanceFieldTextureEffect& dfTexEffect = gp.cast<GrDistanceFiel
dTextureEffect>(); |
| 174 processor.cast<GrDistanceFieldTextureEffect>(); | |
| 175 const DistanceFieldBatchTracker& local = bt.cast<DistanceFieldBatchTrack
er>(); | 174 const DistanceFieldBatchTracker& local = bt.cast<DistanceFieldBatchTrack
er>(); |
| 176 uint32_t key = dfTexEffect.getFlags(); | 175 uint32_t key = dfTexEffect.getFlags(); |
| 177 key |= local.fInputColorType << 16; | 176 key |= local.fInputColorType << 16; |
| 178 key |= local.fUsesLocalCoords && processor.localMatrix().hasPerspective(
) ? 0x1 << 24: 0x0; | 177 key |= local.fUsesLocalCoords && gp.localMatrix().hasPerspective() ? 0x1
<< 24: 0x0; |
| 178 key |= ComputePosKey(gp.viewMatrix()) << 25; |
| 179 b->add32(key); | 179 b->add32(key); |
| 180 } | 180 } |
| 181 | 181 |
| 182 private: | 182 private: |
| 183 GrColor fColor; | 183 GrColor fColor; |
| 184 UniformHandle fColorUniform; | 184 UniformHandle fColorUniform; |
| 185 UniformHandle fTextureSizeUni; | 185 UniformHandle fTextureSizeUni; |
| 186 SkISize fTextureSize; | 186 SkISize fTextureSize; |
| 187 UniformHandle fLuminanceUni; | 187 UniformHandle fLuminanceUni; |
| 188 float fLuminance; | 188 float fLuminance; |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 GrColor fColor; | 317 GrColor fColor; |
| 318 bool fUsesLocalCoords; | 318 bool fUsesLocalCoords; |
| 319 }; | 319 }; |
| 320 | 320 |
| 321 class GrGLDistanceFieldNoGammaTextureEffect : public GrGLGeometryProcessor { | 321 class GrGLDistanceFieldNoGammaTextureEffect : public GrGLGeometryProcessor { |
| 322 public: | 322 public: |
| 323 GrGLDistanceFieldNoGammaTextureEffect(const GrGeometryProcessor&, | 323 GrGLDistanceFieldNoGammaTextureEffect(const GrGeometryProcessor&, |
| 324 const GrBatchTracker&) | 324 const GrBatchTracker&) |
| 325 : fColor(GrColor_ILLEGAL), fTextureSize(SkISize::Make(-1, -1)) {} | 325 : fColor(GrColor_ILLEGAL), fTextureSize(SkISize::Make(-1, -1)) {} |
| 326 | 326 |
| 327 void onEmitCode(EmitArgs& args) SK_OVERRIDE { | 327 void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) SK_OVERRIDE{ |
| 328 const GrDistanceFieldNoGammaTextureEffect& dfTexEffect = | 328 const GrDistanceFieldNoGammaTextureEffect& dfTexEffect = |
| 329 args.fGP.cast<GrDistanceFieldNoGammaTextureEffect>(); | 329 args.fGP.cast<GrDistanceFieldNoGammaTextureEffect>(); |
| 330 | 330 |
| 331 const DistanceFieldNoGammaBatchTracker& local = | 331 const DistanceFieldNoGammaBatchTracker& local = |
| 332 args.fBT.cast<DistanceFieldNoGammaBatchTracker>(); | 332 args.fBT.cast<DistanceFieldNoGammaBatchTracker>(); |
| 333 GrGLGPBuilder* pb = args.fPB; | 333 GrGLGPBuilder* pb = args.fPB; |
| 334 GrGLGPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder(); | 334 GrGLGPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder(); |
| 335 SkAssertResult(fsBuilder->enableFeature( | 335 SkAssertResult(fsBuilder->enableFeature( |
| 336 GrGLFragmentShaderBuilder::kStandardDerivat
ives_GLSLFeature)); | 336 GrGLFragmentShaderBuilder::kStandardDerivat
ives_GLSLFeature)); |
| 337 | 337 |
| 338 GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder(); | 338 GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder(); |
| 339 | 339 |
| 340 // emit attributes | 340 // emit attributes |
| 341 vsBuilder->emitAttributes(dfTexEffect); | 341 vsBuilder->emitAttributes(dfTexEffect); |
| 342 | 342 |
| 343 GrGLVertToFrag v(kVec2f_GrSLType); | 343 GrGLVertToFrag v(kVec2f_GrSLType); |
| 344 args.fPB->addVarying("TextureCoords", &v); | 344 args.fPB->addVarying("TextureCoords", &v); |
| 345 | 345 |
| 346 // setup pass through color | 346 // setup pass through color |
| 347 this->setupColorPassThrough(pb, local.fInputColorType, args.fOutputColor
, | 347 this->setupColorPassThrough(pb, local.fInputColorType, args.fOutputColor
, |
| 348 dfTexEffect.inColor(), &fColorUniform); | 348 dfTexEffect.inColor(), &fColorUniform); |
| 349 | 349 |
| 350 vsBuilder->codeAppendf("%s = %s;", v.vsOut(), dfTexEffect.inTextureCoord
s()->fName); | 350 vsBuilder->codeAppendf("%s = %s;", v.vsOut(), dfTexEffect.inTextureCoord
s()->fName); |
| 351 | 351 |
| 352 // setup uniform viewMatrix | 352 // setup uniform viewMatrix |
| 353 this->addUniformViewMatrix(pb); | 353 this->addUniformViewMatrix(pb); |
| 354 | 354 |
| 355 // Setup position | 355 // Setup position |
| 356 vsBuilder->codeAppendf("%s = %s * vec3(%s, 1);", this->position(), this
->uViewM(), | 356 SetupPosition(vsBuilder, gpArgs, dfTexEffect.inPosition()->fName, |
| 357 dfTexEffect.inPosition()->fName); | 357 dfTexEffect.viewMatrix(), this->uViewM()); |
| 358 | 358 |
| 359 // emit transforms | 359 // emit transforms |
| 360 this->emitTransforms(args.fPB, this->position(), dfTexEffect.inPosition
()->fName, | 360 this->emitTransforms(args.fPB, gpArgs->fPositionVar, dfTexEffect.inPosit
ion()->fName, |
| 361 dfTexEffect.localMatrix(), args.fTransformsIn, args
.fTransformsOut); | 361 dfTexEffect.localMatrix(), args.fTransformsIn, args
.fTransformsOut); |
| 362 | 362 |
| 363 const char* textureSizeUniName = NULL; | 363 const char* textureSizeUniName = NULL; |
| 364 fTextureSizeUni = args.fPB->addUniform(GrGLProgramBuilder::kFragment_Vis
ibility, | 364 fTextureSizeUni = args.fPB->addUniform(GrGLProgramBuilder::kFragment_Vis
ibility, |
| 365 kVec2f_GrSLType, kDefault_GrSLPrec
ision, | 365 kVec2f_GrSLType, kDefault_GrSLPrec
ision, |
| 366 "TextureSize", &textureSizeUniName
); | 366 "TextureSize", &textureSizeUniName
); |
| 367 | 367 |
| 368 fsBuilder->codeAppend("vec4 texColor = "); | 368 fsBuilder->codeAppend("vec4 texColor = "); |
| 369 fsBuilder->appendTextureLookup(args.fSamplers[0], | 369 fsBuilder->appendTextureLookup(args.fSamplers[0], |
| 370 v.fsIn(), | 370 v.fsIn(), |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 | 427 |
| 428 const DistanceFieldNoGammaBatchTracker& local = bt.cast<DistanceFieldNoG
ammaBatchTracker>(); | 428 const DistanceFieldNoGammaBatchTracker& local = bt.cast<DistanceFieldNoG
ammaBatchTracker>(); |
| 429 if (kUniform_GrGPInput == local.fInputColorType && local.fColor != fColo
r) { | 429 if (kUniform_GrGPInput == local.fInputColorType && local.fColor != fColo
r) { |
| 430 GrGLfloat c[4]; | 430 GrGLfloat c[4]; |
| 431 GrColorToRGBAFloat(local.fColor, c); | 431 GrColorToRGBAFloat(local.fColor, c); |
| 432 pdman.set4fv(fColorUniform, 1, c); | 432 pdman.set4fv(fColorUniform, 1, c); |
| 433 fColor = local.fColor; | 433 fColor = local.fColor; |
| 434 } | 434 } |
| 435 } | 435 } |
| 436 | 436 |
| 437 static inline void GenKey(const GrGeometryProcessor& proc, | 437 static inline void GenKey(const GrGeometryProcessor& gp, |
| 438 const GrBatchTracker& bt, | 438 const GrBatchTracker& bt, |
| 439 const GrGLCaps&, | 439 const GrGLCaps&, |
| 440 GrProcessorKeyBuilder* b) { | 440 GrProcessorKeyBuilder* b) { |
| 441 const GrDistanceFieldNoGammaTextureEffect& dfTexEffect = | 441 const GrDistanceFieldNoGammaTextureEffect& dfTexEffect = |
| 442 proc.cast<GrDistanceFieldNoGammaTextureEffect>(); | 442 gp.cast<GrDistanceFieldNoGammaTextureEffect>(); |
| 443 | 443 |
| 444 const DistanceFieldNoGammaBatchTracker& local = bt.cast<DistanceFieldNoG
ammaBatchTracker>(); | 444 const DistanceFieldNoGammaBatchTracker& local = bt.cast<DistanceFieldNoG
ammaBatchTracker>(); |
| 445 uint32_t key = dfTexEffect.getFlags(); | 445 uint32_t key = dfTexEffect.getFlags(); |
| 446 key |= local.fInputColorType << 16; | 446 key |= local.fInputColorType << 16; |
| 447 key |= local.fUsesLocalCoords && proc.localMatrix().hasPerspective() ? 0
x1 << 24: 0x0; | 447 key |= local.fUsesLocalCoords && gp.localMatrix().hasPerspective() ? 0x1
<< 24: 0x0; |
| 448 key |= ComputePosKey(gp.viewMatrix()) << 25; |
| 448 b->add32(key); | 449 b->add32(key); |
| 449 } | 450 } |
| 450 | 451 |
| 451 private: | 452 private: |
| 452 UniformHandle fColorUniform; | 453 UniformHandle fColorUniform; |
| 453 UniformHandle fTextureSizeUni; | 454 UniformHandle fTextureSizeUni; |
| 454 GrColor fColor; | 455 GrColor fColor; |
| 455 SkISize fTextureSize; | 456 SkISize fTextureSize; |
| 456 | 457 |
| 457 typedef GrGLGeometryProcessor INHERITED; | 458 typedef GrGLGeometryProcessor INHERITED; |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 561 }; | 562 }; |
| 562 | 563 |
| 563 class GrGLDistanceFieldLCDTextureEffect : public GrGLGeometryProcessor { | 564 class GrGLDistanceFieldLCDTextureEffect : public GrGLGeometryProcessor { |
| 564 public: | 565 public: |
| 565 GrGLDistanceFieldLCDTextureEffect(const GrGeometryProcessor&, | 566 GrGLDistanceFieldLCDTextureEffect(const GrGeometryProcessor&, |
| 566 const GrBatchTracker&) | 567 const GrBatchTracker&) |
| 567 : fColor(GrColor_ILLEGAL) | 568 : fColor(GrColor_ILLEGAL) |
| 568 , fTextureSize(SkISize::Make(-1,-1)) | 569 , fTextureSize(SkISize::Make(-1,-1)) |
| 569 , fTextColor(GrColor_ILLEGAL) {} | 570 , fTextColor(GrColor_ILLEGAL) {} |
| 570 | 571 |
| 571 void onEmitCode(EmitArgs& args) SK_OVERRIDE { | 572 void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) SK_OVERRIDE{ |
| 572 const GrDistanceFieldLCDTextureEffect& dfTexEffect = | 573 const GrDistanceFieldLCDTextureEffect& dfTexEffect = |
| 573 args.fGP.cast<GrDistanceFieldLCDTextureEffect>(); | 574 args.fGP.cast<GrDistanceFieldLCDTextureEffect>(); |
| 574 const DistanceFieldLCDBatchTracker& local = args.fBT.cast<DistanceFieldL
CDBatchTracker>(); | 575 const DistanceFieldLCDBatchTracker& local = args.fBT.cast<DistanceFieldL
CDBatchTracker>(); |
| 575 GrGLGPBuilder* pb = args.fPB; | 576 GrGLGPBuilder* pb = args.fPB; |
| 576 | 577 |
| 577 GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder(); | 578 GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder(); |
| 578 | 579 |
| 579 // emit attributes | 580 // emit attributes |
| 580 vsBuilder->emitAttributes(dfTexEffect); | 581 vsBuilder->emitAttributes(dfTexEffect); |
| 581 | 582 |
| 582 GrGLVertToFrag v(kVec2f_GrSLType); | 583 GrGLVertToFrag v(kVec2f_GrSLType); |
| 583 args.fPB->addVarying("TextureCoords", &v); | 584 args.fPB->addVarying("TextureCoords", &v); |
| 584 vsBuilder->codeAppendf("%s = %s;", v.vsOut(), dfTexEffect.inTextureCoord
s()->fName); | 585 vsBuilder->codeAppendf("%s = %s;", v.vsOut(), dfTexEffect.inTextureCoord
s()->fName); |
| 585 | 586 |
| 586 // setup pass through color | 587 // setup pass through color |
| 587 this->setupColorPassThrough(pb, local.fInputColorType, args.fOutputColor
, NULL, | 588 this->setupColorPassThrough(pb, local.fInputColorType, args.fOutputColor
, NULL, |
| 588 &fColorUniform); | 589 &fColorUniform); |
| 589 | 590 |
| 590 // setup uniform viewMatrix | 591 // setup uniform viewMatrix |
| 591 this->addUniformViewMatrix(pb); | 592 this->addUniformViewMatrix(pb); |
| 592 | 593 |
| 593 // Setup position | 594 // Setup position |
| 594 vsBuilder->codeAppendf("%s = %s * vec3(%s, 1);", this->position(), this
->uViewM(), | 595 SetupPosition(vsBuilder, gpArgs, dfTexEffect.inPosition()->fName, |
| 595 dfTexEffect.inPosition()->fName); | 596 dfTexEffect.viewMatrix(), this->uViewM()); |
| 596 | 597 |
| 597 // emit transforms | 598 // emit transforms |
| 598 this->emitTransforms(args.fPB, this->position(), dfTexEffect.inPosition
()->fName, | 599 this->emitTransforms(args.fPB, gpArgs->fPositionVar, dfTexEffect.inPosit
ion()->fName, |
| 599 dfTexEffect.localMatrix(), args.fTransformsIn, args
.fTransformsOut); | 600 dfTexEffect.localMatrix(), args.fTransformsIn, args
.fTransformsOut); |
| 600 | 601 |
| 601 const char* textureSizeUniName = NULL; | 602 const char* textureSizeUniName = NULL; |
| 602 // width, height, 1/(3*width) | 603 // width, height, 1/(3*width) |
| 603 fTextureSizeUni = args.fPB->addUniform(GrGLProgramBuilder::kFragment_Vis
ibility, | 604 fTextureSizeUni = args.fPB->addUniform(GrGLProgramBuilder::kFragment_Vis
ibility, |
| 604 kVec3f_GrSLType, kDefault_GrSLPrec
ision, | 605 kVec3f_GrSLType, kDefault_GrSLPrec
ision, |
| 605 "TextureSize", &textureSizeUniName
); | 606 "TextureSize", &textureSizeUniName
); |
| 606 | 607 |
| 607 GrGLGPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder(); | 608 GrGLGPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder(); |
| 608 | 609 |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 742 | 743 |
| 743 const DistanceFieldLCDBatchTracker& local = bt.cast<DistanceFieldLCDBatc
hTracker>(); | 744 const DistanceFieldLCDBatchTracker& local = bt.cast<DistanceFieldLCDBatc
hTracker>(); |
| 744 if (kUniform_GrGPInput == local.fInputColorType && local.fColor != fColo
r) { | 745 if (kUniform_GrGPInput == local.fInputColorType && local.fColor != fColo
r) { |
| 745 GrGLfloat c[4]; | 746 GrGLfloat c[4]; |
| 746 GrColorToRGBAFloat(local.fColor, c); | 747 GrColorToRGBAFloat(local.fColor, c); |
| 747 pdman.set4fv(fColorUniform, 1, c); | 748 pdman.set4fv(fColorUniform, 1, c); |
| 748 fColor = local.fColor; | 749 fColor = local.fColor; |
| 749 } | 750 } |
| 750 } | 751 } |
| 751 | 752 |
| 752 static inline void GenKey(const GrGeometryProcessor& processor, | 753 static inline void GenKey(const GrGeometryProcessor& gp, |
| 753 const GrBatchTracker& bt, | 754 const GrBatchTracker& bt, |
| 754 const GrGLCaps&, | 755 const GrGLCaps&, |
| 755 GrProcessorKeyBuilder* b) { | 756 GrProcessorKeyBuilder* b) { |
| 756 const GrDistanceFieldLCDTextureEffect& dfTexEffect = | 757 const GrDistanceFieldLCDTextureEffect& dfTexEffect = |
| 757 processor.cast<GrDistanceFieldLCDTextureEffect>(); | 758 gp.cast<GrDistanceFieldLCDTextureEffect>(); |
| 758 | 759 |
| 759 const DistanceFieldLCDBatchTracker& local = bt.cast<DistanceFieldLCDBatc
hTracker>(); | 760 const DistanceFieldLCDBatchTracker& local = bt.cast<DistanceFieldLCDBatc
hTracker>(); |
| 760 uint32_t key = dfTexEffect.getFlags(); | 761 uint32_t key = dfTexEffect.getFlags(); |
| 761 key |= local.fInputColorType << 16; | 762 key |= local.fInputColorType << 16; |
| 762 key |= local.fUsesLocalCoords && processor.localMatrix().hasPerspective(
) ? 0x1 << 24: 0x0; | 763 key |= local.fUsesLocalCoords && gp.localMatrix().hasPerspective() ? 0x1
<< 24: 0x0; |
| 764 key |= ComputePosKey(gp.viewMatrix()) << 25; |
| 763 b->add32(key); | 765 b->add32(key); |
| 764 } | 766 } |
| 765 | 767 |
| 766 private: | 768 private: |
| 767 GrColor fColor; | 769 GrColor fColor; |
| 768 UniformHandle fColorUniform; | 770 UniformHandle fColorUniform; |
| 769 UniformHandle fTextureSizeUni; | 771 UniformHandle fTextureSizeUni; |
| 770 SkISize fTextureSize; | 772 SkISize fTextureSize; |
| 771 UniformHandle fTextColorUni; | 773 UniformHandle fTextColorUni; |
| 772 SkColor fTextColor; | 774 SkColor fTextColor; |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 869 uint32_t flags = kUseLCD_DistanceFieldEffectFlag; | 871 uint32_t flags = kUseLCD_DistanceFieldEffectFlag; |
| 870 flags |= random->nextBool() ? kUniformScale_DistanceFieldEffectMask : 0; | 872 flags |= random->nextBool() ? kUniformScale_DistanceFieldEffectMask : 0; |
| 871 flags |= random->nextBool() ? kBGR_DistanceFieldEffectFlag : 0; | 873 flags |= random->nextBool() ? kBGR_DistanceFieldEffectFlag : 0; |
| 872 return GrDistanceFieldLCDTextureEffect::Create(GrRandomColor(random), | 874 return GrDistanceFieldLCDTextureEffect::Create(GrRandomColor(random), |
| 873 GrProcessorUnitTest::TestMatr
ix(random), | 875 GrProcessorUnitTest::TestMatr
ix(random), |
| 874 textures[texIdx], params, | 876 textures[texIdx], params, |
| 875 textures[texIdx2], params2, | 877 textures[texIdx2], params2, |
| 876 textColor, | 878 textColor, |
| 877 flags); | 879 flags); |
| 878 } | 880 } |
| OLD | NEW |