aboutsummaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/core/SkXfermode.h4
-rw-r--r--include/gpu/effects/GrCustomXfermode.h2
-rw-r--r--include/gpu/effects/GrPorterDuffXferProcessor.h51
3 files changed, 50 insertions, 7 deletions
diff --git a/include/core/SkXfermode.h b/include/core/SkXfermode.h
index cb9557f92c..4337d20b61 100644
--- a/include/core/SkXfermode.h
+++ b/include/core/SkXfermode.h
@@ -209,13 +209,13 @@ public:
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 bool asXPFactory(const GrXPFactory** xpf) 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.
*/
- static bool AsXPFactory(SkXfermode*, GrXPFactory**);
+ static bool AsXPFactory(SkXfermode*, const GrXPFactory**);
SK_TO_STRING_PUREVIRT()
SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP()
diff --git a/include/gpu/effects/GrCustomXfermode.h b/include/gpu/effects/GrCustomXfermode.h
index bcbd5833ca..7fe930822a 100644
--- a/include/gpu/effects/GrCustomXfermode.h
+++ b/include/gpu/effects/GrCustomXfermode.h
@@ -18,7 +18,7 @@ class GrTexture;
*/
namespace GrCustomXfermode {
bool IsSupportedMode(SkXfermode::Mode mode);
- GrXPFactory* CreateXPFactory(SkXfermode::Mode mode);
+ const GrXPFactory* CreateXPFactory(SkXfermode::Mode mode);
};
#endif
diff --git a/include/gpu/effects/GrPorterDuffXferProcessor.h b/include/gpu/effects/GrPorterDuffXferProcessor.h
index d297e32908..72faeb572c 100644
--- a/include/gpu/effects/GrPorterDuffXferProcessor.h
+++ b/include/gpu/effects/GrPorterDuffXferProcessor.h
@@ -14,9 +14,9 @@
class GrProcOptInfo;
-class GrPorterDuffXPFactory : public GrXPFactory {
+class GrPDXPFactory : public GrXPFactory {
public:
- static GrXPFactory* Create(SkXfermode::Mode mode);
+ static const GrXPFactory* Create(SkXfermode::Mode mode);
bool supportsRGBCoverage(GrColor /*knownColor*/, uint32_t /*knownColorFlags*/) const override {
return true;
@@ -26,7 +26,7 @@ public:
GrXPFactory::InvariantBlendedColor*) const override;
private:
- GrPorterDuffXPFactory(SkXfermode::Mode);
+ GrPDXPFactory(SkXfermode::Mode);
GrXferProcessor* onCreateXferProcessor(const GrCaps& caps,
const GrProcOptInfo& colorPOI,
@@ -40,7 +40,7 @@ private:
bool hasMixedSamples) const override;
bool onIsEqual(const GrXPFactory& xpfBase) const override {
- const GrPorterDuffXPFactory& xpf = xpfBase.cast<GrPorterDuffXPFactory>();
+ const GrPDXPFactory& xpf = xpfBase.cast<GrPDXPFactory>();
return fXfermode == xpf.fXfermode;
}
@@ -53,4 +53,47 @@ private:
typedef GrXPFactory INHERITED;
};
+class GrSrcOverPDXPFactory : public GrXPFactory {
+public:
+ GrSrcOverPDXPFactory();
+
+ bool supportsRGBCoverage(GrColor /*knownColor*/, uint32_t /*knownColorFlags*/) const override {
+ return true;
+ }
+
+ void getInvariantBlendedColor(const GrProcOptInfo& colorPOI,
+ GrXPFactory::InvariantBlendedColor*) const override;
+
+private:
+ GrXferProcessor* onCreateXferProcessor(const GrCaps& caps,
+ const GrProcOptInfo& colorPOI,
+ const GrProcOptInfo& coveragePOI,
+ bool hasMixedSamples,
+ const DstTexture*) const override;
+
+ bool willReadDstColor(const GrCaps& caps,
+ const GrProcOptInfo& colorPOI,
+ const GrProcOptInfo& coveragePOI,
+ bool hasMixedSamples) const override;
+
+ bool onIsEqual(const GrXPFactory& /*xpfBase*/) const override {
+ return true;
+ }
+
+ GR_DECLARE_XP_FACTORY_TEST;
+
+ typedef GrXPFactory INHERITED;
+};
+
+namespace GrPorterDuffXPFactory {
+ const GrSrcOverPDXPFactory gSrcOverPDXPFactory;
+
+ inline const GrXPFactory* Create(SkXfermode::Mode mode) {
+ if (SkXfermode::kSrcOver_Mode == mode) {
+ return SkRef(&gSrcOverPDXPFactory);
+ }
+ return GrPDXPFactory::Create(mode);
+ }
+};
+
#endif