OLD | NEW |
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 "SkPathOpsCubic.h" | 8 #include "SkPathOpsCubic.h" |
9 #include "SkPathOpsLine.h" | 9 #include "SkPathOpsLine.h" |
10 | 10 |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 | 91 |
92 void allowNear(bool allow) { | 92 void allowNear(bool allow) { |
93 fAllowNear = allow; | 93 fAllowNear = allow; |
94 } | 94 } |
95 | 95 |
96 void checkCoincident() { | 96 void checkCoincident() { |
97 int last = fIntersections->used() - 1; | 97 int last = fIntersections->used() - 1; |
98 for (int index = 0; index < last; ) { | 98 for (int index = 0; index < last; ) { |
99 double cubicMidT = ((*fIntersections)[0][index] + (*fIntersections)[
0][index + 1]) / 2; | 99 double cubicMidT = ((*fIntersections)[0][index] + (*fIntersections)[
0][index + 1]) / 2; |
100 SkDPoint cubicMidPt = fCubic.ptAtT(cubicMidT); | 100 SkDPoint cubicMidPt = fCubic.ptAtT(cubicMidT); |
101 double t = fLine.nearPoint(cubicMidPt, NULL); | 101 double t = fLine.nearPoint(cubicMidPt, nullptr); |
102 if (t < 0) { | 102 if (t < 0) { |
103 ++index; | 103 ++index; |
104 continue; | 104 continue; |
105 } | 105 } |
106 if (fIntersections->isCoincident(index)) { | 106 if (fIntersections->isCoincident(index)) { |
107 fIntersections->removeOne(index); | 107 fIntersections->removeOne(index); |
108 --last; | 108 --last; |
109 } else if (fIntersections->isCoincident(index + 1)) { | 109 } else if (fIntersections->isCoincident(index + 1)) { |
110 fIntersections->removeOne(index + 1); | 110 fIntersections->removeOne(index + 1); |
111 --last; | 111 --last; |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 } | 278 } |
279 | 279 |
280 /* Note that this does not look for endpoints of the line that are near the
cubic. | 280 /* Note that this does not look for endpoints of the line that are near the
cubic. |
281 These points are found later when check ends looks for missing points */ | 281 These points are found later when check ends looks for missing points */ |
282 void addNearEndPoints() { | 282 void addNearEndPoints() { |
283 for (int cIndex = 0; cIndex < 4; cIndex += 3) { | 283 for (int cIndex = 0; cIndex < 4; cIndex += 3) { |
284 double cubicT = (double) (cIndex >> 1); | 284 double cubicT = (double) (cIndex >> 1); |
285 if (fIntersections->hasT(cubicT)) { | 285 if (fIntersections->hasT(cubicT)) { |
286 continue; | 286 continue; |
287 } | 287 } |
288 double lineT = fLine.nearPoint(fCubic[cIndex], NULL); | 288 double lineT = fLine.nearPoint(fCubic[cIndex], nullptr); |
289 if (lineT < 0) { | 289 if (lineT < 0) { |
290 continue; | 290 continue; |
291 } | 291 } |
292 fIntersections->insert(cubicT, lineT, fCubic[cIndex]); | 292 fIntersections->insert(cubicT, lineT, fCubic[cIndex]); |
293 } | 293 } |
294 } | 294 } |
295 | 295 |
296 void addExactHorizontalEndPoints(double left, double right, double y) { | 296 void addExactHorizontalEndPoints(double left, double right, double y) { |
297 for (int cIndex = 0; cIndex < 4; cIndex += 3) { | 297 for (int cIndex = 0; cIndex < 4; cIndex += 3) { |
298 double lineT = SkDLine::ExactPointH(fCubic[cIndex], left, right, y); | 298 double lineT = SkDLine::ExactPointH(fCubic[cIndex], left, right, y); |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
428 | 428 |
429 // SkDCubic accessors to Intersection utilities | 429 // SkDCubic accessors to Intersection utilities |
430 | 430 |
431 int SkDCubic::horizontalIntersect(double yIntercept, double roots[3]) const { | 431 int SkDCubic::horizontalIntersect(double yIntercept, double roots[3]) const { |
432 return LineCubicIntersections::HorizontalIntersect(*this, yIntercept, roots)
; | 432 return LineCubicIntersections::HorizontalIntersect(*this, yIntercept, roots)
; |
433 } | 433 } |
434 | 434 |
435 int SkDCubic::verticalIntersect(double xIntercept, double roots[3]) const { | 435 int SkDCubic::verticalIntersect(double xIntercept, double roots[3]) const { |
436 return LineCubicIntersections::VerticalIntersect(*this, xIntercept, roots); | 436 return LineCubicIntersections::VerticalIntersect(*this, xIntercept, roots); |
437 } | 437 } |
OLD | NEW |