diff --git a/src/core/SkBlendModePriv.h b/src/core/SkBlendModePriv.h index 2767241a01..a86de41397 100644 --- a/src/core/SkBlendModePriv.h +++ b/src/core/SkBlendModePriv.h @@ -24,11 +24,6 @@ static inline void SkBlendMode_AppendStages(SkBlendMode mode, SkRasterPipeline* SkBlendMode_AppendClampIfNeeded(mode, p); } -#if SK_SUPPORT_GPU -#include "GrXferProcessor.h" -const GrXPFactory* SkBlendMode_AsXPFactory(SkBlendMode); -#endif - enum class SkBlendModeCoeff { kZero, /** 0 */ kOne, /** 1 */ @@ -48,4 +43,9 @@ bool SkBlendMode_AsCoeff(SkBlendMode mode, SkBlendModeCoeff* src, SkBlendModeCoe SkPM4f SkBlendMode_Apply(SkBlendMode, const SkPM4f& src, const SkPM4f& dst); +#if SK_SUPPORT_GPU +#include "GrXferProcessor.h" +const GrXPFactory* SkBlendMode_AsXPFactory(SkBlendMode); +#endif + #endif diff --git a/src/core/SkXfermode.cpp b/src/core/SkXfermode.cpp index a0b593517a..1d5cac3a86 100644 --- a/src/core/SkXfermode.cpp +++ b/src/core/SkXfermode.cpp @@ -655,37 +655,9 @@ const SkXfermodeProc gProcs[] = { luminosity_modeproc, }; -bool SkXfermode::asMode(SkBlendMode* mode) const { - return false; -} - -#if SK_SUPPORT_GPU -sk_sp SkXfermode::makeFragmentProcessorForImageFilter( - sk_sp) const { - // This should never be called. - // TODO: make pure virtual in SkXfermode once Android update lands - SkASSERT(0); - return nullptr; -} - -const GrXPFactory* SkXfermode::asXPFactory() const { - // This should never be called. - // TODO: make pure virtual in SkXfermode once Android update lands - SkASSERT(0); - return nullptr; -} -#endif - /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// -bool SkProcCoeffXfermode::asMode(SkBlendMode* mode) const { - if (mode) { - *mode = fMode; - } - return true; -} - void SkProcCoeffXfermode::xfer32(SkPMColor* SK_RESTRICT dst, const SkPMColor* SK_RESTRICT src, int count, const SkAlpha* SK_RESTRICT aa) const { @@ -714,25 +686,6 @@ void SkProcCoeffXfermode::xfer32(SkPMColor* SK_RESTRICT dst, } } -#if SK_SUPPORT_GPU -sk_sp SkProcCoeffXfermode::makeFragmentProcessorForImageFilter( - sk_sp dst) const { - SkASSERT(dst); - return GrXfermodeFragmentProcessor::MakeFromDstProcessor(std::move(dst), fMode); -} - -const GrXPFactory* SkProcCoeffXfermode::asXPFactory() const { - if (SkBlendMode_AsCoeff(fMode, nullptr, nullptr)) { - const GrXPFactory* result(GrPorterDuffXPFactory::Get(fMode)); - SkASSERT(result); - return result; - } - - SkASSERT(GrCustomXfermode::IsSupportedMode(fMode)); - return GrCustomXfermode::Get(fMode); -} -#endif - const char* SkBlendMode_Name(SkBlendMode mode) { SkASSERT((unsigned) mode <= (unsigned)SkBlendMode::kLastMode); const char* gModeStrings[] = { diff --git a/src/core/SkXfermodePriv.h b/src/core/SkXfermodePriv.h index bca627efe8..48a1e4199d 100644 --- a/src/core/SkXfermodePriv.h +++ b/src/core/SkXfermodePriv.h @@ -23,13 +23,6 @@ public: virtual void xfer32(SkPMColor dst[], const SkPMColor src[], int count, const SkAlpha aa[]) const = 0; - /** - * If the xfermode is one of the modes in the Mode enum, then asMode() - * returns true and sets (if not null) mode accordingly. Otherwise it - * returns false and ignores the mode parameter. - */ - virtual bool asMode(SkBlendMode* mode) const; - /** Return an SkXfermode object for the specified mode. */ static sk_sp Make(SkBlendMode); @@ -49,12 +42,6 @@ public: return xfer.get(); } - SkBlendMode blend() const { - SkBlendMode mode; - SkAssertResult(this->asMode(&mode)); - return mode; - } - static SkXfermodeProc GetProc(SkBlendMode); enum SrcColorOpacity { @@ -70,28 +57,8 @@ public: static bool IsOpaque(SkBlendMode, SrcColorOpacity); -#if SK_SUPPORT_GPU - /** Used by the SkXfermodeImageFilter to blend two colors via a GrFragmentProcessor. - The input to the returned FP is the src color. The dst color is - provided by the dst param which becomes a child FP of the returned FP. - It is legal for the function to return a null output. This indicates that - the output of the blend is simply the src color. - */ - virtual sk_sp makeFragmentProcessorForImageFilter( - sk_sp dst) const; - - /** A subclass must implement this factory function to work with the GPU backend. - The xfermode will return a factory for which the caller will get a ref. It is up - to the caller to install it. XferProcessors cannot use a background texture. - */ - virtual const GrXPFactory* asXPFactory() const; -#endif - protected: SkXfermode() {} - virtual ~SkXfermode() {} - -private: }; #endif diff --git a/src/core/SkXfermode_proccoeff.h b/src/core/SkXfermode_proccoeff.h index 59ca2b1e31..3a65a94277 100644 --- a/src/core/SkXfermode_proccoeff.h +++ b/src/core/SkXfermode_proccoeff.h @@ -22,14 +22,6 @@ public: void xfer32(SkPMColor dst[], const SkPMColor src[], int count, const SkAlpha aa[]) const override; - bool asMode(SkBlendMode* mode) const override; - -#if SK_SUPPORT_GPU - sk_sp makeFragmentProcessorForImageFilter( - sk_sp) const override; - const GrXPFactory* asXPFactory() const override; -#endif - protected: SkBlendMode getMode() const { return fMode; } diff --git a/src/effects/SkXfermodeImageFilter.cpp b/src/effects/SkXfermodeImageFilter.cpp index 0be8c22fd1..533df33a28 100644 --- a/src/effects/SkXfermodeImageFilter.cpp +++ b/src/effects/SkXfermodeImageFilter.cpp @@ -221,7 +221,7 @@ void SkXfermodeImageFilter_Base::toString(SkString* str) const { #if SK_SUPPORT_GPU -#include "SkXfermode_proccoeff.h" +#include "effects/GrXfermodeFragmentProcessor.h" sk_sp SkXfermodeImageFilter_Base::filterImageGPU( SkSpecialImage* source, @@ -315,20 +315,7 @@ sk_sp SkXfermodeImageFilter_Base::filterImageGPU( sk_sp SkXfermodeImageFilter_Base::makeFGFrag(sk_sp bgFP) const { - // A null fMode is interpreted to mean kSrcOver_Mode (to match raster). - SkXfermode* xfer = SkXfermode::Peek(fMode); - sk_sp srcover; - if (!xfer) { - // It would be awesome to use SkXfermode::Create here but it knows better - // than us and won't return a kSrcOver_Mode SkXfermode. That means we - // have to get one the hard way. - SkXfermodeProc proc = SkXfermode::GetProc(SkBlendMode::kSrcOver); - - srcover.reset(new SkProcCoeffXfermode(proc, SkBlendMode::kSrcOver)); - xfer = srcover.get(); - - } - return xfer->makeFragmentProcessorForImageFilter(std::move(bgFP)); + return GrXfermodeFragmentProcessor::MakeFromDstProcessor(std::move(bgFP), fMode); } #endif