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

Side by Side Diff: gm/gradientDirtyLaundry.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/gm.cpp ('k') | gm/gradient_matrix.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 "SkGradientShader.h" 8 #include "SkGradientShader.h"
9 9
10 using namespace skiagm; 10 using namespace skiagm;
11 11
12 struct GradData { 12 struct GradData {
13 int fCount; 13 int fCount;
14 const SkColor* fColors; 14 const SkColor* fColors;
15 const SkScalar* fPos; 15 const SkScalar* fPos;
16 }; 16 };
17 17
18 static const SkColor gColors[] = { 18 constexpr SkColor gColors[] = {
19 SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE, SK_ColorWHITE, SK_ColorBLACK, 19 SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE, SK_ColorWHITE, SK_ColorBLACK,
20 SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE, SK_ColorWHITE, SK_ColorBLACK, 20 SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE, SK_ColorWHITE, SK_ColorBLACK,
21 SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE, SK_ColorWHITE, SK_ColorBLACK, 21 SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE, SK_ColorWHITE, SK_ColorBLACK,
22 SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE, SK_ColorWHITE, SK_ColorBLACK, 22 SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE, SK_ColorWHITE, SK_ColorBLACK,
23 SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE, SK_ColorWHITE, SK_ColorBLACK, 23 SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE, SK_ColorWHITE, SK_ColorBLACK,
24 SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE, SK_ColorWHITE, SK_ColorBLACK, 24 SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE, SK_ColorWHITE, SK_ColorBLACK,
25 SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE, SK_ColorWHITE, SK_ColorBLACK, 25 SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE, SK_ColorWHITE, SK_ColorBLACK,
26 SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE, SK_ColorWHITE, SK_ColorBLACK, 26 SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE, SK_ColorWHITE, SK_ColorBLACK,
27 }; 27 };
28 28
29 //static const SkScalar gPos[] = { SK_Scalar1*999/2000, SK_Scalar1*1001/2000 }; 29 //constexpr SkScalar gPos[] = { SK_Scalar1*999/2000, SK_Scalar1*1001/2000 };
30 30
31 static const GradData gGradData[] = { 31 constexpr GradData gGradData[] = {
32 { 40, gColors, nullptr }, 32 { 40, gColors, nullptr },
33 // { 2, gColors, gPos }, 33 // { 2, gColors, gPos },
34 // { 2, gCol2, nullptr }, 34 // { 2, gCol2, nullptr },
35 }; 35 };
36 36
37 static sk_sp<SkShader> MakeLinear(const SkPoint pts[2], const GradData& data, Sk Shader::TileMode tm) { 37 static sk_sp<SkShader> MakeLinear(const SkPoint pts[2], const GradData& data, Sk Shader::TileMode tm) {
38 return SkGradientShader::MakeLinear(pts, data.fColors, data.fPos, data.fCoun t, tm); 38 return SkGradientShader::MakeLinear(pts, data.fColors, data.fPos, data.fCoun t, tm);
39 } 39 }
40 40
41 static sk_sp<SkShader> MakeRadial(const SkPoint pts[2], const GradData& data, Sk Shader::TileMode tm) { 41 static sk_sp<SkShader> MakeRadial(const SkPoint pts[2], const GradData& data, Sk Shader::TileMode tm) {
42 const SkPoint pt{ SkScalarAve(pts[0].fX, pts[1].fX), SkScalarAve(pts[0].fY, pts[1].fY) }; 42 const SkPoint pt{ SkScalarAve(pts[0].fX, pts[1].fX), SkScalarAve(pts[0].fY, pts[1].fY) };
43 return SkGradientShader::MakeRadial(pt, pt.fX, data.fColors, data.fPos, data .fCount, tm); 43 return SkGradientShader::MakeRadial(pt, pt.fX, data.fColors, data.fPos, data .fCount, tm);
44 } 44 }
45 45
46 static sk_sp<SkShader> MakeSweep(const SkPoint pts[2], const GradData& data, SkS hader::TileMode) { 46 static sk_sp<SkShader> MakeSweep(const SkPoint pts[2], const GradData& data, SkS hader::TileMode) {
47 const SkPoint pt{ SkScalarAve(pts[0].fX, pts[1].fX), SkScalarAve(pts[0].fY, pts[1].fY) }; 47 const SkPoint pt{ SkScalarAve(pts[0].fX, pts[1].fX), SkScalarAve(pts[0].fY, pts[1].fY) };
48 return SkGradientShader::MakeSweep(pt.fX, pt.fY, data.fColors, data.fPos, da ta.fCount); 48 return SkGradientShader::MakeSweep(pt.fX, pt.fY, data.fColors, data.fPos, da ta.fCount);
49 } 49 }
50 50
51 51
52 typedef sk_sp<SkShader> (*GradMaker)(const SkPoint pts[2], const GradData&, SkSh ader::TileMode); 52 typedef sk_sp<SkShader> (*GradMaker)(const SkPoint pts[2], const GradData&, SkSh ader::TileMode);
53 53
54 static const GradMaker gGradMakers[] = { 54 constexpr GradMaker gGradMakers[] = {
55 MakeLinear, MakeRadial, MakeSweep, 55 MakeLinear, MakeRadial, MakeSweep,
56 }; 56 };
57 57
58 /////////////////////////////////////////////////////////////////////////////// 58 ///////////////////////////////////////////////////////////////////////////////
59 59
60 class GradientsGM : public GM { 60 class GradientsGM : public GM {
61 public: 61 public:
62 GradientsGM() { 62 GradientsGM() {
63 this->setBGColor(sk_tool_utils::color_to_565(0xFFDDDDDD)); 63 this->setBGColor(sk_tool_utils::color_to_565(0xFFDDDDDD));
64 } 64 }
(...skipping 25 matching lines...) Expand all
90 } 90 }
91 91
92 private: 92 private:
93 typedef GM INHERITED; 93 typedef GM INHERITED;
94 }; 94 };
95 95
96 /////////////////////////////////////////////////////////////////////////////// 96 ///////////////////////////////////////////////////////////////////////////////
97 97
98 static GM* MyFactory(void*) { return new GradientsGM; } 98 static GM* MyFactory(void*) { return new GradientsGM; }
99 static GMRegistry reg(MyFactory); 99 static GMRegistry reg(MyFactory);
OLDNEW
« no previous file with comments | « gm/gm.cpp ('k') | gm/gradient_matrix.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698