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 686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
697 } | 697 } |
698 | 698 |
699 /////////////////////////////////////////////////////////////////////////////// | 699 /////////////////////////////////////////////////////////////////////////////// |
700 | 700 |
701 GrPorterDuffXPFactory::GrPorterDuffXPFactory(SkXfermode::Mode xfermode) | 701 GrPorterDuffXPFactory::GrPorterDuffXPFactory(SkXfermode::Mode xfermode) |
702 : fXfermode(xfermode) { | 702 : fXfermode(xfermode) { |
703 SkASSERT(fXfermode <= SkXfermode::kLastCoeffMode); | 703 SkASSERT(fXfermode <= SkXfermode::kLastCoeffMode); |
704 this->initClassID<GrPorterDuffXPFactory>(); | 704 this->initClassID<GrPorterDuffXPFactory>(); |
705 } | 705 } |
706 | 706 |
707 GrXPFactory* GrPorterDuffXPFactory::Create(SkXfermode::Mode xfermode) { | 707 sk_sp<GrXPFactory> GrPorterDuffXPFactory::Make(SkXfermode::Mode xfermode) { |
708 static GrPorterDuffXPFactory gClearPDXPF(SkXfermode::kClear_Mode); | 708 static GrPorterDuffXPFactory gClearPDXPF(SkXfermode::kClear_Mode); |
709 static GrPorterDuffXPFactory gSrcPDXPF(SkXfermode::kSrc_Mode); | 709 static GrPorterDuffXPFactory gSrcPDXPF(SkXfermode::kSrc_Mode); |
710 static GrPorterDuffXPFactory gDstPDXPF(SkXfermode::kDst_Mode); | 710 static GrPorterDuffXPFactory gDstPDXPF(SkXfermode::kDst_Mode); |
711 static GrPorterDuffXPFactory gSrcOverPDXPF(SkXfermode::kSrcOver_Mode); | 711 static GrPorterDuffXPFactory gSrcOverPDXPF(SkXfermode::kSrcOver_Mode); |
712 static GrPorterDuffXPFactory gDstOverPDXPF(SkXfermode::kDstOver_Mode); | 712 static GrPorterDuffXPFactory gDstOverPDXPF(SkXfermode::kDstOver_Mode); |
713 static GrPorterDuffXPFactory gSrcInPDXPF(SkXfermode::kSrcIn_Mode); | 713 static GrPorterDuffXPFactory gSrcInPDXPF(SkXfermode::kSrcIn_Mode); |
714 static GrPorterDuffXPFactory gDstInPDXPF(SkXfermode::kDstIn_Mode); | 714 static GrPorterDuffXPFactory gDstInPDXPF(SkXfermode::kDstIn_Mode); |
715 static GrPorterDuffXPFactory gSrcOutPDXPF(SkXfermode::kSrcOut_Mode); | 715 static GrPorterDuffXPFactory gSrcOutPDXPF(SkXfermode::kSrcOut_Mode); |
716 static GrPorterDuffXPFactory gDstOutPDXPF(SkXfermode::kDstOut_Mode); | 716 static GrPorterDuffXPFactory gDstOutPDXPF(SkXfermode::kDstOut_Mode); |
717 static GrPorterDuffXPFactory gSrcATopPDXPF(SkXfermode::kSrcATop_Mode); | 717 static GrPorterDuffXPFactory gSrcATopPDXPF(SkXfermode::kSrcATop_Mode); |
718 static GrPorterDuffXPFactory gDstATopPDXPF(SkXfermode::kDstATop_Mode); | 718 static GrPorterDuffXPFactory gDstATopPDXPF(SkXfermode::kDstATop_Mode); |
719 static GrPorterDuffXPFactory gXorPDXPF(SkXfermode::kXor_Mode); | 719 static GrPorterDuffXPFactory gXorPDXPF(SkXfermode::kXor_Mode); |
720 static GrPorterDuffXPFactory gPlusPDXPF(SkXfermode::kPlus_Mode); | 720 static GrPorterDuffXPFactory gPlusPDXPF(SkXfermode::kPlus_Mode); |
721 static GrPorterDuffXPFactory gModulatePDXPF(SkXfermode::kModulate_Mode); | 721 static GrPorterDuffXPFactory gModulatePDXPF(SkXfermode::kModulate_Mode); |
722 static GrPorterDuffXPFactory gScreenPDXPF(SkXfermode::kScreen_Mode); | 722 static GrPorterDuffXPFactory gScreenPDXPF(SkXfermode::kScreen_Mode); |
723 | 723 |
724 static GrPorterDuffXPFactory* gFactories[] = { | 724 static GrPorterDuffXPFactory* gFactories[] = { |
725 &gClearPDXPF, &gSrcPDXPF, &gDstPDXPF, &gSrcOverPDXPF, &gDstOverPDXPF, &g
SrcInPDXPF, | 725 &gClearPDXPF, &gSrcPDXPF, &gDstPDXPF, &gSrcOverPDXPF, &gDstOverPDXPF, &g
SrcInPDXPF, |
726 &gDstInPDXPF, &gSrcOutPDXPF, &gDstOutPDXPF, &gSrcATopPDXPF, &gDstATopPDX
PF, &gXorPDXPF, | 726 &gDstInPDXPF, &gSrcOutPDXPF, &gDstOutPDXPF, &gSrcATopPDXPF, &gDstATopPDX
PF, &gXorPDXPF, |
727 &gPlusPDXPF, &gModulatePDXPF, &gScreenPDXPF | 727 &gPlusPDXPF, &gModulatePDXPF, &gScreenPDXPF |
728 }; | 728 }; |
729 GR_STATIC_ASSERT(SK_ARRAY_COUNT(gFactories) == SkXfermode::kLastCoeffMode +
1); | 729 GR_STATIC_ASSERT(SK_ARRAY_COUNT(gFactories) == SkXfermode::kLastCoeffMode +
1); |
730 | 730 |
731 if (xfermode < 0 || xfermode > SkXfermode::kLastCoeffMode) { | 731 if (xfermode < 0 || xfermode > SkXfermode::kLastCoeffMode) { |
732 return nullptr; | 732 return nullptr; |
733 } | 733 } |
734 return SkRef(gFactories[xfermode]); | 734 return sk_sp<GrXPFactory>(SkRef(gFactories[xfermode])); |
735 } | 735 } |
736 | 736 |
737 GrXferProcessor* | 737 GrXferProcessor* |
738 GrPorterDuffXPFactory::onCreateXferProcessor(const GrCaps& caps, | 738 GrPorterDuffXPFactory::onCreateXferProcessor(const GrCaps& caps, |
739 const GrPipelineOptimizations& opti
mizations, | 739 const GrPipelineOptimizations& opti
mizations, |
740 bool hasMixedSamples, | 740 bool hasMixedSamples, |
741 const DstTexture* dstTexture) const
{ | 741 const DstTexture* dstTexture) const
{ |
742 if (optimizations.fOverrides.fUsePLSDstRead) { | 742 if (optimizations.fOverrides.fUsePLSDstRead) { |
743 return new ShaderPDXferProcessor(dstTexture, hasMixedSamples, fXfermode)
; | 743 return new ShaderPDXferProcessor(dstTexture, hasMixedSamples, fXfermode)
; |
744 } | 744 } |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
819 // We fallback on the shader XP when the blend formula would use dual source
blending but we | 819 // We fallback on the shader XP when the blend formula would use dual source
blending but we |
820 // don't have support for it. | 820 // don't have support for it. |
821 static const bool kHasMixedSamples = false; | 821 static const bool kHasMixedSamples = false; |
822 SkASSERT(!caps.usesMixedSamples()); // We never use mixed samples without du
al source blending. | 822 SkASSERT(!caps.usesMixedSamples()); // We never use mixed samples without du
al source blending. |
823 return get_blend_formula(optimizations.fColorPOI, optimizations.fCoveragePOI
, kHasMixedSamples, | 823 return get_blend_formula(optimizations.fColorPOI, optimizations.fCoveragePOI
, kHasMixedSamples, |
824 fXfermode).hasSecondaryOutput(); | 824 fXfermode).hasSecondaryOutput(); |
825 } | 825 } |
826 | 826 |
827 GR_DEFINE_XP_FACTORY_TEST(GrPorterDuffXPFactory); | 827 GR_DEFINE_XP_FACTORY_TEST(GrPorterDuffXPFactory); |
828 | 828 |
829 const GrXPFactory* GrPorterDuffXPFactory::TestCreate(GrProcessorTestData* d) { | 829 sk_sp<GrXPFactory> GrPorterDuffXPFactory::TestCreate(GrProcessorTestData* d) { |
830 SkXfermode::Mode mode = SkXfermode::Mode(d->fRandom->nextULessThan(SkXfermod
e::kLastCoeffMode)); | 830 SkXfermode::Mode mode = SkXfermode::Mode(d->fRandom->nextULessThan(SkXfermod
e::kLastCoeffMode)); |
831 return GrPorterDuffXPFactory::Create(mode); | 831 return GrPorterDuffXPFactory::Make(mode); |
832 } | 832 } |
833 | 833 |
834 void GrPorterDuffXPFactory::TestGetXPOutputTypes(const GrXferProcessor* xp, | 834 void GrPorterDuffXPFactory::TestGetXPOutputTypes(const GrXferProcessor* xp, |
835 int* outPrimary, | 835 int* outPrimary, |
836 int* outSecondary) { | 836 int* outSecondary) { |
837 if (!!strcmp(xp->name(), "Porter Duff")) { | 837 if (!!strcmp(xp->name(), "Porter Duff")) { |
838 *outPrimary = *outSecondary = -1; | 838 *outPrimary = *outSecondary = -1; |
839 return; | 839 return; |
840 } | 840 } |
841 BlendFormula blendFormula = static_cast<const PorterDuffXferProcessor*>(xp)-
>getBlendFormula(); | 841 BlendFormula blendFormula = static_cast<const PorterDuffXferProcessor*>(xp)-
>getBlendFormula(); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
917 SkXfermode::kSrcOver_Mode).hasSecondaryOutp
ut(); | 917 SkXfermode::kSrcOver_Mode).hasSecondaryOutp
ut(); |
918 } | 918 } |
919 | 919 |
920 // We fallback on the shader XP when the blend formula would use dual source
blending but we | 920 // We fallback on the shader XP when the blend formula would use dual source
blending but we |
921 // don't have support for it. | 921 // don't have support for it. |
922 static const bool kHasMixedSamples = false; | 922 static const bool kHasMixedSamples = false; |
923 SkASSERT(!caps.usesMixedSamples()); // We never use mixed samples without du
al source blending. | 923 SkASSERT(!caps.usesMixedSamples()); // We never use mixed samples without du
al source blending. |
924 return get_blend_formula(optimizations.fColorPOI, optimizations.fCoveragePOI
, | 924 return get_blend_formula(optimizations.fColorPOI, optimizations.fCoveragePOI
, |
925 kHasMixedSamples, SkXfermode::kSrcOver_Mode).hasSec
ondaryOutput(); | 925 kHasMixedSamples, SkXfermode::kSrcOver_Mode).hasSec
ondaryOutput(); |
926 } | 926 } |
OLD | NEW |