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

Side by Side Diff: gm/perspshaders.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/pathfill.cpp ('k') | gm/pictureimagegenerator.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 "SkGradientShader.h" 9 #include "SkGradientShader.h"
10 #include "SkImage.h" 10 #include "SkImage.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 fBitmapShader = SkShader::MakeBitmapShader(fBitmap, SkShader::kClamp_Til eMode, 49 fBitmapShader = SkShader::MakeBitmapShader(fBitmap, SkShader::kClamp_Til eMode,
50 SkShader::kClamp_TileMode); 50 SkShader::kClamp_TileMode);
51 SkPoint pts1[] = { 51 SkPoint pts1[] = {
52 { 0, 0 }, 52 { 0, 0 },
53 { SkIntToScalar(kCellSize), SkIntToScalar(kCellSize) } 53 { SkIntToScalar(kCellSize), SkIntToScalar(kCellSize) }
54 }; 54 };
55 SkPoint pts2[] = { 55 SkPoint pts2[] = {
56 { 0, 0 }, 56 { 0, 0 },
57 { 0, SkIntToScalar(kCellSize) } 57 { 0, SkIntToScalar(kCellSize) }
58 }; 58 };
59 static const SkColor colors[] = { 59 constexpr SkColor colors[] = {
60 SK_ColorRED, SK_ColorGREEN, SK_ColorRED, SK_ColorGREEN, SK_ColorRED 60 SK_ColorRED, SK_ColorGREEN, SK_ColorRED, SK_ColorGREEN, SK_ColorRED
61 }; 61 };
62 static const SkScalar pos[] = { 0, 0.25f, 0.5f, 0.75f, SK_Scalar1 }; 62 constexpr SkScalar pos[] = { 0, 0.25f, 0.5f, 0.75f, SK_Scalar1 };
63 63
64 fLinearGrad1 = SkGradientShader::MakeLinear(pts1, colors, pos, SK_ARRAY_ COUNT(colors), 64 fLinearGrad1 = SkGradientShader::MakeLinear(pts1, colors, pos, SK_ARRAY_ COUNT(colors),
65 SkShader::kClamp_TileMode); 65 SkShader::kClamp_TileMode);
66 fLinearGrad2 = SkGradientShader::MakeLinear(pts2, colors, pos, SK_ARRAY_ COUNT(colors), 66 fLinearGrad2 = SkGradientShader::MakeLinear(pts2, colors, pos, SK_ARRAY_ COUNT(colors),
67 SkShader::kClamp_TileMode); 67 SkShader::kClamp_TileMode);
68 68
69 fPerspMatrix.reset(); 69 fPerspMatrix.reset();
70 fPerspMatrix.setPerspY(SK_Scalar1 / 50); 70 fPerspMatrix.setPerspY(SK_Scalar1 / 50);
71 71
72 fPath.moveTo(0, 0); 72 fPath.moveTo(0, 0);
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 this->drawRow(canvas, kNone_SkFilterQuality); 144 this->drawRow(canvas, kNone_SkFilterQuality);
145 canvas->translate(0, SkIntToScalar(kCellSize)); 145 canvas->translate(0, SkIntToScalar(kCellSize));
146 this->drawRow(canvas, kLow_SkFilterQuality); 146 this->drawRow(canvas, kLow_SkFilterQuality);
147 canvas->translate(0, SkIntToScalar(kCellSize)); 147 canvas->translate(0, SkIntToScalar(kCellSize));
148 this->drawRow(canvas, kMedium_SkFilterQuality); 148 this->drawRow(canvas, kMedium_SkFilterQuality);
149 canvas->translate(0, SkIntToScalar(kCellSize)); 149 canvas->translate(0, SkIntToScalar(kCellSize));
150 this->drawRow(canvas, kHigh_SkFilterQuality); 150 this->drawRow(canvas, kHigh_SkFilterQuality);
151 canvas->translate(0, SkIntToScalar(kCellSize)); 151 canvas->translate(0, SkIntToScalar(kCellSize));
152 } 152 }
153 private: 153 private:
154 static const int kCellSize = 50; 154 static constexpr int kCellSize = 50;
155 static const int kNumRows = 4; 155 static constexpr int kNumRows = 4;
156 static const int kNumCols = 6; 156 static constexpr int kNumCols = 6;
157 157
158 bool fDoAA; 158 bool fDoAA;
159 SkPath fPath; 159 SkPath fPath;
160 sk_sp<SkShader> fBitmapShader; 160 sk_sp<SkShader> fBitmapShader;
161 sk_sp<SkShader> fLinearGrad1; 161 sk_sp<SkShader> fLinearGrad1;
162 sk_sp<SkShader> fLinearGrad2; 162 sk_sp<SkShader> fLinearGrad2;
163 SkMatrix fPerspMatrix; 163 SkMatrix fPerspMatrix;
164 sk_sp<SkImage> fImage; 164 sk_sp<SkImage> fImage;
165 SkBitmap fBitmap; 165 SkBitmap fBitmap;
166 166
167 typedef GM INHERITED; 167 typedef GM INHERITED;
168 }; 168 };
169 169
170 ////////////////////////////////////////////////////////////////////////////// 170 //////////////////////////////////////////////////////////////////////////////
171 171
172 DEF_GM(return new PerspShadersGM(true);) 172 DEF_GM(return new PerspShadersGM(true);)
173 DEF_GM(return new PerspShadersGM(false);) 173 DEF_GM(return new PerspShadersGM(false);)
174 } 174 }
OLDNEW
« no previous file with comments | « gm/pathfill.cpp ('k') | gm/pictureimagegenerator.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698