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/GrGLProgramBuilder.h" | 9 #include "gl/builders/GrGLProgramBuilder.h" |
10 #include "gl/GrGLProcessor.h" | 10 #include "gl/GrGLProcessor.h" |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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(InvariantOutput* ino
ut) const { | 209 void GrDistanceFieldTextureEffect::onComputeInvariantOutput(InvariantOutput* ino
ut) const { |
210 if (inout->isOpaque() && GrPixelConfigIsOpaque(this->texture(0)->config()))
{ | 210 inout->mulByUnknownAlpha(); |
211 inout->fValidFlags = kA_GrColorComponentFlag; | |
212 } else { | |
213 inout->fValidFlags = 0; | |
214 } | |
215 inout->fIsSingleComponent = false; | |
216 } | 211 } |
217 | 212 |
218 const GrBackendGeometryProcessorFactory& GrDistanceFieldTextureEffect::getFactor
y() const { | 213 const GrBackendGeometryProcessorFactory& GrDistanceFieldTextureEffect::getFactor
y() const { |
219 return GrTBackendGeometryProcessorFactory<GrDistanceFieldTextureEffect>::get
Instance(); | 214 return GrTBackendGeometryProcessorFactory<GrDistanceFieldTextureEffect>::get
Instance(); |
220 } | 215 } |
221 | 216 |
222 /////////////////////////////////////////////////////////////////////////////// | 217 /////////////////////////////////////////////////////////////////////////////// |
223 | 218 |
224 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrDistanceFieldTextureEffect); | 219 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrDistanceFieldTextureEffect); |
225 | 220 |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
384 this->addTextureAccess(&fTextureAccess); | 379 this->addTextureAccess(&fTextureAccess); |
385 } | 380 } |
386 | 381 |
387 bool GrDistanceFieldNoGammaTextureEffect::onIsEqual(const GrProcessor& other) co
nst { | 382 bool GrDistanceFieldNoGammaTextureEffect::onIsEqual(const GrProcessor& other) co
nst { |
388 const GrDistanceFieldNoGammaTextureEffect& cte = | 383 const GrDistanceFieldNoGammaTextureEffect& cte = |
389 other.cast<GrDistanceFieldNoGam
maTextureEffect>(); | 384 other.cast<GrDistanceFieldNoGam
maTextureEffect>(); |
390 return fTextureAccess == cte.fTextureAccess && fFlags == cte.fFlags; | 385 return fTextureAccess == cte.fTextureAccess && fFlags == cte.fFlags; |
391 } | 386 } |
392 | 387 |
393 void GrDistanceFieldNoGammaTextureEffect::onComputeInvariantOutput(InvariantOutp
ut* inout) const { | 388 void GrDistanceFieldNoGammaTextureEffect::onComputeInvariantOutput(InvariantOutp
ut* inout) const { |
394 if (inout->isOpaque() && GrPixelConfigIsOpaque(this->texture(0)->config()))
{ | 389 inout->mulByUnknownAlpha(); |
395 inout->fValidFlags = kA_GrColorComponentFlag; | |
396 } else { | |
397 inout->fValidFlags = 0; | |
398 } | |
399 inout->fIsSingleComponent = false; | |
400 } | 390 } |
401 | 391 |
402 const GrBackendGeometryProcessorFactory& GrDistanceFieldNoGammaTextureEffect::ge
tFactory() const { | 392 const GrBackendGeometryProcessorFactory& GrDistanceFieldNoGammaTextureEffect::ge
tFactory() const { |
403 return GrTBackendGeometryProcessorFactory<GrDistanceFieldNoGammaTextureEffec
t>::getInstance(); | 393 return GrTBackendGeometryProcessorFactory<GrDistanceFieldNoGammaTextureEffec
t>::getInstance(); |
404 } | 394 } |
405 | 395 |
406 /////////////////////////////////////////////////////////////////////////////// | 396 /////////////////////////////////////////////////////////////////////////////// |
407 | 397 |
408 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrDistanceFieldNoGammaTextureEffect); | 398 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrDistanceFieldNoGammaTextureEffect); |
409 | 399 |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
640 | 630 |
641 bool GrDistanceFieldLCDTextureEffect::onIsEqual(const GrProcessor& other) const
{ | 631 bool GrDistanceFieldLCDTextureEffect::onIsEqual(const GrProcessor& other) const
{ |
642 const GrDistanceFieldLCDTextureEffect& cte = other.cast<GrDistanceFieldLCDTe
xtureEffect>(); | 632 const GrDistanceFieldLCDTextureEffect& cte = other.cast<GrDistanceFieldLCDTe
xtureEffect>(); |
643 return (fTextureAccess == cte.fTextureAccess && | 633 return (fTextureAccess == cte.fTextureAccess && |
644 fGammaTextureAccess == cte.fGammaTextureAccess && | 634 fGammaTextureAccess == cte.fGammaTextureAccess && |
645 fTextColor == cte.fTextColor && | 635 fTextColor == cte.fTextColor && |
646 fFlags == cte.fFlags); | 636 fFlags == cte.fFlags); |
647 } | 637 } |
648 | 638 |
649 void GrDistanceFieldLCDTextureEffect::onComputeInvariantOutput(InvariantOutput*
inout) const { | 639 void GrDistanceFieldLCDTextureEffect::onComputeInvariantOutput(InvariantOutput*
inout) const { |
650 if (inout->isOpaque() && GrPixelConfigIsOpaque(this->texture(0)->config()))
{ | 640 inout->mulByUnknownColor(); |
651 inout->fValidFlags = kA_GrColorComponentFlag; | |
652 } else { | |
653 inout->fValidFlags = 0; | |
654 } | |
655 inout->fIsSingleComponent = false; | |
656 } | 641 } |
657 | 642 |
658 const GrBackendGeometryProcessorFactory& GrDistanceFieldLCDTextureEffect::getFac
tory() const { | 643 const GrBackendGeometryProcessorFactory& GrDistanceFieldLCDTextureEffect::getFac
tory() const { |
659 return GrTBackendGeometryProcessorFactory<GrDistanceFieldLCDTextureEffect>::
getInstance(); | 644 return GrTBackendGeometryProcessorFactory<GrDistanceFieldLCDTextureEffect>::
getInstance(); |
660 } | 645 } |
661 | 646 |
662 /////////////////////////////////////////////////////////////////////////////// | 647 /////////////////////////////////////////////////////////////////////////////// |
663 | 648 |
664 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrDistanceFieldLCDTextureEffect); | 649 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrDistanceFieldLCDTextureEffect); |
665 | 650 |
(...skipping 23 matching lines...) Expand all Loading... |
689 random->nextULessThan(256), | 674 random->nextULessThan(256), |
690 random->nextULessThan(256)); | 675 random->nextULessThan(256)); |
691 uint32_t flags = kUseLCD_DistanceFieldEffectFlag; | 676 uint32_t flags = kUseLCD_DistanceFieldEffectFlag; |
692 flags |= random->nextBool() ? kUniformScale_DistanceFieldEffectMask : 0; | 677 flags |= random->nextBool() ? kUniformScale_DistanceFieldEffectMask : 0; |
693 flags |= random->nextBool() ? kBGR_DistanceFieldEffectFlag : 0; | 678 flags |= random->nextBool() ? kBGR_DistanceFieldEffectFlag : 0; |
694 return GrDistanceFieldLCDTextureEffect::Create(textures[texIdx], params, | 679 return GrDistanceFieldLCDTextureEffect::Create(textures[texIdx], params, |
695 textures[texIdx2], params2, | 680 textures[texIdx2], params2, |
696 textColor, | 681 textColor, |
697 flags); | 682 flags); |
698 } | 683 } |
OLD | NEW |