path ops -- fix skp bugs
This fixes a series of bugs discovered by running
the small set of Skia skp files through pathops
to flatten the clips.
Review URL: https://codereview.chromium.org/14798004
git-svn-id: http://skia.googlecode.com/svn/trunk@9042 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/pathops/SkPathOpsOp.cpp b/src/pathops/SkPathOpsOp.cpp
index 80e698c..db55635 100644
--- a/src/pathops/SkPathOpsOp.cpp
+++ b/src/pathops/SkPathOpsOp.cpp
@@ -149,11 +149,15 @@
do {
if (current->activeOp(index, endIndex, xorMask, xorOpMask, op)) {
do {
- #if DEBUG_ACTIVE_SPANS
if (!unsortable && current->done()) {
+ #if DEBUG_ACTIVE_SPANS
DebugShowActiveSpans(contourList);
- }
#endif
+ if (simple->isEmpty()) {
+ simple->init();
+ break;
+ }
+ }
SkASSERT(unsortable || !current->done());
int nextStart = index;
int nextEnd = endIndex;
@@ -177,10 +181,10 @@
current = next;
index = nextStart;
endIndex = nextEnd;
- } while (!simple->isClosed() && ((!unsortable)
+ } while (!simple->isClosed() && (!unsortable
|| !current->done(SkMin32(index, endIndex))));
if (current->activeWinding(index, endIndex) && !simple->isClosed()) {
- SkASSERT(unsortable);
+ SkASSERT(unsortable || simple->isEmpty());
int min = SkMin32(index, endIndex);
if (!current->done(min)) {
current->addCurveTo(index, endIndex, simple, true);
@@ -227,6 +231,11 @@
};
bool Op(const SkPath& one, const SkPath& two, SkPathOp op, SkPath* result) {
+#if DEBUG_SHOW_PATH
+ ShowPath(one, "path");
+ ShowPath(two, "pathB");
+ ShowOp(op, "path", "pathB");
+#endif
op = gOpInverse[op][one.isInverseFillType()][two.isInverseFillType()];
SkPath::FillType fillType = gOutInverse[op][one.isInverseFillType()][two.isInverseFillType()]
? SkPath::kInverseEvenOdd_FillType : SkPath::kEvenOdd_FillType;
@@ -288,7 +297,7 @@
#endif
FixOtherTIndex(&contourList);
SortSegments(&contourList);
-#if DEBUG_ACTIVE_SPANS
+#if DEBUG_ACTIVE_SPANS || DEBUG_ACTIVE_SPANS_FIRST_ONLY
DebugShowActiveSpans(contourList);
#endif
// construct closed contours