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

Side by Side Diff: gm/aaxfermodes.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/aarectmodes.cpp ('k') | gm/alphagradients.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 #include "gm.h" 7 #include "gm.h"
8 #include "SkArithmeticMode.h" 8 #include "SkArithmeticMode.h"
9 #include "SkPath.h" 9 #include "SkPath.h"
10 #include "SkShader.h" 10 #include "SkShader.h"
11 #include "SkXfermode.h" 11 #include "SkXfermode.h"
12 12
13 enum { 13 enum {
14 kXfermodeCount = SkXfermode::kLastMode + 2, // All xfermodes plus arithmetic mode. 14 kXfermodeCount = SkXfermode::kLastMode + 2, // All xfermodes plus arithmetic mode.
15 kShapeSize = 22, 15 kShapeSize = 22,
16 kShapeSpacing = 36, 16 kShapeSpacing = 36,
17 kShapeTypeSpacing = 4 * kShapeSpacing / 3, 17 kShapeTypeSpacing = 4 * kShapeSpacing / 3,
18 kPaintSpacing = 4 * kShapeTypeSpacing, 18 kPaintSpacing = 4 * kShapeTypeSpacing,
19 kLabelSpacing = 3 * kShapeSize, 19 kLabelSpacing = 3 * kShapeSize,
20 kMargin = kShapeSpacing / 2, 20 kMargin = kShapeSpacing / 2,
21 kXfermodeTypeSpacing = kLabelSpacing + 2 * kPaintSpacing + kShapeTypeSpacing , 21 kXfermodeTypeSpacing = kLabelSpacing + 2 * kPaintSpacing + kShapeTypeSpacing ,
22 kTitleSpacing = 3 * kShapeSpacing / 4, 22 kTitleSpacing = 3 * kShapeSpacing / 4,
23 kSubtitleSpacing = 5 * kShapeSpacing / 8 23 kSubtitleSpacing = 5 * kShapeSpacing / 8
24 }; 24 };
25 25
26 static const SkColor kBGColor = SkColorSetARGB(200, 210, 184, 135); 26 constexpr SkColor kBGColor = 0xc8d2b887;
27 27
28 static const SkColor kShapeColors[2] = { 28 constexpr SkColor kShapeColors[2] = {
29 SkColorSetARGB(130, 255, 0, 128), // input color unknown 29 0x82ff0080, // input color unknown
30 SkColorSetARGB(255, 0, 255, 255) // input color opaque 30 0xff00ffff, // input color opaque
31 }; 31 };
32 32
33 enum Shape { 33 enum Shape {
34 kSquare_Shape, 34 kSquare_Shape,
35 kDiamond_Shape, 35 kDiamond_Shape,
36 kOval_Shape, 36 kOval_Shape,
37 kConcave_Shape, 37 kConcave_Shape,
38 38
39 kLast_Shape = kConcave_Shape 39 kLast_Shape = kConcave_Shape
40 }; 40 };
(...skipping 25 matching lines...) Expand all
66 2 * kMargin + kTitleSpacing + kSubtitleSpacing + 66 2 * kMargin + kTitleSpacing + kSubtitleSpacing +
67 (1 + SkXfermode::kLastCoeffMode) * kShapeSpacing); 67 (1 + SkXfermode::kLastCoeffMode) * kShapeSpacing);
68 } 68 }
69 69
70 void onOnceBeforeDraw() override { 70 void onOnceBeforeDraw() override {
71 fLabelPaint.setAntiAlias(true); 71 fLabelPaint.setAntiAlias(true);
72 sk_tool_utils::set_portable_typeface(&fLabelPaint); 72 sk_tool_utils::set_portable_typeface(&fLabelPaint);
73 fLabelPaint.setTextSize(5 * kShapeSize/8); 73 fLabelPaint.setTextSize(5 * kShapeSize/8);
74 fLabelPaint.setSubpixelText(true); 74 fLabelPaint.setSubpixelText(true);
75 75
76 static const SkScalar radius = -1.4f * kShapeSize/2; 76 constexpr SkScalar radius = -1.4f * kShapeSize/2;
77 SkPoint pts[4] = { 77 SkPoint pts[4] = {
78 {-radius, 0}, 78 {-radius, 0},
79 {0, -1.33f * radius}, 79 {0, -1.33f * radius},
80 {radius, 0}, 80 {radius, 0},
81 {0, 1.33f * radius} 81 {0, 1.33f * radius}
82 }; 82 };
83 fOval.moveTo(pts[0]); 83 fOval.moveTo(pts[0]);
84 fOval.quadTo(pts[1], pts[2]); 84 fOval.quadTo(pts[1], pts[2]);
85 fOval.quadTo(pts[3], pts[0]); 85 fOval.quadTo(pts[3], pts[0]);
86 86
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 275
276 typedef GM INHERITED; 276 typedef GM INHERITED;
277 }; 277 };
278 278
279 ////////////////////////////////////////////////////////////////////////////// 279 //////////////////////////////////////////////////////////////////////////////
280 280
281 static GM* MyFactory(void*) { return new AAXfermodesGM; } 281 static GM* MyFactory(void*) { return new AAXfermodesGM; }
282 static GMRegistry reg(MyFactory); 282 static GMRegistry reg(MyFactory);
283 283
284 } 284 }
OLDNEW
« no previous file with comments | « gm/aarectmodes.cpp ('k') | gm/alphagradients.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698