change SkXfermodeImageFilter to carry no impl information
BUG=skia:
NOTREECHECKS=True
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2584
Change-Id: Ibf2dfa7722348ae71a99f1c895de0d2996350e58
Reviewed-on: https://skia-review.googlesource.com/2584
Commit-Queue: Mike Reed <reed@google.com>
Reviewed-by: Florin Malita <fmalita@chromium.org>
Reviewed-by: Robert Phillips <robertphillips@google.com>
diff --git a/include/effects/SkXfermodeImageFilter.h b/include/effects/SkXfermodeImageFilter.h
index 135c0f6..e391575 100644
--- a/include/effects/SkXfermodeImageFilter.h
+++ b/include/effects/SkXfermodeImageFilter.h
@@ -10,19 +10,18 @@
#include "SkImageFilter.h"
-class SkBitmap;
class SkXfermode;
-class SK_API SkXfermodeImageFilter : public SkImageFilter {
- /**
- * This filter takes an xfermode, and uses it to composite the foreground
- * over the background. If foreground or background is NULL, the input
- * bitmap (src) is used instead.
- */
-
+/**
+ * This filter takes an xfermode, and uses it to composite the foreground
+ * over the background. If foreground or background is NULL, the input
+ * bitmap (src) is used instead.
+ */
+class SK_API SkXfermodeImageFilter {
public:
static sk_sp<SkImageFilter> Make(sk_sp<SkXfermode> mode, sk_sp<SkImageFilter> background,
- sk_sp<SkImageFilter> foreground, const CropRect* cropRect);
+ sk_sp<SkImageFilter> foreground,
+ const SkImageFilter::CropRect* cropRect);
static sk_sp<SkImageFilter> Make(sk_sp<SkXfermode> mode, sk_sp<SkImageFilter> background) {
return Make(std::move(mode), std::move(background), nullptr, nullptr);
}
@@ -30,7 +29,7 @@
#ifdef SK_SUPPORT_LEGACY_XFERMODE_PTR
static SkImageFilter* Create(SkXfermode* mode, SkImageFilter* background,
SkImageFilter* foreground = NULL,
- const CropRect* cropRect = NULL) {
+ const SkImageFilter::CropRect* cropRect = NULL) {
return Make(sk_ref_sp(mode),
sk_ref_sp(background),
sk_ref_sp(foreground),
@@ -39,7 +38,8 @@
#endif
#ifdef SK_SUPPORT_LEGACY_IMAGEFILTER_PTR
static sk_sp<SkImageFilter> Make(sk_sp<SkXfermode> mode, SkImageFilter* background,
- SkImageFilter* foreground, const CropRect* cropRect) {
+ SkImageFilter* foreground,
+ const SkImageFilter::CropRect* cropRect) {
return Make(std::move(mode),
sk_ref_sp(background),
sk_ref_sp(foreground),
@@ -50,30 +50,10 @@
}
#endif
- SK_TO_STRING_OVERRIDE()
- SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkXfermodeImageFilter)
-
-protected:
- sk_sp<SkSpecialImage> onFilterImage(SkSpecialImage* source, const Context&,
- SkIPoint* offset) const override;
-
-#if SK_SUPPORT_GPU
- sk_sp<SkSpecialImage> filterImageGPU(SkSpecialImage* source,
- sk_sp<SkSpecialImage> background,
- const SkIPoint& backgroundOffset,
- sk_sp<SkSpecialImage> foreground,
- const SkIPoint& foregroundOffset,
- const SkIRect& bounds,
- const OutputProperties& outputProperties) const;
-#endif
-
- SkXfermodeImageFilter(sk_sp<SkXfermode> mode, sk_sp<SkImageFilter> inputs[2],
- const CropRect* cropRect);
- void flatten(SkWriteBuffer&) const override;
+ SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP();
private:
- sk_sp<SkXfermode> fMode;
- typedef SkImageFilter INHERITED;
+ SkXfermodeImageFilter(); // can't instantiate
};
#endif
diff --git a/src/effects/SkXfermodeImageFilter.cpp b/src/effects/SkXfermodeImageFilter.cpp
index c7e4143..bbba0a5 100644
--- a/src/effects/SkXfermodeImageFilter.cpp
+++ b/src/effects/SkXfermodeImageFilter.cpp
@@ -24,35 +24,69 @@
#include "SkGrPriv.h"
#endif
+class SK_API SkXfermodeImageFilter_Base : public SkImageFilter {
+public:
+ SkXfermodeImageFilter_Base(sk_sp<SkXfermode> mode, sk_sp<SkImageFilter> inputs[2],
+ const CropRect* cropRect);
+
+ SK_TO_STRING_OVERRIDE()
+ SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkXfermodeImageFilter_Base)
+
+protected:
+ sk_sp<SkSpecialImage> onFilterImage(SkSpecialImage* source, const Context&,
+ SkIPoint* offset) const override;
+
+#if SK_SUPPORT_GPU
+ sk_sp<SkSpecialImage> filterImageGPU(SkSpecialImage* source,
+ sk_sp<SkSpecialImage> background,
+ const SkIPoint& backgroundOffset,
+ sk_sp<SkSpecialImage> foreground,
+ const SkIPoint& foregroundOffset,
+ const SkIRect& bounds,
+ const OutputProperties& outputProperties) const;
+#endif
+
+ void flatten(SkWriteBuffer&) const override;
+
+
+private:
+ sk_sp<SkXfermode> fMode;
+
+ friend class SkXfermodeImageFilter;
+
+ typedef SkImageFilter INHERITED;
+};
+
///////////////////////////////////////////////////////////////////////////////
sk_sp<SkImageFilter> SkXfermodeImageFilter::Make(sk_sp<SkXfermode> mode,
sk_sp<SkImageFilter> background,
sk_sp<SkImageFilter> foreground,
- const CropRect* cropRect) {
+ const SkImageFilter::CropRect* cropRect) {
sk_sp<SkImageFilter> inputs[2] = { std::move(background), std::move(foreground) };
- return sk_sp<SkImageFilter>(new SkXfermodeImageFilter(mode, inputs, cropRect));
+ return sk_sp<SkImageFilter>(new SkXfermodeImageFilter_Base(mode, inputs, cropRect));
}
-SkXfermodeImageFilter::SkXfermodeImageFilter(sk_sp<SkXfermode> mode,
+SkXfermodeImageFilter_Base::SkXfermodeImageFilter_Base(sk_sp<SkXfermode> mode,
sk_sp<SkImageFilter> inputs[2],
const CropRect* cropRect)
: INHERITED(inputs, 2, cropRect)
, fMode(std::move(mode)) {
}
-sk_sp<SkFlattenable> SkXfermodeImageFilter::CreateProc(SkReadBuffer& buffer) {
+sk_sp<SkFlattenable> SkXfermodeImageFilter_Base::CreateProc(SkReadBuffer& buffer) {
SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 2);
sk_sp<SkXfermode> mode(buffer.readXfermode());
- return Make(std::move(mode), common.getInput(0), common.getInput(1), &common.cropRect());
+ return SkXfermodeImageFilter::Make(std::move(mode), common.getInput(0), common.getInput(1),
+ &common.cropRect());
}
-void SkXfermodeImageFilter::flatten(SkWriteBuffer& buffer) const {
+void SkXfermodeImageFilter_Base::flatten(SkWriteBuffer& buffer) const {
this->INHERITED::flatten(buffer);
buffer.writeFlattenable(fMode.get());
}
-sk_sp<SkSpecialImage> SkXfermodeImageFilter::onFilterImage(SkSpecialImage* source,
+sk_sp<SkSpecialImage> SkXfermodeImageFilter_Base::onFilterImage(SkSpecialImage* source,
const Context& ctx,
SkIPoint* offset) const {
SkIPoint backgroundOffset = SkIPoint::Make(0, 0);
@@ -134,7 +168,7 @@
}
#ifndef SK_IGNORE_TO_STRING
-void SkXfermodeImageFilter::toString(SkString* str) const {
+void SkXfermodeImageFilter_Base::toString(SkString* str) const {
str->appendf("SkXfermodeImageFilter: (");
str->appendf("xfermode: (");
if (fMode) {
@@ -159,7 +193,7 @@
#include "SkXfermode_proccoeff.h"
-sk_sp<SkSpecialImage> SkXfermodeImageFilter::filterImageGPU(
+sk_sp<SkSpecialImage> SkXfermodeImageFilter_Base::filterImageGPU(
SkSpecialImage* source,
sk_sp<SkSpecialImage> background,
const SkIPoint& backgroundOffset,
@@ -263,3 +297,12 @@
}
#endif
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkXfermodeImageFilter)
+ SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkXfermodeImageFilter_Base)
+ // manually register the legacy serialized name "SkXfermodeImageFilter"
+ SkFlattenable::Register("SkXfermodeImageFilter", SkXfermodeImageFilter_Base::CreateProc,
+ SkFlattenable::kSkImageFilter_Type);
+SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
diff --git a/src/ports/SkGlobalInitialization_default.cpp b/src/ports/SkGlobalInitialization_default.cpp
index ed8b0e1..be41422 100644
--- a/src/ports/SkGlobalInitialization_default.cpp
+++ b/src/ports/SkGlobalInitialization_default.cpp
@@ -106,6 +106,7 @@
// ImageFilter
SkImageFilter::InitializeFlattenables();
+ SkXfermodeImageFilter::InitializeFlattenables();
SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDilateImageFilter)
SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDisplacementMapEffect)
SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDropShadowImageFilter)
@@ -115,7 +116,6 @@
SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkPaintImageFilter)
SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkPictureImageFilter)
SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkTileImageFilter)
- SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkXfermodeImageFilter)
SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkMagnifierImageFilter)
SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkMatrixConvolutionImageFilter)
SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkOffsetImageFilter)