diff options
author | Mike Reed <reed@google.com> | 2018-02-22 14:13:21 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-02-24 15:20:07 +0000 |
commit | 0a78e1e37ebdb3250f472a64b067fa463bea37ff (patch) | |
tree | 6123b5785ca33da766ff80ac46eccf340d6da906 /src | |
parent | fc015d2d39d2cfa14e04f60cb39bce2e5f3ed513 (diff) |
handle conic underflow calc
w0 and w2 can both be non-zero, but w2*w0 can be zero -- unless we promote to doubles
Bug: oss-fuzz:6506
Change-Id: Id0716e22e1d989d2eb6d86417575cf917a31cb89
Reviewed-on: https://skia-review.googlesource.com/109480
Reviewed-by: Cary Clark <caryclark@google.com>
Commit-Queue: Mike Reed <reed@google.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/core/SkGeometry.cpp | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/core/SkGeometry.cpp b/src/core/SkGeometry.cpp index 734f6e00d9..d42a3b1961 100644 --- a/src/core/SkGeometry.cpp +++ b/src/core/SkGeometry.cpp @@ -1350,8 +1350,7 @@ bool SkConic::findMaxCurvature(SkScalar* t) const { } #endif -SkScalar SkConic::TransformW(const SkPoint pts[], SkScalar w, - const SkMatrix& matrix) { +SkScalar SkConic::TransformW(const SkPoint pts[], SkScalar w, const SkMatrix& matrix) { if (!matrix.hasPerspective()) { return w; } @@ -1363,11 +1362,11 @@ SkScalar SkConic::TransformW(const SkPoint pts[], SkScalar w, matrix.mapHomogeneousPoints(dst, src, 3); // w' = sqrt(w1*w1/w0*w2) - SkScalar w0 = dst[0].fZ; - SkScalar w1 = dst[1].fZ; - SkScalar w2 = dst[2].fZ; - w = SkScalarSqrt((w1 * w1) / (w0 * w2)); - return w; + // use doubles temporarily, to handle small numer/denom + double w0 = dst[0].fZ; + double w1 = dst[1].fZ; + double w2 = dst[2].fZ; + return sk_double_to_float(sqrt((w1 * w1) / (w0 * w2))); } int SkConic::BuildUnitArc(const SkVector& uStart, const SkVector& uStop, SkRotationDirection dir, |