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

Side by Side Diff: gm/xfermodes2.cpp

Issue 2396953002: Revert[8] "replace SkXfermode obj with SkBlendMode enum in paints" (Closed)
Patch Set: add tmp virtual to unroll legacy arithmodes Created 4 years, 2 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
« no previous file with comments | « gm/xfermodes.cpp ('k') | gm/xfermodes3.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 #include "gm.h" 7 #include "gm.h"
8 #include "SkBitmap.h" 8 #include "SkBitmap.h"
9 #include "SkShader.h" 9 #include "SkShader.h"
10 #include "SkXfermode.h" 10 #include "SkXfermode.h"
(...skipping 22 matching lines...) Expand all
33 33
34 SkPaint labelP; 34 SkPaint labelP;
35 labelP.setAntiAlias(true); 35 labelP.setAntiAlias(true);
36 sk_tool_utils::set_portable_typeface(&labelP); 36 sk_tool_utils::set_portable_typeface(&labelP);
37 labelP.setTextAlign(SkPaint::kCenter_Align); 37 labelP.setTextAlign(SkPaint::kCenter_Align);
38 38
39 const int W = 6; 39 const int W = 6;
40 40
41 SkScalar x = 0, y = 0; 41 SkScalar x = 0, y = 0;
42 for (size_t m = 0; m <= SkXfermode::kLastMode; m++) { 42 for (size_t m = 0; m <= SkXfermode::kLastMode; m++) {
43 SkXfermode::Mode mode = static_cast<SkXfermode::Mode>(m); 43 SkBlendMode mode = static_cast<SkBlendMode>(m);
44 44
45 canvas->save(); 45 canvas->save();
46 46
47 canvas->translate(x, y); 47 canvas->translate(x, y);
48 SkPaint p; 48 SkPaint p;
49 p.setAntiAlias(false); 49 p.setAntiAlias(false);
50 p.setStyle(SkPaint::kFill_Style); 50 p.setStyle(SkPaint::kFill_Style);
51 p.setShader(fBG); 51 p.setShader(fBG);
52 SkRect r = SkRect::MakeWH(w, h); 52 SkRect r = SkRect::MakeWH(w, h);
53 canvas->drawRect(r, p); 53 canvas->drawRect(r, p);
54 54
55 canvas->saveLayer(&r, nullptr); 55 canvas->saveLayer(&r, nullptr);
56 56
57 p.setShader(fDst); 57 p.setShader(fDst);
58 canvas->drawRect(r, p); 58 canvas->drawRect(r, p);
59 p.setShader(fSrc); 59 p.setShader(fSrc);
60 p.setXfermode(SkXfermode::Make(mode)); 60 p.setBlendMode(mode);
61 canvas->drawRect(r, p); 61 canvas->drawRect(r, p);
62 62
63 canvas->restore(); 63 canvas->restore();
64 64
65 r.inset(-SK_ScalarHalf, -SK_ScalarHalf); 65 r.inset(-SK_ScalarHalf, -SK_ScalarHalf);
66 p.setStyle(SkPaint::kStroke_Style); 66 p.setStyle(SkPaint::kStroke_Style);
67 p.setShader(nullptr); 67 p.setShader(nullptr);
68 p.setXfermode(nullptr); 68 p.setBlendMode(SkBlendMode::kSrcOver);
69 canvas->drawRect(r, p); 69 canvas->drawRect(r, p);
70 70
71 canvas->restore(); 71 canvas->restore();
72 72
73 #if 1 73 #if 1
74 canvas->drawText(SkXfermode::ModeName(mode), strlen(SkXfermode::Mode Name(mode)), 74 canvas->drawText(SkXfermode::ModeName(mode), strlen(SkXfermode::Mode Name(mode)),
75 x + w/2, y - labelP.getTextSize()/2, labelP); 75 x + w/2, y - labelP.getTextSize()/2, labelP);
76 #endif 76 #endif
77 x += w + SkIntToScalar(10); 77 x += w + SkIntToScalar(10);
78 if ((m % W) == W - 1) { 78 if ((m % W) == W - 1) {
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 138
139 typedef GM INHERITED; 139 typedef GM INHERITED;
140 }; 140 };
141 141
142 ////////////////////////////////////////////////////////////////////////////// 142 //////////////////////////////////////////////////////////////////////////////
143 143
144 static GM* MyFactory(void*) { return new Xfermodes2GM; } 144 static GM* MyFactory(void*) { return new Xfermodes2GM; }
145 static GMRegistry reg(MyFactory); 145 static GMRegistry reg(MyFactory);
146 146
147 } 147 }
OLDNEW
« no previous file with comments | « gm/xfermodes.cpp ('k') | gm/xfermodes3.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698