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

Side by Side Diff: gm/drawatlas.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/colortypexfermode.cpp ('k') | gm/drawatlascolor.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 2015 Google Inc. 2 * Copyright 2015 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 7
8 #include "gm.h" 8 #include "gm.h"
9 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkRSXform.h" 10 #include "SkRSXform.h"
11 #include "SkSurface.h" 11 #include "SkSurface.h"
12 12
13 class DrawAtlasGM : public skiagm::GM { 13 class DrawAtlasGM : public skiagm::GM {
14 static sk_sp<SkImage> MakeAtlas(SkCanvas* caller, const SkRect& target) { 14 static sk_sp<SkImage> MakeAtlas(SkCanvas* caller, const SkRect& target) {
15 SkImageInfo info = SkImageInfo::MakeN32Premul(100, 100); 15 SkImageInfo info = SkImageInfo::MakeN32Premul(100, 100);
16 auto surface(caller->makeSurface(info)); 16 auto surface(caller->makeSurface(info));
17 if (nullptr == surface) { 17 if (nullptr == surface) {
18 surface = SkSurface::MakeRaster(info); 18 surface = SkSurface::MakeRaster(info);
19 } 19 }
20 SkCanvas* canvas = surface->getCanvas(); 20 SkCanvas* canvas = surface->getCanvas();
21 // draw red everywhere, but we don't expect to see it in the draw, testi ng the notion 21 // draw red everywhere, but we don't expect to see it in the draw, testi ng the notion
22 // that drawAtlas draws a subset-region of the atlas. 22 // that drawAtlas draws a subset-region of the atlas.
23 canvas->clear(SK_ColorRED); 23 canvas->clear(SK_ColorRED);
24 24
25 SkPaint paint; 25 SkPaint paint;
26 paint.setXfermodeMode(SkXfermode::kClear_Mode); 26 paint.setBlendMode(SkBlendMode::kClear);
27 SkRect r(target); 27 SkRect r(target);
28 r.inset(-1, -1); 28 r.inset(-1, -1);
29 // zero out a place (with a 1-pixel border) to land our drawing. 29 // zero out a place (with a 1-pixel border) to land our drawing.
30 canvas->drawRect(r, paint); 30 canvas->drawRect(r, paint);
31 paint.setXfermode(nullptr); 31 paint.setBlendMode(SkBlendMode::kSrcOver);
32 paint.setColor(SK_ColorBLUE); 32 paint.setColor(SK_ColorBLUE);
33 paint.setAntiAlias(true); 33 paint.setAntiAlias(true);
34 canvas->drawOval(target, paint); 34 canvas->drawOval(target, paint);
35 return surface->makeImageSnapshot(); 35 return surface->makeImageSnapshot();
36 } 36 }
37 37
38 public: 38 public:
39 DrawAtlasGM() {} 39 DrawAtlasGM() {}
40 40
41 protected: 41 protected:
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 SkPath path; 161 SkPath path;
162 path.addOval(SkRect::MakeXYWH(160, 160, 540, 540)); 162 path.addOval(SkRect::MakeXYWH(160, 160, 540, 540));
163 163
164 draw_text_on_path_rigid(canvas, text0, N, pos, path, paint); 164 draw_text_on_path_rigid(canvas, text0, N, pos, path, paint);
165 165
166 paint.setStyle(SkPaint::kStroke_Style); 166 paint.setStyle(SkPaint::kStroke_Style);
167 canvas->drawPath(path, paint); 167 canvas->drawPath(path, paint);
168 } 168 }
169 169
170 170
OLDNEW
« no previous file with comments | « gm/colortypexfermode.cpp ('k') | gm/drawatlascolor.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698