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

Side by Side Diff: gm/stringart.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/smallpaths.cpp ('k') | gm/stroke_rect_shader.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 7
8 #include "gm.h" 8 #include "gm.h"
9 #include "SkAnimTimer.h" 9 #include "SkAnimTimer.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
11 #include "SkPath.h" 11 #include "SkPath.h"
12 12
13 // Reproduces https://code.google.com/p/chromium/issues/detail?id=279014 13 // Reproduces https://code.google.com/p/chromium/issues/detail?id=279014
14 14
15 static const int kWidth = 440; 15 constexpr int kWidth = 440;
16 static const int kHeight = 440; 16 constexpr int kHeight = 440;
17 static const SkScalar kAngle = 0.305f; 17 constexpr SkScalar kAngle = 0.305f;
18 static const int kMaxNumSteps = 140; 18 constexpr int kMaxNumSteps = 140;
19 19
20 // Renders a string art shape. 20 // Renders a string art shape.
21 // The particular shape rendered can be controlled by adjusting kAngle, from 0 t o 1 21 // The particular shape rendered can be controlled by adjusting kAngle, from 0 t o 1
22 22
23 class StringArtGM : public skiagm::GM { 23 class StringArtGM : public skiagm::GM {
24 public: 24 public:
25 StringArtGM() : fNumSteps(kMaxNumSteps) {} 25 StringArtGM() : fNumSteps(kMaxNumSteps) {}
26 26
27 protected: 27 protected:
28 28
(...skipping 25 matching lines...) Expand all
54 54
55 SkPaint paint; 55 SkPaint paint;
56 paint.setAntiAlias(true); 56 paint.setAntiAlias(true);
57 paint.setStyle(SkPaint::kStroke_Style); 57 paint.setStyle(SkPaint::kStroke_Style);
58 paint.setColor(sk_tool_utils::color_to_565(0xFF007700)); 58 paint.setColor(sk_tool_utils::color_to_565(0xFF007700));
59 59
60 canvas->drawPath(path, paint); 60 canvas->drawPath(path, paint);
61 } 61 }
62 62
63 bool onAnimate(const SkAnimTimer& timer) override { 63 bool onAnimate(const SkAnimTimer& timer) override {
64 static const SkScalar kDesiredDurationSecs = 3.0f; 64 constexpr SkScalar kDesiredDurationSecs = 3.0f;
65 65
66 // Make the animation ping-pong back and forth but start in the fully dr awn state 66 // Make the animation ping-pong back and forth but start in the fully dr awn state
67 SkScalar fraction = 1.0f - timer.scaled(2.0f/kDesiredDurationSecs, 2.0f) ; 67 SkScalar fraction = 1.0f - timer.scaled(2.0f/kDesiredDurationSecs, 2.0f) ;
68 if (fraction <= 0.0f) { 68 if (fraction <= 0.0f) {
69 fraction = -fraction; 69 fraction = -fraction;
70 } 70 }
71 71
72 SkASSERT(fraction >= 0.0f && fraction <= 1.0f); 72 SkASSERT(fraction >= 0.0f && fraction <= 1.0f);
73 73
74 fNumSteps = (int) (fraction * kMaxNumSteps); 74 fNumSteps = (int) (fraction * kMaxNumSteps);
75 return true; 75 return true;
76 } 76 }
77 77
78 private: 78 private:
79 int fNumSteps; 79 int fNumSteps;
80 80
81 typedef GM INHERITED; 81 typedef GM INHERITED;
82 }; 82 };
83 83
84 DEF_GM( return new StringArtGM; ) 84 DEF_GM( return new StringArtGM; )
OLDNEW
« no previous file with comments | « gm/smallpaths.cpp ('k') | gm/stroke_rect_shader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698