aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/pathops/SkPathOpsCommon.cpp
diff options
context:
space:
mode:
authorGravatar hcm <hcm@google.com>2014-10-28 10:55:54 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-10-28 10:55:54 -0700
commit27c46a08a9210e9306b8ea1b00349ec198153c38 (patch)
tree31548283108b4e997adc12651ae77acbb6c3fc8c /src/pathops/SkPathOpsCommon.cpp
parentee0c2e4fd429424beaa35f29e7f656997ba3f115 (diff)
Revert of harden pathops for pathological test (patchset #19 id:410001 of https://codereview.chromium.org/633393002/)
Reason for revert: Compile errors on bots Original issue's description: > These tests stress pathops by describing the union of circle-like paths that have tiny line segments embedded and double back to create near-coincident conditions. > > The fixes include > - detect when finding the active top loops between two possible answers > - preflight chasing winding to ensure answer is consistent > - binary search more often when quadratic intersection fails > - add more failure paths when an intersect is missed > > While this fixes the chrome bug, reenabling path ops in svg should be deferred until additional fixes are landed. > > TBR= > BUG=421132 > > Committed: https://skia.googlesource.com/skia/+/6f726addf3178b01949bb389ef83cf14a1d7b6b2 TBR=caryclark@google.com NOTREECHECKS=true NOTRY=true BUG=421132 Review URL: https://codereview.chromium.org/686843002
Diffstat (limited to 'src/pathops/SkPathOpsCommon.cpp')
-rw-r--r--src/pathops/SkPathOpsCommon.cpp63
1 files changed, 7 insertions, 56 deletions
diff --git a/src/pathops/SkPathOpsCommon.cpp b/src/pathops/SkPathOpsCommon.cpp
index 1a5bfc1889..f7b7273a8d 100644
--- a/src/pathops/SkPathOpsCommon.cpp
+++ b/src/pathops/SkPathOpsCommon.cpp
@@ -161,7 +161,7 @@ SkOpSegment* FindChase(SkTDArray<SkOpSpan*>* chase, int* tIndex, int* endIndex)
if (!sortable) {
continue;
}
- // find first angle, initialize winding to computed wind sum
+ // find first angle, initialize winding to computed fWindSum
const SkOpAngle* angle = segment->spanToAngle(*tIndex, *endIndex);
const SkOpAngle* firstAngle;
SkDEBUGCODE(firstAngle = angle);
@@ -208,8 +208,7 @@ SkOpSegment* FindChase(SkTDArray<SkOpSpan*>* chase, int* tIndex, int* endIndex)
if (SkOpSegment::UseInnerWinding(maxWinding, winding)) {
maxWinding = winding;
}
- // allowed to do nothing
- (void) segment->markAndChaseWinding(angle, maxWinding, 0, NULL);
+ (void) segment->markAndChaseWinding(angle, maxWinding, 0);
break;
}
}
@@ -316,12 +315,6 @@ static void skipVertical(const SkTArray<SkOpContour*, true>& contourList,
return;
}
-struct SortableTop { // error if local in pre-C++11
- SkOpSegment* fSegment;
- int fIndex;
- int fEndIndex;
-};
-
SkOpSegment* FindSortableTop(const SkTArray<SkOpContour*, true>& contourList,
SkOpAngle::IncludeType angleIncludeType, bool* firstContour, int* indexPtr,
int* endIndexPtr, SkPoint* topLeft, bool* unsortable, bool* done, bool* onlyVertical,
@@ -363,8 +356,6 @@ SkOpSegment* FindSortableTop(const SkTArray<SkOpContour*, true>& contourList,
double tHit;
SkScalar hitDx = 0;
SkScalar hitOppDx = 0;
- // keep track of subsequent returns to detect infinite loops
- SkTDArray<SortableTop> sortableTops;
do {
// if current is vertical, find another candidate which is not
// if only remaining candidates are vertical, then they can be marked done
@@ -375,35 +366,6 @@ SkOpSegment* FindSortableTop(const SkTArray<SkOpContour*, true>& contourList,
tryAgain = false;
contourWinding = rightAngleWinding(contourList, &current, indexPtr, endIndexPtr, &tHit,
&hitDx, &tryAgain, onlyVertical, false);
- if (tryAgain) {
- bool giveUp = false;
- int count = sortableTops.count();
- for (int index = 0; index < count; ++index) {
- const SortableTop& prev = sortableTops[index];
- if (giveUp) {
- prev.fSegment->markDoneFinal(prev.fIndex);
- } else if (prev.fSegment == current
- && (prev.fIndex == *indexPtr || prev.fEndIndex == *endIndexPtr)) {
- // remaining edges are non-vertical and cannot have their winding computed
- // mark them as done and return, and hope that assembly can fill the holes
- giveUp = true;
- index = -1;
- }
- }
- if (giveUp) {
- *done = true;
- return NULL;
- }
- }
- SortableTop* sortableTop = sortableTops.append();
- sortableTop->fSegment = current;
- sortableTop->fIndex = *indexPtr;
- sortableTop->fEndIndex = *endIndexPtr;
-#if DEBUG_SORT
- SkDebugf("%s current=%d index=%d endIndex=%d tHit=%1.9g hitDx=%1.9g try=%d vert=%d\n",
- __FUNCTION__, current->debugID(), *indexPtr, *endIndexPtr, tHit, hitDx, tryAgain,
- *onlyVertical);
-#endif
if (*onlyVertical) {
return current;
}
@@ -416,16 +378,10 @@ SkOpSegment* FindSortableTop(const SkTArray<SkOpContour*, true>& contourList,
oppContourWinding = rightAngleWinding(contourList, &current, indexPtr, endIndexPtr, &tHit,
&hitOppDx, &tryAgain, NULL, true);
} while (tryAgain);
- bool success = current->initWinding(*indexPtr, *endIndexPtr, tHit, contourWinding, hitDx,
- oppContourWinding, hitOppDx);
+ current->initWinding(*indexPtr, *endIndexPtr, tHit, contourWinding, hitDx, oppContourWinding,
+ hitOppDx);
if (current->done()) {
return NULL;
- } else if (!success) { // check if the span has a valid winding
- int min = SkTMin(*indexPtr, *endIndexPtr);
- const SkOpSpan& span = current->span(min);
- if (span.fWindSum == SK_MinS32) {
- return NULL;
- }
}
return current;
}
@@ -449,17 +405,14 @@ static void checkDuplicates(SkTArray<SkOpContour*, true>* contourList) {
}
}
-static bool checkEnds(SkTArray<SkOpContour*, true>* contourList) {
+static void checkEnds(SkTArray<SkOpContour*, true>* contourList) {
// it's hard to determine if the end of a cubic or conic nearly intersects another curve.
// instead, look to see if the connecting curve intersected at that same end.
int contourCount = (*contourList).count();
for (int cTest = 0; cTest < contourCount; ++cTest) {
SkOpContour* contour = (*contourList)[cTest];
- if (!contour->checkEnds()) {
- return false;
- }
+ contour->checkEnds();
}
- return true;
}
static bool checkMultiples(SkTArray<SkOpContour*, true>* contourList) {
@@ -753,9 +706,7 @@ bool HandleCoincidence(SkTArray<SkOpContour*, true>* contourList, int total) {
SkOpContour::debugShowWindingValues(contourList);
#endif
fixOtherTIndex(contourList);
- if (!checkEnds(contourList)) { // check if connecting curve intersected at the same end
- return false;
- }
+ checkEnds(contourList); // check if connecting curve intersected at the same end
bool hasM = checkMultiples(contourList); // check if intersections agree on t and point values
SkTDArray<SkOpSegment::AlignedSpan> aligned;
if (hasM) {