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

Side by Side Diff: gm/pathfill.cpp

Issue 2300623005: Replace a lot of 'static const' with 'constexpr' or 'const'. (Closed)
Patch Set: small msvc concession Created 4 years, 3 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/patheffects.cpp ('k') | gm/perspshaders.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 2011 Google Inc. 2 * Copyright 2011 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 "SkPath.h" 9 #include "SkPath.h"
10 10
11 typedef SkScalar (*MakePathProc)(SkPath*); 11 typedef SkScalar (*MakePathProc)(SkPath*);
12 12
13 static SkScalar make_frame(SkPath* path) { 13 static SkScalar make_frame(SkPath* path) {
14 SkRect r = { SkIntToScalar(10), SkIntToScalar(10), 14 SkRect r = { SkIntToScalar(10), SkIntToScalar(10),
15 SkIntToScalar(630), SkIntToScalar(470) }; 15 SkIntToScalar(630), SkIntToScalar(470) };
16 path->addRoundRect(r, SkIntToScalar(15), SkIntToScalar(15)); 16 path->addRoundRect(r, SkIntToScalar(15), SkIntToScalar(15));
17 17
18 SkPaint paint; 18 SkPaint paint;
19 paint.setStyle(SkPaint::kStroke_Style); 19 paint.setStyle(SkPaint::kStroke_Style);
20 paint.setStrokeWidth(SkIntToScalar(5)); 20 paint.setStrokeWidth(SkIntToScalar(5));
21 paint.getFillPath(*path, path); 21 paint.getFillPath(*path, path);
22 return SkIntToScalar(15); 22 return SkIntToScalar(15);
23 } 23 }
24 24
25 static SkScalar make_triangle(SkPath* path) { 25 static SkScalar make_triangle(SkPath* path) {
26 static const int gCoord[] = { 26 constexpr int gCoord[] = {
27 10, 20, 15, 5, 30, 30 27 10, 20, 15, 5, 30, 30
28 }; 28 };
29 path->moveTo(SkIntToScalar(gCoord[0]), SkIntToScalar(gCoord[1])); 29 path->moveTo(SkIntToScalar(gCoord[0]), SkIntToScalar(gCoord[1]));
30 path->lineTo(SkIntToScalar(gCoord[2]), SkIntToScalar(gCoord[3])); 30 path->lineTo(SkIntToScalar(gCoord[2]), SkIntToScalar(gCoord[3]));
31 path->lineTo(SkIntToScalar(gCoord[4]), SkIntToScalar(gCoord[5])); 31 path->lineTo(SkIntToScalar(gCoord[4]), SkIntToScalar(gCoord[5]));
32 path->close(); 32 path->close();
33 path->offset(SkIntToScalar(10), SkIntToScalar(0)); 33 path->offset(SkIntToScalar(10), SkIntToScalar(0));
34 return SkIntToScalar(30); 34 return SkIntToScalar(30);
35 } 35 }
36 36
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 path->moveTo(SkIntToScalar(30), SkIntToScalar(30)); 95 path->moveTo(SkIntToScalar(30), SkIntToScalar(30));
96 path->lineTo(SkIntToScalar(120), SkIntToScalar(40)); 96 path->lineTo(SkIntToScalar(120), SkIntToScalar(40));
97 path->close(); 97 path->close();
98 path->moveTo(SkIntToScalar(150), SkIntToScalar(30)); 98 path->moveTo(SkIntToScalar(150), SkIntToScalar(30));
99 path->lineTo(SkIntToScalar(150), SkIntToScalar(30)); 99 path->lineTo(SkIntToScalar(150), SkIntToScalar(30));
100 path->lineTo(SkIntToScalar(300), SkIntToScalar(40)); 100 path->lineTo(SkIntToScalar(300), SkIntToScalar(40));
101 path->close(); 101 path->close();
102 return SkIntToScalar(40); 102 return SkIntToScalar(40);
103 } 103 }
104 104
105 static const MakePathProc gProcs[] = { 105 constexpr MakePathProc gProcs[] = {
106 make_frame, 106 make_frame,
107 make_triangle, 107 make_triangle,
108 make_rect, 108 make_rect,
109 make_oval, 109 make_oval,
110 make_sawtooth, 110 make_sawtooth,
111 make_star_5, 111 make_star_5,
112 make_star_13, 112 make_star_13,
113 make_line, 113 make_line,
114 }; 114 };
115 115
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 // Rotated path, which is not antialiased on GPU 232 // Rotated path, which is not antialiased on GPU
233 p.setColor(SK_ColorRED); 233 p.setColor(SK_ColorRED);
234 canvas->rotate(90); 234 canvas->rotate(90);
235 canvas->drawPath(path, p); 235 canvas->drawPath(path, p);
236 } 236 }
237 237
238 /////////////////////////////////////////////////////////////////////////////// 238 ///////////////////////////////////////////////////////////////////////////////
239 239
240 DEF_GM( return new PathFillGM; ) 240 DEF_GM( return new PathFillGM; )
241 DEF_GM( return new PathInverseFillGM; ) 241 DEF_GM( return new PathInverseFillGM; )
OLDNEW
« no previous file with comments | « gm/patheffects.cpp ('k') | gm/perspshaders.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698