robertphillips 2016-04-15 04:37:07 -07:00 committed by Commit bot
parent 834d9e1092
commit a53011ef44
12 changed files with 171 additions and 167 deletions

View File

@ -18,9 +18,7 @@
class DisplacementBaseBench : public Benchmark {
public:
DisplacementBaseBench(bool small) :
fInitialized(false), fIsSmall(small) {
}
DisplacementBaseBench(bool small) : fInitialized(false), fIsSmall(small) { }
protected:
void onDelayedSetup() override {
@ -92,8 +90,7 @@ private:
class DisplacementZeroBench : public DisplacementBaseBench {
public:
DisplacementZeroBench(bool small) : INHERITED(small) {
}
DisplacementZeroBench(bool small) : INHERITED(small) { }
protected:
const char* onGetName() override {
@ -104,9 +101,10 @@ protected:
SkPaint paint;
sk_sp<SkImageFilter> displ(SkImageSource::Make(fCheckerboard));
// No displacement effect
paint.setImageFilter(SkDisplacementMapEffect::Create(
SkDisplacementMapEffect::kR_ChannelSelectorType,
SkDisplacementMapEffect::kG_ChannelSelectorType, 0.0f, displ.get()))->unref();
paint.setImageFilter(SkDisplacementMapEffect::Make(
SkDisplacementMapEffect::kR_ChannelSelectorType,
SkDisplacementMapEffect::kG_ChannelSelectorType,
0.0f, std::move(displ), nullptr));
for (int i = 0; i < loops; i++) {
this->drawClippedBitmap(canvas, 0, 0, paint);
@ -119,8 +117,7 @@ private:
class DisplacementAlphaBench : public DisplacementBaseBench {
public:
DisplacementAlphaBench(bool small) : INHERITED(small) {
}
DisplacementAlphaBench(bool small) : INHERITED(small) { }
protected:
const char* onGetName() override {
@ -131,11 +128,12 @@ protected:
SkPaint paint;
sk_sp<SkImageFilter> displ(SkImageSource::Make(fCheckerboard));
// Displacement, with 1 alpha component (which isn't pre-multiplied)
paint.setImageFilter(SkDisplacementMapEffect::Create(
SkDisplacementMapEffect::kB_ChannelSelectorType,
SkDisplacementMapEffect::kA_ChannelSelectorType, 16.0f, displ.get()))->unref();
paint.setImageFilter(SkDisplacementMapEffect::Make(
SkDisplacementMapEffect::kB_ChannelSelectorType,
SkDisplacementMapEffect::kA_ChannelSelectorType,
16.0f, std::move(displ), nullptr));
for (int i = 0; i < loops; i++) {
drawClippedBitmap(canvas, 100, 0, paint);
this->drawClippedBitmap(canvas, 100, 0, paint);
}
}
@ -145,8 +143,7 @@ private:
class DisplacementFullBench : public DisplacementBaseBench {
public:
DisplacementFullBench(bool small) : INHERITED(small) {
}
DisplacementFullBench(bool small) : INHERITED(small) { }
protected:
const char* onGetName() override {
@ -157,9 +154,10 @@ protected:
SkPaint paint;
sk_sp<SkImageFilter> displ(SkImageSource::Make(fCheckerboard));
// Displacement, with 2 non-alpha components
paint.setImageFilter(SkDisplacementMapEffect::Create(
SkDisplacementMapEffect::kR_ChannelSelectorType,
SkDisplacementMapEffect::kB_ChannelSelectorType, 32.0f, displ.get()))->unref();
paint.setImageFilter(SkDisplacementMapEffect::Make(
SkDisplacementMapEffect::kR_ChannelSelectorType,
SkDisplacementMapEffect::kB_ChannelSelectorType,
32.0f, std::move(displ), nullptr));
for (int i = 0; i < loops; ++i) {
this->drawClippedBitmap(canvas, 200, 0, paint);
}

View File

@ -62,10 +62,11 @@ 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(std::move(displ));
paint.setImageFilter(SkDisplacementMapEffect::Make(xSelector, ySelector, scale,
blur, blur));
SkRect rect = SkRect::Make(SkIRect::MakeWH(400, 400));
canvas->drawRect(rect, paint);
}

View File

@ -706,17 +706,13 @@ static sk_sp<SkImageFilter> make_image_filter(bool canBeNull) {
}
break;
}
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()));
case DISPLACE:
filter = SkDisplacementMapEffect::Make(make_channel_selector_type(),
make_channel_selector_type(),
make_scalar(),
make_image_filter(false),
make_image_filter());
break;
}
case TILE: {
sk_sp<SkImageFilter> subFilter(make_image_filter(false));

View File

@ -58,142 +58,142 @@ protected:
canvas->clear(SK_ColorBLACK);
SkPaint paint;
sk_sp<SkImageFilter> displ(SkImageSource::Make(fCheckerboard));
paint.setImageFilter(SkDisplacementMapEffect::Create(
paint.setImageFilter(SkDisplacementMapEffect::Make(
SkDisplacementMapEffect::kR_ChannelSelectorType,
SkDisplacementMapEffect::kG_ChannelSelectorType, 0.0f, displ.get()))->unref();
drawClippedBitmap(canvas, 0, 0, paint);
paint.setImageFilter(SkDisplacementMapEffect::Create(
SkDisplacementMapEffect::kG_ChannelSelectorType, 0.0f, displ, nullptr));
this->drawClippedBitmap(canvas, 0, 0, paint);
paint.setImageFilter(SkDisplacementMapEffect::Make(
SkDisplacementMapEffect::kB_ChannelSelectorType,
SkDisplacementMapEffect::kA_ChannelSelectorType, 16.0f, displ.get()))->unref();
drawClippedBitmap(canvas, 100, 0, paint);
paint.setImageFilter(SkDisplacementMapEffect::Create(
SkDisplacementMapEffect::kA_ChannelSelectorType, 16.0f, displ, nullptr));
this->drawClippedBitmap(canvas, 100, 0, paint);
paint.setImageFilter(SkDisplacementMapEffect::Make(
SkDisplacementMapEffect::kR_ChannelSelectorType,
SkDisplacementMapEffect::kB_ChannelSelectorType, 32.0f, displ.get()))->unref();
drawClippedBitmap(canvas, 200, 0, paint);
paint.setImageFilter(SkDisplacementMapEffect::Create(
SkDisplacementMapEffect::kB_ChannelSelectorType, 32.0f, displ, nullptr));
this->drawClippedBitmap(canvas, 200, 0, paint);
paint.setImageFilter(SkDisplacementMapEffect::Make(
SkDisplacementMapEffect::kG_ChannelSelectorType,
SkDisplacementMapEffect::kA_ChannelSelectorType, 48.0f, displ.get()))->unref();
drawClippedBitmap(canvas, 300, 0, paint);
paint.setImageFilter(SkDisplacementMapEffect::Create(
SkDisplacementMapEffect::kA_ChannelSelectorType, 48.0f, displ, nullptr));
this->drawClippedBitmap(canvas, 300, 0, paint);
paint.setImageFilter(SkDisplacementMapEffect::Make(
SkDisplacementMapEffect::kR_ChannelSelectorType,
SkDisplacementMapEffect::kA_ChannelSelectorType, 64.0f, displ.get()))->unref();
drawClippedBitmap(canvas, 400, 0, paint);
SkDisplacementMapEffect::kA_ChannelSelectorType, 64.0f, displ, nullptr));
this->drawClippedBitmap(canvas, 400, 0, paint);
paint.setImageFilter(SkDisplacementMapEffect::Create(
paint.setImageFilter(SkDisplacementMapEffect::Make(
SkDisplacementMapEffect::kR_ChannelSelectorType,
SkDisplacementMapEffect::kG_ChannelSelectorType, 40.0f, displ.get()))->unref();
drawClippedBitmap(canvas, 0, 100, paint);
paint.setImageFilter(SkDisplacementMapEffect::Create(
SkDisplacementMapEffect::kG_ChannelSelectorType, 40.0f, displ, nullptr));
this->drawClippedBitmap(canvas, 0, 100, paint);
paint.setImageFilter(SkDisplacementMapEffect::Make(
SkDisplacementMapEffect::kB_ChannelSelectorType,
SkDisplacementMapEffect::kA_ChannelSelectorType, 40.0f, displ.get()))->unref();
drawClippedBitmap(canvas, 100, 100, paint);
paint.setImageFilter(SkDisplacementMapEffect::Create(
SkDisplacementMapEffect::kA_ChannelSelectorType, 40.0f, displ, nullptr));
this->drawClippedBitmap(canvas, 100, 100, paint);
paint.setImageFilter(SkDisplacementMapEffect::Make(
SkDisplacementMapEffect::kR_ChannelSelectorType,
SkDisplacementMapEffect::kB_ChannelSelectorType, 40.0f, displ.get()))->unref();
drawClippedBitmap(canvas, 200, 100, paint);
paint.setImageFilter(SkDisplacementMapEffect::Create(
SkDisplacementMapEffect::kB_ChannelSelectorType, 40.0f, displ, nullptr));
this->drawClippedBitmap(canvas, 200, 100, paint);
paint.setImageFilter(SkDisplacementMapEffect::Make(
SkDisplacementMapEffect::kG_ChannelSelectorType,
SkDisplacementMapEffect::kA_ChannelSelectorType, 40.0f, displ.get()))->unref();
drawClippedBitmap(canvas, 300, 100, paint);
paint.setImageFilter(SkDisplacementMapEffect::Create(
SkDisplacementMapEffect::kA_ChannelSelectorType, 40.0f, displ, nullptr));
this->drawClippedBitmap(canvas, 300, 100, paint);
paint.setImageFilter(SkDisplacementMapEffect::Make(
SkDisplacementMapEffect::kR_ChannelSelectorType,
SkDisplacementMapEffect::kA_ChannelSelectorType, 40.0f, displ.get()))->unref();
drawClippedBitmap(canvas, 400, 100, paint);
SkDisplacementMapEffect::kA_ChannelSelectorType, 40.0f, displ, nullptr));
this->drawClippedBitmap(canvas, 400, 100, paint);
SkImageFilter::CropRect cropRect(SkRect::MakeXYWH(30, 30, 40, 40));
paint.setImageFilter(SkDisplacementMapEffect::Create(
paint.setImageFilter(SkDisplacementMapEffect::Make(
SkDisplacementMapEffect::kR_ChannelSelectorType,
SkDisplacementMapEffect::kG_ChannelSelectorType,
0.0f, displ.get(), nullptr, &cropRect))->unref();
drawClippedBitmap(canvas, 0, 200, paint);
paint.setImageFilter(SkDisplacementMapEffect::Create(
0.0f, displ, nullptr, &cropRect));
this->drawClippedBitmap(canvas, 0, 200, paint);
paint.setImageFilter(SkDisplacementMapEffect::Make(
SkDisplacementMapEffect::kB_ChannelSelectorType,
SkDisplacementMapEffect::kA_ChannelSelectorType,
16.0f, displ.get(), nullptr, &cropRect))->unref();
drawClippedBitmap(canvas, 100, 200, paint);
paint.setImageFilter(SkDisplacementMapEffect::Create(
16.0f, displ, nullptr, &cropRect));
this->drawClippedBitmap(canvas, 100, 200, paint);
paint.setImageFilter(SkDisplacementMapEffect::Make(
SkDisplacementMapEffect::kR_ChannelSelectorType,
SkDisplacementMapEffect::kB_ChannelSelectorType,
32.0f, displ.get(), nullptr, &cropRect))->unref();
drawClippedBitmap(canvas, 200, 200, paint);
paint.setImageFilter(SkDisplacementMapEffect::Create(
32.0f, displ, nullptr, &cropRect));
this->drawClippedBitmap(canvas, 200, 200, paint);
paint.setImageFilter(SkDisplacementMapEffect::Make(
SkDisplacementMapEffect::kG_ChannelSelectorType,
SkDisplacementMapEffect::kA_ChannelSelectorType,
48.0f, displ.get(), nullptr, &cropRect))->unref();
drawClippedBitmap(canvas, 300, 200, paint);
paint.setImageFilter(SkDisplacementMapEffect::Create(
48.0f, displ, nullptr, &cropRect));
this->drawClippedBitmap(canvas, 300, 200, paint);
paint.setImageFilter(SkDisplacementMapEffect::Make(
SkDisplacementMapEffect::kR_ChannelSelectorType,
SkDisplacementMapEffect::kA_ChannelSelectorType,
64.0f, displ.get(), nullptr, &cropRect))->unref();
drawClippedBitmap(canvas, 400, 200, paint);
64.0f, displ, nullptr, &cropRect));
this->drawClippedBitmap(canvas, 400, 200, paint);
paint.setImageFilter(SkDisplacementMapEffect::Create(
paint.setImageFilter(SkDisplacementMapEffect::Make(
SkDisplacementMapEffect::kR_ChannelSelectorType,
SkDisplacementMapEffect::kG_ChannelSelectorType,
40.0f, displ.get(), nullptr, &cropRect))->unref();
drawClippedBitmap(canvas, 0, 300, paint);
paint.setImageFilter(SkDisplacementMapEffect::Create(
40.0f, displ, nullptr, &cropRect));
this->drawClippedBitmap(canvas, 0, 300, paint);
paint.setImageFilter(SkDisplacementMapEffect::Make(
SkDisplacementMapEffect::kB_ChannelSelectorType,
SkDisplacementMapEffect::kA_ChannelSelectorType,
40.0f, displ.get(), nullptr, &cropRect))->unref();
drawClippedBitmap(canvas, 100, 300, paint);
paint.setImageFilter(SkDisplacementMapEffect::Create(
40.0f, displ, nullptr, &cropRect));
this->drawClippedBitmap(canvas, 100, 300, paint);
paint.setImageFilter(SkDisplacementMapEffect::Make(
SkDisplacementMapEffect::kR_ChannelSelectorType,
SkDisplacementMapEffect::kB_ChannelSelectorType,
40.0f, displ.get(), nullptr, &cropRect))->unref();
drawClippedBitmap(canvas, 200, 300, paint);
paint.setImageFilter(SkDisplacementMapEffect::Create(
40.0f, displ, nullptr, &cropRect));
this->drawClippedBitmap(canvas, 200, 300, paint);
paint.setImageFilter(SkDisplacementMapEffect::Make(
SkDisplacementMapEffect::kG_ChannelSelectorType,
SkDisplacementMapEffect::kA_ChannelSelectorType,
40.0f, displ.get(), nullptr, &cropRect))->unref();
drawClippedBitmap(canvas, 300, 300, paint);
paint.setImageFilter(SkDisplacementMapEffect::Create(
40.0f, displ, nullptr, &cropRect));
this->drawClippedBitmap(canvas, 300, 300, paint);
paint.setImageFilter(SkDisplacementMapEffect::Make(
SkDisplacementMapEffect::kR_ChannelSelectorType,
SkDisplacementMapEffect::kA_ChannelSelectorType,
40.0f, displ.get(), nullptr, &cropRect))->unref();
drawClippedBitmap(canvas, 400, 300, paint);
40.0f, displ, nullptr, &cropRect));
this->drawClippedBitmap(canvas, 400, 300, paint);
// Test for negative scale.
paint.setImageFilter(SkDisplacementMapEffect::Create(
paint.setImageFilter(SkDisplacementMapEffect::Make(
SkDisplacementMapEffect::kG_ChannelSelectorType,
SkDisplacementMapEffect::kA_ChannelSelectorType,
-40.0f, displ.get()))->unref();
-40.0f, displ, nullptr));
this->drawClippedBitmap(canvas, 500, 0, paint);
// Tests for images of different sizes
displ = SkImageSource::Make(fSmall);
paint.setImageFilter(SkDisplacementMapEffect::Create(
paint.setImageFilter(SkDisplacementMapEffect::Make(
SkDisplacementMapEffect::kR_ChannelSelectorType,
SkDisplacementMapEffect::kG_ChannelSelectorType,
40.0f, displ.get()))->unref();
drawClippedBitmap(canvas, 0, 400, paint);
40.0f, std::move(displ), nullptr));
this->drawClippedBitmap(canvas, 0, 400, paint);
displ = SkImageSource::Make(fLarge);
paint.setImageFilter(SkDisplacementMapEffect::Create(
paint.setImageFilter(SkDisplacementMapEffect::Make(
SkDisplacementMapEffect::kB_ChannelSelectorType,
SkDisplacementMapEffect::kA_ChannelSelectorType,
40.0f, displ.get()))->unref();
drawClippedBitmap(canvas, 100, 400, paint);
40.0f, std::move(displ), nullptr));
this->drawClippedBitmap(canvas, 100, 400, paint);
displ = SkImageSource::Make(fLargeW);
paint.setImageFilter(SkDisplacementMapEffect::Create(
paint.setImageFilter(SkDisplacementMapEffect::Make(
SkDisplacementMapEffect::kR_ChannelSelectorType,
SkDisplacementMapEffect::kB_ChannelSelectorType,
40.0f, displ.get()))->unref();
drawClippedBitmap(canvas, 200, 400, paint);
40.0f, std::move(displ), nullptr));
this->drawClippedBitmap(canvas, 200, 400, paint);
displ = SkImageSource::Make(fLargeH);
paint.setImageFilter(SkDisplacementMapEffect::Create(
paint.setImageFilter(SkDisplacementMapEffect::Make(
SkDisplacementMapEffect::kG_ChannelSelectorType,
SkDisplacementMapEffect::kA_ChannelSelectorType,
40.0f, displ.get()))->unref();
drawClippedBitmap(canvas, 300, 400, paint);
40.0f, std::move(displ), nullptr));
this->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::Create(
paint.setImageFilter(SkDisplacementMapEffect::Make(
SkDisplacementMapEffect::kG_ChannelSelectorType,
SkDisplacementMapEffect::kA_ChannelSelectorType,
40.0f, nullptr))->unref();
drawClippedBitmap(canvas, 400, 400, paint);
40.0f, nullptr, nullptr));
this->drawClippedBitmap(canvas, 400, 400, paint);
}
private:

View File

@ -100,12 +100,11 @@ protected:
SkIntToScalar(3), SkIntToScalar(3), SK_ColorGREEN,
SkDropShadowImageFilter::kDrawShadowAndForeground_ShadowMode,
nullptr),
sk_sp<SkImageFilter>(SkDisplacementMapEffect::Create(
SkDisplacementMapEffect::kR_ChannelSelectorType,
SkDisplacementMapEffect::kR_ChannelSelectorType,
SkIntToScalar(12),
gradient.get(),
checkerboard.get())),
SkDisplacementMapEffect::Make(SkDisplacementMapEffect::kR_ChannelSelectorType,
SkDisplacementMapEffect::kR_ChannelSelectorType,
SkIntToScalar(12),
std::move(gradient),
checkerboard),
SkDilateImageFilter::Make(2, 2, checkerboard),
SkErodeImageFilter::Make(2, 2, checkerboard),
SkOffsetImageFilter::Make(SkIntToScalar(-16), SkIntToScalar(32), nullptr),

View File

@ -107,13 +107,12 @@ protected:
&bigRect));
Draw(canvas, checkerboard, rect,
sk_sp<SkImageFilter>(SkDisplacementMapEffect::Create(
SkDisplacementMapEffect::kR_ChannelSelectorType,
SkDisplacementMapEffect::kR_ChannelSelectorType,
SkIntToScalar(12),
gradientCircleSource.get(),
noopCropped.get(),
&bigRect)));
SkDisplacementMapEffect::Make(SkDisplacementMapEffect::kR_ChannelSelectorType,
SkDisplacementMapEffect::kR_ChannelSelectorType,
SkIntToScalar(12),
std::move(gradientCircleSource),
noopCropped,
&bigRect));
Draw(canvas, checkerboard, rect,
SkOffsetImageFilter::Make(SkIntToScalar(-8), SkIntToScalar(16),

View File

@ -98,12 +98,11 @@ protected:
SkIntToScalar(3), SkIntToScalar(3), SK_ColorYELLOW,
SkDropShadowImageFilter::kDrawShadowAndForeground_ShadowMode,
nullptr),
sk_sp<SkImageFilter>(SkDisplacementMapEffect::Create(
SkDisplacementMapEffect::kR_ChannelSelectorType,
SkDisplacementMapEffect::kR_ChannelSelectorType,
SkIntToScalar(12),
gradient.get(),
checkerboard.get())),
SkDisplacementMapEffect::Make(SkDisplacementMapEffect::kR_ChannelSelectorType,
SkDisplacementMapEffect::kR_ChannelSelectorType,
SkIntToScalar(12),
std::move(gradient),
checkerboard),
SkDilateImageFilter::Make(1, 1, checkerboard),
SkErodeImageFilter::Make(1, 1, checkerboard),
SkOffsetImageFilter::Make(SkIntToScalar(32), 0, nullptr),

View File

@ -69,12 +69,11 @@ protected:
SkBlurImageFilter::Make(12, 0, nullptr),
SkDropShadowImageFilter::Make(0, 15, 8, 0, SK_ColorGREEN,
SkDropShadowImageFilter::kDrawShadowAndForeground_ShadowMode, nullptr),
sk_sp<SkImageFilter>(SkDisplacementMapEffect::Create(
SkDisplacementMapEffect::kR_ChannelSelectorType,
SkDisplacementMapEffect::kR_ChannelSelectorType,
12,
gradient.get(),
checkerboard.get())),
SkDisplacementMapEffect::Make(SkDisplacementMapEffect::kR_ChannelSelectorType,
SkDisplacementMapEffect::kR_ChannelSelectorType,
12,
std::move(gradient),
checkerboard),
SkDilateImageFilter::Make(2, 2, checkerboard),
SkErodeImageFilter::Make(2, 2, checkerboard),
};

