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

Unified Diff: src/pathops/SkDLineIntersection.cpp

Issue 633393002: harden pathops for pathological test (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: exclude new test that asserts in debug Created 6 years, 1 month 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 | « src/pathops/SkDCubicIntersection.cpp ('k') | src/pathops/SkDQuadIntersection.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/pathops/SkDLineIntersection.cpp
diff --git a/src/pathops/SkDLineIntersection.cpp b/src/pathops/SkDLineIntersection.cpp
index b209474066bde4865da3e2fa27e1c6a004c265c2..8fc673f2fb80e36558df1ae889a82863e6e05975 100644
--- a/src/pathops/SkDLineIntersection.cpp
+++ b/src/pathops/SkDLineIntersection.cpp
@@ -26,19 +26,24 @@ SkDPoint SkIntersections::Line(const SkDLine& a, const SkDLine& b) {
return p;
}
-void SkIntersections::cleanUpCoincidence() {
- SkASSERT(fUsed == 2);
- // both t values are good
- bool startMatch = fT[0][0] == 0 && (fT[1][0] == 0 || fT[1][0] == 1);
- bool endMatch = fT[0][1] == 1 && (fT[1][1] == 0 || fT[1][1] == 1);
- if (startMatch || endMatch) {
- removeOne(startMatch);
- return;
- }
- // either t value is good
- bool pStartMatch = fT[0][0] == 0 || fT[1][0] == 0 || fT[1][0] == 1;
- bool pEndMatch = fT[0][1] == 1 || fT[1][1] == 0 || fT[1][1] == 1;
- removeOne(pStartMatch || !pEndMatch);
+int SkIntersections::cleanUpCoincidence() {
+ do {
+ int last = fUsed - 1;
+ for (int index = 0; index < last; ++index) {
+ if (fT[0][index] == fT[0][index + 1]) {
+ removeOne(index + (int) (fT[1][index] == 0 || fT[1][index] == 1));
+ goto tryAgain;
+ }
+ }
+ for (int index = 0; index < last; ++index) {
+ if (fT[1][index] == fT[1][index + 1]) {
+ removeOne(index + (int) (fT[0][index] == 0 || fT[0][index] == 1));
+ goto tryAgain;
+ }
+ }
+ return fUsed;
+tryAgain: ;
+ } while (true);
}
void SkIntersections::cleanUpParallelLines(bool parallel) {
« no previous file with comments | « src/pathops/SkDCubicIntersection.cpp ('k') | src/pathops/SkDQuadIntersection.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698