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/private/SkFloatingPoint.h | |
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/private/SkFloatingPoint.h')
-rw-r--r-- | include/private/SkFloatingPoint.h | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/include/private/SkFloatingPoint.h b/include/private/SkFloatingPoint.h index a2e6ee5122..adf7b279b9 100644 --- a/include/private/SkFloatingPoint.h +++ b/include/private/SkFloatingPoint.h @@ -12,6 +12,7 @@ #include "SkTypes.h" #include "SkSafe_math.h" #include <float.h> +#include <math.h> #if SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSE1 #include <xmmintrin.h> @@ -64,17 +65,17 @@ static inline float sk_float_pow(float base, float exp) { #define sk_float_log2(x) log2f(x) #endif -#ifdef SK_BUILD_FOR_WIN - #define sk_float_isfinite(x) _finite(x) - #define sk_float_isnan(x) _isnan(x) - static inline int sk_float_isinf(float x) { - return x && (x + x == x); - } -#else - #define sk_float_isfinite(x) isfinite(x) - #define sk_float_isnan(x) isnan(x) - #define sk_float_isinf(x) isinf(x) -#endif +static inline bool sk_float_isfinite(float x) { + return SkFloatBits_IsFinite(SkFloat2Bits(x)); +} + +static inline bool sk_float_isinf(float x) { + return SkFloatBits_IsInf(SkFloat2Bits(x)); +} + +static inline bool sk_float_isnan(float x) { + return !(x == x); +} #define sk_double_isnan(a) sk_float_isnan(a) @@ -200,4 +201,11 @@ static inline float sk_ieee_float_divide(float numer, float denom) { return numer / denom; } +#ifdef __clang__ +__attribute__((no_sanitize("float-divide-by-zero"))) +#endif +static inline double sk_ieee_double_divide(double numer, double denom) { + return numer / denom; +} + #endif |