}
protected:
- virtual const char* onGetName() {
+ const char* onGetName() override {
return fName.c_str();
}
- virtual void onDraw(int loops, SkCanvas* canvas) {
+ void onDraw(int loops, SkCanvas* canvas) override {
SkPaint paint;
this->setupPaint(&paint);
r.offset(fRadius, fRadius);
if (fRadius > 0) {
- SkImageFilter* mf = nullptr;
+ sk_sp<SkImageFilter> mf;
switch (fStyle) {
case kDilate_MT:
- mf = SkDilateImageFilter::Create(SkScalarFloorToInt(fRadius),
- SkScalarFloorToInt(fRadius));
+ mf = SkDilateImageFilter::Make(SkScalarFloorToInt(fRadius),
+ SkScalarFloorToInt(fRadius),
+ nullptr);
break;
case kErode_MT:
- mf = SkErodeImageFilter::Create(SkScalarFloorToInt(fRadius),
- SkScalarFloorToInt(fRadius));
+ mf = SkErodeImageFilter::Make(SkScalarFloorToInt(fRadius),
+ SkScalarFloorToInt(fRadius),
+ nullptr);
break;
}
- paint.setImageFilter(mf)->unref();
+ paint.setImageFilter(std::move(mf));
}
canvas->drawOval(r, paint);
}
DEF_SIMPLE_GM(savelayer_with_backdrop, canvas, 830, 550) {
SkColorMatrix cm;
cm.setSaturation(10);
- auto cf(SkColorFilter::MakeMatrixFilterRowMajor255(cm.fMat));
+ sk_sp<SkColorFilter> cf(SkColorFilter::MakeMatrixFilterRowMajor255(cm.fMat));
const SkScalar kernel[] = { 4, 0, 4, 0, -15, 0, 4, 0, 4 };
SkImageFilter* filters[] = {
SkBlurImageFilter::Make(10, 10, nullptr).release(),
- SkDilateImageFilter::Create(8, 8),
+ SkDilateImageFilter::Make(8, 8, nullptr).release(),
SkMatrixConvolutionImageFilter::Create({ 3, 3 }, kernel, 1, 0, { 0, 0 },
SkMatrixConvolutionImageFilter::kClampToBlack_TileMode,
true),
SkIntToScalar(12),
gradient.get(),
checkerboard.get()),
- SkDilateImageFilter::Create(2, 2, checkerboard.get()),
- SkErodeImageFilter::Create(2, 2, checkerboard.get()),
- SkOffsetImageFilter::Make(SkIntToScalar(-16),
- SkIntToScalar(32),
- nullptr).release(),
+ SkDilateImageFilter::Make(2, 2, checkerboard).release(),
+ SkErodeImageFilter::Make(2, 2, checkerboard).release(),
+ SkOffsetImageFilter::Make(SkIntToScalar(-16), SkIntToScalar(32), nullptr).release(),
SkImageFilter::CreateMatrixFilter(resizeMatrix, kNone_SkFilterQuality),
SkLightingImageFilter::CreatePointLitDiffuse(pointLocation, SK_ColorWHITE, SK_Scalar1,
SkIntToScalar(2), checkerboard.get()),
noopCropped,
&bigRect));
- Draw(canvas, checkerboard, rect,
- sk_sp<SkImageFilter>(SkDilateImageFilter::Create(2, 2,
- noopCropped.get(),
- &bigRect)));
+ Draw(canvas, checkerboard, rect, SkDilateImageFilter::Make(2, 2,
+ noopCropped,
+ &bigRect));
- Draw(canvas, checkerboard, rect,
- sk_sp<SkImageFilter>(SkErodeImageFilter::Create(2, 2,
- noopCropped.get(),
- &bigRect)));
+ Draw(canvas, checkerboard, rect, SkErodeImageFilter::Make(2, 2,
+ noopCropped,
+ &bigRect));
Draw(canvas, checkerboard, rect,
sk_sp<SkImageFilter>(SkDropShadowImageFilter::Create(
///////////////////////////////////////////////////////////////////////////////
-static void draw_paint(SkCanvas* canvas, const SkRect& r, SkImageFilter* imf) {
+static void draw_paint(SkCanvas* canvas, const SkRect& r, sk_sp<SkImageFilter> imf) {
SkPaint paint;
- paint.setImageFilter(imf);
+ paint.setImageFilter(std::move(imf));
paint.setColor(SK_ColorBLACK);
canvas->save();
canvas->clipRect(r);
canvas->restore();
}
-static void draw_path(SkCanvas* canvas, const SkRect& r, SkImageFilter* imf) {
+static void draw_path(SkCanvas* canvas, const SkRect& r, sk_sp<SkImageFilter> imf) {
SkPaint paint;
paint.setColor(SK_ColorMAGENTA);
- paint.setImageFilter(imf);
+ paint.setImageFilter(std::move(imf));
paint.setAntiAlias(true);
canvas->drawCircle(r.centerX(), r.centerY(), r.width()*2/5, paint);
}
-static void draw_text(SkCanvas* canvas, const SkRect& r, SkImageFilter* imf) {
+static void draw_text(SkCanvas* canvas, const SkRect& r, sk_sp<SkImageFilter> imf) {
SkPaint paint;
- paint.setImageFilter(imf);
+ paint.setImageFilter(std::move(imf));
paint.setColor(SK_ColorGREEN);
paint.setAntiAlias(true);
sk_tool_utils::set_portable_typeface(&paint);
canvas->drawText("Text", 4, r.centerX(), r.centerY(), paint);
}
-static void draw_bitmap(SkCanvas* canvas, const SkRect& r, SkImageFilter* imf) {
+static void draw_bitmap(SkCanvas* canvas, const SkRect& r, sk_sp<SkImageFilter> imf) {
SkPaint paint;
SkIRect bounds;
SkCanvas c(bm);
draw_path(&c, r, nullptr);
- paint.setImageFilter(imf);
+ paint.setImageFilter(std::move(imf));
canvas->drawBitmap(bm, 0, 0, &paint);
}
}
virtual void onDraw(SkCanvas* canvas) override {
- void (*drawProc[])(SkCanvas*, const SkRect&, SkImageFilter*) = {
+ void (*drawProc[])(SkCanvas*, const SkRect&, sk_sp<SkImageFilter>) = {
draw_bitmap, draw_path, draw_paint, draw_text
};
- auto cf(SkColorFilter::MakeModeFilter(SK_ColorBLUE, SkXfermode::kSrcIn_Mode));
- SkImageFilter::CropRect cropRect(SkRect::Make(SkIRect::MakeXYWH(10, 10, 44, 44)), SkImageFilter::CropRect::kHasAll_CropEdge);
- SkImageFilter::CropRect bogusRect(SkRect::Make(SkIRect::MakeXYWH(-100, -100, 10, 10)), SkImageFilter::CropRect::kHasAll_CropEdge);
+ sk_sp<SkColorFilter> cf(SkColorFilter::MakeModeFilter(SK_ColorBLUE,
+ SkXfermode::kSrcIn_Mode));
+ SkImageFilter::CropRect cropRect(SkRect::Make(SkIRect::MakeXYWH(10, 10, 44, 44)),
+ SkImageFilter::CropRect::kHasAll_CropEdge);
+ SkImageFilter::CropRect bogusRect(SkRect::Make(SkIRect::MakeXYWH(-100, -100, 10, 10)),
+ SkImageFilter::CropRect::kHasAll_CropEdge);
sk_sp<SkImageFilter> offset(SkOffsetImageFilter::Make(SkIntToScalar(-10),
SkIntToScalar(-10),
sk_sp<SkImageFilter> cfOffset(SkColorFilterImageFilter::Create(cf.get(), offset.get()));
- SkAutoTUnref<SkImageFilter> erodeX(SkErodeImageFilter::Create(8, 0, nullptr, &cropRect));
- SkAutoTUnref<SkImageFilter> erodeY(SkErodeImageFilter::Create(0, 8, nullptr, &cropRect));
+ sk_sp<SkImageFilter> erodeX(SkErodeImageFilter::Make(8, 0, nullptr, &cropRect));
+ sk_sp<SkImageFilter> erodeY(SkErodeImageFilter::Make(0, 8, nullptr, &cropRect));
- SkImageFilter* filters[] = {
+ sk_sp<SkImageFilter> filters[] = {
nullptr,
- SkColorFilterImageFilter::Create(cf.get(), nullptr, &cropRect),
- SkBlurImageFilter::Make(0.0f, 0.0f, nullptr, &cropRect).release(),
- SkBlurImageFilter::Make(1.0f, 1.0f, nullptr, &cropRect).release(),
- SkBlurImageFilter::Make(8.0f, 0.0f, nullptr, &cropRect).release(),
- SkBlurImageFilter::Make(0.0f, 8.0f, nullptr, &cropRect).release(),
- SkBlurImageFilter::Make(8.0f, 8.0f, nullptr, &cropRect).release(),
- SkErodeImageFilter::Create(1, 1, nullptr, &cropRect),
- SkErodeImageFilter::Create(8, 0, erodeY, &cropRect),
- SkErodeImageFilter::Create(0, 8, erodeX, &cropRect),
- SkErodeImageFilter::Create(8, 8, nullptr, &cropRect),
- SkMergeImageFilter::Make(nullptr, std::move(cfOffset),
- SkXfermode::kSrcOver_Mode, &cropRect).release(),
- SkBlurImageFilter::Make(8.0f, 8.0f, nullptr, &bogusRect).release(),
- SkColorFilterImageFilter::Create(cf.get(), nullptr, &bogusRect),
+ sk_sp<SkImageFilter>(SkColorFilterImageFilter::Create(cf.get(), nullptr, &cropRect)),
+ SkBlurImageFilter::Make(0.0f, 0.0f, nullptr, &cropRect),
+ SkBlurImageFilter::Make(1.0f, 1.0f, nullptr, &cropRect),
+ SkBlurImageFilter::Make(8.0f, 0.0f, nullptr, &cropRect),
+ SkBlurImageFilter::Make(0.0f, 8.0f, nullptr, &cropRect),
+ SkBlurImageFilter::Make(8.0f, 8.0f, nullptr, &cropRect),
+ SkErodeImageFilter::Make(1, 1, nullptr, &cropRect),
+ SkErodeImageFilter::Make(8, 0, std::move(erodeY), &cropRect),
+ SkErodeImageFilter::Make(0, 8, std::move(erodeX), &cropRect),
+ SkErodeImageFilter::Make(8, 8, nullptr, &cropRect),
+ SkMergeImageFilter::Make(nullptr,
+ std::move(cfOffset),
+ SkXfermode::kSrcOver_Mode,
+ &cropRect),
+ SkBlurImageFilter::Make(8.0f, 8.0f, nullptr, &bogusRect),
+ sk_sp<SkImageFilter>(SkColorFilterImageFilter::Create(cf.get(), nullptr, &bogusRect)),
};
SkRect r = SkRect::MakeWH(SkIntToScalar(64), SkIntToScalar(64));
canvas->restore();
canvas->translate(DX, 0);
}
-
- for(size_t j = 0; j < SK_ARRAY_COUNT(filters); ++j) {
- SkSafeUnref(filters[j]);
- }
}
private:
sk_sp<SkColorFilter> cf(SkColorFilter::MakeModeFilter(SK_ColorRED,
SkXfermode::kSrcIn_Mode));
sk_sp<SkImageFilter> blur(SkBlurImageFilter::Make(4.0f, 4.0f, std::move(bitmapSource)));
- sk_sp<SkImageFilter> erode(SkErodeImageFilter::Create(4, 4, blur.get()));
+ sk_sp<SkImageFilter> erode(SkErodeImageFilter::Make(4, 4, blur));
sk_sp<SkImageFilter> color(SkColorFilterImageFilter::Create(cf.get(), erode.get()));
sk_sp<SkImageFilter> merge(SkMergeImageFilter::Make(blur, color));
canvas->translate(SkIntToScalar(100), 0);
}
{
- sk_sp<SkImageFilter> morph(SkDilateImageFilter::Create(5, 5));
+ sk_sp<SkImageFilter> morph(SkDilateImageFilter::Make(5, 5, nullptr));
SkScalar matrix[20] = { SK_Scalar1, 0, 0, 0, 0,
0, SK_Scalar1, 0, 0, 0,
// This tests that a filter using asFragmentProcessor (matrix
// convolution) correctly handles a non-zero source offset
// (supplied by the dilate).
- SkAutoTUnref<SkImageFilter> dilate(SkDilateImageFilter::Create(5, 5));
+ sk_sp<SkImageFilter> dilate(SkDilateImageFilter::Make(5, 5, nullptr));
SkScalar kernel[9] = {
SkIntToScalar(-1), SkIntToScalar( -1 ), SkIntToScalar(-1),
SkIPoint kernelOffset = SkIPoint::Make(1, 1);
auto tileMode = SkMatrixConvolutionImageFilter::kClamp_TileMode;
bool convolveAlpha = false;
- SkAutoTUnref<SkImageFilter> convolve(
+ sk_sp<SkImageFilter> convolve(
SkMatrixConvolutionImageFilter::Create(kernelSize,
kernel,
gain,
kernelOffset,
tileMode,
convolveAlpha,
- dilate));
+ dilate.get()));
SkPaint paint;
- paint.setImageFilter(convolve);
+ paint.setImageFilter(std::move(convolve));
DrawClippedImage(canvas, fImage.get(), paint);
canvas->translate(SkIntToScalar(100), 0);
}
SkIntToScalar(80), SkIntToScalar(80)));
SkImageFilter::CropRect innerRect(SkRect::MakeXYWH(SkIntToScalar(20), SkIntToScalar(20),
SkIntToScalar(60), SkIntToScalar(60)));
- SkAutoTUnref<SkImageFilter> color1(SkColorFilterImageFilter::Create(cf1.get(), nullptr, &outerRect));
- SkAutoTUnref<SkImageFilter> color2(SkColorFilterImageFilter::Create(cf2.get(), color1, &innerRect));
+ sk_sp<SkImageFilter> color1(SkColorFilterImageFilter::Create(cf1.get(),
+ nullptr,
+ &outerRect));
+ sk_sp<SkImageFilter> color2(SkColorFilterImageFilter::Create(cf2.get(),
+ color1.get(),
+ &innerRect));
SkPaint paint;
- paint.setImageFilter(color2);
+ paint.setImageFilter(std::move(color2));
paint.setColor(SK_ColorRED);
canvas->drawRect(SkRect::MakeXYWH(0, 0, 100, 100), paint);
canvas->translate(SkIntToScalar(100), 0);
SkIntToScalar(12),
gradient.get(),
checkerboard.get()),
- SkDilateImageFilter::Create(1, 1, checkerboard.get()),
- SkErodeImageFilter::Create(1, 1, checkerboard.get()),
+ SkDilateImageFilter::Make(1, 1, checkerboard).release(),
+ SkErodeImageFilter::Make(1, 1, checkerboard).release(),
SkOffsetImageFilter::Make(SkIntToScalar(32), 0, nullptr).release(),
SkImageFilter::CreateMatrixFilter(resizeMatrix, kNone_SkFilterQuality),
SkPaintImageFilter::Make(noisePaint).release(),
12,
gradient.get(),
checkerboard.get()),
- SkDilateImageFilter::Create(2, 2, checkerboard.get()),
- SkErodeImageFilter::Create(2, 2, checkerboard.get()),
+ SkDilateImageFilter::Make(2, 2, checkerboard).release(),
+ SkErodeImageFilter::Make(2, 2, checkerboard).release(),
};
const SkScalar margin = SkIntToScalar(20);
return surface->makeImageSnapshot();
}
-typedef SkImageFilter* (*ImageFilterFactory)();
+typedef sk_sp<SkImageFilter> (*ImageFilterFactory)();
// +[]{...} did not work on windows (VS)
// (ImageFilterFactory)[]{...} did not work on linux (gcc)
sk_sp<SkImage> image0(make_image(canvas));
const ImageFilterFactory factories[] = {
- IFCCast([]{ return SkBlurImageFilter::Make(8, 8, nullptr).release(); }),
- IFCCast([]{ return SkDilateImageFilter::Create(8, 8); }),
- IFCCast([]{ return SkErodeImageFilter::Create(8, 8); }),
- IFCCast([]{ return SkOffsetImageFilter::Make(8, 8, nullptr).release(); }),
+ IFCCast([]{ return SkBlurImageFilter::Make(8, 8, nullptr); }),
+ IFCCast([]{ return SkDilateImageFilter::Make(8, 8, nullptr); }),
+ IFCCast([]{ return SkErodeImageFilter::Make(8, 8, nullptr); }),
+ IFCCast([]{ return SkOffsetImageFilter::Make(8, 8, nullptr); }),
};
const SkMatrix matrices[] = {
for (unsigned i = 0; i < SK_ARRAY_COUNT(samples); ++i) {
const SkImageFilter::CropRect* cr = j & 0x02 ? &cropRect : nullptr;
if (j & 0x01) {
- paint.setImageFilter(SkErodeImageFilter::Create(
- samples[i].fRadiusX,
- samples[i].fRadiusY,
- nullptr,
- cr))->unref();
+ paint.setImageFilter(SkErodeImageFilter::Make(samples[i].fRadiusX,
+ samples[i].fRadiusY,
+ nullptr,
+ cr));
} else {
- paint.setImageFilter(SkDilateImageFilter::Create(
- samples[i].fRadiusX,
- samples[i].fRadiusY,
- nullptr,
- cr))->unref();
+ paint.setImageFilter(SkDilateImageFilter::Make(samples[i].fRadiusX,
+ samples[i].fRadiusY,
+ nullptr,
+ cr));
}
this->drawClippedBitmap(canvas, paint, i * 140, j * 140);
}
virtual Op op() const = 0;
- SkMorphologyImageFilter(int radiusX, int radiusY, SkImageFilter* input,
+ SkMorphologyImageFilter(int radiusX, int radiusY,
+ sk_sp<SkImageFilter> input,
const CropRect* cropRect);
sk_sp<SkSpecialImage> onFilterImage(SkSpecialImage* source,
const Context&,
///////////////////////////////////////////////////////////////////////////////
class SK_API SkDilateImageFilter : public SkMorphologyImageFilter {
public:
- static SkImageFilter* Create(int radiusX, int radiusY,
- SkImageFilter* input = nullptr,
- const CropRect* cropRect = nullptr) {
+ static sk_sp<SkImageFilter> Make(int radiusX, int radiusY,
+ sk_sp<SkImageFilter> input,
+ const CropRect* cropRect = nullptr) {
if (radiusX < 0 || radiusY < 0) {
return nullptr;
}
- return new SkDilateImageFilter(radiusX, radiusY, input, cropRect);
+ return sk_sp<SkImageFilter>(new SkDilateImageFilter(radiusX, radiusY,
+ std::move(input),
+ cropRect));
}
SK_TO_STRING_OVERRIDE()
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDilateImageFilter)
+#ifdef SK_SUPPORT_LEGACY_IMAGEFILTER_PTR
+ static SkImageFilter* Create(int radiusX, int radiusY,
+ SkImageFilter* input = nullptr,
+ const CropRect* cropRect = nullptr) {
+ return Make(radiusX, radiusY,
+ sk_ref_sp<SkImageFilter>(input),
+ cropRect).release();
+ }
+#endif
+
protected:
Op op() const override { return kDilate_Op; }
private:
- SkDilateImageFilter(int radiusX, int radiusY, SkImageFilter* input, const CropRect* cropRect)
+ SkDilateImageFilter(int radiusX, int radiusY,
+ sk_sp<SkImageFilter> input,
+ const CropRect* cropRect)
: INHERITED(radiusX, radiusY, input, cropRect) {}
typedef SkMorphologyImageFilter INHERITED;
///////////////////////////////////////////////////////////////////////////////
class SK_API SkErodeImageFilter : public SkMorphologyImageFilter {
public:
- static SkImageFilter* Create(int radiusX, int radiusY,
- SkImageFilter* input = nullptr,
- const CropRect* cropRect = nullptr) {
+ static sk_sp<SkImageFilter> Make(int radiusX, int radiusY,
+ sk_sp<SkImageFilter> input,
+ const CropRect* cropRect = nullptr) {
if (radiusX < 0 || radiusY < 0) {
return nullptr;
}
- return new SkErodeImageFilter(radiusX, radiusY, input, cropRect);
+ return sk_sp<SkImageFilter>(new SkErodeImageFilter(radiusX, radiusY,
+ std::move(input),
+ cropRect));
}
SK_TO_STRING_OVERRIDE()
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkErodeImageFilter)
+#ifdef SK_SUPPORT_LEGACY_IMAGEFILTER_PTR
+ static SkImageFilter* Create(int radiusX, int radiusY,
+ SkImageFilter* input = nullptr,
+ const CropRect* cropRect = nullptr) {
+ return Make(radiusX, radiusY,
+ sk_ref_sp<SkImageFilter>(input),
+ cropRect).release();
+ }
+#endif
+
protected:
Op op() const override { return kErode_Op; }
private:
- SkErodeImageFilter(int radiusX, int radiusY, SkImageFilter* input, const CropRect* cropRect)
+ SkErodeImageFilter(int radiusX, int radiusY,
+ sk_sp<SkImageFilter> input, const CropRect* cropRect)
: INHERITED(radiusX, radiusY, input, cropRect) {}
typedef SkMorphologyImageFilter INHERITED;
nullptr));
break;
}
- case MORPHOLOGY: {
- sk_sp<SkImageFilter> subFilter(make_image_filter());
-
+ case MORPHOLOGY:
if (R(2) == 1) {
- filter = sk_sp<SkImageFilter>(SkDilateImageFilter::Create(R(static_cast<float>(kBitmapSize)),
- R(static_cast<float>(kBitmapSize)),
- subFilter.get()));
+ filter = SkDilateImageFilter::Make(R(static_cast<float>(kBitmapSize)),
+ R(static_cast<float>(kBitmapSize)),
+ make_image_filter());
} else {
- filter = sk_sp<SkImageFilter>(SkErodeImageFilter::Create(R(static_cast<float>(kBitmapSize)),
- R(static_cast<float>(kBitmapSize)),
- subFilter.get()));
+ filter = SkErodeImageFilter::Make(R(static_cast<float>(kBitmapSize)),
+ R(static_cast<float>(kBitmapSize)),
+ make_image_filter());
}
break;
- }
case BITMAP: {
sk_sp<SkImage> image(SkImage::MakeFromBitmap(make_bitmap()));
if (R(2) == 1) {
SkPoint fCenter;
SkScalar fAngle;
sk_sp<SkImage> fImage;
- SkAutoTUnref<SkImageFilter> fFilter;
+ sk_sp<SkImageFilter> fFilter;
public:
BackdropView() {
fCenter.set(200, 150);
fAngle = 0;
fImage = GetResourceAsImage("mandrill_512.png");
- fFilter.reset(SkDilateImageFilter::Create(8, 8));
+ fFilter = SkDilateImageFilter::Make(8, 8, nullptr);
}
protected:
SkPaint paint;
paint.setAlpha(0xCC);
- canvas->saveLayer({ &bounds, &paint, fFilter, 0 });
+ canvas->saveLayer({ &bounds, &paint, fFilter.get(), 0 });
canvas->restore();
}
SkMorphologyImageFilter::SkMorphologyImageFilter(int radiusX,
int radiusY,
- SkImageFilter* input,
+ sk_sp<SkImageFilter> input,
const CropRect* cropRect)
- : INHERITED(1, &input, cropRect)
+ : INHERITED(&input, 1, cropRect)
, fRadius(SkISize::Make(radiusX, radiusY)) {
}
SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1);
const int width = buffer.readInt();
const int height = buffer.readInt();
- return sk_sp<SkFlattenable>(Create(width, height, common.getInput(0).get(),
- &common.cropRect()));
+ return Make(width, height, common.getInput(0), &common.cropRect());
}
sk_sp<SkFlattenable> SkDilateImageFilter::CreateProc(SkReadBuffer& buffer) {
SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1);
const int width = buffer.readInt();
const int height = buffer.readInt();
- return sk_sp<SkFlattenable>(Create(width, height, common.getInput(0).get(),
- &common.cropRect()));
+ return Make(width, height, common.getInput(0), &common.cropRect());
}
#ifndef SK_IGNORE_TO_STRING
class FilterList {
public:
- FilterList(SkImageFilter* input = nullptr, const SkImageFilter::CropRect* cropRect = nullptr) {
+ FilterList(sk_sp<SkImageFilter> input, const SkImageFilter::CropRect* cropRect = nullptr) {
SkPoint3 location = SkPoint3::Make(0, 0, SK_Scalar1);
SkScalar kernel[9] = {
SkIntToScalar( 1), SkIntToScalar( 1), SkIntToScalar( 1),
SkXfermode::kSrcIn_Mode));
this->addFilter("color filter",
- SkColorFilterImageFilter::Create(cf.get(), input, cropRect));
+ SkColorFilterImageFilter::Create(cf.get(), input.get(), cropRect));
}
{
this->addFilter("displacement map", SkDisplacementMapEffect::Create(
SkDisplacementMapEffect::kR_ChannelSelectorType,
SkDisplacementMapEffect::kB_ChannelSelectorType,
- 20.0f, gradientSource.get(), input, cropRect));
+ 20.0f, gradientSource.get(), input.get(), cropRect));
}
this->addFilter("blur", SkBlurImageFilter::Make(SK_Scalar1,
SK_Scalar1,
- sk_ref_sp<SkImageFilter>(input),
+ input,
cropRect).release());
this->addFilter("drop shadow", SkDropShadowImageFilter::Create(
SK_Scalar1, SK_Scalar1, SK_Scalar1, SK_Scalar1, SK_ColorGREEN,
- SkDropShadowImageFilter::kDrawShadowAndForeground_ShadowMode, input, cropRect));
+ SkDropShadowImageFilter::kDrawShadowAndForeground_ShadowMode,
+ input.get(), cropRect));
this->addFilter("diffuse lighting", SkLightingImageFilter::CreatePointLitDiffuse(
- location, SK_ColorGREEN, 0, 0, input, cropRect));
+ location, SK_ColorGREEN, 0, 0, input.get(), cropRect));
this->addFilter("specular lighting",
SkLightingImageFilter::CreatePointLitSpecular(location, SK_ColorGREEN, 0, 0, 0,
- input, cropRect));
+ input.get(), cropRect));
this->addFilter("matrix convolution",
SkMatrixConvolutionImageFilter::Create(
kernelSize, kernel, gain, bias, SkIPoint::Make(1, 1),
- SkMatrixConvolutionImageFilter::kRepeat_TileMode, false, input, cropRect));
- this->addFilter("merge", SkMergeImageFilter::Make(sk_ref_sp<SkImageFilter>(input),
- sk_ref_sp<SkImageFilter>(input),
+ SkMatrixConvolutionImageFilter::kRepeat_TileMode, false,
+ input.get(), cropRect));
+ this->addFilter("merge", SkMergeImageFilter::Make(input, input,
SkXfermode::kSrcOver_Mode,
cropRect).release());
{
}
this->addFilter("offset",
- SkOffsetImageFilter::Make(SK_Scalar1, SK_Scalar1,
- sk_ref_sp<SkImageFilter>(input),
+ SkOffsetImageFilter::Make(SK_Scalar1, SK_Scalar1, input,
cropRect).release());
- this->addFilter("dilate", SkDilateImageFilter::Create(3, 2, input, cropRect));
- this->addFilter("erode", SkErodeImageFilter::Create(2, 3, input, cropRect));
+ this->addFilter("dilate", SkDilateImageFilter::Make(3, 2, input, cropRect).release());
+ this->addFilter("erode", SkErodeImageFilter::Make(2, 3, input, cropRect).release());
this->addFilter("tile", SkTileImageFilter::Create(
SkRect::MakeXYWH(0, 0, 50, 50),
cropRect ? cropRect->rect() : SkRect::MakeXYWH(0, 0, 100, 100),
- input));
+ input.get()));
if (!cropRect) {
this->addFilter("matrix", SkImageFilter::CreateMatrixFilter(
- matrix, kLow_SkFilterQuality, input));
+ matrix, kLow_SkFilterQuality, input.get()));
}
{
- sk_sp<SkImageFilter> blur(SkBlurImageFilter::Make(five, five,
- sk_ref_sp<SkImageFilter>(input)));
+ sk_sp<SkImageFilter> blur(SkBlurImageFilter::Make(five, five, input));
this->addFilter("blur and offset", SkOffsetImageFilter::Make(five, five,
std::move(blur),
cropRect).release());
}
this->addFilter("xfermode", SkXfermodeImageFilter::Make(
- SkXfermode::Make(SkXfermode::kSrc_Mode), input, input, cropRect).release());
+ SkXfermode::Make(SkXfermode::kSrc_Mode), input.get(), input.get(),
+ cropRect).release());
}
int count() const { return fFilters.count(); }
SkImageFilter* getFilter(int index) const { return fFilters[index].fFilter.get(); }
SkImageFilter::CropRect inputCropRect(SkRect::MakeXYWH(8, 13, 80, 80));
SkImageFilter::CropRect cropRect(SkRect::MakeXYWH(20, 30, 60, 60));
- SkAutoTUnref<SkImageFilter> input(make_grayscale(nullptr, &inputCropRect));
+ sk_sp<SkImageFilter> input(make_grayscale(nullptr, &inputCropRect));
- FilterList filters(input.get(), &cropRect);
+ FilterList filters(input, &cropRect);
for (int i = 0; i < filters.count(); ++i) {
SkImageFilter* filter = filters.getFilter(i);
// match the same filters drawn with a single full-canvas bitmap draw.
// Tests pass by not asserting.
- FilterList filters;
+ FilterList filters(nullptr);
SkBitmap untiledResult, tiledResult;
const int width = 64, height = 64;
}
DEF_TEST(ImageFilterDilateThenBlurBounds, reporter) {
- sk_sp<SkImageFilter> filter1(SkDilateImageFilter::Create(2, 2));
+ sk_sp<SkImageFilter> filter1(SkDilateImageFilter::Make(2, 2, nullptr));
sk_sp<SkImageFilter> filter2(make_drop_shadow(std::move(filter1)));
SkIRect bounds = SkIRect::MakeXYWH(0, 0, 100, 100);