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

Unified Diff: gm/dropshadowimagefilter.cpp

Issue 1861843002: Update DropShadowImageFilter to sk_sp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Address code review issues Created 4 years, 8 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 | « fuzz/FilterFuzz.cpp ('k') | gm/filterfastbounds.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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:
« no previous file with comments | « fuzz/FilterFuzz.cpp ('k') | gm/filterfastbounds.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698