| 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 "gl/builders/GrGLFullProgramBuilder.h" | 9 #include "gl/builders/GrGLFullProgramBuilder.h" |
| 10 #include "gl/GrGLProcessor.h" | 10 #include "gl/GrGLProcessor.h" |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 bool GrDistanceFieldTextureEffect::onIsEqual(const GrProcessor& other) const { | 199 bool GrDistanceFieldTextureEffect::onIsEqual(const GrProcessor& other) const { |
| 200 const GrDistanceFieldTextureEffect& cte = other.cast<GrDistanceFieldTextureE
ffect>(); | 200 const GrDistanceFieldTextureEffect& cte = other.cast<GrDistanceFieldTextureE
ffect>(); |
| 201 return fTextureAccess == cte.fTextureAccess && | 201 return fTextureAccess == cte.fTextureAccess && |
| 202 #ifdef SK_GAMMA_APPLY_TO_A8 | 202 #ifdef SK_GAMMA_APPLY_TO_A8 |
| 203 fGammaTextureAccess == cte.fGammaTextureAccess && | 203 fGammaTextureAccess == cte.fGammaTextureAccess && |
| 204 fLuminance == cte.fLuminance && | 204 fLuminance == cte.fLuminance && |
| 205 #endif | 205 #endif |
| 206 fFlags == cte.fFlags; | 206 fFlags == cte.fFlags; |
| 207 } | 207 } |
| 208 | 208 |
| 209 void GrDistanceFieldTextureEffect::onComputeInvariantOutput( | 209 void GrDistanceFieldTextureEffect::getConstantColorComponents(GrColor* color, |
| 210 InvariantOutput* inout) const { | 210 uint32_t* validFlag
s) const { |
| 211 if (inout->isOpaque() && GrPixelConfigIsOpaque(this->texture(0)->config()))
{ | 211 if ((*validFlags & kA_GrColorComponentFlag) && 0xFF == GrColorUnpackA(*color
) && |
| 212 inout->fValidFlags = kA_GrColorComponentFlag; | 212 GrPixelConfigIsOpaque(this->texture(0)->config())) { |
| 213 *validFlags = kA_GrColorComponentFlag; |
| 213 } else { | 214 } else { |
| 214 inout->fValidFlags = 0; | 215 *validFlags = 0; |
| 215 } | 216 } |
| 216 inout->fIsSingleComponent = false; | |
| 217 } | 217 } |
| 218 | 218 |
| 219 const GrBackendGeometryProcessorFactory& GrDistanceFieldTextureEffect::getFactor
y() const { | 219 const GrBackendGeometryProcessorFactory& GrDistanceFieldTextureEffect::getFactor
y() const { |
| 220 return GrTBackendGeometryProcessorFactory<GrDistanceFieldTextureEffect>::get
Instance(); | 220 return GrTBackendGeometryProcessorFactory<GrDistanceFieldTextureEffect>::get
Instance(); |
| 221 } | 221 } |
| 222 | 222 |
| 223 /////////////////////////////////////////////////////////////////////////////// | 223 /////////////////////////////////////////////////////////////////////////////// |
| 224 | 224 |
| 225 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrDistanceFieldTextureEffect); | 225 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrDistanceFieldTextureEffect); |
| 226 | 226 |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 469 } | 469 } |
| 470 | 470 |
| 471 bool GrDistanceFieldLCDTextureEffect::onIsEqual(const GrProcessor& other) const
{ | 471 bool GrDistanceFieldLCDTextureEffect::onIsEqual(const GrProcessor& other) const
{ |
| 472 const GrDistanceFieldLCDTextureEffect& cte = other.cast<GrDistanceFieldLCDTe
xtureEffect>(); | 472 const GrDistanceFieldLCDTextureEffect& cte = other.cast<GrDistanceFieldLCDTe
xtureEffect>(); |
| 473 return (fTextureAccess == cte.fTextureAccess && | 473 return (fTextureAccess == cte.fTextureAccess && |
| 474 fGammaTextureAccess == cte.fGammaTextureAccess && | 474 fGammaTextureAccess == cte.fGammaTextureAccess && |
| 475 fTextColor == cte.fTextColor && | 475 fTextColor == cte.fTextColor && |
| 476 fFlags == cte.fFlags); | 476 fFlags == cte.fFlags); |
| 477 } | 477 } |
| 478 | 478 |
| 479 void GrDistanceFieldLCDTextureEffect::onComputeInvariantOutput( | 479 void GrDistanceFieldLCDTextureEffect::getConstantColorComponents(GrColor* color, |
| 480 InvariantOutput* inout) const { | 480 uint32_t* valid
Flags) const { |
| 481 if (inout->isOpaque() && GrPixelConfigIsOpaque(this->texture(0)->config()))
{ | 481 if ((*validFlags & kA_GrColorComponentFlag) && 0xFF == GrColorUnpackA(*color
) && |
| 482 inout->fValidFlags = kA_GrColorComponentFlag; | 482 GrPixelConfigIsOpaque(this->texture(0)->config())) { |
| 483 *validFlags = kA_GrColorComponentFlag; |
| 483 } else { | 484 } else { |
| 484 inout->fValidFlags = 0; | 485 *validFlags = 0; |
| 485 } | 486 } |
| 486 inout->fIsSingleComponent = false; | |
| 487 } | 487 } |
| 488 | 488 |
| 489 const GrBackendGeometryProcessorFactory& GrDistanceFieldLCDTextureEffect::getFac
tory() const { | 489 const GrBackendGeometryProcessorFactory& GrDistanceFieldLCDTextureEffect::getFac
tory() const { |
| 490 return GrTBackendGeometryProcessorFactory<GrDistanceFieldLCDTextureEffect>::
getInstance(); | 490 return GrTBackendGeometryProcessorFactory<GrDistanceFieldLCDTextureEffect>::
getInstance(); |
| 491 } | 491 } |
| 492 | 492 |
| 493 /////////////////////////////////////////////////////////////////////////////// | 493 /////////////////////////////////////////////////////////////////////////////// |
| 494 | 494 |
| 495 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrDistanceFieldLCDTextureEffect); | 495 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrDistanceFieldLCDTextureEffect); |
| 496 | 496 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 520 random->nextULessThan(256), | 520 random->nextULessThan(256), |
| 521 random->nextULessThan(256)); | 521 random->nextULessThan(256)); |
| 522 uint32_t flags = kUseLCD_DistanceFieldEffectFlag; | 522 uint32_t flags = kUseLCD_DistanceFieldEffectFlag; |
| 523 flags |= random->nextBool() ? kUniformScale_DistanceFieldEffectMask : 0; | 523 flags |= random->nextBool() ? kUniformScale_DistanceFieldEffectMask : 0; |
| 524 flags |= random->nextBool() ? kBGR_DistanceFieldEffectFlag : 0; | 524 flags |= random->nextBool() ? kBGR_DistanceFieldEffectFlag : 0; |
| 525 return GrDistanceFieldLCDTextureEffect::Create(textures[texIdx], params, | 525 return GrDistanceFieldLCDTextureEffect::Create(textures[texIdx], params, |
| 526 textures[texIdx2], params2, | 526 textures[texIdx2], params2, |
| 527 textColor, | 527 textColor, |
| 528 flags); | 528 flags); |
| 529 } | 529 } |
| OLD | NEW |