diff options
author | robertphillips <robertphillips@google.com> | 2016-03-31 09:05:49 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-03-31 09:05:49 -0700 |
commit | 51a315eff9b86bd60e7884240c4efc199129d37a (patch) | |
tree | 4e08f4a93e4359dc808c1302557337dad88bfabc /gm/xfermodeimagefilter.cpp | |
parent | 865a289bfec169cb19970c734e9aa855c267f060 (diff) |
Update SkOffsetImageFilter to sk_sp
TBR=reed@google.com
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1842193002
Review URL: https://codereview.chromium.org/1842193002
Diffstat (limited to 'gm/xfermodeimagefilter.cpp')
-rw-r--r-- | gm/xfermodeimagefilter.cpp | 49 |
1 files changed, 30 insertions, 19 deletions
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) { |