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

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

Issue 2338323002: quad and conic do not intersect (Closed)
Patch Set: turn off under development 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 | « src/pathops/SkOpCoincidence.cpp ('k') | src/pathops/SkPathOpsDebug.h » ('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 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 #include "SkPathOpsBounds.h" 7 #include "SkPathOpsBounds.h"
8 #include "SkPathOpsRect.h" 8 #include "SkPathOpsRect.h"
9 #include "SkPathOpsCurve.h" 9 #include "SkPathOpsCurve.h"
10 10
11 // this cheats and assumes that the perpendicular to the point is the closest r ay to the curve 11 // this cheats and assumes that the perpendicular to the point is the closest r ay to the curve
12 // this case (where the line and the curve are nearly coincident) may be the on ly case that counts 12 // this case (where the line and the curve are nearly coincident) may be the on ly case that counts
13 double SkDCurve::nearPoint(SkPath::Verb verb, const SkDPoint& xy, const SkDPoint & opp) const { 13 double SkDCurve::nearPoint(SkPath::Verb verb, const SkDPoint& xy, const SkDPoint & opp) const {
14 int count = SkPathOpsVerbToPoints(verb); 14 int count = SkPathOpsVerbToPoints(verb);
15 double minX = fCubic.fPts[0].fX; 15 double minX = fCubic.fPts[0].fX;
16 double maxX = minX; 16 double maxX = minX;
17 for (int index = 0; index < count; ++index) { 17 for (int index = 1; index <= count; ++index) {
18 minX = SkTMin(minX, fCubic.fPts[index].fX); 18 minX = SkTMin(minX, fCubic.fPts[index].fX);
19 maxX = SkTMax(maxX, fCubic.fPts[index].fX); 19 maxX = SkTMax(maxX, fCubic.fPts[index].fX);
20 } 20 }
21 if (!AlmostBetweenUlps(minX, xy.fX, maxX)) { 21 if (!AlmostBetweenUlps(minX, xy.fX, maxX)) {
22 return -1; 22 return -1;
23 } 23 }
24 double minY = fCubic.fPts[0].fY; 24 double minY = fCubic.fPts[0].fY;
25 double maxY = minY; 25 double maxY = minY;
26 for (int index = 0; index < count; ++index) { 26 for (int index = 1; index <= count; ++index) {
27 minY = SkTMin(minY, fCubic.fPts[index].fY); 27 minY = SkTMin(minY, fCubic.fPts[index].fY);
28 maxY = SkTMax(maxY, fCubic.fPts[index].fY); 28 maxY = SkTMax(maxY, fCubic.fPts[index].fY);
29 } 29 }
30 if (!AlmostBetweenUlps(minY, xy.fY, maxY)) { 30 if (!AlmostBetweenUlps(minY, xy.fY, maxY)) {
31 return -1; 31 return -1;
32 } 32 }
33 SkIntersections i; 33 SkIntersections i;
34 SkDLine perp = {{ xy, { xy.fX + opp.fY - xy.fY, xy.fY + xy.fX - opp.fX }}}; 34 SkDLine perp = {{ xy, { xy.fX + opp.fY - xy.fY, xy.fY + xy.fX - opp.fX }}};
35 (*CurveDIntersectRay[verb])(*this, perp, &i); 35 (*CurveDIntersectRay[verb])(*this, perp, &i);
36 int minIndex = -1; 36 int minIndex = -1;
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 if (s3x2 * s2x1 < 0) { 136 if (s3x2 * s2x1 < 0) {
137 SkASSERT(s2x1 * s1x3 > 0); 137 SkASSERT(s2x1 * s1x3 > 0);
138 fSweep[0] = fSweep[1]; 138 fSweep[0] = fSweep[1];
139 fOrdered = false; 139 fOrdered = false;
140 } 140 }
141 fSweep[1] = thirdSweep; 141 fSweep[1] = thirdSweep;
142 } 142 }
143 setIsCurve: 143 setIsCurve:
144 fIsCurve = fSweep[0].crossCheck(fSweep[1]) != 0; 144 fIsCurve = fSweep[0].crossCheck(fSweep[1]) != 0;
145 } 145 }
OLDNEW
« no previous file with comments | « src/pathops/SkOpCoincidence.cpp ('k') | src/pathops/SkPathOpsDebug.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698