diff options
author | 2016-02-09 05:09:27 -0800 | |
---|---|---|
committer | 2016-02-09 05:09:28 -0800 | |
commit | 4f0379444db31421894d2fce7c85889fe5eaa01a (patch) | |
tree | e15ab5418f286694b6bc6cb2cd3ddbb6cec77253 /include | |
parent | 81bb79b7b97909eb2b10444c4bd06bc9e1e56db3 (diff) |
Alter SkXfermode's asFragmentProcessor & asXPFactory contracts
TBR=bsalomon@google.com
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1674673002
Review URL: https://codereview.chromium.org/1674673002
Diffstat (limited to 'include')
-rw-r--r-- | include/client/android/SkAvoidXfermode.h | 6 | ||||
-rw-r--r-- | include/client/android/SkPixelXorXfermode.h | 7 | ||||
-rw-r--r-- | include/core/SkXfermode.h | 39 | ||||
-rw-r--r-- | include/effects/SkXfermodeImageFilter.h | 4 |
4 files changed, 19 insertions, 37 deletions
diff --git a/include/client/android/SkAvoidXfermode.h b/include/client/android/SkAvoidXfermode.h index 8d08827489..34deb8f02f 100644 --- a/include/client/android/SkAvoidXfermode.h +++ b/include/client/android/SkAvoidXfermode.h @@ -52,9 +52,9 @@ public: const SkAlpha aa[]) const override; #if SK_SUPPORT_GPU - bool asFragmentProcessor(const GrFragmentProcessor** output, - const GrFragmentProcessor* dst) const override; - bool asXPFactory(GrXPFactory** xpf) const override; + const GrFragmentProcessor* getFragmentProcessorForImageFilter( + const GrFragmentProcessor* dst) const override; + GrXPFactory* asXPFactory() const override; #endif SK_TO_STRING_OVERRIDE() diff --git a/include/client/android/SkPixelXorXfermode.h b/include/client/android/SkPixelXorXfermode.h index 4aa78ccf5e..447bd81317 100644 --- a/include/client/android/SkPixelXorXfermode.h +++ b/include/client/android/SkPixelXorXfermode.h @@ -22,10 +22,9 @@ public: } #if SK_SUPPORT_GPU - bool asFragmentProcessor(const GrFragmentProcessor** output, - const GrFragmentProcessor* dst) const override; - - bool asXPFactory(GrXPFactory**) const override; + const GrFragmentProcessor* getFragmentProcessorForImageFilter( + const GrFragmentProcessor* dst) const override; + GrXPFactory* asXPFactory() const override; #endif SK_TO_STRING_OVERRIDE() diff --git a/include/core/SkXfermode.h b/include/core/SkXfermode.h index 9549452960..76c57a51dd 100644 --- a/include/core/SkXfermode.h +++ b/include/core/SkXfermode.h @@ -194,37 +194,22 @@ public: */ static bool IsOpaque(const SkXfermode* xfer, SrcColorOpacity opacityType); - /** Used to do in-shader blending between two colors computed in the shader 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. If the params are - null then this is just a query of whether the SkXfermode could support this functionality. - It is legal for the function to succeed but return a null output. This indicates that +#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 bool asFragmentProcessor(const GrFragmentProcessor** output, - const GrFragmentProcessor* dst) const; - - /** A subclass may implement this factory function to work with the GPU backend. It is legal - to call this with xpf NULL to simply test the return value. If xpf is non-NULL then the - xfermode may optionally allocate a factory to return to the caller as *xpf. The caller - will install it and own a ref to it. Since the xfermode may or may not assign *xpf, the - caller should set *xpf to NULL beforehand. XferProcessors cannot use a background texture. - */ - virtual bool asXPFactory(GrXPFactory** xpf) const; + virtual const GrFragmentProcessor* getFragmentProcessorForImageFilter( + const GrFragmentProcessor* dst) const; - /** Returns true if the xfermode can be expressed as an xfer processor factory (xpFactory). - This helper calls the asXPFactory() virtual. If the xfermode is NULL, it is treated as - kSrcOver_Mode. It is legal to call this with xpf param NULL to simply test the return value. + /** 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. */ - static inline bool AsXPFactory(SkXfermode* xfermode, GrXPFactory** xpf) { - if (nullptr == xfermode) { - if (xpf) { - *xpf = nullptr; - } - return true; - } - return xfermode->asXPFactory(xpf); - } + virtual GrXPFactory* asXPFactory() const; +#endif SK_TO_STRING_PUREVIRT() SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP() diff --git a/include/effects/SkXfermodeImageFilter.h b/include/effects/SkXfermodeImageFilter.h index d59b7a2b25..693425ed05 100644 --- a/include/effects/SkXfermodeImageFilter.h +++ b/include/effects/SkXfermodeImageFilter.h @@ -21,8 +21,6 @@ class SK_API SkXfermodeImageFilter : public SkImageFilter { */ public: - virtual ~SkXfermodeImageFilter(); - static SkImageFilter* Create(SkXfermode* mode, SkImageFilter* background, SkImageFilter* foreground = NULL, const CropRect* cropRect = NULL) { @@ -50,7 +48,7 @@ protected: void flatten(SkWriteBuffer&) const override; private: - SkXfermode* fMode; + SkAutoTUnref<SkXfermode> fMode; typedef SkImageFilter INHERITED; }; |