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

Side by Side Diff: gm/degeneratesegments.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/dcshader.cpp ('k') | gm/distantclip.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 #include "gm.h" 7 #include "gm.h"
8 #include "SkCanvas.h" 8 #include "SkCanvas.h"
9 #include "SkPaint.h" 9 #include "SkPaint.h"
10 #include "SkPath.h" 10 #include "SkPath.h"
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 paint.setStrokeJoin(join); 201 paint.setStrokeJoin(join);
202 paint.setColor(color); 202 paint.setColor(color);
203 paint.setStyle(style); 203 paint.setStyle(style);
204 canvas->save(); 204 canvas->save();
205 canvas->clipRect(clip); 205 canvas->clipRect(clip);
206 canvas->drawPath(path, paint); 206 canvas->drawPath(path, paint);
207 canvas->restore(); 207 canvas->restore();
208 } 208 }
209 209
210 virtual void onDraw(SkCanvas* canvas) { 210 virtual void onDraw(SkCanvas* canvas) {
211 static const AddSegmentFunc gSegmentFunctions[] = { 211 constexpr AddSegmentFunc gSegmentFunctions[] = {
212 AddMove, 212 AddMove,
213 AddMoveClose, 213 AddMoveClose,
214 AddDegenLine, 214 AddDegenLine,
215 AddMoveDegenLine, 215 AddMoveDegenLine,
216 AddMoveDegenLineClose, 216 AddMoveDegenLineClose,
217 AddDegenQuad, 217 AddDegenQuad,
218 AddMoveDegenQuad, 218 AddMoveDegenQuad,
219 AddMoveDegenQuadClose, 219 AddMoveDegenQuadClose,
220 AddDegenCubic, 220 AddDegenCubic,
221 AddMoveDegenCubic, 221 AddMoveDegenCubic,
222 AddMoveDegenCubicClose, 222 AddMoveDegenCubicClose,
223 AddClose, 223 AddClose,
224 AddLine, 224 AddLine,
225 AddMoveLine, 225 AddMoveLine,
226 AddMoveLineClose, 226 AddMoveLineClose,
227 AddQuad, 227 AddQuad,
228 AddMoveQuad, 228 AddMoveQuad,
229 AddMoveQuadClose, 229 AddMoveQuadClose,
230 AddCubic, 230 AddCubic,
231 AddMoveCubic, 231 AddMoveCubic,
232 AddMoveCubicClose 232 AddMoveCubicClose
233 }; 233 };
234 static const char* gSegmentNames[] = { 234 const char* gSegmentNames[] = {
235 "Move", 235 "Move",
236 "MoveClose", 236 "MoveClose",
237 "DegenLine", 237 "DegenLine",
238 "MoveDegenLine", 238 "MoveDegenLine",
239 "MoveDegenLineClose", 239 "MoveDegenLineClose",
240 "DegenQuad", 240 "DegenQuad",
241 "MoveDegenQuad", 241 "MoveDegenQuad",
242 "MoveDegenQuadClose", 242 "MoveDegenQuadClose",
243 "DegenCubic", 243 "DegenCubic",
244 "MoveDegenCubic", 244 "MoveDegenCubic",
245 "MoveDegenCubicClose", 245 "MoveDegenCubicClose",
246 "Close", 246 "Close",
247 "Line", 247 "Line",
248 "MoveLine", 248 "MoveLine",
249 "MoveLineClose", 249 "MoveLineClose",
250 "Quad", 250 "Quad",
251 "MoveQuad", 251 "MoveQuad",
252 "MoveQuadClose", 252 "MoveQuadClose",
253 "Cubic", 253 "Cubic",
254 "MoveCubic", 254 "MoveCubic",
255 "MoveCubicClose" 255 "MoveCubicClose"
256 }; 256 };
257 257
258 struct FillAndName { 258 struct FillAndName {
259 SkPath::FillType fFill; 259 SkPath::FillType fFill;
260 const char* fName; 260 const char* fName;
261 }; 261 };
262 static const FillAndName gFills[] = { 262 constexpr FillAndName gFills[] = {
263 {SkPath::kWinding_FillType, "Winding"}, 263 {SkPath::kWinding_FillType, "Winding"},
264 {SkPath::kEvenOdd_FillType, "Even / Odd"}, 264 {SkPath::kEvenOdd_FillType, "Even / Odd"},
265 {SkPath::kInverseWinding_FillType, "Inverse Winding"}, 265 {SkPath::kInverseWinding_FillType, "Inverse Winding"},
266 {SkPath::kInverseEvenOdd_FillType, "Inverse Even / Odd"} 266 {SkPath::kInverseEvenOdd_FillType, "Inverse Even / Odd"}
267 }; 267 };
268 struct StyleAndName { 268 struct StyleAndName {
269 SkPaint::Style fStyle; 269 SkPaint::Style fStyle;
270 const char* fName; 270 const char* fName;
271 }; 271 };
272 static const StyleAndName gStyles[] = { 272 constexpr StyleAndName gStyles[] = {
273 {SkPaint::kFill_Style, "Fill"}, 273 {SkPaint::kFill_Style, "Fill"},
274 {SkPaint::kStroke_Style, "Stroke 10"}, 274 {SkPaint::kStroke_Style, "Stroke 10"},
275 {SkPaint::kStrokeAndFill_Style, "Stroke 10 And Fill"} 275 {SkPaint::kStrokeAndFill_Style, "Stroke 10 And Fill"}
276 }; 276 };
277 struct CapAndName { 277 struct CapAndName {
278 SkPaint::Cap fCap; 278 SkPaint::Cap fCap;
279 SkPaint::Join fJoin; 279 SkPaint::Join fJoin;
280 const char* fName; 280 const char* fName;
281 }; 281 };
282 static const CapAndName gCaps[] = { 282 constexpr CapAndName gCaps[] = {
283 {SkPaint::kButt_Cap, SkPaint::kBevel_Join, "Butt"}, 283 {SkPaint::kButt_Cap, SkPaint::kBevel_Join, "Butt"},
284 {SkPaint::kRound_Cap, SkPaint::kRound_Join, "Round"}, 284 {SkPaint::kRound_Cap, SkPaint::kRound_Join, "Round"},
285 {SkPaint::kSquare_Cap, SkPaint::kBevel_Join, "Square"} 285 {SkPaint::kSquare_Cap, SkPaint::kBevel_Join, "Square"}
286 }; 286 };
287 287
288 SkPaint titlePaint; 288 SkPaint titlePaint;
289 titlePaint.setColor(SK_ColorBLACK); 289 titlePaint.setColor(SK_ColorBLACK);
290 titlePaint.setAntiAlias(true); 290 titlePaint.setAntiAlias(true);
291 sk_tool_utils::set_portable_typeface(&titlePaint); 291 sk_tool_utils::set_portable_typeface(&titlePaint);
292 titlePaint.setTextSize(15 * SK_Scalar1); 292 titlePaint.setTextSize(15 * SK_Scalar1);
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 private: 392 private:
393 typedef GM INHERITED; 393 typedef GM INHERITED;
394 }; 394 };
395 395
396 ////////////////////////////////////////////////////////////////////////////// 396 //////////////////////////////////////////////////////////////////////////////
397 397
398 static GM* MyFactory(void*) { return new DegenerateSegmentsGM; } 398 static GM* MyFactory(void*) { return new DegenerateSegmentsGM; }
399 static GMRegistry reg(MyFactory); 399 static GMRegistry reg(MyFactory);
400 400
401 } 401 }
OLDNEW
« no previous file with comments | « gm/dcshader.cpp ('k') | gm/distantclip.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698