| 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 InvariantBlendedColor* blen
dedColor) const { |
| 775 GrXPFactory::InvariantOutput* out
put) const { | 776 // Find the blended color info based on the formula that does not have cover
age. |
| 776 output->fWillBlendWithDst = true; | 777 BlendFormula colorFormula = gBlendTable[colorPOI.isOpaque()][0][fXfermode]; |
| 777 output->fBlendedColorFlags = kNone_GrColorComponentFlags; | 778 if (colorFormula.usesDstColor()) { |
| 778 | 779 blendedColor->fWillBlendWithDst = true; |
| 779 // The blend table doesn't support LCD coverage, but these formulas never ha
ve invariant output. | 780 blendedColor->fKnownColorFlags = kNone_GrColorComponentFlags; |
| 780 if (coveragePOI.isFourChannelOutput()) { | |
| 781 return; | 781 return; |
| 782 } | 782 } |
| 783 | 783 |
| 784 const BlendFormula& blendFormula = get_blend_formula(fXfermode, colorPOI, co
veragePOI); | 784 blendedColor->fWillBlendWithDst = false; |
| 785 if (blendFormula.usesDstColor()) { | |
| 786 return; | |
| 787 } | |
| 788 | 785 |
| 789 SkASSERT(coveragePOI.isSolidWhite()); | 786 SkASSERT(kAdd_GrBlendEquation == colorFormula.fBlendEquation); |
| 790 SkASSERT(kAdd_GrBlendEquation == blendFormula.fBlendEquation); | |
| 791 | 787 |
| 792 output->fWillBlendWithDst = false; | 788 switch (colorFormula.fSrcCoeff) { |
| 793 | |
| 794 switch (blendFormula.fSrcCoeff) { | |
| 795 case kZero_GrBlendCoeff: | 789 case kZero_GrBlendCoeff: |
| 796 output->fBlendedColor = 0; | 790 blendedColor->fKnownColor = 0; |
| 797 output->fBlendedColorFlags = kRGBA_GrColorComponentFlags; | 791 blendedColor->fKnownColorFlags = kRGBA_GrColorComponentFlags; |
| 798 return; | 792 return; |
| 799 | 793 |
| 800 case kOne_GrBlendCoeff: | 794 case kOne_GrBlendCoeff: |
| 801 output->fBlendedColor = colorPOI.color(); | 795 blendedColor->fKnownColor = colorPOI.color(); |
| 802 output->fBlendedColorFlags = colorPOI.validFlags(); | 796 blendedColor->fKnownColorFlags = colorPOI.validFlags(); |
| 803 return; | 797 return; |
| 804 | 798 |
| 805 default: return; | 799 default: |
| 800 blendedColor->fKnownColorFlags = kNone_GrColorComponentFlags; |
| 801 return; |
| 806 } | 802 } |
| 807 } | 803 } |
| 808 | 804 |
| 809 bool GrPorterDuffXPFactory::willReadDstColor(const GrCaps& caps, | 805 bool GrPorterDuffXPFactory::willReadDstColor(const GrCaps& caps, |
| 810 const GrProcOptInfo& colorPOI, | 806 const GrProcOptInfo& colorPOI, |
| 811 const GrProcOptInfo& coveragePOI) c
onst { | 807 const GrProcOptInfo& coveragePOI) c
onst { |
| 812 if (coveragePOI.isFourChannelOutput()) { | 808 if (coveragePOI.isFourChannelOutput()) { |
| 813 return false; // The LCD XP never does a dst read. | 809 return false; // The LCD XP never does a dst read. |
| 814 } | 810 } |
| 815 | 811 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 834 int* outSecondary) { | 830 int* outSecondary) { |
| 835 if (!!strcmp(xp->name(), "Porter Duff")) { | 831 if (!!strcmp(xp->name(), "Porter Duff")) { |
| 836 *outPrimary = *outSecondary = -1; | 832 *outPrimary = *outSecondary = -1; |
| 837 return; | 833 return; |
| 838 } | 834 } |
| 839 BlendFormula blendFormula = static_cast<const PorterDuffXferProcessor*>(xp)-
>getBlendFormula(); | 835 BlendFormula blendFormula = static_cast<const PorterDuffXferProcessor*>(xp)-
>getBlendFormula(); |
| 840 *outPrimary = blendFormula.fPrimaryOutputType; | 836 *outPrimary = blendFormula.fPrimaryOutputType; |
| 841 *outSecondary = blendFormula.fSecondaryOutputType; | 837 *outSecondary = blendFormula.fSecondaryOutputType; |
| 842 } | 838 } |
| 843 | 839 |
| OLD | NEW |