aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Cary Clark <caryclark@skia.org>2017-12-01 15:23:00 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-12-01 20:48:40 +0000
commitafca4d6bc00a16e80b93f20742db9391bf65f508 (patch)
tree34091d8480f105ee6ee23e5bce086b902e9bd7a4 /src
parentbbf05759dedafcc924fe2247f2cbdd30688a3bfe (diff)
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 <caryclark@google.com> Reviewed-by: Cary Clark <caryclark@skia.org>
Diffstat (limited to 'src')
-rw-r--r--src/pathops/SkOpEdgeBuilder.cpp3
-rw-r--r--src/pathops/SkPathOpsCubic.cpp5
2 files changed, 7 insertions, 1 deletions
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);
}