From afca4d6bc00a16e80b93f20742db9391bf65f508 Mon Sep 17 00:00:00 2001 From: Cary Clark Date: Fri, 1 Dec 2017 15:23:00 -0500 Subject: fix pathops handling of tiny wrapback quads and cubics If a quad or cubic reverses on itself, path ops breaks it in two. It determines the type of curve remaining, but needs to replace near-zero with zero first. TBR=reed@google.com Bug:790731 Change-Id: I3a1afa14fff064ca874b5abc768ec1ec5c2cf22f Reviewed-on: https://skia-review.googlesource.com/79400 Commit-Queue: Cary Clark Reviewed-by: Cary Clark --- src/pathops/SkOpEdgeBuilder.cpp | 3 +++ src/pathops/SkPathOpsCubic.cpp | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/pathops/SkOpEdgeBuilder.cpp b/src/pathops/SkOpEdgeBuilder.cpp index c1224c3603..572942dab4 100644 --- a/src/pathops/SkOpEdgeBuilder.cpp +++ b/src/pathops/SkOpEdgeBuilder.cpp @@ -215,6 +215,9 @@ bool SkOpEdgeBuilder::walk() { if (!SkScalarsAreFinite(&pair[0].fX, SK_ARRAY_COUNT(pair) * 2)) { return false; } + for (unsigned index = 0; index < SK_ARRAY_COUNT(pair); ++index) { + force_small_to_zero(&pair[index]); + } SkPoint cStorage[2][2]; SkPath::Verb v1 = SkReduceOrder::Quad(&pair[0], cStorage[0]); SkPath::Verb v2 = SkReduceOrder::Quad(&pair[2], cStorage[1]); diff --git a/src/pathops/SkPathOpsCubic.cpp b/src/pathops/SkPathOpsCubic.cpp index 5c672fa397..33229fa8ae 100644 --- a/src/pathops/SkPathOpsCubic.cpp +++ b/src/pathops/SkPathOpsCubic.cpp @@ -713,7 +713,10 @@ bool SkDCubic::toFloatPoints(SkPoint* pts) const { const double* dCubic = &fPts[0].fX; SkScalar* cubic = &pts[0].fX; for (int index = 0; index < kPointCount * 2; ++index) { - *cubic++ = SkDoubleToScalar(*dCubic++); + cubic[index] = SkDoubleToScalar(dCubic[index]); + if (SkScalarAbs(cubic[index]) < FLT_EPSILON_ORDERABLE_ERR) { + cubic[index] = 0; + } } return SkScalarsAreFinite(&pts->fX, kPointCount * 2); } -- cgit v1.2.3