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

Side by Side Diff: src/pathops/SkDLineIntersection.cpp

Issue 239563004: fix minor skp-found bugs (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix mac-detected errors Created 6 years, 7 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 | « src/pathops/SkDCubicIntersection.cpp ('k') | src/pathops/SkDQuadLineIntersection.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 2012 Google Inc. 2 * Copyright 2012 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 #include "SkIntersections.h" 7 #include "SkIntersections.h"
8 #include "SkPathOpsLine.h" 8 #include "SkPathOpsLine.h"
9 9
10 /* Determine the intersection point of two lines. This assumes the lines are not parallel, 10 /* Determine the intersection point of two lines. This assumes the lines are not parallel,
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 fT[0][0] = vertical_intercept(line, x); 285 fT[0][0] = vertical_intercept(line, x);
286 } else if (verticalType == 2) { 286 } else if (verticalType == 2) {
287 fT[0][0] = 0; 287 fT[0][0] = 0;
288 fT[0][1] = 1; 288 fT[0][1] = 1;
289 } 289 }
290 return fUsed = verticalType; 290 return fUsed = verticalType;
291 } 291 }
292 292
293 int SkIntersections::vertical(const SkDLine& line, double top, double bottom, 293 int SkIntersections::vertical(const SkDLine& line, double top, double bottom,
294 double x, bool flipped) { 294 double x, bool flipped) {
295 fMax = 2; 295 fMax = 3; // cleanup parallel lines will bring this back line
296 // see if end points intersect the opposite line 296 // see if end points intersect the opposite line
297 double t; 297 double t;
298 SkDPoint topPt = { x, top }; 298 SkDPoint topPt = { x, top };
299 if ((t = line.exactPoint(topPt)) >= 0) { 299 if ((t = line.exactPoint(topPt)) >= 0) {
300 insert(t, (double) flipped, topPt); 300 insert(t, (double) flipped, topPt);
301 } 301 }
302 if (top != bottom) { 302 if (top != bottom) {
303 SkDPoint bottomPt = { x, bottom }; 303 SkDPoint bottomPt = { x, bottom };
304 if ((t = line.exactPoint(bottomPt)) >= 0) { 304 if ((t = line.exactPoint(bottomPt)) >= 0) {
305 insert(t, (double) !flipped, bottomPt); 305 insert(t, (double) !flipped, bottomPt);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 insert(t, (double) !flipped, bottomPt); 337 insert(t, (double) !flipped, bottomPt);
338 } 338 }
339 for (int index = 0; index < 2; ++index) { 339 for (int index = 0; index < 2; ++index) {
340 if ((t = SkDLine::NearPointV(line[index], top, bottom, x)) >= 0) { 340 if ((t = SkDLine::NearPointV(line[index], top, bottom, x)) >= 0) {
341 insert((double) index, flipped ? 1 - t : t, line[index]); 341 insert((double) index, flipped ? 1 - t : t, line[index]);
342 } 342 }
343 } 343 }
344 } 344 }
345 } 345 }
346 cleanUpParallelLines(result == 2); 346 cleanUpParallelLines(result == 2);
347 SkASSERT(fUsed <= 2);
347 return fUsed; 348 return fUsed;
348 } 349 }
349 350
350 // from http://www.bryceboe.com/wordpress/wp-content/uploads/2006/10/intersect.p y 351 // from http://www.bryceboe.com/wordpress/wp-content/uploads/2006/10/intersect.p y
351 // 4 subs, 2 muls, 1 cmp 352 // 4 subs, 2 muls, 1 cmp
352 static bool ccw(const SkDPoint& A, const SkDPoint& B, const SkDPoint& C) { 353 static bool ccw(const SkDPoint& A, const SkDPoint& B, const SkDPoint& C) {
353 return (C.fY - A.fY) * (B.fX - A.fX) > (B.fY - A.fY) * (C.fX - A.fX); 354 return (C.fY - A.fY) * (B.fX - A.fX) > (B.fY - A.fY) * (C.fX - A.fX);
354 } 355 }
355 356
356 // 16 subs, 8 muls, 6 cmps 357 // 16 subs, 8 muls, 6 cmps
357 bool SkIntersections::Test(const SkDLine& a, const SkDLine& b) { 358 bool SkIntersections::Test(const SkDLine& a, const SkDLine& b) {
358 return ccw(a[0], b[0], b[1]) != ccw(a[1], b[0], b[1]) 359 return ccw(a[0], b[0], b[1]) != ccw(a[1], b[0], b[1])
359 && ccw(a[0], a[1], b[0]) != ccw(a[0], a[1], b[1]); 360 && ccw(a[0], a[1], b[0]) != ccw(a[0], a[1], b[1]);
360 } 361 }
OLDNEW
« no previous file with comments | « src/pathops/SkDCubicIntersection.cpp ('k') | src/pathops/SkDQuadLineIntersection.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698