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 691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
702 // a point where we have RGB coverage. We don't need any color stages si
nce the known color | 702 // a point where we have RGB coverage. We don't need any color stages si
nce the known color |
703 // output is already baked into the blendConstant. | 703 // output is already baked into the blendConstant. |
704 *overrideColor = GrColorPackRGBA(fAlpha, fAlpha, fAlpha, fAlpha); | 704 *overrideColor = GrColorPackRGBA(fAlpha, fAlpha, fAlpha, fAlpha); |
705 return GrXferProcessor::kOverrideColor_OptFlag; | 705 return GrXferProcessor::kOverrideColor_OptFlag; |
706 } | 706 } |
707 | 707 |
708 /////////////////////////////////////////////////////////////////////////////// | 708 /////////////////////////////////////////////////////////////////////////////// |
709 | 709 |
710 GrPorterDuffXPFactory::GrPorterDuffXPFactory(SkXfermode::Mode xfermode) | 710 GrPorterDuffXPFactory::GrPorterDuffXPFactory(SkXfermode::Mode xfermode) |
711 : fXfermode(xfermode) { | 711 : fXfermode(xfermode) { |
| 712 SkASSERT(fXfermode <= SkXfermode::kLastCoeffMode); |
712 this->initClassID<GrPorterDuffXPFactory>(); | 713 this->initClassID<GrPorterDuffXPFactory>(); |
713 } | 714 } |
714 | 715 |
715 GrXPFactory* GrPorterDuffXPFactory::Create(SkXfermode::Mode xfermode) { | 716 GrXPFactory* GrPorterDuffXPFactory::Create(SkXfermode::Mode xfermode) { |
716 static GrPorterDuffXPFactory gClearPDXPF(SkXfermode::kClear_Mode); | 717 static GrPorterDuffXPFactory gClearPDXPF(SkXfermode::kClear_Mode); |
717 static GrPorterDuffXPFactory gSrcPDXPF(SkXfermode::kSrc_Mode); | 718 static GrPorterDuffXPFactory gSrcPDXPF(SkXfermode::kSrc_Mode); |
718 static GrPorterDuffXPFactory gDstPDXPF(SkXfermode::kDst_Mode); | 719 static GrPorterDuffXPFactory gDstPDXPF(SkXfermode::kDst_Mode); |
719 static GrPorterDuffXPFactory gSrcOverPDXPF(SkXfermode::kSrcOver_Mode); | 720 static GrPorterDuffXPFactory gSrcOverPDXPF(SkXfermode::kSrcOver_Mode); |
720 static GrPorterDuffXPFactory gDstOverPDXPF(SkXfermode::kDstOver_Mode); | 721 static GrPorterDuffXPFactory gDstOverPDXPF(SkXfermode::kDstOver_Mode); |
721 static GrPorterDuffXPFactory gSrcInPDXPF(SkXfermode::kSrcIn_Mode); | 722 static GrPorterDuffXPFactory gSrcInPDXPF(SkXfermode::kSrcIn_Mode); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
763 | 764 |
764 bool GrPorterDuffXPFactory::supportsRGBCoverage(GrColor /*knownColor*/, | 765 bool GrPorterDuffXPFactory::supportsRGBCoverage(GrColor /*knownColor*/, |
765 uint32_t knownColorFlags) const
{ | 766 uint32_t knownColorFlags) const
{ |
766 if (SkXfermode::kSrcOver_Mode == fXfermode && | 767 if (SkXfermode::kSrcOver_Mode == fXfermode && |
767 kRGBA_GrColorComponentFlags == knownColorFlags) { | 768 kRGBA_GrColorComponentFlags == knownColorFlags) { |
768 return true; | 769 return true; |
769 } | 770 } |
770 return false; | 771 return false; |
771 } | 772 } |
772 | 773 |
773 void GrPorterDuffXPFactory::getInvariantOutput(const GrProcOptInfo& colorPOI, | 774 void GrPorterDuffXPFactory::getInvariantBlendedColor(const GrProcOptInfo& colorP
OI, |
774 const GrProcOptInfo& coveragePOI, | 775 const GrProcOptInfo& /*cove
ragePOI*/, |
775 GrXPFactory::InvariantOutput* out
put) const { | 776 InvariantBlendedColor* blen
dedColor) const { |
776 output->fWillBlendWithDst = true; | 777 // Find the blended color info based on the formula that does not have cover
age. |
777 output->fBlendedColorFlags = kNone_GrColorComponentFlags; | 778 BlendFormula colorFormula = gBlendTable[colorPOI.isOpaque()][0][fXfermode]; |
778 | 779 if (colorFormula.usesDstColor()) { |
779 // The blend table doesn't support LCD coverage, but these formulas never ha
ve invariant output. | 780 blendedColor->fWillBlendWithDst = true; |
780 if (coveragePOI.isFourChannelOutput()) { | 781 blendedColor->fKnownColorFlags = kNone_GrColorComponentFlags; |
781 return; | 782 return; |
782 } | 783 } |
783 | 784 |
784 const BlendFormula& blendFormula = get_blend_formula(fXfermode, colorPOI, co
veragePOI); | 785 blendedColor->fWillBlendWithDst = false; |
785 if (blendFormula.usesDstColor()) { | |
786 return; | |
787 } | |
788 | 786 |
789 SkASSERT(coveragePOI.isSolidWhite()); | 787 SkASSERT(kAdd_GrBlendEquation == colorFormula.fBlendEquation); |
790 SkASSERT(kAdd_GrBlendEquation == blendFormula.fBlendEquation); | |
791 | 788 |
792 output->fWillBlendWithDst = false; | 789 switch (colorFormula.fSrcCoeff) { |
793 | |
794 switch (blendFormula.fSrcCoeff) { | |
795 case kZero_GrBlendCoeff: | 790 case kZero_GrBlendCoeff: |
796 output->fBlendedColor = 0; | 791 blendedColor->fKnownColor = 0; |
797 output->fBlendedColorFlags = kRGBA_GrColorComponentFlags; | 792 blendedColor->fKnownColorFlags = kRGBA_GrColorComponentFlags; |
798 return; | 793 return; |
799 | 794 |
800 case kOne_GrBlendCoeff: | 795 case kOne_GrBlendCoeff: |
801 output->fBlendedColor = colorPOI.color(); | 796 blendedColor->fKnownColor = colorPOI.color(); |
802 output->fBlendedColorFlags = colorPOI.validFlags(); | 797 blendedColor->fKnownColorFlags = colorPOI.validFlags(); |
803 return; | 798 return; |
804 | 799 |
805 default: return; | 800 default: |
| 801 blendedColor->fKnownColorFlags = kNone_GrColorComponentFlags; |
| 802 return; |
806 } | 803 } |
807 } | 804 } |
808 | 805 |
809 bool GrPorterDuffXPFactory::willReadDstColor(const GrCaps& caps, | 806 bool GrPorterDuffXPFactory::willReadDstColor(const GrCaps& caps, |
810 const GrProcOptInfo& colorPOI, | 807 const GrProcOptInfo& colorPOI, |
811 const GrProcOptInfo& coveragePOI) c
onst { | 808 const GrProcOptInfo& coveragePOI) c
onst { |
812 if (coveragePOI.isFourChannelOutput()) { | 809 if (coveragePOI.isFourChannelOutput()) { |
813 return false; // The LCD XP never does a dst read. | 810 return false; // The LCD XP never does a dst read. |
814 } | 811 } |
815 | 812 |
(...skipping 18 matching lines...) Expand all Loading... |
834 int* outSecondary) { | 831 int* outSecondary) { |
835 if (!!strcmp(xp->name(), "Porter Duff")) { | 832 if (!!strcmp(xp->name(), "Porter Duff")) { |
836 *outPrimary = *outSecondary = -1; | 833 *outPrimary = *outSecondary = -1; |
837 return; | 834 return; |
838 } | 835 } |
839 BlendFormula blendFormula = static_cast<const PorterDuffXferProcessor*>(xp)-
>getBlendFormula(); | 836 BlendFormula blendFormula = static_cast<const PorterDuffXferProcessor*>(xp)-
>getBlendFormula(); |
840 *outPrimary = blendFormula.fPrimaryOutputType; | 837 *outPrimary = blendFormula.fPrimaryOutputType; |
841 *outSecondary = blendFormula.fSecondaryOutputType; | 838 *outSecondary = blendFormula.fSecondaryOutputType; |
842 } | 839 } |
843 | 840 |
OLD | NEW |