Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(100)

Unified Diff: src/pathops/SkOpContour.cpp

Issue 556433002: fail when coincidence is too far apart (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: merge fix from trunk for issue 410552 Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/pathops/SkOpSegment.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/pathops/SkOpContour.cpp
diff --git a/src/pathops/SkOpContour.cpp b/src/pathops/SkOpContour.cpp
index e4dd62a653d3235aea9f623ef7f402c95a59f0ad..467fab31f57da1a92febb42e2cd59fc9159016bf 100644
--- a/src/pathops/SkOpContour.cpp
+++ b/src/pathops/SkOpContour.cpp
@@ -57,6 +57,21 @@ SkOpSegment* SkOpContour::nonVerticalSegment(int* start, int* end) {
return NULL;
}
+// if one is very large the smaller may have collapsed to nothing
+static void bump_out_close_span(double* startTPtr, double* endTPtr) {
+ double startT = *startTPtr;
+ double endT = *endTPtr;
+ if (approximately_negative(endT - startT)) {
+ if (endT <= 1 - FLT_EPSILON) {
+ *endTPtr += FLT_EPSILON;
+ SkASSERT(*endTPtr <= 1);
+ } else {
+ *startTPtr -= FLT_EPSILON;
+ SkASSERT(*startTPtr >= 0);
+ }
+ }
+}
+
// first pass, add missing T values
// second pass, determine winding values of overlaps
void SkOpContour::addCoincidentPoints() {
@@ -82,15 +97,7 @@ void SkOpContour::addCoincidentPoints() {
if ((cancelers = startSwapped = startT > endT)) {
SkTSwap(startT, endT);
}
- if (startT == endT) { // if one is very large the smaller may have collapsed to nothing
- if (endT <= 1 - FLT_EPSILON) {
- endT += FLT_EPSILON;
- SkASSERT(endT <= 1);
- } else {
- startT -= FLT_EPSILON;
- SkASSERT(startT >= 0);
- }
- }
+ bump_out_close_span(&startT, &endT);
SkASSERT(!approximately_negative(endT - startT));
double oStartT = coincidence.fTs[1][0];
double oEndT = coincidence.fTs[1][1];
@@ -98,6 +105,7 @@ void SkOpContour::addCoincidentPoints() {
SkTSwap(oStartT, oEndT);
cancelers ^= true;
}
+ bump_out_close_span(&oStartT, &oEndT);
SkASSERT(!approximately_negative(oEndT - oStartT));
const SkPoint& startPt = coincidence.fPts[0][startSwapped];
if (cancelers) {
@@ -559,15 +567,7 @@ void SkOpContour::calcCommonCoincidentWinding(const SkCoincidence& coincidence)
SkTSwap<double>(startT, endT);
SkTSwap<const SkPoint*>(startPt, endPt);
}
- if (startT == endT) { // if span is very large, the smaller may have collapsed to nothing
- if (endT <= 1 - FLT_EPSILON) {
- endT += FLT_EPSILON;
- SkASSERT(endT <= 1);
- } else {
- startT -= FLT_EPSILON;
- SkASSERT(startT >= 0);
- }
- }
+ bump_out_close_span(&startT, &endT);
SkASSERT(!approximately_negative(endT - startT));
double oStartT = coincidence.fTs[1][0];
double oEndT = coincidence.fTs[1][1];
@@ -575,6 +575,7 @@ void SkOpContour::calcCommonCoincidentWinding(const SkCoincidence& coincidence)
SkTSwap<double>(oStartT, oEndT);
cancelers ^= true;
}
+ bump_out_close_span(&oStartT, &oEndT);
SkASSERT(!approximately_negative(oEndT - oStartT));
if (cancelers) {
thisOne.addTCancel(*startPt, *endPt, &other);
« no previous file with comments | « no previous file | src/pathops/SkOpSegment.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698