| 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 "gl/builders/GrGLProgramBuilder.h" | 10 #include "gl/builders/GrGLProgramBuilder.h" |
| 10 #include "gl/GrGLProcessor.h" | 11 #include "gl/GrGLProcessor.h" |
| 11 #include "gl/GrGLSL.h" | 12 #include "gl/GrGLSL.h" |
| 12 #include "gl/GrGLTexture.h" | 13 #include "gl/GrGLTexture.h" |
| 13 #include "gl/GrGLGeometryProcessor.h" | 14 #include "gl/GrGLGeometryProcessor.h" |
| 14 #include "GrTBackendProcessorFactory.h" | 15 #include "GrTBackendProcessorFactory.h" |
| 15 #include "GrTexture.h" | 16 #include "GrTexture.h" |
| 16 | 17 |
| 17 #include "SkDistanceFieldGen.h" | 18 #include "SkDistanceFieldGen.h" |
| 18 | 19 |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 | 183 |
| 183 bool GrDistanceFieldTextureEffect::onIsEqual(const GrGeometryProcessor& other) c
onst { | 184 bool GrDistanceFieldTextureEffect::onIsEqual(const GrGeometryProcessor& other) c
onst { |
| 184 const GrDistanceFieldTextureEffect& cte = other.cast<GrDistanceFieldTextureE
ffect>(); | 185 const GrDistanceFieldTextureEffect& cte = other.cast<GrDistanceFieldTextureE
ffect>(); |
| 185 return | 186 return |
| 186 #ifdef SK_GAMMA_APPLY_TO_A8 | 187 #ifdef SK_GAMMA_APPLY_TO_A8 |
| 187 fLuminance == cte.fLuminance && | 188 fLuminance == cte.fLuminance && |
| 188 #endif | 189 #endif |
| 189 fFlags == cte.fFlags; | 190 fFlags == cte.fFlags; |
| 190 } | 191 } |
| 191 | 192 |
| 192 void GrDistanceFieldTextureEffect::onComputeInvariantOutput(InvariantOutput* ino
ut) const { | 193 void GrDistanceFieldTextureEffect::onComputeInvariantOutput(GrInvariantOutput* i
nout) const { |
| 193 inout->mulByUnknownAlpha(); | 194 inout->mulByUnknownAlpha(); |
| 194 } | 195 } |
| 195 | 196 |
| 196 const GrBackendGeometryProcessorFactory& GrDistanceFieldTextureEffect::getFactor
y() const { | 197 const GrBackendGeometryProcessorFactory& GrDistanceFieldTextureEffect::getFactor
y() const { |
| 197 return GrTBackendGeometryProcessorFactory<GrDistanceFieldTextureEffect>::get
Instance(); | 198 return GrTBackendGeometryProcessorFactory<GrDistanceFieldTextureEffect>::get
Instance(); |
| 198 } | 199 } |
| 199 | 200 |
| 200 /////////////////////////////////////////////////////////////////////////////// | 201 /////////////////////////////////////////////////////////////////////////////// |
| 201 | 202 |
| 202 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrDistanceFieldTextureEffect); | 203 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrDistanceFieldTextureEffect); |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 SkASSERT(!(flags & ~kNonLCD_DistanceFieldEffectMask)); | 357 SkASSERT(!(flags & ~kNonLCD_DistanceFieldEffectMask)); |
| 357 this->addTextureAccess(&fTextureAccess); | 358 this->addTextureAccess(&fTextureAccess); |
| 358 } | 359 } |
| 359 | 360 |
| 360 bool GrDistanceFieldNoGammaTextureEffect::onIsEqual(const GrGeometryProcessor& o
ther) const { | 361 bool GrDistanceFieldNoGammaTextureEffect::onIsEqual(const GrGeometryProcessor& o
ther) const { |
| 361 const GrDistanceFieldNoGammaTextureEffect& cte = | 362 const GrDistanceFieldNoGammaTextureEffect& cte = |
| 362 other.cast<GrDistanceFieldNoGam
maTextureEffect>(); | 363 other.cast<GrDistanceFieldNoGam
maTextureEffect>(); |
| 363 return fFlags == cte.fFlags; | 364 return fFlags == cte.fFlags; |
| 364 } | 365 } |
| 365 | 366 |
| 366 void GrDistanceFieldNoGammaTextureEffect::onComputeInvariantOutput(InvariantOutp
ut* inout) const { | 367 void GrDistanceFieldNoGammaTextureEffect::onComputeInvariantOutput(GrInvariantOu
tput* inout) const { |
| 367 inout->mulByUnknownAlpha(); | 368 inout->mulByUnknownAlpha(); |
| 368 } | 369 } |
| 369 | 370 |
| 370 const GrBackendGeometryProcessorFactory& GrDistanceFieldNoGammaTextureEffect::ge
tFactory() const { | 371 const GrBackendGeometryProcessorFactory& GrDistanceFieldNoGammaTextureEffect::ge
tFactory() const { |
| 371 return GrTBackendGeometryProcessorFactory<GrDistanceFieldNoGammaTextureEffec
t>::getInstance(); | 372 return GrTBackendGeometryProcessorFactory<GrDistanceFieldNoGammaTextureEffec
t>::getInstance(); |
| 372 } | 373 } |
| 373 | 374 |
| 374 /////////////////////////////////////////////////////////////////////////////// | 375 /////////////////////////////////////////////////////////////////////////////// |
| 375 | 376 |
| 376 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrDistanceFieldNoGammaTextureEffect); | 377 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrDistanceFieldNoGammaTextureEffect); |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 599 this->addTextureAccess(&fTextureAccess); | 600 this->addTextureAccess(&fTextureAccess); |
| 600 this->addTextureAccess(&fGammaTextureAccess); | 601 this->addTextureAccess(&fGammaTextureAccess); |
| 601 } | 602 } |
| 602 | 603 |
| 603 bool GrDistanceFieldLCDTextureEffect::onIsEqual(const GrGeometryProcessor& other
) const { | 604 bool GrDistanceFieldLCDTextureEffect::onIsEqual(const GrGeometryProcessor& other
) const { |
| 604 const GrDistanceFieldLCDTextureEffect& cte = other.cast<GrDistanceFieldLCDTe
xtureEffect>(); | 605 const GrDistanceFieldLCDTextureEffect& cte = other.cast<GrDistanceFieldLCDTe
xtureEffect>(); |
| 605 return (fTextColor == cte.fTextColor && | 606 return (fTextColor == cte.fTextColor && |
| 606 fFlags == cte.fFlags); | 607 fFlags == cte.fFlags); |
| 607 } | 608 } |
| 608 | 609 |
| 609 void GrDistanceFieldLCDTextureEffect::onComputeInvariantOutput(InvariantOutput*
inout) const { | 610 void GrDistanceFieldLCDTextureEffect::onComputeInvariantOutput(GrInvariantOutput
* inout) const { |
| 610 inout->mulByUnknownColor(); | 611 inout->mulByUnknownColor(); |
| 611 } | 612 } |
| 612 | 613 |
| 613 const GrBackendGeometryProcessorFactory& GrDistanceFieldLCDTextureEffect::getFac
tory() const { | 614 const GrBackendGeometryProcessorFactory& GrDistanceFieldLCDTextureEffect::getFac
tory() const { |
| 614 return GrTBackendGeometryProcessorFactory<GrDistanceFieldLCDTextureEffect>::
getInstance(); | 615 return GrTBackendGeometryProcessorFactory<GrDistanceFieldLCDTextureEffect>::
getInstance(); |
| 615 } | 616 } |
| 616 | 617 |
| 617 /////////////////////////////////////////////////////////////////////////////// | 618 /////////////////////////////////////////////////////////////////////////////// |
| 618 | 619 |
| 619 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrDistanceFieldLCDTextureEffect); | 620 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrDistanceFieldLCDTextureEffect); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 644 random->nextULessThan(256), | 645 random->nextULessThan(256), |
| 645 random->nextULessThan(256)); | 646 random->nextULessThan(256)); |
| 646 uint32_t flags = kUseLCD_DistanceFieldEffectFlag; | 647 uint32_t flags = kUseLCD_DistanceFieldEffectFlag; |
| 647 flags |= random->nextBool() ? kUniformScale_DistanceFieldEffectMask : 0; | 648 flags |= random->nextBool() ? kUniformScale_DistanceFieldEffectMask : 0; |
| 648 flags |= random->nextBool() ? kBGR_DistanceFieldEffectFlag : 0; | 649 flags |= random->nextBool() ? kBGR_DistanceFieldEffectFlag : 0; |
| 649 return GrDistanceFieldLCDTextureEffect::Create(textures[texIdx], params, | 650 return GrDistanceFieldLCDTextureEffect::Create(textures[texIdx], params, |
| 650 textures[texIdx2], params2, | 651 textures[texIdx2], params2, |
| 651 textColor, | 652 textColor, |
| 652 flags); | 653 flags); |
| 653 } | 654 } |
| OLD | NEW |