View File

@ -20,13 +20,14 @@ public:
kA_ChannelSelectorType
};
~SkDisplacementMapEffect();
~SkDisplacementMapEffect() override;
static SkImageFilter* Create(ChannelSelectorType xChannelSelector,
ChannelSelectorType yChannelSelector,
SkScalar scale, SkImageFilter* displacement,
SkImageFilter* color = NULL,
const CropRect* cropRect = NULL);
static sk_sp<SkImageFilter> Make(ChannelSelectorType xChannelSelector,
ChannelSelectorType yChannelSelector,
SkScalar scale,
sk_sp<SkImageFilter> displacement,
sk_sp<SkImageFilter> color,
const CropRect* cropRect = nullptr);
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDisplacementMapEffect)
@ -38,13 +39,26 @@ 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, SkImageFilter* inputs[2],
SkScalar scale, sk_sp<SkImageFilter> inputs[2],
const CropRect* cropRect);
void flatten(SkWriteBuffer&) const override;

View File

@ -709,17 +709,13 @@ static sk_sp<SkImageFilter> make_image_filter(bool canBeNull) {
}
break;
}
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()));
case DISPLACE:
filter = SkDisplacementMapEffect::Make(make_channel_selector_type(),
make_channel_selector_type(),
make_scalar(),
make_image_filter(false),
make_image_filter());
break;
}
case TILE: {
sk_sp<SkImageFilter> subFilter(make_image_filter(false));

View File

@ -163,27 +163,29 @@ bool channel_selector_type_is_valid(SkDisplacementMapEffect::ChannelSelectorType
///////////////////////////////////////////////////////////////////////////////
SkImageFilter* SkDisplacementMapEffect::Create(ChannelSelectorType xChannelSelector,
ChannelSelectorType yChannelSelector,
SkScalar scale,
SkImageFilter* displacement,
SkImageFilter* color,
const CropRect* cropRect) {
sk_sp<SkImageFilter> SkDisplacementMapEffect::Make(ChannelSelectorType xChannelSelector,
ChannelSelectorType yChannelSelector,
SkScalar scale,
sk_sp<SkImageFilter> displacement,
sk_sp<SkImageFilter> color,
const CropRect* cropRect) {
if (!channel_selector_type_is_valid(xChannelSelector) ||
!channel_selector_type_is_valid(yChannelSelector)) {
return nullptr;
}
SkImageFilter* inputs[2] = { displacement, color };
return new SkDisplacementMapEffect(xChannelSelector, yChannelSelector, scale, inputs, cropRect);
sk_sp<SkImageFilter> inputs[2] = { std::move(displacement), std::move(color) };
return sk_sp<SkImageFilter>(new SkDisplacementMapEffect(xChannelSelector,
yChannelSelector,
scale, inputs, cropRect));
}
SkDisplacementMapEffect::SkDisplacementMapEffect(ChannelSelectorType xChannelSelector,
ChannelSelectorType yChannelSelector,
SkScalar scale,
SkImageFilter* inputs[2],
sk_sp<SkImageFilter> inputs[2],
const CropRect* cropRect)
: INHERITED(2, inputs, cropRect)
: INHERITED(inputs, 2, cropRect)
, fXChannelSelector(xChannelSelector)
, fYChannelSelector(yChannelSelector)
, fScale(scale) {
@ -197,8 +199,9 @@ sk_sp<SkFlattenable> SkDisplacementMapEffect::CreateProc(SkReadBuffer& buffer) {
ChannelSelectorType xsel = (ChannelSelectorType)buffer.readInt();
ChannelSelectorType ysel = (ChannelSelectorType)buffer.readInt();
SkScalar scale = buffer.readScalar();
return sk_sp<SkFlattenable>(Create(xsel, ysel, scale, common.getInput(0).get(),
common.getInput(1).get(), &common.cropRect()));
return Make(xsel, ysel, scale,
common.getInput(0), common.getInput(1),
&common.cropRect());
}
void SkDisplacementMapEffect::flatten(SkWriteBuffer& buffer) const {

View File

@ -160,10 +160,10 @@ public:
sk_sp<SkImageFilter> gradientSource(SkImageSource::Make(std::move(gradientImage)));
this->addFilter("displacement map",
sk_sp<SkImageFilter>(SkDisplacementMapEffect::Create(
SkDisplacementMapEffect::kR_ChannelSelectorType,
SkDisplacementMapEffect::kB_ChannelSelectorType,
20.0f, gradientSource.get(), input.get(), cropRect)));
SkDisplacementMapEffect::Make(SkDisplacementMapEffect::kR_ChannelSelectorType,
SkDisplacementMapEffect::kB_ChannelSelectorType,
20.0f,
std::move(gradientSource), input, cropRect));
}
this->addFilter("blur", SkBlurImageFilter::Make(SK_Scalar1,