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 "SkPathPriv.h" |
9 | 10 |
10 static void create_ngon(int n, SkPoint* pts, SkScalar width, SkScalar height) { | 11 static void create_ngon(int n, SkPoint* pts, SkScalar width, SkScalar height) { |
11 float angleStep = 360.0f / n, angle = 0.0f, sin, cos; | 12 float angleStep = 360.0f / n, angle = 0.0f, sin, cos; |
12 if ((n % 2) == 1) { | 13 if ((n % 2) == 1) { |
13 angle = angleStep/2.0f; | 14 angle = angleStep/2.0f; |
14 } | 15 } |
15 | 16 |
16 for (int i = 0; i < n; ++i) { | 17 for (int i = 0; i < n; ++i) { |
17 sin = SkScalarSinCos(SkDegreesToRadians(angle), &cos); | 18 sin = SkScalarSinCos(SkDegreesToRadians(angle), &cos); |
18 pts[i].fX = -sin * width; | 19 pts[i].fX = -sin * width; |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 } | 231 } |
231 } | 232 } |
232 | 233 |
233 path.close(); | 234 path.close(); |
234 #ifdef SK_DEBUG | 235 #ifdef SK_DEBUG |
235 // Each path this method returns should be convex, only composed of | 236 // Each path this method returns should be convex, only composed of |
236 // lines, wound the right direction, and short enough to fit in one | 237 // lines, wound the right direction, and short enough to fit in one |
237 // of the GMs rows. | 238 // of the GMs rows. |
238 SkASSERT(path.isConvex()); | 239 SkASSERT(path.isConvex()); |
239 SkASSERT(SkPath::kLine_SegmentMask == path.getSegmentMasks()); | 240 SkASSERT(SkPath::kLine_SegmentMask == path.getSegmentMasks()); |
240 SkPath::Direction actualDir; | 241 SkPathPriv::FirstDirection actualDir; |
241 SkASSERT(path.cheapComputeDirection(&actualDir)); | 242 SkASSERT(SkPathPriv::CheapComputeFirstDirection(path, &actualDir)); |
242 SkASSERT(dir == actualDir); | 243 SkASSERT(SkPathPriv::AsFirstDirection(dir) == actualDir); |
243 SkRect bounds = path.getBounds(); | 244 SkRect bounds = path.getBounds(); |
244 SkASSERT(SkScalarNearlyEqual(bounds.centerX(), 0.0f)); | 245 SkASSERT(SkScalarNearlyEqual(bounds.centerX(), 0.0f)); |
245 SkASSERT(bounds.height() <= kMaxPathHeight); | 246 SkASSERT(bounds.height() <= kMaxPathHeight); |
246 #endif | 247 #endif |
247 return path; | 248 return path; |
248 } | 249 } |
249 | 250 |
250 // Draw a single path several times, shrinking it, flipping its direction | 251 // Draw a single path several times, shrinking it, flipping its direction |
251 // and changing its start vertex each time. | 252 // and changing its start vertex each time. |
252 void drawPath(SkCanvas* canvas, int index, SkPoint* offset) { | 253 void drawPath(SkCanvas* canvas, int index, SkPoint* offset) { |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 static const int kGMHeight = 512; | 313 static const int kGMHeight = 512; |
313 | 314 |
314 typedef GM INHERITED; | 315 typedef GM INHERITED; |
315 }; | 316 }; |
316 | 317 |
317 ////////////////////////////////////////////////////////////////////////////// | 318 ////////////////////////////////////////////////////////////////////////////// |
318 | 319 |
319 DEF_GM( return SkNEW(ConvexLineOnlyPathsGM); ) | 320 DEF_GM( return SkNEW(ConvexLineOnlyPathsGM); ) |
320 | 321 |
321 } | 322 } |
OLD | NEW |