aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm
diff options
context:
space:
mode:
authorGravatar robertphillips <robertphillips@google.com>2016-03-31 09:05:49 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-03-31 09:05:49 -0700
commit51a315eff9b86bd60e7884240c4efc199129d37a (patch)
tree4e08f4a93e4359dc808c1302557337dad88bfabc /gm
parent865a289bfec169cb19970c734e9aa855c267f060 (diff)
Update SkOffsetImageFilter to sk_sp
Diffstat (limited to 'gm')
-rw-r--r--gm/filterfastbounds.cpp5
-rw-r--r--gm/imagefiltersclipped.cpp4
-rw-r--r--gm/imagefilterscropexpand.cpp81
-rw-r--r--gm/imagefilterscropped.cpp5
-rw-r--r--gm/imagefiltersscaled.cpp2
-rw-r--r--gm/imagefiltersstroked.cpp2
-rw-r--r--gm/lighting.cpp2
-rw-r--r--gm/localmatriximagefilter.cpp2
-rw-r--r--gm/offsetimagefilter.cpp31
-rw-r--r--gm/testimagefilters.cpp52
-rw-r--r--gm/xfermodeimagefilter.cpp49
11 files changed, 139 insertions, 96 deletions
diff --git a/gm/filterfastbounds.cpp b/gm/filterfastbounds.cpp
index bcecff9379..8bc186e48d 100644
--- a/gm/filterfastbounds.cpp
+++ b/gm/filterfastbounds.cpp
@@ -150,9 +150,10 @@ static void create_paints(SkImageFilter* source, SkTArray<SkPaint>* paints) {
}
{
- SkAutoTUnref<SkImageFilter> oif(SkOffsetImageFilter::Create(15, 15, source));
+ sk_sp<SkImageFilter> oif(SkOffsetImageFilter::Make(15, 15,
+ sk_ref_sp<SkImageFilter>(source)));
- add_paint(oif, paints);
+ add_paint(oif.get(), paints);
}
}
diff --git a/gm/imagefiltersclipped.cpp b/gm/imagefiltersclipped.cpp
index 5401ef537f..a0c74db10e 100644
--- a/gm/imagefiltersclipped.cpp
+++ b/gm/imagefiltersclipped.cpp
@@ -108,7 +108,9 @@ protected:
checkerboard.get()),
SkDilateImageFilter::Create(2, 2, checkerboard.get()),
SkErodeImageFilter::Create(2, 2, checkerboard.get()),
- SkOffsetImageFilter::Create(SkIntToScalar(-16), SkIntToScalar(32)),
+ SkOffsetImageFilter::Make(SkIntToScalar(-16),
+ SkIntToScalar(32),
+ nullptr).release(),
SkImageFilter::CreateMatrixFilter(resizeMatrix, kNone_SkFilterQuality),
SkLightingImageFilter::CreatePointLitDiffuse(pointLocation, SK_ColorWHITE, SK_Scalar1, SkIntToScalar(2), checkerboard.get()),
diff --git a/gm/imagefilterscropexpand.cpp b/gm/imagefilterscropexpand.cpp
index 450610aded..6b2484e1a8 100644
--- a/gm/imagefilterscropexpand.cpp
+++ b/gm/imagefilterscropexpand.cpp
@@ -50,8 +50,7 @@ protected:
SkAutoTUnref<SkImageFilter> gradientCircleSource(
SkImageSource::Create(gradientCircle.get()));
- SkAutoTUnref<SkImageFilter> noopCropped(
- SkOffsetImageFilter::Create(0, 0, nullptr, &cropRect));
+ sk_sp<SkImageFilter> noopCropped(SkOffsetImageFilter::Make(0, 0, nullptr, &cropRect));
SkScalar sk255 = SkIntToScalar(255);
SkScalar matrix[20] = { 1, 0, 0, 0, 0,
0, 1, 0, 0, sk255,
@@ -77,40 +76,63 @@ protected:
SkIntToScalar(outset));
SkImageFilter::CropRect bigRect(rect, SkImageFilter::CropRect::kHasAll_CropEdge);
- Draw(canvas, checkerboard, rect, SkColorFilterImageFilter::Create(
- cfAlphaTrans.get(), noopCropped.get(), &bigRect));
+ Draw(canvas, checkerboard, rect,
+ sk_sp<SkImageFilter>(SkColorFilterImageFilter::Create(cfAlphaTrans.get(),
+ noopCropped.get(),
+ &bigRect)));
- Draw(canvas, checkerboard, rect, SkBlurImageFilter::Create(
- 0.3f, 0.3f, noopCropped.get(), &bigRect));
+ Draw(canvas, checkerboard, rect,
+ sk_sp<SkImageFilter>(SkBlurImageFilter::Create(0.3f, 0.3f,
+ noopCropped.get(),
+ &bigRect)));
- Draw(canvas, checkerboard, rect, SkBlurImageFilter::Create(
- 8.0f, 8.0f, noopCropped.get(), &bigRect));
+ Draw(canvas, checkerboard, rect,
+ sk_sp<SkImageFilter>(SkBlurImageFilter::Create(8.0f, 8.0f,
+ noopCropped.get(),
+ &bigRect)));
- Draw(canvas, checkerboard, rect, SkDilateImageFilter::Create(
- 2, 2, noopCropped.get(), &bigRect));
+ Draw(canvas, checkerboard, rect,
+ sk_sp<SkImageFilter>(SkDilateImageFilter::Create(2, 2,
+ noopCropped.get(),
+ &bigRect)));
- Draw(canvas, checkerboard, rect, SkErodeImageFilter::Create(
- 2, 2, noopCropped.get(), &bigRect));
+ Draw(canvas, checkerboard, rect,
+ sk_sp<SkImageFilter>(SkErodeImageFilter::Create(2, 2,
+ noopCropped.get(),
+ &bigRect)));
- Draw(canvas, checkerboard, rect, SkDropShadowImageFilter::Create(
- SkIntToScalar(10), SkIntToScalar(10), SkIntToScalar(3), SkIntToScalar(3),
- SK_ColorBLUE, SkDropShadowImageFilter::kDrawShadowAndForeground_ShadowMode,
- noopCropped.get(), &bigRect));
+ Draw(canvas, checkerboard, rect,
+ sk_sp<SkImageFilter>(SkDropShadowImageFilter::Create(
+ SkIntToScalar(10),
+ SkIntToScalar(10),
+ SkIntToScalar(3),
+ SkIntToScalar(3),
+ SK_ColorBLUE,
+ SkDropShadowImageFilter::kDrawShadowAndForeground_ShadowMode,
+ noopCropped.get(),
+ &bigRect)));
- Draw(canvas, checkerboard, rect, SkDisplacementMapEffect::Create(
- SkDisplacementMapEffect::kR_ChannelSelectorType,
- SkDisplacementMapEffect::kR_ChannelSelectorType,
- SkIntToScalar(12),
- gradientCircleSource.get(),
- noopCropped.get(),
- &bigRect));
+ Draw(canvas, checkerboard, rect,
+ sk_sp<SkImageFilter>(SkDisplacementMapEffect::Create(
+ SkDisplacementMapEffect::kR_ChannelSelectorType,
+ SkDisplacementMapEffect::kR_ChannelSelectorType,
+ SkIntToScalar(12),
+ gradientCircleSource.get(),
+ noopCropped.get(),
+ &bigRect)));
- Draw(canvas, checkerboard, rect, SkOffsetImageFilter::Create(
- SkIntToScalar(-8), SkIntToScalar(16), noopCropped.get(), &bigRect));
+ Draw(canvas, checkerboard, rect,
+ SkOffsetImageFilter::Make(SkIntToScalar(-8), SkIntToScalar(16),
+ noopCropped,
+ &bigRect));
Draw(canvas, checkerboard, rect,
- SkLightingImageFilter::CreatePointLitDiffuse(pointLocation, SK_ColorWHITE,
- surfaceScale, kd, noopCropped.get(), &bigRect));
+ sk_sp<SkImageFilter>(SkLightingImageFilter::CreatePointLitDiffuse(pointLocation,
+ SK_ColorWHITE,
+ surfaceScale,
+ kd,
+ noopCropped.get(),
+ &bigRect)));
canvas->restore();
canvas->translate(0, SkIntToScalar(80));
@@ -157,9 +179,10 @@ private:
return surface->makeImageSnapshot();
}
- static void Draw(SkCanvas* canvas, const SkBitmap& bitmap, const SkRect& rect, SkImageFilter* filter) {
+ static void Draw(SkCanvas* canvas, const SkBitmap& bitmap, const SkRect& rect,
+ sk_sp<SkImageFilter> filter) {
SkPaint paint;
- paint.setImageFilter(filter)->unref();
+ paint.setImageFilter(std::move(filter));
canvas->saveLayer(&rect, &paint);
canvas->drawBitmap(bitmap, 0, 0);
canvas->restore();
diff --git a/gm/imagefilterscropped.cpp b/gm/imagefilterscropped.cpp
index 612990984a..9c8705cfae 100644
--- a/gm/imagefilterscropped.cpp
+++ b/gm/imagefilterscropped.cpp
@@ -119,8 +119,9 @@ protected:
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);
- SkAutoTUnref<SkImageFilter> offset(SkOffsetImageFilter::Create(
- SkIntToScalar(-10), SkIntToScalar(-10)));
+ sk_sp<SkImageFilter> offset(SkOffsetImageFilter::Make(SkIntToScalar(-10),
+ SkIntToScalar(-10),
+ nullptr));
sk_sp<SkImageFilter> cfOffset(SkColorFilterImageFilter::Create(cf.get(), offset.get()));
diff --git a/gm/imagefiltersscaled.cpp b/gm/imagefiltersscaled.cpp
index 9bfac68c12..d9f38bb443 100644
--- a/gm/imagefiltersscaled.cpp
+++ b/gm/imagefiltersscaled.cpp
@@ -84,7 +84,7 @@ protected:
checkerboard.get()),
SkDilateImageFilter::Create(1, 1, checkerboard.get()),
SkErodeImageFilter::Create(1, 1, checkerboard.get()),
- SkOffsetImageFilter::Create(SkIntToScalar(32), 0),
+ SkOffsetImageFilter::Make(SkIntToScalar(32), 0, nullptr).release(),
SkImageFilter::CreateMatrixFilter(resizeMatrix, kNone_SkFilterQuality),
SkPaintImageFilter::Make(noisePaint).release(),
SkLightingImageFilter::CreatePointLitDiffuse(pointLocation, white, surfaceScale, kd),
diff --git a/gm/imagefiltersstroked.cpp b/gm/imagefiltersstroked.cpp
index 1b68a7e066..9275990573 100644
--- a/gm/imagefiltersstroked.cpp
+++ b/gm/imagefiltersstroked.cpp
@@ -61,7 +61,7 @@ protected:
SkBlurImageFilter::Create(5, 5),
SkDropShadowImageFilter::Create(10, 10, 3, 3, SK_ColorGREEN,
SkDropShadowImageFilter::kDrawShadowAndForeground_ShadowMode),
- SkOffsetImageFilter::Create(-16, 32),
+ SkOffsetImageFilter::Make(-16, 32, nullptr).release(),
SkImageFilter::CreateMatrixFilter(resizeMatrix, kNone_SkFilterQuality),
};
diff --git a/gm/lighting.cpp b/gm/lighting.cpp
index af102d7d03..e0a317d328 100644
--- a/gm/lighting.cpp
+++ b/gm/lighting.cpp
@@ -80,7 +80,7 @@ protected:
SkImageFilter::CropRect cropRect(SkRect::MakeXYWH(20, 10, 60, 65));
SkImageFilter::CropRect fullSizeCropRect(SkRect::MakeXYWH(0, 0, 100, 100));
- SkAutoTUnref<SkImageFilter> noopCropped(SkOffsetImageFilter::Create(0, 0, nullptr, &cropRect));
+ sk_sp<SkImageFilter> noopCropped(SkOffsetImageFilter::Make(0, 0, nullptr, &cropRect));
int y = 0;
for (int i = 0; i < 3; i++) {
diff --git a/gm/localmatriximagefilter.cpp b/gm/localmatriximagefilter.cpp
index 5414fe341c..5c49671cd6 100644
--- a/gm/localmatriximagefilter.cpp
+++ b/gm/localmatriximagefilter.cpp
@@ -68,7 +68,7 @@ protected:
IFCCast([]{ return SkBlurImageFilter::Create(8, 8); }),
IFCCast([]{ return SkDilateImageFilter::Create(8, 8); }),
IFCCast([]{ return SkErodeImageFilter::Create(8, 8); }),
- IFCCast([]{ return SkOffsetImageFilter::Create(8, 8); }),
+ IFCCast([]{ return SkOffsetImageFilter::Make(8, 8, nullptr).release(); }),
};
const SkMatrix matrices[] = {
diff --git a/gm/offsetimagefilter.cpp b/gm/offsetimagefilter.cpp
index 11da041fd7..51a93f86f1 100644
--- a/gm/offsetimagefilter.cpp
+++ b/gm/offsetimagefilter.cpp
@@ -53,20 +53,17 @@ protected:
image->width() - i * 8,
image->height() - i * 12);
SkImageFilter::CropRect rect(SkRect::Make(cropRect));
- SkAutoTUnref<SkImageFilter> tileInput(SkImageSource::Create(image));
+ sk_sp<SkImageFilter> tileInput(SkImageSource::Create(image));
SkScalar dx = SkIntToScalar(i*5);
SkScalar dy = SkIntToScalar(i*10);
- SkAutoTUnref<SkImageFilter> filter(SkOffsetImageFilter::Create(dx, dy, tileInput,
- &rect));
- paint.setImageFilter(filter);
+ paint.setImageFilter(SkOffsetImageFilter::Make(dx, dy, std::move(tileInput), &rect));
DrawClippedImage(canvas, image, paint, 1, cropRect);
canvas->translate(SkIntToScalar(image->width() + MARGIN), 0);
}
SkIRect cropRect = SkIRect::MakeXYWH(0, 0, 100, 100);
SkImageFilter::CropRect rect(SkRect::Make(cropRect));
- SkAutoTUnref<SkImageFilter> filter(SkOffsetImageFilter::Create(-5, -10, nullptr, &rect));
- paint.setImageFilter(filter);
+ paint.setImageFilter(SkOffsetImageFilter::Make(-5, -10, nullptr, &rect));
DrawClippedImage(canvas, fBitmap.get(), paint, 2, cropRect);
}
private:
@@ -111,7 +108,7 @@ protected:
SkISize onISize() override { return SkISize::Make(640, 200); }
- void doDraw(SkCanvas* canvas, const SkRect& r, SkImageFilter* imgf,
+ void doDraw(SkCanvas* canvas, const SkRect& r, sk_sp<SkImageFilter> imgf,
const SkRect* clipR = nullptr) {
SkPaint p;
@@ -139,7 +136,7 @@ protected:
canvas->clipRect(*clipR);
}
if (imgf) {
- p.setImageFilter(imgf)->unref();
+ p.setImageFilter(std::move(imgf));
}
p.setColor(0x66FF0000);
canvas->drawRect(r, p);
@@ -162,20 +159,20 @@ protected:
this->doDraw(canvas, r, nullptr);
canvas->translate(100, 0);
- this->doDraw(canvas, r, SkOffsetImageFilter::Create(20, 20));
+ this->doDraw(canvas, r, SkOffsetImageFilter::Make(20, 20, nullptr));
canvas->translate(100, 0);
- this->doDraw(canvas, r, SkOffsetImageFilter::Create(20, 20, nullptr, &cr0));
+ this->doDraw(canvas, r, SkOffsetImageFilter::Make(20, 20, nullptr, &cr0));
canvas->translate(100, 0);
- this->doDraw(canvas, r, SkOffsetImageFilter::Create(20, 20), &r);
+ this->doDraw(canvas, r, SkOffsetImageFilter::Make(20, 20, nullptr), &r);
canvas->translate(100, 0);
- this->doDraw(canvas, r, SkOffsetImageFilter::Create(20, 20, nullptr, &cr1));
+ this->doDraw(canvas, r, SkOffsetImageFilter::Make(20, 20, nullptr, &cr1));
SkRect clipR = SkRect::MakeXYWH(40, 40, 40, 40);
canvas->translate(100, 0);
- this->doDraw(canvas, r, SkOffsetImageFilter::Create(20, 20, nullptr, nullptr), &clipR);
+ this->doDraw(canvas, r, SkOffsetImageFilter::Make(20, 20, nullptr, nullptr), &clipR);
canvas->restore();
// 2nd row
@@ -186,19 +183,19 @@ protected:
*/
// crop==clip==src
- this->doDraw(canvas, r, SkOffsetImageFilter::Create(40, 0, nullptr, &cr0), &r);
+ this->doDraw(canvas, r, SkOffsetImageFilter::Make(40, 0, nullptr, &cr0), &r);
// crop==src, clip==dst
canvas->translate(100, 0);
- this->doDraw(canvas, r, SkOffsetImageFilter::Create(40, 0, nullptr, &cr0), &r2);
+ this->doDraw(canvas, r, SkOffsetImageFilter::Make(40, 0, nullptr, &cr0), &r2);
// crop==dst, clip==src
canvas->translate(100, 0);
- this->doDraw(canvas, r, SkOffsetImageFilter::Create(40, 0, nullptr, &cr2), &r);
+ this->doDraw(canvas, r, SkOffsetImageFilter::Make(40, 0, nullptr, &cr2), &r);
// crop==clip==dst
canvas->translate(100, 0);
- this->doDraw(canvas, r, SkOffsetImageFilter::Create(40, 0, nullptr, &cr2), &r2);
+ this->doDraw(canvas, r, SkOffsetImageFilter::Make(40, 0, nullptr, &cr2), &r2);
}
private:
diff --git a/gm/testimagefilters.cpp b/gm/testimagefilters.cpp
index c4bddbf4e8..9c2a5a9d4c 100644
--- a/gm/testimagefilters.cpp
+++ b/gm/testimagefilters.cpp
@@ -21,55 +21,63 @@
#define FILTER_WIDTH SkIntToScalar(150)
#define FILTER_HEIGHT SkIntToScalar(200)
-static SkImageFilter* make0() {
- return SkDownSampleImageFilter::Create(SK_Scalar1 / 5);
+static sk_sp<SkImageFilter> make0() {
+ return sk_sp<SkImageFilter>(SkDownSampleImageFilter::Create(SK_Scalar1 / 5));
}
-static SkImageFilter* make1() {
- return SkOffsetImageFilter::Create(SkIntToScalar(16), SkIntToScalar(16));
+static sk_sp<SkImageFilter> make1() {
+ return SkOffsetImageFilter::Make(SkIntToScalar(16), SkIntToScalar(16), nullptr);
}
-static SkImageFilter* make2() {
+static sk_sp<SkImageFilter> make2() {
sk_sp<SkColorFilter> cf(SkColorFilter::MakeModeFilter(SK_ColorBLUE, SkXfermode::kSrcIn_Mode));
- return SkColorFilterImageFilter::Create(cf.get());
+ return sk_sp<SkImageFilter>(SkColorFilterImageFilter::Create(cf.get()));
}
-static SkImageFilter* make3() {
- return SkBlurImageFilter::Create(8, 0);
+static sk_sp<SkImageFilter> make3() {
+ return sk_sp<SkImageFilter>(SkBlurImageFilter::Create(8, 0));
}
-static SkImageFilter* make4() {
- sk_sp<SkImageFilter> outer(SkOffsetImageFilter::Create(SkIntToScalar(16), SkIntToScalar(16)));
+static sk_sp<SkImageFilter> make4() {
+ sk_sp<SkImageFilter> outer(SkOffsetImageFilter::Make(SkIntToScalar(16),
+ SkIntToScalar(16),
+ nullptr));
sk_sp<SkImageFilter> inner(SkDownSampleImageFilter::Create(SK_Scalar1 / 5));
- return SkComposeImageFilter::Make(std::move(outer), std::move(inner)).release();
+ return SkComposeImageFilter::Make(std::move(outer), std::move(inner));
}
-static SkImageFilter* make5() {
- sk_sp<SkImageFilter> first(SkOffsetImageFilter::Create(SkIntToScalar(16), SkIntToScalar(16)));
+static sk_sp<SkImageFilter> make5() {
+ sk_sp<SkImageFilter> first(SkOffsetImageFilter::Make(SkIntToScalar(16),
+ SkIntToScalar(16),
+ nullptr));
sk_sp<SkImageFilter> second(SkDownSampleImageFilter::Create(SK_Scalar1 / 5));
- return SkMergeImageFilter::Make(std::move(first), std::move(second)).release();
+ return SkMergeImageFilter::Make(std::move(first), std::move(second));
}
-static SkImageFilter* make6() {
- sk_sp<SkImageFilter> outer(SkOffsetImageFilter::Create(SkIntToScalar(16), SkIntToScalar(16)));
+static sk_sp<SkImageFilter> make6() {
+ sk_sp<SkImageFilter> outer(SkOffsetImageFilter::Make(SkIntToScalar(16),
+ SkIntToScalar(16),
+ nullptr));
sk_sp<SkImageFilter> inner(SkDownSampleImageFilter::Create(SK_Scalar1 / 5));
sk_sp<SkImageFilter> compose(SkComposeImageFilter::Make(std::move(outer), std::move(inner)));
sk_sp<SkColorFilter> cf(SkColorFilter::MakeModeFilter(0x880000FF, SkXfermode::kSrcIn_Mode));
sk_sp<SkImageFilter> blue(SkColorFilterImageFilter::Create(cf.get()));
- return SkMergeImageFilter::Make(std::move(compose), std::move(blue)).release();
+ return SkMergeImageFilter::Make(std::move(compose), std::move(blue));
}
-static SkImageFilter* make7() {
- sk_sp<SkImageFilter> outer(SkOffsetImageFilter::Create(SkIntToScalar(16), SkIntToScalar(16)));
+static sk_sp<SkImageFilter> make7() {
+ sk_sp<SkImageFilter> outer(SkOffsetImageFilter::Make(SkIntToScalar(16),
+ SkIntToScalar(16),
+ nullptr));
sk_sp<SkImageFilter> inner(make3());
sk_sp<SkImageFilter> compose(SkComposeImageFilter::Make(std::move(outer), std::move(inner)));
sk_sp<SkColorFilter> cf(SkColorFilter::MakeModeFilter(0x880000FF, SkXfermode::kSrcIn_Mode));
sk_sp<SkImageFilter> blue(SkColorFilterImageFilter::Create(cf.get()));
- return SkMergeImageFilter::Make(std::move(compose), std::move(blue)).release();
+ return SkMergeImageFilter::Make(std::move(compose), std::move(blue));
}
static void draw0(SkCanvas* canvas) {
@@ -96,7 +104,7 @@ protected:
void onDraw(SkCanvas* canvas) override {
// this->drawSizeBounds(canvas, 0xFFCCCCCC);
- static SkImageFilter* (*gFilterProc[])() = {
+ static sk_sp<SkImageFilter> (*gFilterProc[])() = {
make0, make1, make2, make3, make4, make5, make6, make7
};
@@ -119,7 +127,7 @@ protected:
canvas->drawRect(bounds, p);
SkPaint paint;
- paint.setImageFilter(gFilterProc[i]())->unref();
+ paint.setImageFilter(gFilterProc[i]());
canvas->saveLayer(&bounds, &paint);
draw0(canvas);
}
diff --git a/gm/xfermodeimagefilter.cpp b/gm/xfermodeimagefilter.cpp
index 5603c78456..dc8cbede21 100644
--- a/gm/xfermodeimagefilter.cpp
+++ b/gm/xfermodeimagefilter.cpp
@@ -85,10 +85,10 @@ protected:
};
int x = 0, y = 0;
- SkAutoTUnref<SkImageFilter> background(SkImageSource::Create(fCheckerboard.get()));
+ sk_sp<SkImageFilter> background(SkImageSource::Create(fCheckerboard.get()));
for (size_t i = 0; i < SK_ARRAY_COUNT(gModes); i++) {
paint.setImageFilter(SkXfermodeImageFilter::Make(SkXfermode::Make(gModes[i].fMode),
- background));
+ background.get()));
DrawClippedBitmap(canvas, fBitmap, paint, x, y);
x += fBitmap.width() + MARGIN;
if (x + fBitmap.width() > WIDTH) {
@@ -98,7 +98,8 @@ protected:
}
// Test arithmetic mode as image filter
paint.setImageFilter(SkXfermodeImageFilter::Make(
- SkArithmeticMode::Make(0, SK_Scalar1, SK_Scalar1, 0), background));
+ SkArithmeticMode::Make(0, SK_Scalar1, SK_Scalar1, 0),
+ background.get()));
DrawClippedBitmap(canvas, fBitmap, paint, x, y);
x += fBitmap.width() + MARGIN;
if (x + fBitmap.width() > WIDTH) {
@@ -106,7 +107,7 @@ protected:
y += fBitmap.height() + MARGIN;
}
// Test nullptr mode
- paint.setImageFilter(SkXfermodeImageFilter::Make(nullptr, background));
+ paint.setImageFilter(SkXfermodeImageFilter::Make(nullptr, background.get()));
DrawClippedBitmap(canvas, fBitmap, paint, x, y);
x += fBitmap.width() + MARGIN;
if (x + fBitmap.width() > WIDTH) {
@@ -117,14 +118,18 @@ protected:
SkIntToScalar(fBitmap.height() + 4));
// Test offsets on SrcMode (uses fixed-function blend)
sk_sp<SkImage> bitmapImage(SkImage::MakeFromBitmap(fBitmap));
- SkAutoTUnref<SkImageFilter> foreground(SkImageSource::Create(bitmapImage.get()));
- SkAutoTUnref<SkImageFilter> offsetForeground(SkOffsetImageFilter::Create(
- SkIntToScalar(4), SkIntToScalar(-4), foreground));
- SkAutoTUnref<SkImageFilter> offsetBackground(SkOffsetImageFilter::Create(
- SkIntToScalar(4), SkIntToScalar(4), background));
+ sk_sp<SkImageFilter> foreground(SkImageSource::Create(bitmapImage.get()));
+ sk_sp<SkImageFilter> offsetForeground(SkOffsetImageFilter::Make(SkIntToScalar(4),
+ SkIntToScalar(-4),
+ foreground));
+ sk_sp<SkImageFilter> offsetBackground(SkOffsetImageFilter::Make(SkIntToScalar(4),
+ SkIntToScalar(4),
+ background));
paint.setImageFilter(SkXfermodeImageFilter::Make(
- SkXfermode::Make(SkXfermode::kSrcOver_Mode), offsetBackground,
- offsetForeground, nullptr));
+ SkXfermode::Make(SkXfermode::kSrcOver_Mode),
+ offsetBackground.get(),
+ offsetForeground.get(),
+ nullptr));
DrawClippedPaint(canvas, clipRect, paint, x, y);
x += fBitmap.width() + MARGIN;
if (x + fBitmap.width() > WIDTH) {
@@ -133,7 +138,9 @@ protected:
}
// Test offsets on Darken (uses shader blend)
paint.setImageFilter(SkXfermodeImageFilter::Make(SkXfermode::Make(SkXfermode::kDarken_Mode),
- offsetBackground, offsetForeground, nullptr));
+ offsetBackground.get(),
+ offsetForeground.get(),
+ nullptr));
DrawClippedPaint(canvas, clipRect, paint, x, y);
x += fBitmap.width() + MARGIN;
if (x + fBitmap.width() > WIDTH) {
@@ -154,8 +161,10 @@ protected:
fBitmap.width() + offsets[i][2],
fBitmap.height() + offsets[i][3]);
SkImageFilter::CropRect rect(SkRect::Make(cropRect));
- paint.setImageFilter(SkXfermodeImageFilter::Make(
- SkXfermode::Make(sampledModes[i]), offsetBackground, offsetForeground, &rect));
+ paint.setImageFilter(SkXfermodeImageFilter::Make(SkXfermode::Make(sampledModes[i]),
+ offsetBackground.get(),
+ offsetForeground.get(),
+ &rect));
DrawClippedPaint(canvas, clipRect, paint, x, y);
x += fBitmap.width() + MARGIN;
if (x + fBitmap.width() > WIDTH) {
@@ -166,9 +175,9 @@ protected:
// Test small bg, large fg with Screen (uses shader blend)
auto mode = SkXfermode::Make(SkXfermode::kScreen_Mode);
SkImageFilter::CropRect cropRect(SkRect::MakeXYWH(10, 10, 60, 60));
- SkAutoTUnref<SkImageFilter> cropped(
- SkOffsetImageFilter::Create(0, 0, foreground, &cropRect));
- paint.setImageFilter(SkXfermodeImageFilter::Make(mode, cropped, background, nullptr));
+ sk_sp<SkImageFilter> cropped(SkOffsetImageFilter::Make(0, 0, foreground, &cropRect));
+ paint.setImageFilter(SkXfermodeImageFilter::Make(mode, cropped.get(),
+ background.get(), nullptr));
DrawClippedPaint(canvas, clipRect, paint, x, y);
x += fBitmap.width() + MARGIN;
if (x + fBitmap.width() > WIDTH) {
@@ -176,7 +185,8 @@ protected:
y += fBitmap.height() + MARGIN;
}
// Test small fg, large bg with Screen (uses shader blend)
- paint.setImageFilter(SkXfermodeImageFilter::Make(mode, background, cropped, nullptr));
+ paint.setImageFilter(SkXfermodeImageFilter::Make(mode, background.get(),
+ cropped.get(), nullptr));
DrawClippedPaint(canvas, clipRect, paint, x, y);
x += fBitmap.width() + MARGIN;
if (x + fBitmap.width() > WIDTH) {
@@ -188,7 +198,8 @@ protected:
// the region outside the foreground.
mode = SkXfermode::Make(SkXfermode::kSrcIn_Mode);
SkImageFilter::CropRect cropRectFull(SkRect::MakeXYWH(0, 0, 80, 80));
- paint.setImageFilter(SkXfermodeImageFilter::Make(mode, background, cropped, &cropRectFull));
+ paint.setImageFilter(SkXfermodeImageFilter::Make(mode, background.get(),
+ cropped.get(), &cropRectFull));
DrawClippedPaint(canvas, clipRect, paint, x, y);
x += fBitmap.width() + MARGIN;
if (x + fBitmap.width() > WIDTH) {