diff options
author | Mike Reed <reed@google.com> | 2018-05-14 16:05:08 +0000 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-05-14 16:05:20 +0000 |
commit | 0e6db75eebab430e7f6665c8cfa1e7dcd2fef123 (patch) | |
tree | 2959f7e76f8b56681280f8c7ecbb83399bbaf23c /include/core/SkScalar.h | |
parent | 8c2de8f76bc1f48702ca006c484ac9750dc8e3b0 (diff) |
Revert "implement SkScalar versions in terms of float versions"
This reverts commit 4c3cb3767f5af3860998b932702dc18619ab3e1e.
Reason for revert: investigate asan failures
Original change's description:
> implement SkScalar versions in terms of float versions
>
> Bug: skia:
> Change-Id: I44ce228290f7fda5b7e3553c8543dcf581b1ca3b
> Reviewed-on: https://skia-review.googlesource.com/127128
> Reviewed-by: Cary Clark <caryclark@google.com>
> Commit-Queue: Mike Reed <reed@google.com>
TBR=caryclark@google.com,reed@google.com
Change-Id: Ic790b15130a67f46a0a99fdf991c5c08d682be5e
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:
Reviewed-on: https://skia-review.googlesource.com/128060
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
Diffstat (limited to 'include/core/SkScalar.h')
-rw-r--r-- | include/core/SkScalar.h | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/include/core/SkScalar.h b/include/core/SkScalar.h index f44d0369cc..9c015e5ea4 100644 --- a/include/core/SkScalar.h +++ b/include/core/SkScalar.h @@ -68,10 +68,22 @@ static inline bool SkScalarIsNaN(SkScalar x) { return x != x; } /** Returns true if x is not NaN and not infinite */ -static inline bool SkScalarIsFinite(SkScalar x) { return sk_float_isfinite(x); } +static inline bool SkScalarIsFinite(SkScalar x) { + // We rely on the following behavior of infinities and nans + // 0 * finite --> 0 + // 0 * infinity --> NaN + // 0 * NaN --> NaN + SkScalar prod = x * 0; + // At this point, prod will either be NaN or 0 + return !SkScalarIsNaN(prod); +} static inline bool SkScalarsAreFinite(SkScalar a, SkScalar b) { - return sk_float_isfinite(a) && sk_float_isfinite(b); + SkScalar prod = 0; + prod *= a; + prod *= b; + // At this point, prod will either be NaN or 0 + return !SkScalarIsNaN(prod); } static inline bool SkScalarsAreFinite(const SkScalar array[], int count) { @@ -80,7 +92,7 @@ static inline bool SkScalarsAreFinite(const SkScalar array[], int count) { prod *= array[i]; } // At this point, prod will either be NaN or 0 - return prod == 0; // if prod is NaN, this check will return false + return !SkScalarIsNaN(prod); } /** |