rework xor to be more like winding
Pathops is very well exercised with winding paths,
but less so with xor (even odd) paths.
Rewrite the xor main loop to look like the winding
one to take advantage of the latter's bug fixes.
TBR=reed@google.com
BUG=skia:6041
Change-Id: Ied8d522254a327b1817b54f0abbf4414f5fab7da
Reviewed-on: https://skia-review.googlesource.com/6228
Reviewed-by: Cary Clark <caryclark@google.com>
Commit-Queue: Cary Clark <caryclark@google.com>
diff --git a/src/pathops/SkPathOpsSimplify.cpp b/src/pathops/SkPathOpsSimplify.cpp
index 8cd770d..eb71e73 100644
--- a/src/pathops/SkPathOpsSimplify.cpp
+++ b/src/pathops/SkPathOpsSimplify.cpp
@@ -84,30 +84,25 @@
// returns true if all edges were processed
static bool bridgeXor(SkOpContourHead* contourList, SkPathWriter* simple) {
- SkOpSegment* current;
- SkOpSpanBase* start;
- SkOpSpanBase* end;
bool unsortable = false;
- while ((current = FindUndone(contourList, &start, &end))) {
+ do {
+ SkOpSpan* span = FindUndone(contourList);
+ if (!span) {
+ break;
+ }
+ SkOpSegment* current = span->segment();
+ SkOpSpanBase* start = span->next();
+ SkOpSpanBase* end = span;
do {
if (!unsortable && current->done()) {
- SkPathOpsDebug::ShowActiveSpans(contourList);
+ break;
}
SkASSERT(unsortable || !current->done());
SkOpSpanBase* nextStart = start;
SkOpSpanBase* nextEnd = end;
- SkOpSegment* next = current->findNextXor(&nextStart, &nextEnd, &unsortable);
+ SkOpSegment* next = current->findNextXor(&nextStart, &nextEnd,
+ &unsortable);
if (!next) {
- if (!unsortable && simple->hasMove()
- && current->verb() != SkPath::kLine_Verb
- && !simple->isClosed()) {
- if (!current->addCurveTo(start, end, simple)) {
- return false;
- }
- if (!simple->isClosed()) {
- SkPathOpsDebug::ShowActiveSpans(contourList);
- }
- }
break;
}
#if DEBUG_FLOW
@@ -123,7 +118,6 @@
end = nextEnd;
} while (!simple->isClosed() && (!unsortable || !start->starter(end)->done()));
if (!simple->isClosed()) {
- SkASSERT(unsortable);
SkOpSpan* spanStart = start->starter(end);
if (!spanStart->done()) {
if (!current->addCurveTo(start, end, simple)) {
@@ -134,7 +128,7 @@
}
simple->finishContour();
SkPathOpsDebug::ShowActiveSpans(contourList);
- }
+ } while (true);
return true;
}