| 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::getConstantColorComponents(GrColor* color, | 209 void GrDistanceFieldTextureEffect::onComputeInvarientOutput( |
| 210 uint32_t* validFlag
s) const { | 210 InvarientOutput* invarientOutput) const { |
| 211 if ((*validFlags & kA_GrColorComponentFlag) && 0xFF == GrColorUnpackA(*color
) && | 211 if (invarientOutput->hasOpaqueAlpha() && GrPixelConfigIsOpaque(this->texture
(0)->config())) { |
| 212 GrPixelConfigIsOpaque(this->texture(0)->config())) { | 212 invarientOutput->validFlags = kA_GrColorComponentFlag; |
| 213 *validFlags = kA_GrColorComponentFlag; | |
| 214 } else { | 213 } else { |
| 215 *validFlags = 0; | 214 invarientOutput->validFlags = 0; |
| 216 } | 215 } |
| 216 invarientOutput->isSingleComponent = 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::getConstantColorComponents(GrColor* color, | 479 void GrDistanceFieldLCDTextureEffect::onComputeInvarientOutput( |
| 480 uint32_t* valid
Flags) const { | 480 InvarientOutput* invarientOutput) const { |
| 481 if ((*validFlags & kA_GrColorComponentFlag) && 0xFF == GrColorUnpackA(*color
) && | 481 if (invarientOutput->hasOpaqueAlpha() && GrPixelConfigIsOpaque(this->texture
(0)->config())) { |
| 482 GrPixelConfigIsOpaque(this->texture(0)->config())) { | 482 invarientOutput->validFlags = kA_GrColorComponentFlag; |
| 483 *validFlags = kA_GrColorComponentFlag; | |
| 484 } else { | 483 } else { |
| 485 *validFlags = 0; | 484 invarientOutput->validFlags = 0; |
| 486 } | 485 } |
| 486 invarientOutput->isSingleComponent = 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 |