Index: gm/dropshadowimagefilter.cpp |
diff --git a/gm/dropshadowimagefilter.cpp b/gm/dropshadowimagefilter.cpp |
index 11fa9a86fa7c8828779e2025d86dd677d6bcb1d6..370b569b8397bc8a0ccee3708817da1739060f40 100644 |
--- a/gm/dropshadowimagefilter.cpp |
+++ b/gm/dropshadowimagefilter.cpp |
@@ -13,9 +13,9 @@ |
/////////////////////////////////////////////////////////////////////////////// |
-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); |
@@ -23,10 +23,10 @@ static void draw_paint(SkCanvas* canvas, const SkRect& r, SkImageFilter* imf) { |
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_ColorGREEN); |
- paint.setImageFilter(imf); |
+ paint.setImageFilter(std::move(imf)); |
paint.setAntiAlias(true); |
canvas->save(); |
canvas->clipRect(r); |
@@ -34,9 +34,9 @@ static void draw_path(SkCanvas* canvas, const SkRect& r, SkImageFilter* imf) { |
canvas->restore(); |
} |
-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); |
@@ -48,7 +48,7 @@ static void draw_text(SkCanvas* canvas, const SkRect& r, SkImageFilter* imf) { |
canvas->restore(); |
} |
-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; |
@@ -60,7 +60,7 @@ static void draw_bitmap(SkCanvas* canvas, const SkRect& r, SkImageFilter* imf) { |
SkCanvas c(bm); |
draw_path(&c, r, nullptr); |
- paint.setImageFilter(imf); |
+ paint.setImageFilter(std::move(imf)); |
canvas->save(); |
canvas->clipRect(r); |
canvas->drawBitmap(bm, 0, 0, &paint); |
@@ -75,21 +75,14 @@ public: |
protected: |
- virtual SkString onShortName() { |
+ SkString onShortName() override { |
return SkString("dropshadowimagefilter"); |
} |
- virtual SkISize onISize() { return SkISize::Make(400, 656); } |
+ SkISize onISize() override { return SkISize::Make(400, 656); } |
- void draw_frame(SkCanvas* canvas, const SkRect& r) { |
- SkPaint paint; |
- paint.setStyle(SkPaint::kStroke_Style); |
- paint.setColor(SK_ColorRED); |
- canvas->drawRect(r, paint); |
- } |
- |
- virtual void onDraw(SkCanvas* canvas) { |
- void (*drawProc[])(SkCanvas*, const SkRect&, SkImageFilter*) = { |
+ void onDraw(SkCanvas* canvas) override { |
+ void (*drawProc[])(SkCanvas*, const SkRect&, sk_sp<SkImageFilter>) = { |
draw_bitmap, draw_path, draw_paint, draw_text |
}; |
@@ -101,22 +94,22 @@ protected: |
SkImageFilter::CropRect bogusRect(SkRect::Make(SkIRect::MakeXYWH(-100, -100, 10, 10)), |
SkImageFilter::CropRect::kHasAll_CropEdge); |
- SkImageFilter* filters[] = { |
+ sk_sp<SkImageFilter> filters[] = { |
nullptr, |
- SkDropShadowImageFilter::Create(7.0f, 0.0f, 0.0f, 3.0f, SK_ColorBLUE, |
- SkDropShadowImageFilter::kDrawShadowAndForeground_ShadowMode), |
- SkDropShadowImageFilter::Create(0.0f, 7.0f, 3.0f, 0.0f, SK_ColorBLUE, |
- SkDropShadowImageFilter::kDrawShadowAndForeground_ShadowMode), |
- SkDropShadowImageFilter::Create(7.0f, 7.0f, 3.0f, 3.0f, SK_ColorBLUE, |
- SkDropShadowImageFilter::kDrawShadowAndForeground_ShadowMode), |
- SkDropShadowImageFilter::Create(7.0f, 7.0f, 3.0f, 3.0f, SK_ColorBLUE, |
- SkDropShadowImageFilter::kDrawShadowAndForeground_ShadowMode, cfif.get(), nullptr), |
- SkDropShadowImageFilter::Create(7.0f, 7.0f, 3.0f, 3.0f, SK_ColorBLUE, |
+ SkDropShadowImageFilter::Make(7.0f, 0.0f, 0.0f, 3.0f, SK_ColorBLUE, |
+ SkDropShadowImageFilter::kDrawShadowAndForeground_ShadowMode, nullptr), |
+ SkDropShadowImageFilter::Make(0.0f, 7.0f, 3.0f, 0.0f, SK_ColorBLUE, |
+ SkDropShadowImageFilter::kDrawShadowAndForeground_ShadowMode, nullptr), |
+ SkDropShadowImageFilter::Make(7.0f, 7.0f, 3.0f, 3.0f, SK_ColorBLUE, |
+ SkDropShadowImageFilter::kDrawShadowAndForeground_ShadowMode, nullptr), |
+ SkDropShadowImageFilter::Make(7.0f, 7.0f, 3.0f, 3.0f, SK_ColorBLUE, |
+ SkDropShadowImageFilter::kDrawShadowAndForeground_ShadowMode, std::move(cfif)), |
+ SkDropShadowImageFilter::Make(7.0f, 7.0f, 3.0f, 3.0f, SK_ColorBLUE, |
SkDropShadowImageFilter::kDrawShadowAndForeground_ShadowMode, nullptr, &cropRect), |
- SkDropShadowImageFilter::Create(7.0f, 7.0f, 3.0f, 3.0f, SK_ColorBLUE, |
+ SkDropShadowImageFilter::Make(7.0f, 7.0f, 3.0f, 3.0f, SK_ColorBLUE, |
SkDropShadowImageFilter::kDrawShadowAndForeground_ShadowMode, nullptr, &bogusRect), |
- SkDropShadowImageFilter::Create(7.0f, 7.0f, 3.0f, 3.0f, SK_ColorBLUE, |
- SkDropShadowImageFilter::kDrawShadowOnly_ShadowMode), |
+ SkDropShadowImageFilter::Make(7.0f, 7.0f, 3.0f, 3.0f, SK_ColorBLUE, |
+ SkDropShadowImageFilter::kDrawShadowOnly_ShadowMode, nullptr), |
}; |
SkRect r = SkRect::MakeWH(SkIntToScalar(64), SkIntToScalar(64)); |
@@ -134,10 +127,6 @@ protected: |
canvas->restore(); |
canvas->translate(DX, 0); |
} |
- |
- for(size_t j = 0; j < SK_ARRAY_COUNT(filters); ++j) { |
- SkSafeUnref(filters[j]); |
- } |
} |
private: |