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

Unified Diff: samplecode/SampleXfermodesBlur.cpp

Issue 1832223002: switch xfermodes over to sk_sp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase 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
Index: samplecode/SampleXfermodesBlur.cpp
diff --git a/samplecode/SampleXfermodesBlur.cpp b/samplecode/SampleXfermodesBlur.cpp
index 52419a06d0adb4d3669bc64dd14460aaa4dcd127..cab13391ed0468d6ef1a40eb37e48a5e378ce362 100644
--- a/samplecode/SampleXfermodesBlur.cpp
+++ b/samplecode/SampleXfermodesBlur.cpp
@@ -39,7 +39,7 @@ class XfermodesBlurView : public SampleView {
SkBitmap fBG;
SkBitmap fSrcB, fDstB;
- void draw_mode(SkCanvas* canvas, SkXfermode* mode, int alpha,
+ void draw_mode(SkCanvas* canvas, sk_sp<SkXfermode> mode, int alpha,
SkScalar x, SkScalar y) {
SkPaint p;
SkMaskFilter* mf = SkBlurMaskFilter::Create(kNormal_SkBlurStyle,
@@ -58,7 +58,7 @@ class XfermodesBlurView : public SampleView {
r.offset(x, y);
canvas->drawOval(r, p);
- p.setXfermode(mode);
+ p.setXfermode(std::move(mode));
// draw a square overlapping the circle
// in the lower right of the canvas
@@ -163,8 +163,6 @@ protected:
for (int twice = 0; twice < 2; twice++) {
SkScalar x = x0, y = 0;
for (size_t i = 0; i < SK_ARRAY_COUNT(gModes); i++) {
- SkXfermode* mode = SkXfermode::Create(gModes[i].fMode);
- SkAutoUnref aur(mode);
SkRect r;
r.set(x, y, x+w, y+h);
@@ -174,7 +172,8 @@ protected:
canvas->drawRect(r, p);
canvas->saveLayer(&r, nullptr);
- draw_mode(canvas, mode, twice ? 0x88 : 0xFF, r.fLeft, r.fTop);
+ draw_mode(canvas, SkXfermode::Make(gModes[i].fMode),
+ twice ? 0x88 : 0xFF, r.fLeft, r.fTop);
canvas->restore();
r.inset(-SK_ScalarHalf, -SK_ScalarHalf);

Powered by Google App Engine
This is Rietveld 408576698