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

Side by Side Diff: gm/convex_all_line_paths.cpp

Issue 1176953002: move SkPath direction-as-computed into SkPathPriv (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 6 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 | « no previous file | gm/strokefill.cpp » ('j') | src/core/SkPath.cpp » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « no previous file | gm/strokefill.cpp » ('j') | src/core/SkPath.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698