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

Side by Side Diff: gm/convexpolyeffect.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/convexpolyclip.cpp ('k') | gm/cubicpaths.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 2014 Google Inc. 2 * Copyright 2014 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 // This test only works with the GPU backend. 8 // This test only works with the GPU backend.
9 9
10 #include "gm.h" 10 #include "gm.h"
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 tri.lineTo(100.f, 20.f); 103 tri.lineTo(100.f, 20.f);
104 tri.lineTo(15.f, 100.f); 104 tri.lineTo(15.f, 100.f);
105 105
106 fPaths.addToTail(tri); 106 fPaths.addToTail(tri);
107 fPaths.addToTail(SkPath())->reverseAddPath(tri); 107 fPaths.addToTail(SkPath())->reverseAddPath(tri);
108 108
109 tri.close(); 109 tri.close();
110 fPaths.addToTail(tri); 110 fPaths.addToTail(tri);
111 111
112 SkPath ngon; 112 SkPath ngon;
113 static const SkScalar kRadius = 50.f; 113 constexpr SkScalar kRadius = 50.f;
114 const SkPoint center = { kRadius, kRadius }; 114 const SkPoint center = { kRadius, kRadius };
115 for (int i = 0; i < GrConvexPolyEffect::kMaxEdges; ++i) { 115 for (int i = 0; i < GrConvexPolyEffect::kMaxEdges; ++i) {
116 SkScalar angle = 2 * SK_ScalarPI * i / GrConvexPolyEffect::kMaxEdges ; 116 SkScalar angle = 2 * SK_ScalarPI * i / GrConvexPolyEffect::kMaxEdges ;
117 SkPoint point; 117 SkPoint point;
118 point.fY = SkScalarSinCos(angle, &point.fX); 118 point.fY = SkScalarSinCos(angle, &point.fX);
119 point.scale(kRadius); 119 point.scale(kRadius);
120 point = center + point; 120 point = center + point;
121 if (0 == i) { 121 if (0 == i) {
122 ngon.moveTo(point); 122 ngon.moveTo(point);
123 } else { 123 } else {
(...skipping 29 matching lines...) Expand all
153 } 153 }
154 154
155 void onDraw(SkCanvas* canvas) override { 155 void onDraw(SkCanvas* canvas) override {
156 GrDrawContext* drawContext = canvas->internal_private_accessTopLayerDraw Context(); 156 GrDrawContext* drawContext = canvas->internal_private_accessTopLayerDraw Context();
157 if (!drawContext) { 157 if (!drawContext) {
158 skiagm::GM::DrawGpuOnlyMessage(canvas); 158 skiagm::GM::DrawGpuOnlyMessage(canvas);
159 return; 159 return;
160 } 160 }
161 161
162 SkScalar y = 0; 162 SkScalar y = 0;
163 static const SkScalar kDX = 12.f; 163 constexpr SkScalar kDX = 12.f;
164 for (PathList::Iter iter(fPaths, PathList::Iter::kHead_IterStart); 164 for (PathList::Iter iter(fPaths, PathList::Iter::kHead_IterStart);
165 iter.get(); 165 iter.get();
166 iter.next()) { 166 iter.next()) {
167 const SkPath* path = iter.get(); 167 const SkPath* path = iter.get();
168 SkScalar x = 0; 168 SkScalar x = 0;
169 169
170 for (int et = 0; et < kGrProcessorEdgeTypeCnt; ++et) { 170 for (int et = 0; et < kGrProcessorEdgeTypeCnt; ++et) {
171 const SkMatrix m = SkMatrix::MakeTrans(x, y); 171 const SkMatrix m = SkMatrix::MakeTrans(x, y);
172 SkPath p; 172 SkPath p;
173 path->transform(m, &p); 173 path->transform(m, &p);
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 PathList fPaths; 248 PathList fPaths;
249 RectList fRects; 249 RectList fRects;
250 250
251 typedef GM INHERITED; 251 typedef GM INHERITED;
252 }; 252 };
253 253
254 DEF_GM(return new ConvexPolyEffect;) 254 DEF_GM(return new ConvexPolyEffect;)
255 } 255 }
256 256
257 #endif 257 #endif
OLDNEW
« no previous file with comments | « gm/convexpolyclip.cpp ('k') | gm/cubicpaths.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698