diff options
author | deanm <deanm@chromium.org> | 2016-04-26 14:15:21 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-04-26 14:15:21 -0700 |
commit | 83496425e3216a1d3d1613a8ddd4d3bb7d71638a (patch) | |
tree | db15c46d05618cb0bbadcc58ab7f292ab35539f2 | |
parent | b77821c30cd07507447244271eedf4e7c615e35a (diff) |
pathops: Split loop type cubics only when there is a self-intersection.
The ComplexBreak code comes from Loop and Blinn, which requires loops to be
split if either double point is visible. However for intersection loops only
need to be split when there is actually a self-intersection (when both double
points are in [0, 1]). This patch splits cubics much less often so the output
doesn't have extra segments unless the input had a self-intersecting loop.
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1920663002
Review URL: https://codereview.chromium.org/1920663002
-rw-r--r-- | src/pathops/SkPathOpsCubic.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/pathops/SkPathOpsCubic.cpp b/src/pathops/SkPathOpsCubic.cpp index 2542ca5884..6b74fb00ef 100644 --- a/src/pathops/SkPathOpsCubic.cpp +++ b/src/pathops/SkPathOpsCubic.cpp @@ -240,12 +240,12 @@ 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 (roughly_between(0, ls, lt) && roughly_between(0, ms, mt)) { 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; + SkASSERT(roughly_between(0, ls, 1) && roughly_between(0, ms, 1)); + *t = (ls + ms) / 2; + SkASSERT(roughly_between(0, *t, 1)); return *t > 0 && *t < 1; } } else if (kSerpentine_SkCubicType == cubicType || kCusp_SkCubicType == cubicType) { |