Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Unified Diff: gm/imagefilterscropexpand.cpp

Issue 1842193002: Update SkOffsetImageFilter to sk_sp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: update to ToT Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gm/imagefiltersclipped.cpp ('k') | gm/imagefilterscropped.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/imagefilterscropexpand.cpp
diff --git a/gm/imagefilterscropexpand.cpp b/gm/imagefilterscropexpand.cpp
index 450610aded50aad6aa2b3d2ad8407d8f76b702cb..6b2484e1a840aa0ecdf7ed380fa9bc645dc908b0 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();
« no previous file with comments | « gm/imagefiltersclipped.cpp ('k') | gm/imagefilterscropped.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698