change more effects to only expose factories
BUG=skia:
TBR=
Review URL: https://codereview.chromium.org/1395403002
diff --git a/include/effects/SkColorFilterImageFilter.h b/include/effects/SkColorFilterImageFilter.h
index f23f16d..200ec86 100644
--- a/include/effects/SkColorFilterImageFilter.h
+++ b/include/effects/SkColorFilterImageFilter.h
@@ -14,20 +14,16 @@
class SK_API SkColorFilterImageFilter : public SkImageFilter {
public:
- static SkColorFilterImageFilter* Create(SkColorFilter* cf,
- SkImageFilter* input = NULL,
- const CropRect* cropRect = NULL);
- virtual ~SkColorFilterImageFilter();
+ static SkImageFilter* Create(SkColorFilter* cf, SkImageFilter* input = NULL,
+ const CropRect* cropRect = NULL);
SK_TO_STRING_OVERRIDE()
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkColorFilterImageFilter)
protected:
void flatten(SkWriteBuffer&) const override;
-
- virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&,
- SkBitmap* result, SkIPoint* loc) const override;
-
+ bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, SkBitmap* result,
+ SkIPoint* loc) const override;
bool onIsColorFilterNode(SkColorFilter**) const override;
bool affectsTransparentBlack() const override;
@@ -35,6 +31,8 @@
SkColorFilterImageFilter(SkColorFilter* cf,
SkImageFilter* input,
const CropRect* cropRect);
+ virtual ~SkColorFilterImageFilter();
+
SkColorFilter* fColorFilter;
typedef SkImageFilter INHERITED;
diff --git a/include/effects/SkModeColorFilter.h b/include/effects/SkModeColorFilter.h
index 0c876ae..06eec43 100644
--- a/include/effects/SkModeColorFilter.h
+++ b/include/effects/SkModeColorFilter.h
@@ -15,11 +15,9 @@
class SkModeColorFilter : public SkColorFilter {
public:
- SkModeColorFilter(SkColor color, SkXfermode::Mode mode) {
- fColor = color;
- fMode = mode;
- this->updateCache();
- };
+ static SkColorFilter* Create(SkColor color, SkXfermode::Mode mode) {
+ return new SkModeColorFilter(color, mode);
+ }
SkColor getColor() const { return fColor; }
SkXfermode::Mode getMode() const { return fMode; }
@@ -44,6 +42,12 @@
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkModeColorFilter)
protected:
+ SkModeColorFilter(SkColor color, SkXfermode::Mode mode) {
+ fColor = color;
+ fMode = mode;
+ this->updateCache();
+ };
+
void flatten(SkWriteBuffer&) const override;
private:
diff --git a/src/effects/SkColorFilterImageFilter.cpp b/src/effects/SkColorFilterImageFilter.cpp
index e5f64ce..46bad10 100644
--- a/src/effects/SkColorFilterImageFilter.cpp
+++ b/src/effects/SkColorFilterImageFilter.cpp
@@ -15,8 +15,8 @@
#include "SkTableColorFilter.h"
#include "SkWriteBuffer.h"
-SkColorFilterImageFilter* SkColorFilterImageFilter::Create(SkColorFilter* cf,
- SkImageFilter* input, const CropRect* cropRect) {
+SkImageFilter* SkColorFilterImageFilter::Create(SkColorFilter* cf, SkImageFilter* input,
+ const CropRect* cropRect) {
if (nullptr == cf) {
return nullptr;
}
diff --git a/src/effects/SkColorFilters.cpp b/src/effects/SkColorFilters.cpp
index 1e34b1e..4515c0d 100644
--- a/src/effects/SkColorFilters.cpp
+++ b/src/effects/SkColorFilters.cpp
@@ -166,7 +166,7 @@
case SkXfermode::kSrcOver_Mode:
return new SrcOver_SkModeColorFilter(color);
default:
- return new SkModeColorFilter(color, mode);
+ return SkModeColorFilter::Create(color, mode);
}
}
diff --git a/tests/ImageFilterTest.cpp b/tests/ImageFilterTest.cpp
index f83d315..6b9064e 100644
--- a/tests/ImageFilterTest.cpp
+++ b/tests/ImageFilterTest.cpp
@@ -904,7 +904,7 @@
SkAutoTUnref<SkColorFilter> green(
SkColorFilter::CreateModeFilter(SK_ColorGREEN, SkXfermode::kSrc_Mode));
- SkAutoTUnref<SkColorFilterImageFilter> imageFilter(
+ SkAutoTUnref<SkImageFilter> imageFilter(
SkColorFilterImageFilter::Create(green.get()));
SkPaint imageFilterPaint;
imageFilterPaint.setImageFilter(imageFilter.get());
@@ -1027,10 +1027,9 @@
SkAutoTUnref<SkColorFilter> green(
SkColorFilter::CreateModeFilter(SK_ColorGREEN, SkXfermode::kSrcIn_Mode));
- SkAutoTUnref<SkColorFilterImageFilter> greenFilter(
- SkColorFilterImageFilter::Create(green.get()));
+ SkAutoTUnref<SkImageFilter> greenFilter(SkColorFilterImageFilter::Create(green.get()));
SkImageFilter::CropRect cropRect(SkRect::MakeEmpty());
- SkAutoTUnref<SkColorFilterImageFilter> croppedOut(
+ SkAutoTUnref<SkImageFilter> croppedOut(
SkColorFilterImageFilter::Create(green.get(), nullptr, &cropRect));
// Check that an xfermode image filter whose input has been cropped out still draws the other