aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar robertphillips <robertphillips@google.com>2016-04-15 05:09:32 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-04-15 05:09:32 -0700
commit47db5fe4436c924f42b05bc63f8fad833b99bfbe (patch)
treeee36eee27a6b983aec2a6600a2a50768ec9e4fc0
parentad3dc0da218cc43c9917a256d4afb8cf0d7c5899 (diff)
Revert of Update DisplacementMapEffect to sk_sp (patchset #3 id:40001 of https://codereview.chromium.org/1877783003/ )
Reason for revert: unexpected image diffs in imagefilterscropexpand GM Original issue's description: > Update DisplacementMapEffect to sk_sp > > TBR=reed@google.com > > GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1877783003 > > Committed: https://skia.googlesource.com/skia/+/a53011ef44705a091a8e24f7ea289a3f9ad759f2 TBR=fmalita@chromium.org,reed@google.com # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true Review URL: https://codereview.chromium.org/1884253004
-rw-r--r--bench/DisplacementBench.cpp36
-rw-r--r--bench/ImageFilterDAGBench.cpp7
-rw-r--r--fuzz/FilterFuzz.cpp16
-rw-r--r--gm/displacement.cpp154
-rw-r--r--gm/imagefiltersclipped.cpp11
-rw-r--r--gm/imagefilterscropexpand.cpp13
-rw-r--r--gm/imagefiltersscaled.cpp11
-rw-r--r--gm/imagefilterstransformed.cpp11
-rw-r--r--include/effects/SkDisplacementMapEffect.h28
-rw-r--r--samplecode/SampleFilterFuzz.cpp16
-rw-r--r--src/effects/SkDisplacementMapEffect.cpp27
-rw-r--r--tests/ImageFilterTest.cpp8
12 files changed, 167 insertions, 171 deletions
diff --git a/bench/DisplacementBench.cpp b/bench/DisplacementBench.cpp
index 9edf21476c..82857e630f 100644
--- a/bench/DisplacementBench.cpp
+++ b/bench/DisplacementBench.cpp
@@ -18,7 +18,9 @@
class DisplacementBaseBench : public Benchmark {
public:
- DisplacementBaseBench(bool small) : fInitialized(false), fIsSmall(small) { }
+ DisplacementBaseBench(bool small) :
+ fInitialized(false), fIsSmall(small) {
+ }
protected:
void onDelayedSetup() override {
@@ -90,7 +92,8 @@ private:
class DisplacementZeroBench : public DisplacementBaseBench {
public:
- DisplacementZeroBench(bool small) : INHERITED(small) { }
+ DisplacementZeroBench(bool small) : INHERITED(small) {
+ }
protected:
const char* onGetName() override {
@@ -101,10 +104,9 @@ protected:
SkPaint paint;
sk_sp<SkImageFilter> displ(SkImageSource::Make(fCheckerboard));
// No displacement effect
- paint.setImageFilter(SkDisplacementMapEffect::Make(
- SkDisplacementMapEffect::kR_ChannelSelectorType,
- SkDisplacementMapEffect::kG_ChannelSelectorType,
- 0.0f, std::move(displ), nullptr));
+ paint.setImageFilter(SkDisplacementMapEffect::Create(
+ SkDisplacementMapEffect::kR_ChannelSelectorType,
+ SkDisplacementMapEffect::kG_ChannelSelectorType, 0.0f, displ.get()))->unref();
for (int i = 0; i < loops; i++) {
this->drawClippedBitmap(canvas, 0, 0, paint);
@@ -117,7 +119,8 @@ private:
class DisplacementAlphaBench : public DisplacementBaseBench {
public:
- DisplacementAlphaBench(bool small) : INHERITED(small) { }
+ DisplacementAlphaBench(bool small) : INHERITED(small) {
+ }
protected:
const char* onGetName() override {
@@ -128,12 +131,11 @@ protected:
SkPaint paint;
sk_sp<SkImageFilter> displ(SkImageSource::Make(fCheckerboard));
// Displacement, with 1 alpha component (which isn't pre-multiplied)
- paint.setImageFilter(SkDisplacementMapEffect::Make(
- SkDisplacementMapEffect::kB_ChannelSelectorType,
- SkDisplacementMapEffect::kA_ChannelSelectorType,
- 16.0f, std::move(displ), nullptr));
+ paint.setImageFilter(SkDisplacementMapEffect::Create(
+ SkDisplacementMapEffect::kB_ChannelSelectorType,
+ SkDisplacementMapEffect::kA_ChannelSelectorType, 16.0f, displ.get()))->unref();
for (int i = 0; i < loops; i++) {
- this->drawClippedBitmap(canvas, 100, 0, paint);
+ drawClippedBitmap(canvas, 100, 0, paint);
}
}
@@ -143,7 +145,8 @@ private:
class DisplacementFullBench : public DisplacementBaseBench {
public:
- DisplacementFullBench(bool small) : INHERITED(small) { }
+ DisplacementFullBench(bool small) : INHERITED(small) {
+ }
protected:
const char* onGetName() override {
@@ -154,10 +157,9 @@ protected:
SkPaint paint;
sk_sp<SkImageFilter> displ(SkImageSource::Make(fCheckerboard));
// Displacement, with 2 non-alpha components
- paint.setImageFilter(SkDisplacementMapEffect::Make(
- SkDisplacementMapEffect::kR_ChannelSelectorType,
- SkDisplacementMapEffect::kB_ChannelSelectorType,
- 32.0f, std::move(displ), nullptr));
+ paint.setImageFilter(SkDisplacementMapEffect::Create(
+ SkDisplacementMapEffect::kR_ChannelSelectorType,
+ SkDisplacementMapEffect::kB_ChannelSelectorType, 32.0f, displ.get()))->unref();
for (int i = 0; i < loops; ++i) {
this->drawClippedBitmap(canvas, 200, 0, paint);
}
diff --git a/bench/ImageFilterDAGBench.cpp b/bench/ImageFilterDAGBench.cpp
index 776ee787fd..308b3b0037 100644
--- a/bench/ImageFilterDAGBench.cpp
+++ b/bench/ImageFilterDAGBench.cpp
@@ -62,11 +62,10 @@ protected:
auto xSelector = SkDisplacementMapEffect::kR_ChannelSelectorType;
auto ySelector = SkDisplacementMapEffect::kB_ChannelSelectorType;
SkScalar scale = 2;
-
+ sk_sp<SkImageFilter> displ(SkDisplacementMapEffect::Create(xSelector, ySelector, scale,
+ blur.get(), blur.get()));
SkPaint paint;
- paint.setImageFilter(SkDisplacementMapEffect::Make(xSelector, ySelector, scale,
- blur, blur));
-
+ paint.setImageFilter(std::move(displ));
SkRect rect = SkRect::Make(SkIRect::MakeWH(400, 400));
canvas->drawRect(rect, paint);
}
diff --git a/fuzz/FilterFuzz.cpp b/fuzz/FilterFuzz.cpp
index 484bbf7624..791fe01a33 100644
--- a/fuzz/FilterFuzz.cpp
+++ b/fuzz/FilterFuzz.cpp
@@ -706,13 +706,17 @@ static sk_sp<SkImageFilter> make_image_filter(bool canBeNull) {
}
break;
}
- case DISPLACE:
- filter = SkDisplacementMapEffect::Make(make_channel_selector_type(),
- make_channel_selector_type(),
- make_scalar(),
- make_image_filter(false),
- make_image_filter());
+ case DISPLACE: {
+ sk_sp<SkImageFilter> subFilter1(make_image_filter(false));
+ sk_sp<SkImageFilter> subFilter2(make_image_filter());
+
+ filter = sk_sp<SkImageFilter>(SkDisplacementMapEffect::Create(make_channel_selector_type(),
+ make_channel_selector_type(),
+ make_scalar(),
+ subFilter1.get(),
+ subFilter2.get()));
break;
+ }
case TILE: {
sk_sp<SkImageFilter> subFilter(make_image_filter(false));
diff --git a/gm/displacement.cpp b/gm/displacement.cpp
index 9fea0188df..9b62a60ab3 100644
--- a/gm/displacement.cpp
+++ b/gm/displacement.cpp
@@ -58,142 +58,142 @@ protected:
canvas->clear(SK_ColorBLACK);
SkPaint paint;
sk_sp<SkImageFilter> displ(SkImageSource::Make(fCheckerboard));
- paint.setImageFilter(SkDisplacementMapEffect::Make(
+ paint.setImageFilter(SkDisplacementMapEffect::Create(
SkDisplacementMapEffect::kR_ChannelSelectorType,
- SkDisplacementMapEffect::kG_ChannelSelectorType, 0.0f, displ, nullptr));
- this->drawClippedBitmap(canvas, 0, 0, paint);
- paint.setImageFilter(SkDisplacementMapEffect::Make(
+ SkDisplacementMapEffect::kG_ChannelSelectorType, 0.0f, displ.get()))->unref();
+ drawClippedBitmap(canvas, 0, 0, paint);
+ paint.setImageFilter(SkDisplacementMapEffect::Create(
SkDisplacementMapEffect::kB_ChannelSelectorType,
- SkDisplacementMapEffect::kA_ChannelSelectorType, 16.0f, displ, nullptr));
- this->drawClippedBitmap(canvas, 100, 0, paint);
- paint.setImageFilter(SkDisplacementMapEffect::Make(
+ SkDisplacementMapEffect::kA_ChannelSelectorType, 16.0f, displ.get()))->unref();
+ drawClippedBitmap(canvas, 100, 0, paint);
+ paint.setImageFilter(SkDisplacementMapEffect::Create(
SkDisplacementMapEffect::kR_ChannelSelectorType,
- SkDisplacementMapEffect::kB_ChannelSelectorType, 32.0f, displ, nullptr));
- this->drawClippedBitmap(canvas, 200, 0, paint);
- paint.setImageFilter(SkDisplacementMapEffect::Make(
+ SkDisplacementMapEffect::kB_ChannelSelectorType, 32.0f, displ.get()))->unref();
+ drawClippedBitmap(canvas, 200, 0, paint);
+ paint.setImageFilter(SkDisplacementMapEffect::Create(
SkDisplacementMapEffect::kG_ChannelSelectorType,
- SkDisplacementMapEffect::kA_ChannelSelectorType, 48.0f, displ, nullptr));
- this->drawClippedBitmap(canvas, 300, 0, paint);
- paint.setImageFilter(SkDisplacementMapEffect::Make(
+ SkDisplacementMapEffect::kA_ChannelSelectorType, 48.0f, displ.get()))->unref();
+ drawClippedBitmap(canvas, 300, 0, paint);
+ paint.setImageFilter(SkDisplacementMapEffect::Create(
SkDisplacementMapEffect::kR_ChannelSelectorType,
- SkDisplacementMapEffect::kA_ChannelSelectorType, 64.0f, displ, nullptr));
- this->drawClippedBitmap(canvas, 400, 0, paint);
+ SkDisplacementMapEffect::kA_ChannelSelectorType, 64.0f, displ.get()))->unref();
+ drawClippedBitmap(canvas, 400, 0, paint);
- paint.setImageFilter(SkDisplacementMapEffect::Make(
+ paint.setImageFilter(SkDisplacementMapEffect::Create(
SkDisplacementMapEffect::kR_ChannelSelectorType,
- SkDisplacementMapEffect::kG_ChannelSelectorType, 40.0f, displ, nullptr));
- this->drawClippedBitmap(canvas, 0, 100, paint);
- paint.setImageFilter(SkDisplacementMapEffect::Make(
+ SkDisplacementMapEffect::kG_ChannelSelectorType, 40.0f, displ.get()))->unref();
+ drawClippedBitmap(canvas, 0, 100, paint);
+ paint.setImageFilter(SkDisplacementMapEffect::Create(
SkDisplacementMapEffect::kB_ChannelSelectorType,
- SkDisplacementMapEffect::kA_ChannelSelectorType, 40.0f, displ, nullptr));
- this->drawClippedBitmap(canvas, 100, 100, paint);
- paint.setImageFilter(SkDisplacementMapEffect::Make(
+ SkDisplacementMapEffect::kA_ChannelSelectorType, 40.0f, displ.get()))->unref();
+ drawClippedBitmap(canvas, 100, 100, paint);
+ paint.setImageFilter(SkDisplacementMapEffect::Create(
SkDisplacementMapEffect::kR_ChannelSelectorType,
- SkDisplacementMapEffect::kB_ChannelSelectorType, 40.0f, displ, nullptr));
- this->drawClippedBitmap(canvas, 200, 100, paint);
- paint.setImageFilter(SkDisplacementMapEffect::Make(
+ SkDisplacementMapEffect::kB_ChannelSelectorType, 40.0f, displ.get()))->unref();
+ drawClippedBitmap(canvas, 200, 100, paint);
+ paint.setImageFilter(SkDisplacementMapEffect::Create(
SkDisplacementMapEffect::kG_ChannelSelectorType,
- SkDisplacementMapEffect::kA_ChannelSelectorType, 40.0f, displ, nullptr));
- this->drawClippedBitmap(canvas, 300, 100, paint);
- paint.setImageFilter(SkDisplacementMapEffect::Make(
+ SkDisplacementMapEffect::kA_ChannelSelectorType, 40.0f, displ.get()))->unref();
+ drawClippedBitmap(canvas, 300, 100, paint);
+ paint.setImageFilter(SkDisplacementMapEffect::Create(
SkDisplacementMapEffect::kR_ChannelSelectorType,
- SkDisplacementMapEffect::kA_ChannelSelectorType, 40.0f, displ, nullptr));
- this->drawClippedBitmap(canvas, 400, 100, paint);
+ SkDisplacementMapEffect::kA_ChannelSelectorType, 40.0f, displ.get()))->unref();
+ drawClippedBitmap(canvas, 400, 100, paint);
SkImageFilter::CropRect cropRect(SkRect::MakeXYWH(30, 30, 40, 40));
- paint.setImageFilter(SkDisplacementMapEffect::Make(
+ paint.setImageFilter(SkDisplacementMapEffect::Create(
SkDisplacementMapEffect::kR_ChannelSelectorType,
SkDisplacementMapEffect::kG_ChannelSelectorType,
- 0.0f, displ, nullptr, &cropRect));
- this->drawClippedBitmap(canvas, 0, 200, paint);
- paint.setImageFilter(SkDisplacementMapEffect::Make(
+ 0.0f, displ.get(), nullptr, &cropRect))->unref();
+ drawClippedBitmap(canvas, 0, 200, paint);
+ paint.setImageFilter(SkDisplacementMapEffect::Create(
SkDisplacementMapEffect::kB_ChannelSelectorType,
SkDisplacementMapEffect::kA_ChannelSelectorType,
- 16.0f, displ, nullptr, &cropRect));
- this->drawClippedBitmap(canvas, 100, 200, paint);
- paint.setImageFilter(SkDisplacementMapEffect::Make(
+ 16.0f, displ.get(), nullptr, &cropRect))->unref();
+ drawClippedBitmap(canvas, 100, 200, paint);
+ paint.setImageFilter(SkDisplacementMapEffect::Create(
SkDisplacementMapEffect::kR_ChannelSelectorType,
SkDisplacementMapEffect::kB_ChannelSelectorType,
- 32.0f, displ, nullptr, &cropRect));
- this->drawClippedBitmap(canvas, 200, 200, paint);
- paint.setImageFilter(SkDisplacementMapEffect::Make(
+ 32.0f, displ.get(), nullptr, &cropRect))->unref();
+ drawClippedBitmap(canvas, 200, 200, paint);
+ paint.setImageFilter(SkDisplacementMapEffect::Create(
SkDisplacementMapEffect::kG_ChannelSelectorType,
SkDisplacementMapEffect::kA_ChannelSelectorType,
- 48.0f, displ, nullptr, &cropRect));
- this->drawClippedBitmap(canvas, 300, 200, paint);
- paint.setImageFilter(SkDisplacementMapEffect::Make(
+ 48.0f, displ.get(), nullptr, &cropRect))->unref();
+ drawClippedBitmap(canvas, 300, 200, paint);
+ paint.setImageFilter(SkDisplacementMapEffect::Create(
SkDisplacementMapEffect::kR_ChannelSelectorType,
SkDisplacementMapEffect::kA_ChannelSelectorType,
- 64.0f, displ, nullptr, &cropRect));
- this->drawClippedBitmap(canvas, 400, 200, paint);
+ 64.0f, displ.get(), nullptr, &cropRect))->unref();
+ drawClippedBitmap(canvas, 400, 200, paint);
- paint.setImageFilter(SkDisplacementMapEffect::Make(
+ paint.setImageFilter(SkDisplacementMapEffect::Create(
SkDisplacementMapEffect::kR_ChannelSelectorType,
SkDisplacementMapEffect::kG_ChannelSelectorType,
- 40.0f, displ, nullptr, &cropRect));
- this->drawClippedBitmap(canvas, 0, 300, paint);
- paint.setImageFilter(SkDisplacementMapEffect::Make(
+ 40.0f, displ.get(), nullptr, &cropRect))->unref();
+ drawClippedBitmap(canvas, 0, 300, paint);
+ paint.setImageFilter(SkDisplacementMapEffect::Create(
SkDisplacementMapEffect::kB_ChannelSelectorType,
SkDisplacementMapEffect::kA_ChannelSelectorType,
- 40.0f, displ, nullptr, &cropRect));
- this->drawClippedBitmap(canvas, 100, 300, paint);
- paint.setImageFilter(SkDisplacementMapEffect::Make(
+ 40.0f, displ.get(), nullptr, &cropRect))->unref();
+ drawClippedBitmap(canvas, 100, 300, paint);
+ paint.setImageFilter(SkDisplacementMapEffect::Create(
SkDisplacementMapEffect::kR_ChannelSelectorType,
SkDisplacementMapEffect::kB_ChannelSelectorType,
- 40.0f, displ, nullptr, &cropRect));
- this->drawClippedBitmap(canvas, 200, 300, paint);
- paint.setImageFilter(SkDisplacementMapEffect::Make(
+ 40.0f, displ.get(), nullptr, &cropRect))->unref();
+ drawClippedBitmap(canvas, 200, 300, paint);
+ paint.setImageFilter(SkDisplacementMapEffect::Create(
SkDisplacementMapEffect::kG_ChannelSelectorType,
SkDisplacementMapEffect::kA_ChannelSelectorType,
- 40.0f, displ, nullptr, &cropRect));
- this->drawClippedBitmap(canvas, 300, 300, paint);
- paint.setImageFilter(SkDisplacementMapEffect::Make(
+ 40.0f, displ.get(), nullptr, &cropRect))->unref();
+ drawClippedBitmap(canvas, 300, 300, paint);
+ paint.setImageFilter(SkDisplacementMapEffect::Create(
SkDisplacementMapEffect::kR_ChannelSelectorType,
SkDisplacementMapEffect::kA_ChannelSelectorType,
- 40.0f, displ, nullptr, &cropRect));
- this->drawClippedBitmap(canvas, 400, 300, paint);
+ 40.0f, displ.get(), nullptr, &cropRect))->unref();
+ drawClippedBitmap(canvas, 400, 300, paint);
// Test for negative scale.
- paint.setImageFilter(SkDisplacementMapEffect::Make(
+ paint.setImageFilter(SkDisplacementMapEffect::Create(
SkDisplacementMapEffect::kG_ChannelSelectorType,
SkDisplacementMapEffect::kA_ChannelSelectorType,
- -40.0f, displ, nullptr));
+ -40.0f, displ.get()))->unref();
this->drawClippedBitmap(canvas, 500, 0, paint);
// Tests for images of different sizes
displ = SkImageSource::Make(fSmall);
- paint.setImageFilter(SkDisplacementMapEffect::Make(
+ paint.setImageFilter(SkDisplacementMapEffect::Create(
SkDisplacementMapEffect::kR_ChannelSelectorType,
SkDisplacementMapEffect::kG_ChannelSelectorType,
- 40.0f, std::move(displ), nullptr));
- this->drawClippedBitmap(canvas, 0, 400, paint);
+ 40.0f, displ.get()))->unref();
+ drawClippedBitmap(canvas, 0, 400, paint);
displ = SkImageSource::Make(fLarge);
- paint.setImageFilter(SkDisplacementMapEffect::Make(
+ paint.setImageFilter(SkDisplacementMapEffect::Create(
SkDisplacementMapEffect::kB_ChannelSelectorType,
SkDisplacementMapEffect::kA_ChannelSelectorType,
- 40.0f, std::move(displ), nullptr));
- this->drawClippedBitmap(canvas, 100, 400, paint);
+ 40.0f, displ.get()))->unref();
+ drawClippedBitmap(canvas, 100, 400, paint);
displ = SkImageSource::Make(fLargeW);
- paint.setImageFilter(SkDisplacementMapEffect::Make(
+ paint.setImageFilter(SkDisplacementMapEffect::Create(
SkDisplacementMapEffect::kR_ChannelSelectorType,
SkDisplacementMapEffect::kB_ChannelSelectorType,
- 40.0f, std::move(displ), nullptr));
- this->drawClippedBitmap(canvas, 200, 400, paint);
+ 40.0f, displ.get()))->unref();
+ drawClippedBitmap(canvas, 200, 400, paint);
displ = SkImageSource::Make(fLargeH);
- paint.setImageFilter(SkDisplacementMapEffect::Make(
+ paint.setImageFilter(SkDisplacementMapEffect::Create(
SkDisplacementMapEffect::kG_ChannelSelectorType,
SkDisplacementMapEffect::kA_ChannelSelectorType,
- 40.0f, std::move(displ), nullptr));
- this->drawClippedBitmap(canvas, 300, 400, paint);
+ 40.0f, displ.get()))->unref();
+ drawClippedBitmap(canvas, 300, 400, paint);
// Test for no given displacement input. In this case, both displacement
// and color should use the same bitmap, given to SkCanvas::drawBitmap()
// as an input argument.
- paint.setImageFilter(SkDisplacementMapEffect::Make(
+ paint.setImageFilter(SkDisplacementMapEffect::Create(
SkDisplacementMapEffect::kG_ChannelSelectorType,
SkDisplacementMapEffect::kA_ChannelSelectorType,
- 40.0f, nullptr, nullptr));
- this->drawClippedBitmap(canvas, 400, 400, paint);
+ 40.0f, nullptr))->unref();
+ drawClippedBitmap(canvas, 400, 400, paint);
}
private:
diff --git a/gm/imagefiltersclipped.cpp b/gm/imagefiltersclipped.cpp
index 7989f8b4b0..f2434112fa 100644
--- a/gm/imagefiltersclipped.cpp
+++ b/gm/imagefiltersclipped.cpp
@@ -100,11 +100,12 @@ protected:
SkIntToScalar(3), SkIntToScalar(3), SK_ColorGREEN,
SkDropShadowImageFilter::kDrawShadowAndForeground_ShadowMode,
nullptr),
- SkDisplacementMapEffect::Make(SkDisplacementMapEffect::kR_ChannelSelectorType,
- SkDisplacementMapEffect::kR_ChannelSelectorType,
- SkIntToScalar(12),
- std::move(gradient),
- checkerboard),
+ sk_sp<SkImageFilter>(SkDisplacementMapEffect::Create(
+ SkDisplacementMapEffect::kR_ChannelSelectorType,
+ SkDisplacementMapEffect::kR_ChannelSelectorType,
+ SkIntToScalar(12),
+ gradient.get(),
+ checkerboard.get())),
SkDilateImageFilter::Make(2, 2, checkerboard),
SkErodeImageFilter::Make(2, 2, checkerboard),
SkOffsetImageFilter::Make(SkIntToScalar(-16), SkIntToScalar(32), nullptr),
diff --git a/gm/imagefilterscropexpand.cpp b/gm/imagefilterscropexpand.cpp
index f3084435fe..3d5fcf3612 100644
--- a/gm/imagefilterscropexpand.cpp
+++ b/gm/imagefilterscropexpand.cpp
@@ -107,12 +107,13 @@ protected:
&bigRect));
Draw(canvas, checkerboard, rect,
- SkDisplacementMapEffect::Make(SkDisplacementMapEffect::kR_ChannelSelectorType,
- SkDisplacementMapEffect::kR_ChannelSelectorType,
- SkIntToScalar(12),
- std::move(gradientCircleSource),
- noopCropped,
- &bigRect));
+ sk_sp<SkImageFilter>(SkDisplacementMapEffect::Create(
+ SkDisplacementMapEffect::kR_ChannelSelectorType,
+ SkDisplacementMapEffect::kR_ChannelSelectorType,
+ SkIntToScalar(12),
+ gradientCircleSource.get(),
+ noopCropped.get(),
+ &bigRect)));
Draw(canvas, checkerboard, rect,
SkOffsetImageFilter::Make(SkIntToScalar(-8), SkIntToScalar(16),
diff --git a/gm/imagefiltersscaled.cpp b/gm/imagefiltersscaled.cpp
index 756b7c624c..4c48aec869 100644
--- a/gm/imagefiltersscaled.cpp
+++ b/gm/imagefiltersscaled.cpp
@@ -98,11 +98,12 @@ protected:
SkIntToScalar(3), SkIntToScalar(3), SK_ColorYELLOW,
SkDropShadowImageFilter::kDrawShadowAndForeground_ShadowMode,
nullptr),
- SkDisplacementMapEffect::Make(SkDisplacementMapEffect::kR_ChannelSelectorType,
- SkDisplacementMapEffect::kR_ChannelSelectorType,
- SkIntToScalar(12),
- std::move(gradient),
- checkerboard),
+ sk_sp<SkImageFilter>(SkDisplacementMapEffect::Create(
+ SkDisplacementMapEffect::kR_ChannelSelectorType,
+ SkDisplacementMapEffect::kR_ChannelSelectorType,
+ SkIntToScalar(12),
+ gradient.get(),
+ checkerboard.get())),
SkDilateImageFilter::Make(1, 1, checkerboard),
SkErodeImageFilter::Make(1, 1, checkerboard),
SkOffsetImageFilter::Make(SkIntToScalar(32), 0, nullptr),
diff --git a/gm/imagefilterstransformed.cpp b/gm/imagefilterstransformed.cpp
index ce7ba5d6e0..291d1d46ec 100644
--- a/gm/imagefilterstransformed.cpp
+++ b/gm/imagefilterstransformed.cpp
@@ -69,11 +69,12 @@ protected:
SkBlurImageFilter::Make(12, 0, nullptr),
SkDropShadowImageFilter::Make(0, 15, 8, 0, SK_ColorGREEN,
SkDropShadowImageFilter::kDrawShadowAndForeground_ShadowMode, nullptr),
- SkDisplacementMapEffect::Make(SkDisplacementMapEffect::kR_ChannelSelectorType,
- SkDisplacementMapEffect::kR_ChannelSelectorType,
- 12,
- std::move(gradient),
- checkerboard),
+ sk_sp<SkImageFilter>(SkDisplacementMapEffect::Create(
+ SkDisplacementMapEffect::kR_ChannelSelectorType,
+ SkDisplacementMapEffect::kR_ChannelSelectorType,
+ 12,
+ gradient.get(),
+ checkerboard.get())),
SkDilateImageFilter::Make(2, 2, checkerboard),
SkErodeImageFilter::Make(2, 2, checkerboard),
};
diff --git a/include/effects/SkDisplacementMapEffect.h b/include/effects/SkDisplacementMapEffect.h
index f93f2c4454..4b6f321a22 100644
--- a/include/effects/SkDisplacementMapEffect.h
+++ b/include/effects/SkDisplacementMapEffect.h
@@ -20,14 +20,13 @@ public:
kA_ChannelSelectorType
};
- ~SkDisplacementMapEffect() override;
+ ~SkDisplacementMapEffect();
- static sk_sp<SkImageFilter> Make(ChannelSelectorType xChannelSelector,
- ChannelSelectorType yChannelSelector,
- SkScalar scale,
- sk_sp<SkImageFilter> displacement,
- sk_sp<SkImageFilter> color,
- const CropRect* cropRect = nullptr);
+ static SkImageFilter* Create(ChannelSelectorType xChannelSelector,
+ ChannelSelectorType yChannelSelector,
+ SkScalar scale, SkImageFilter* displacement,
+ SkImageFilter* color = NULL,
+ const CropRect* cropRect = NULL);
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDisplacementMapEffect)
@@ -39,26 +38,13 @@ public:
SK_TO_STRING_OVERRIDE()
-#ifdef SK_SUPPORT_LEGACY_IMAGEFILTER_PTR
- static SkImageFilter* Create(ChannelSelectorType xChannelSelector,
- ChannelSelectorType yChannelSelector,
- SkScalar scale, SkImageFilter* displacement,
- SkImageFilter* color = nullptr,
- const CropRect* cropRect = nullptr) {
- return Make(xChannelSelector, yChannelSelector, scale,
- sk_ref_sp<SkImageFilter>(displacement),
- sk_ref_sp<SkImageFilter>(color),
- cropRect).release();
- }
-#endif
-
protected:
sk_sp<SkSpecialImage> onFilterImage(SkSpecialImage* source, const Context&,
SkIPoint* offset) const override;
SkDisplacementMapEffect(ChannelSelectorType xChannelSelector,
ChannelSelectorType yChannelSelector,
- SkScalar scale, sk_sp<SkImageFilter> inputs[2],
+ SkScalar scale, SkImageFilter* inputs[2],
const CropRect* cropRect);
void flatten(SkWriteBuffer&) const override;
diff --git a/samplecode/SampleFilterFuzz.cpp b/samplecode/SampleFilterFuzz.cpp
index 12b6a8af99..5f06731ae5 100644
--- a/samplecode/SampleFilterFuzz.cpp
+++ b/samplecode/SampleFilterFuzz.cpp
@@ -709,13 +709,17 @@ static sk_sp<SkImageFilter> make_image_filter(bool canBeNull) {
}
break;
}
- case DISPLACE:
- filter = SkDisplacementMapEffect::Make(make_channel_selector_type(),
- make_channel_selector_type(),
- make_scalar(),
- make_image_filter(false),
- make_image_filter());
+ case DISPLACE: {
+ sk_sp<SkImageFilter> subFilter1(make_image_filter(false));
+ sk_sp<SkImageFilter> subFilter2(make_image_filter());
+
+ filter = sk_sp<SkImageFilter>(SkDisplacementMapEffect::Create(make_channel_selector_type(),
+ make_channel_selector_type(),
+ make_scalar(),
+ subFilter1.get(),
+ subFilter2.get()));
break;
+ }
case TILE: {
sk_sp<SkImageFilter> subFilter(make_image_filter(false));
diff --git a/src/effects/SkDisplacementMapEffect.cpp b/src/effects/SkDisplacementMapEffect.cpp
index b715f6a4f3..aee15ef753 100644
--- a/src/effects/SkDisplacementMapEffect.cpp
+++ b/src/effects/SkDisplacementMapEffect.cpp
@@ -163,29 +163,27 @@ bool channel_selector_type_is_valid(SkDisplacementMapEffect::ChannelSelectorType
///////////////////////////////////////////////////////////////////////////////
-sk_sp<SkImageFilter> SkDisplacementMapEffect::Make(ChannelSelectorType xChannelSelector,
- ChannelSelectorType yChannelSelector,
- SkScalar scale,
- sk_sp<SkImageFilter> displacement,
- sk_sp<SkImageFilter> color,
- const CropRect* cropRect) {
+SkImageFilter* SkDisplacementMapEffect::Create(ChannelSelectorType xChannelSelector,
+ ChannelSelectorType yChannelSelector,
+ SkScalar scale,
+ SkImageFilter* displacement,
+ SkImageFilter* color,
+ const CropRect* cropRect) {
if (!channel_selector_type_is_valid(xChannelSelector) ||
!channel_selector_type_is_valid(yChannelSelector)) {
return nullptr;
}
- sk_sp<SkImageFilter> inputs[2] = { std::move(displacement), std::move(color) };
- return sk_sp<SkImageFilter>(new SkDisplacementMapEffect(xChannelSelector,
- yChannelSelector,
- scale, inputs, cropRect));
+ SkImageFilter* inputs[2] = { displacement, color };
+ return new SkDisplacementMapEffect(xChannelSelector, yChannelSelector, scale, inputs, cropRect);
}
SkDisplacementMapEffect::SkDisplacementMapEffect(ChannelSelectorType xChannelSelector,
ChannelSelectorType yChannelSelector,
SkScalar scale,
- sk_sp<SkImageFilter> inputs[2],
+ SkImageFilter* inputs[2],
const CropRect* cropRect)
- : INHERITED(inputs, 2, cropRect)
+ : INHERITED(2, inputs, cropRect)
, fXChannelSelector(xChannelSelector)
, fYChannelSelector(yChannelSelector)
, fScale(scale) {
@@ -199,9 +197,8 @@ sk_sp<SkFlattenable> SkDisplacementMapEffect::CreateProc(SkReadBuffer& buffer) {
ChannelSelectorType xsel = (ChannelSelectorType)buffer.readInt();
ChannelSelectorType ysel = (ChannelSelectorType)buffer.readInt();
SkScalar scale = buffer.readScalar();
- return Make(xsel, ysel, scale,
- common.getInput(0), common.getInput(1),
- &common.cropRect());
+ return sk_sp<SkFlattenable>(Create(xsel, ysel, scale, common.getInput(0).get(),
+ common.getInput(1).get(), &common.cropRect()));
}
void SkDisplacementMapEffect::flatten(SkWriteBuffer& buffer) const {
diff --git a/tests/ImageFilterTest.cpp b/tests/ImageFilterTest.cpp
index 172f84fa77..114c342ada 100644
--- a/tests/ImageFilterTest.cpp
+++ b/tests/ImageFilterTest.cpp
@@ -160,10 +160,10 @@ public:
sk_sp<SkImageFilter> gradientSource(SkImageSource::Make(std::move(gradientImage)));
this->addFilter("displacement map",
- SkDisplacementMapEffect::Make(SkDisplacementMapEffect::kR_ChannelSelectorType,
- SkDisplacementMapEffect::kB_ChannelSelectorType,
- 20.0f,
- std::move(gradientSource), input, cropRect));
+ sk_sp<SkImageFilter>(SkDisplacementMapEffect::Create(
+ SkDisplacementMapEffect::kR_ChannelSelectorType,
+ SkDisplacementMapEffect::kB_ChannelSelectorType,
+ 20.0f, gradientSource.get(), input.get(), cropRect)));
}
this->addFilter("blur", SkBlurImageFilter::Make(SK_Scalar1,