diff options
author | Mike Reed <reed@google.com> | 2018-05-14 13:37:16 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-05-14 18:20:29 +0000 |
commit | 9236b02264d4b15208be3b8b8919f4ed441a3c85 (patch) | |
tree | f22a1d3856bca63ffb7f204ece2ecbf2c77d6f3f /include/core | |
parent | 9030b94c6012c7f02ba91ed352503a44c22764eb (diff) |
Revert "Revert "implement SkScalar versions in terms of float versions""
This reverts commit 0e6db75eebab430e7f6665c8cfa1e7dcd2fef123.
Bug: skia:
Change-Id: I015d01efc58dfe03dae6bcc57c4b1102276e7566
Reviewed-on: https://skia-review.googlesource.com/127967
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
Diffstat (limited to 'include/core')
-rw-r--r-- | include/core/SkScalar.h | 20 |
1 files changed, 4 insertions, 16 deletions
diff --git a/include/core/SkScalar.h b/include/core/SkScalar.h index 9c015e5ea4..938f698e05 100644 --- a/include/core/SkScalar.h +++ b/include/core/SkScalar.h @@ -60,7 +60,7 @@ typedef float SkScalar; #define SkScalarToFloat(x) static_cast<float>(x) #define SkFloatToScalar(x) static_cast<SkScalar>(x) #define SkScalarToDouble(x) static_cast<double>(x) -#define SkDoubleToScalar(x) static_cast<SkScalar>(x) +#define SkDoubleToScalar(x) sk_double_to_float(x) #define SK_ScalarMin (-SK_ScalarMax) @@ -68,22 +68,10 @@ 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) { - // 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 SkScalarIsFinite(SkScalar x) { return sk_float_isfinite(x); } static inline bool SkScalarsAreFinite(SkScalar a, SkScalar b) { - SkScalar prod = 0; - prod *= a; - prod *= b; - // At this point, prod will either be NaN or 0 - return !SkScalarIsNaN(prod); + return sk_float_isfinite(a) && sk_float_isfinite(b); } static inline bool SkScalarsAreFinite(const SkScalar array[], int count) { @@ -92,7 +80,7 @@ static inline bool SkScalarsAreFinite(const SkScalar array[], int count) { prod *= array[i]; } // At this point, prod will either be NaN or 0 - return !SkScalarIsNaN(prod); + return prod == 0; // if prod is NaN, this check will return false } /** |