aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/core/SkScalar.h
diff options
context:
space:
mode:
authorGravatar Mike Reed <reed@google.com>2018-05-13 14:18:45 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-05-14 14:17:59 +0000
commit4c3cb3767f5af3860998b932702dc18619ab3e1e (patch)
tree94328640ca645e4db12260bbaf01f381a9f81857 /include/core/SkScalar.h
parent31ed9ebf988996a696d8bae468a240ce55e351aa (diff)
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>
Diffstat (limited to 'include/core/SkScalar.h')
-rw-r--r--include/core/SkScalar.h18
1 files changed, 3 insertions, 15 deletions
diff --git a/include/core/SkScalar.h b/include/core/SkScalar.h
index 9c015e5ea4..f44d0369cc 100644
--- a/include/core/SkScalar.h
+++ b/include/core/SkScalar.h
@@ -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
}
/**