path ops : fix empty-diff bug, op-in-place

add some debugging around reverse diff, inverse
Review URL: https://codereview.chromium.org/13851015

git-svn-id: http://skia.googlecode.com/svn/trunk@8852 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/pathops/SkOpEdgeBuilder.cpp b/src/pathops/SkOpEdgeBuilder.cpp
index 56e7c20..d1d7af8 100644
--- a/src/pathops/SkOpEdgeBuilder.cpp
+++ b/src/pathops/SkOpEdgeBuilder.cpp
@@ -53,9 +53,13 @@
     fExtra.reset();  // we're done with this
 }
 
-// FIXME:remove once we can access path pts directly
+// Note that copying the points here avoids copying the resulting path later.
+// To allow Op() to take one of the input paths as an output parameter, either the source data
+// must be copied (as implemented below) or the result must be copied.
+// OPTIMIZATION: This copies both sets of input points every time. If the input data was read
+// directly, the output path would only need to be copied if it was also one of the input paths.
 int SkOpEdgeBuilder::preFetch() {
-    SkPath::RawIter iter(*fPath);  // FIXME: access path directly when allowed
+    SkPath::RawIter iter(*fPath);
     SkPoint pts[4];
     SkPath::Verb verb;
     do {
@@ -78,7 +82,11 @@
     const SkPoint* finalCurveStart = NULL;
     const SkPoint* finalCurveEnd = NULL;
     SkPath::Verb verb;
-    while ((verb = (SkPath::Verb) *verbPtr++) != SkPath::kDone_Verb) {
+    while ((verb = (SkPath::Verb) *verbPtr) != SkPath::kDone_Verb) {
+        if (verbPtr == endOfFirstHalf) {
+            fOperand = true;
+        }
+        verbPtr++;
         switch (verb) {
             case SkPath::kMove_Verb:
                 complete();
@@ -89,7 +97,7 @@
                     *fExtra.append() = -1;  // start new contour
                 }
                 finalCurveEnd = pointsPtr++;
-                goto nextVerb;
+                continue;
             case SkPath::kLine_Verb:
                 // skip degenerate points
                 if (pointsPtr[-1].fX != pointsPtr[0].fX || pointsPtr[-1].fY != pointsPtr[0].fY) {
@@ -132,7 +140,7 @@
                     *fExtra.append() = fCurrentContour->addLine(fReducePts.end() - 2);
                 }
                 complete();
-                goto nextVerb;
+                continue;
             default:
                 SkDEBUGFAIL("bad verb");
                 return;
@@ -140,9 +148,5 @@
         finalCurveStart = &pointsPtr[verb - 1];
         pointsPtr += verb;
         SkASSERT(fCurrentContour);
-    nextVerb:
-        if (verbPtr == endOfFirstHalf) {
-            fOperand = true;
-        }
     }
 }