aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkGeometry.cpp
diff options
context:
space:
mode:
authorGravatar Cary Clark <caryclark@skia.org>2018-02-02 11:02:46 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-02-02 16:50:29 +0000
commita0e30b1e40459629e48c5e59f7385b51067e31d6 (patch)
tree6d28350f722c4343739cdd8bee4facc04dd09f16 /src/core/SkGeometry.cpp
parent5d3f7704bf9f3b4a075dc55b6951eec6f574c333 (diff)
switch to double in conic split on infinities
If the input conic doesn't contain infinities, it should be possible to compute the split conic without infinities as well. Fix the case fuzzer exposes. R=reed@google.com,fmalita@chromium.org Bug: skia:7435 Change-Id: Ic128fa14ea0622188e5c43efc16b684efa342e9e Reviewed-on: https://skia-review.googlesource.com/102425 Commit-Queue: Cary Clark <caryclark@google.com> Reviewed-by: Florin Malita <fmalita@chromium.org>
Diffstat (limited to 'src/core/SkGeometry.cpp')
-rw-r--r--src/core/SkGeometry.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/core/SkGeometry.cpp b/src/core/SkGeometry.cpp
index 7717a37073..734f6e00d9 100644
--- a/src/core/SkGeometry.cpp
+++ b/src/core/SkGeometry.cpp
@@ -1125,10 +1125,17 @@ void SkConic::chop(SkConic * SK_RESTRICT dst) const {
Sk2s wp1 = ww * p1;
Sk2s m = (p0 + times_2(wp1) + p2) * scale * Sk2s(0.5f);
-
+ SkPoint mPt = to_point(m);
+ if (!mPt.isFinite()) {
+ double w_d = fW;
+ double w_2 = w_d * 2;
+ double scale_half = 1 / (1 + w_d) * 0.5;
+ mPt.fX = SkDoubleToScalar((fPts[0].fX + w_2 * fPts[1].fX + fPts[2].fX) * scale_half);
+ mPt.fY = SkDoubleToScalar((fPts[0].fY + w_2 * fPts[1].fY + fPts[2].fY) * scale_half);
+ }
dst[0].fPts[0] = fPts[0];
dst[0].fPts[1] = to_point((p0 + wp1) * scale);
- dst[0].fPts[2] = dst[1].fPts[0] = to_point(m);
+ dst[0].fPts[2] = dst[1].fPts[0] = mPt;
dst[1].fPts[1] = to_point((wp1 + p2) * scale);
dst[1].fPts[2] = fPts[2];
@@ -1209,7 +1216,7 @@ static SkPoint* subdivide(const SkConic& src, SkPoint pts[], int level) {
SkConic dst[2];
src.chop(dst);
const SkScalar startY = src.fPts[0].fY;
- const SkScalar endY = src.fPts[2].fY;
+ SkScalar endY = src.fPts[2].fY;
if (between(startY, src.fPts[1].fY, endY)) {
// If the input is monotonic and the output is not, the scan converter hangs.
// Ensure that the chopped conics maintain their y-order.