OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 "effects/GrPorterDuffXferProcessor.h" | 8 #include "effects/GrPorterDuffXferProcessor.h" |
9 | 9 |
10 #include "GrBlend.h" | 10 #include "GrBlend.h" |
(...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
584 | 584 |
585 bool GrPorterDuffXPFactory::supportsRGBCoverage(GrColor /*knownColor*/, | 585 bool GrPorterDuffXPFactory::supportsRGBCoverage(GrColor /*knownColor*/, |
586 uint32_t knownColorFlags) const
{ | 586 uint32_t knownColorFlags) const
{ |
587 if (kOne_GrBlendCoeff == fSrcCoeff && kISA_GrBlendCoeff == fDstCoeff && | 587 if (kOne_GrBlendCoeff == fSrcCoeff && kISA_GrBlendCoeff == fDstCoeff && |
588 kRGBA_GrColorComponentFlags == knownColorFlags) { | 588 kRGBA_GrColorComponentFlags == knownColorFlags) { |
589 return true; | 589 return true; |
590 } | 590 } |
591 return false; | 591 return false; |
592 } | 592 } |
593 | 593 |
594 bool GrPorterDuffXPFactory::canTweakAlphaForCoverage() const { | |
595 return can_tweak_alpha_for_coverage(fDstCoeff); | |
596 } | |
597 | |
598 void GrPorterDuffXPFactory::getInvariantOutput(const GrProcOptInfo& colorPOI, | 594 void GrPorterDuffXPFactory::getInvariantOutput(const GrProcOptInfo& colorPOI, |
599 const GrProcOptInfo& coveragePOI, | 595 const GrProcOptInfo& coveragePOI, |
600 GrXPFactory::InvariantOutput* out
put) const { | 596 GrXPFactory::InvariantOutput* out
put) const { |
601 if (!coveragePOI.isSolidWhite()) { | 597 if (!coveragePOI.isSolidWhite()) { |
602 output->fWillBlendWithDst = true; | 598 output->fWillBlendWithDst = true; |
603 output->fBlendedColorFlags = 0; | 599 output->fBlendedColorFlags = 0; |
604 return; | 600 return; |
605 } | 601 } |
606 | 602 |
607 GrBlendCoeff srcCoeff = fSrcCoeff; | 603 GrBlendCoeff srcCoeff = fSrcCoeff; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
665 } | 661 } |
666 | 662 |
667 bool GrPorterDuffXPFactory::willReadDstColor(const GrDrawTargetCaps& caps, | 663 bool GrPorterDuffXPFactory::willReadDstColor(const GrDrawTargetCaps& caps, |
668 const GrProcOptInfo& colorPOI, | 664 const GrProcOptInfo& colorPOI, |
669 const GrProcOptInfo& coveragePOI) c
onst { | 665 const GrProcOptInfo& coveragePOI) c
onst { |
670 // We can always blend correctly if we have dual source blending. | 666 // We can always blend correctly if we have dual source blending. |
671 if (caps.shaderCaps()->dualSourceBlendingSupport()) { | 667 if (caps.shaderCaps()->dualSourceBlendingSupport()) { |
672 return false; | 668 return false; |
673 } | 669 } |
674 | 670 |
675 if (this->canTweakAlphaForCoverage()) { | 671 if (can_tweak_alpha_for_coverage(fDstCoeff)) { |
676 return false; | 672 return false; |
677 } | 673 } |
678 | 674 |
679 bool srcAIsOne = colorPOI.isOpaque(); | 675 bool srcAIsOne = colorPOI.isOpaque(); |
680 | 676 |
681 if (kZero_GrBlendCoeff == fDstCoeff) { | 677 if (kZero_GrBlendCoeff == fDstCoeff) { |
682 if (kZero_GrBlendCoeff == fSrcCoeff || srcAIsOne) { | 678 if (kZero_GrBlendCoeff == fSrcCoeff || srcAIsOne) { |
683 return false; | 679 return false; |
684 } | 680 } |
685 } | 681 } |
(...skipping 14 matching lines...) Expand all Loading... |
700 GR_DEFINE_XP_FACTORY_TEST(GrPorterDuffXPFactory); | 696 GR_DEFINE_XP_FACTORY_TEST(GrPorterDuffXPFactory); |
701 | 697 |
702 GrXPFactory* GrPorterDuffXPFactory::TestCreate(SkRandom* random, | 698 GrXPFactory* GrPorterDuffXPFactory::TestCreate(SkRandom* random, |
703 GrContext*, | 699 GrContext*, |
704 const GrDrawTargetCaps&, | 700 const GrDrawTargetCaps&, |
705 GrTexture*[]) { | 701 GrTexture*[]) { |
706 SkXfermode::Mode mode = SkXfermode::Mode(random->nextULessThan(SkXfermode::k
LastCoeffMode)); | 702 SkXfermode::Mode mode = SkXfermode::Mode(random->nextULessThan(SkXfermode::k
LastCoeffMode)); |
707 return GrPorterDuffXPFactory::Create(mode); | 703 return GrPorterDuffXPFactory::Create(mode); |
708 } | 704 } |
709 | 705 |
OLD | NEW |