OLD | NEW |
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 "SkPath.h" | 9 #include "SkPath.h" |
10 | 10 |
11 typedef SkScalar (*MakePathProc)(SkPath*); | 11 typedef SkScalar (*MakePathProc)(SkPath*); |
12 | 12 |
13 static SkScalar make_triangle(SkPath* path) { | 13 static SkScalar make_triangle(SkPath* path) { |
14 static const int gCoord[] = { | 14 constexpr int gCoord[] = { |
15 10, 20, 15, 5, 30, 30 | 15 10, 20, 15, 5, 30, 30 |
16 }; | 16 }; |
17 path->moveTo(SkIntToScalar(gCoord[0]), SkIntToScalar(gCoord[1])); | 17 path->moveTo(SkIntToScalar(gCoord[0]), SkIntToScalar(gCoord[1])); |
18 path->lineTo(SkIntToScalar(gCoord[2]), SkIntToScalar(gCoord[3])); | 18 path->lineTo(SkIntToScalar(gCoord[2]), SkIntToScalar(gCoord[3])); |
19 path->lineTo(SkIntToScalar(gCoord[4]), SkIntToScalar(gCoord[5])); | 19 path->lineTo(SkIntToScalar(gCoord[4]), SkIntToScalar(gCoord[5])); |
20 path->close(); | 20 path->close(); |
21 path->offset(SkIntToScalar(10), SkIntToScalar(0)); | 21 path->offset(SkIntToScalar(10), SkIntToScalar(0)); |
22 return SkIntToScalar(30); | 22 return SkIntToScalar(30); |
23 } | 23 } |
24 | 24 |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 path->lineTo(28.049999f + xOffset, 25.136419f); | 147 path->lineTo(28.049999f + xOffset, 25.136419f); |
148 path->lineTo(7.7024879f + xOffset, 46.135998f); | 148 path->lineTo(7.7024879f + xOffset, 46.135998f); |
149 path->lineTo(14.810181f + xOffset, 28.683645f); | 149 path->lineTo(14.810181f + xOffset, 28.683645f); |
150 path->lineTo(7.5166659f + xOffset, 28.683645f); | 150 path->lineTo(7.5166659f + xOffset, 28.683645f); |
151 path->lineTo(10.907918f + xOffset, 12.886665f); | 151 path->lineTo(10.907918f + xOffset, 12.886665f); |
152 path->close(); | 152 path->close(); |
153 | 153 |
154 return SkIntToScalar(70); | 154 return SkIntToScalar(70); |
155 } | 155 } |
156 | 156 |
157 static const MakePathProc gProcs[] = { | 157 constexpr MakePathProc gProcs[] = { |
158 make_triangle, | 158 make_triangle, |
159 make_rect, | 159 make_rect, |
160 make_oval, | 160 make_oval, |
161 make_star_5, | 161 make_star_5, |
162 make_star_13, | 162 make_star_13, |
163 make_three_line, | 163 make_three_line, |
164 make_arrow, | 164 make_arrow, |
165 make_curve, | 165 make_curve, |
166 make_battery, | 166 make_battery, |
167 make_battery2 | 167 make_battery2 |
168 }; | 168 }; |
169 | 169 |
170 static const SkScalar gWidths[] = { | 170 constexpr SkScalar gWidths[] = { |
171 2.0f, | 171 2.0f, |
172 3.0f, | 172 3.0f, |
173 4.0f, | 173 4.0f, |
174 5.0f, | 174 5.0f, |
175 6.0f, | 175 6.0f, |
176 7.0f, | 176 7.0f, |
177 7.0f, | 177 7.0f, |
178 14.0f, | 178 14.0f, |
179 0.0f, | 179 0.0f, |
180 0.0f, | 180 0.0f, |
181 }; | 181 }; |
182 | 182 |
183 static const SkScalar gMiters[] = { | 183 constexpr SkScalar gMiters[] = { |
184 2.0f, | 184 2.0f, |
185 3.0f, | 185 3.0f, |
186 3.0f, | 186 3.0f, |
187 3.0f, | 187 3.0f, |
188 4.0f, | 188 4.0f, |
189 4.0f, | 189 4.0f, |
190 4.0f, | 190 4.0f, |
191 4.0f, | 191 4.0f, |
192 4.0f, | 192 4.0f, |
193 4.0f, | 193 4.0f, |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 canvas->translate(SkIntToScalar(0), fDY[i]); | 266 canvas->translate(SkIntToScalar(0), fDY[i]); |
267 } | 267 } |
268 | 268 |
269 } | 269 } |
270 | 270 |
271 private: | 271 private: |
272 typedef skiagm::GM INHERITED; | 272 typedef skiagm::GM INHERITED; |
273 }; | 273 }; |
274 | 274 |
275 DEF_GM(return new SmallPathsGM;) | 275 DEF_GM(return new SmallPathsGM;) |
OLD | NEW |