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

Side by Side Diff: gm/xfermodes2.cpp

Issue 1832223002: switch xfermodes over to sk_sp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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 unified diff | Download patch
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2013 Google Inc. 3 * Copyright 2013 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 #include "gm.h" 8 #include "gm.h"
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkShader.h" 10 #include "SkShader.h"
(...skipping 24 matching lines...) Expand all
35 SkPaint labelP; 35 SkPaint labelP;
36 labelP.setAntiAlias(true); 36 labelP.setAntiAlias(true);
37 sk_tool_utils::set_portable_typeface(&labelP); 37 sk_tool_utils::set_portable_typeface(&labelP);
38 labelP.setTextAlign(SkPaint::kCenter_Align); 38 labelP.setTextAlign(SkPaint::kCenter_Align);
39 39
40 const int W = 6; 40 const int W = 6;
41 41
42 SkScalar x = 0, y = 0; 42 SkScalar x = 0, y = 0;
43 for (size_t m = 0; m <= SkXfermode::kLastMode; m++) { 43 for (size_t m = 0; m <= SkXfermode::kLastMode; m++) {
44 SkXfermode::Mode mode = static_cast<SkXfermode::Mode>(m); 44 SkXfermode::Mode mode = static_cast<SkXfermode::Mode>(m);
45 SkXfermode* xm = SkXfermode::Create(mode);
46 SkAutoUnref aur(xm);
47 45
48 canvas->save(); 46 canvas->save();
49 47
50 canvas->translate(x, y); 48 canvas->translate(x, y);
51 SkPaint p; 49 SkPaint p;
52 p.setAntiAlias(false); 50 p.setAntiAlias(false);
53 p.setStyle(SkPaint::kFill_Style); 51 p.setStyle(SkPaint::kFill_Style);
54 p.setShader(fBG); 52 p.setShader(fBG);
55 SkRect r = SkRect::MakeWH(w, h); 53 SkRect r = SkRect::MakeWH(w, h);
56 canvas->drawRect(r, p); 54 canvas->drawRect(r, p);
57 55
58 canvas->saveLayer(&r, nullptr); 56 canvas->saveLayer(&r, nullptr);
59 57
60 p.setShader(fDst); 58 p.setShader(fDst);
61 canvas->drawRect(r, p); 59 canvas->drawRect(r, p);
62 p.setShader(fSrc); 60 p.setShader(fSrc);
63 p.setXfermode(xm); 61 p.setXfermode(SkXfermode::Make(mode));
64 canvas->drawRect(r, p); 62 canvas->drawRect(r, p);
65 63
66 canvas->restore(); 64 canvas->restore();
67 65
68 r.inset(-SK_ScalarHalf, -SK_ScalarHalf); 66 r.inset(-SK_ScalarHalf, -SK_ScalarHalf);
69 p.setStyle(SkPaint::kStroke_Style); 67 p.setStyle(SkPaint::kStroke_Style);
70 p.setShader(nullptr); 68 p.setShader(nullptr);
71 p.setXfermode(nullptr); 69 p.setXfermode(nullptr);
72 canvas->drawRect(r, p); 70 canvas->drawRect(r, p);
73 71
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 139
142 typedef GM INHERITED; 140 typedef GM INHERITED;
143 }; 141 };
144 142
145 ////////////////////////////////////////////////////////////////////////////// 143 //////////////////////////////////////////////////////////////////////////////
146 144
147 static GM* MyFactory(void*) { return new Xfermodes2GM; } 145 static GM* MyFactory(void*) { return new Xfermodes2GM; }
148 static GMRegistry reg(MyFactory); 146 static GMRegistry reg(MyFactory);
149 147
150 } 148 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698