path ops work in progress
path ops work in progress
BUG=
Review URL: https://codereview.chromium.org/21359002
git-svn-id: http://skia.googlecode.com/svn/trunk@11291 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/pathops/SkAddIntersections.cpp b/src/pathops/SkAddIntersections.cpp
index 0d65446..0507984 100644
--- a/src/pathops/SkAddIntersections.cpp
+++ b/src/pathops/SkAddIntersections.cpp
@@ -176,9 +176,10 @@
bool AddIntersectTs(SkOpContour* test, SkOpContour* next) {
if (test != next) {
- if (test->bounds().fBottom < next->bounds().fTop) {
+ if (AlmostLessUlps(test->bounds().fBottom, next->bounds().fTop)) {
return false;
}
+ // OPTIMIZATION: outset contour bounds a smidgen instead?
if (!SkPathOpsBounds::Intersects(test->bounds(), next->bounds())) {
return true;
}
@@ -373,12 +374,22 @@
continue;
}
}
+ if (pts >= 2) {
+ for (int pt = 0; pt < pts - 1; ++pt) {
+ const SkDPoint& point = ts.pt(pt);
+ const SkDPoint& next = ts.pt(pt + 1);
+ if (wt.isNear(ts[swap][pt], ts[swap][pt + 1], point, next)
+ && wn.isNear(ts[!swap][pt], ts[!swap][pt + 1], point, next)) {
+ wt.addPartialCoincident(wn, ts, pt, swap);
+ }
+ }
+ }
for (int pt = 0; pt < pts; ++pt) {
SkASSERT(ts[0][pt] >= 0 && ts[0][pt] <= 1);
SkASSERT(ts[1][pt] >= 0 && ts[1][pt] <= 1);
SkPoint point = ts.pt(pt).asSkPoint();
- int testTAt = wt.addT(wn, point, ts[swap][pt]);
- int nextTAt = wn.addT(wt, point, ts[!swap][pt]);
+ int testTAt = wt.addT(wn, point, ts[swap][pt], swap && ts.isNear(pt));
+ int nextTAt = wn.addT(wt, point, ts[!swap][pt], !swap && ts.isNear(pt));
wt.addOtherT(testTAt, ts[!swap][pt], nextTAt);
wn.addOtherT(nextTAt, ts[swap][pt], testTAt);
}
@@ -405,7 +416,7 @@
SkASSERT(ts[1][0] >= 0 && ts[1][0] <= 1);
SkPoint point = ts.pt(0).asSkPoint();
int testTAt = wt.addSelfT(wt, point, ts[0][0]);
- int nextTAt = wt.addT(wt, point, ts[1][0]);
+ int nextTAt = wt.addT(wt, point, ts[1][0], ts.isNear(0));
wt.addOtherT(testTAt, ts[1][0], nextTAt);
wt.addOtherT(nextTAt, ts[0][0], testTAt);
} while (wt.advance());
@@ -425,6 +436,6 @@
}
for (int cIndex = 0; cIndex < contourCount; ++cIndex) {
SkOpContour* contour = (*contourList)[cIndex];
- contour->findTooCloseToCall();
+ contour->calcPartialCoincidentWinding();
}
}