aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/pathops/SkDLineIntersection.cpp
diff options
context:
space:
mode:
authorGravatar caryclark <caryclark@google.com>2014-11-13 06:58:52 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2014-11-13 06:58:52 -0800
commit65f553182ab7069378ef863d30094d0327f178d0 (patch)
tree4e7a435941ae82ddd6cab0abcfb2ed7946f79969 /src/pathops/SkDLineIntersection.cpp
parentb1cff03325c42bb1cd87204d9b0dd3d6b9678d3e (diff)
These tests stress pathops by describing the union of circle-like paths that have tiny line segments embedded and double back to create near-coincident conditions.
The fixes include - detect when finding the active top loops between two possible answers - preflight chasing winding to ensure answer is consistent - binary search more often when quadratic intersection fails - add more failure paths when an intersect is missed While this fixes the chrome bug, reenabling path ops in svg should be deferred until additional fixes are landed. TBR= BUG=421132 Committed: https://skia.googlesource.com/skia/+/6f726addf3178b01949bb389ef83cf14a1d7b6b2 Review URL: https://codereview.chromium.org/633393002
Diffstat (limited to 'src/pathops/SkDLineIntersection.cpp')
-rw-r--r--src/pathops/SkDLineIntersection.cpp31
1 files changed, 18 insertions, 13 deletions
diff --git a/src/pathops/SkDLineIntersection.cpp b/src/pathops/SkDLineIntersection.cpp
index b209474066..8fc673f2fb 100644
--- a/src/pathops/SkDLineIntersection.cpp
+++ b/src/pathops/SkDLineIntersection.cpp
@@ -26,19 +26,24 @@ SkDPoint SkIntersections::Line(const SkDLine& a, const SkDLine& b) {
return p;
}
-void SkIntersections::cleanUpCoincidence() {
- SkASSERT(fUsed == 2);
- // both t values are good
- bool startMatch = fT[0][0] == 0 && (fT[1][0] == 0 || fT[1][0] == 1);
- bool endMatch = fT[0][1] == 1 && (fT[1][1] == 0 || fT[1][1] == 1);
- if (startMatch || endMatch) {
- removeOne(startMatch);
- return;
- }
- // either t value is good
- bool pStartMatch = fT[0][0] == 0 || fT[1][0] == 0 || fT[1][0] == 1;
- bool pEndMatch = fT[0][1] == 1 || fT[1][1] == 0 || fT[1][1] == 1;
- removeOne(pStartMatch || !pEndMatch);
+int SkIntersections::cleanUpCoincidence() {
+ do {
+ int last = fUsed - 1;
+ for (int index = 0; index < last; ++index) {
+ if (fT[0][index] == fT[0][index + 1]) {
+ removeOne(index + (int) (fT[1][index] == 0 || fT[1][index] == 1));
+ goto tryAgain;
+ }
+ }
+ for (int index = 0; index < last; ++index) {
+ if (fT[1][index] == fT[1][index + 1]) {
+ removeOne(index + (int) (fT[0][index] == 0 || fT[0][index] == 1));
+ goto tryAgain;
+ }
+ }
+ return fUsed;
+tryAgain: ;
+ } while (true);
}
void SkIntersections::cleanUpParallelLines(bool parallel) {