path ops work in progress

BUG=

Review URL: https://codereview.chromium.org/18058007

git-svn-id: http://skia.googlecode.com/svn/trunk@9908 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/pathops/SkIntersections.cpp b/src/pathops/SkIntersections.cpp
index ace8474..af6cc08 100644
--- a/src/pathops/SkIntersections.cpp
+++ b/src/pathops/SkIntersections.cpp
@@ -56,10 +56,31 @@
 
 void SkIntersections::insertCoincidentPair(double s1, double e1, double s2, double e2,
         const SkDPoint& startPt, const SkDPoint& endPt) {
-    if (fSwap) {
-        remove(s2, e2, startPt, endPt);
-    } else {
-        remove(s1, e1, startPt, endPt);
+    SkASSERT(s1 < e1);
+    SkASSERT(s2 != e2);
+    if (coincidentUsed() != fUsed) { // if the curve is partially coincident, treat it as fully so
+        for (int index = fUsed - 1; index >= 0; --index) {
+            if (fIsCoincident[0] & (1 << index)) {
+                continue;
+            }
+            double nonCoinT = fT[0][index];
+            if (!between(s1, nonCoinT, e1)) {
+                if (s1 > nonCoinT) {
+                    s1 = nonCoinT;
+                } else {
+                    e1 = nonCoinT;
+                }
+            }
+            nonCoinT = fT[1][index];
+            if (!between(s2, nonCoinT, e2)) {
+                if ((s2 > nonCoinT) ^ (s2 > e2)) {
+                    s2 = nonCoinT;
+                } else {
+                    e2 = nonCoinT;
+                }
+            }
+            removeOne(index);
+        }
     }
     SkASSERT(coincidentUsed() == fUsed);
     SkASSERT((coincidentUsed() & 1) != 1);
@@ -135,7 +156,7 @@
     insertCoincident(e1, e2, endPt);
 }
 
-int SkIntersections::insert(double one, double two, const SkDPoint& pt) {
+int SkIntersections::insert(double one, double two, double x, double y) {
     if (fIsCoincident[0] == 3 && between(fT[0][0], one, fT[0][1])) {
         // For now, don't allow a mix of coincident and non-coincident intersections
         return -1;
@@ -152,7 +173,8 @@
                     || (precisely_equal(two, 1) && !precisely_equal(oldTwo, 1))) {
                 fT[0][index] = one;
                 fT[1][index] = two;
-                fPt[index] = pt;
+                fPt[index].fX = x;
+                fPt[index].fY = y;
             }
             return -1;
         }
@@ -174,13 +196,18 @@
         fIsCoincident[0] += fIsCoincident[0] & ~((1 << index) - 1);
         fIsCoincident[1] += fIsCoincident[1] & ~((1 << index) - 1);
     }
-    fPt[index] = pt;
+    fPt[index].fX = x;
+    fPt[index].fY = y;
     fT[0][index] = one;
     fT[1][index] = two;
     ++fUsed;
     return index;
 }
 
+int SkIntersections::insert(double one, double two, const SkDPoint& pt) {
+    return insert(one, two, pt.fX, pt.fY);
+}
+
 void SkIntersections::insertCoincident(double one, double two, const SkDPoint& pt) {
     int index = insertSwap(one, two, pt);
     int bit = 1 << index;
@@ -209,6 +236,7 @@
     }
 }
 
+#if 0
 void SkIntersections::remove(double one, double two, const SkDPoint& startPt,
         const SkDPoint& endPt) {
     for (int index = fUsed - 1; index >= 0; --index) {
@@ -220,6 +248,7 @@
         }
     }
 }
+#endif
 
 void SkIntersections::removeOne(int index) {
     int remaining = --fUsed - index;