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

Unified Diff: src/pathops/SkPathOpsCubic.cpp

Issue 1920663002: pathops: Split loop type cubics only when there is a self-intersection. (Closed) Base URL: https://skia.googlesource.com/skia.git/@master
Patch Set: Created 4 years, 8 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 | « src/pathops/SkOpEdgeBuilder.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/pathops/SkPathOpsCubic.cpp
diff --git a/src/pathops/SkPathOpsCubic.cpp b/src/pathops/SkPathOpsCubic.cpp
index 2542ca58848c9e7da4834b165473c1f71ed3bc83..c511d0da50eab2b51bab9fa3edefc83a8fded5ed 100644
--- a/src/pathops/SkPathOpsCubic.cpp
+++ b/src/pathops/SkPathOpsCubic.cpp
@@ -240,13 +240,13 @@ bool SkDCubic::ComplexBreak(const SkPoint pointsPtr[4], SkScalar* t) {
SkScalar lt = 2.f * d[0];
SkScalar ms = d[1] + tempSqrt;
SkScalar mt = 2.f * d[0];
- if (between(0, ls, lt) || between(0, ms, mt)) {
+ if (between(0, ls, lt) && between(0, ms, mt)) { // Both in [0, 1] interval.
ls = ls / lt;
ms = ms / mt;
- SkScalar smaller = SkTMax(0.f, SkTMin(ls, ms));
- SkScalar larger = SkTMin(1.f, SkTMax(ls, ms));
- *t = (smaller + larger) / 2;
- return *t > 0 && *t < 1;
+ SkASSERT(ls >= 0 && ls <= 1 && ms >= 0 && ms <= 1); // Both in [0, 1].
caryclark 2016/04/25 14:46:30 use between, e.g.: SkASSERT(between(0, ls, 1) &&
+ *t = (ls + ms) / 2;
+ SkASSERT(*t >= 0 && *t <= 1); // Average should also be in [0, 1].
caryclark 2016/04/25 14:46:30 use between
+ return *t > 0 && *t < 1; // Check that the cut isn't on an endpoint.
caryclark 2016/04/25 14:46:30 use zero_or_one(t)
}
} else if (kSerpentine_SkCubicType == cubicType || kCusp_SkCubicType == cubicType) {
SkDCubic cubic;
« no previous file with comments | « src/pathops/SkOpEdgeBuilder.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698