aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/private/SkFloatBits.h
diff options
context:
space:
mode:
authorGravatar Mike Reed <reed@google.com>2018-05-14 13:37:16 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-05-14 18:20:29 +0000
commit9236b02264d4b15208be3b8b8919f4ed441a3c85 (patch)
treef22a1d3856bca63ffb7f204ece2ecbf2c77d6f3f /include/private/SkFloatBits.h
parent9030b94c6012c7f02ba91ed352503a44c22764eb (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/SkFloatBits.h')
-rw-r--r--include/private/SkFloatBits.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/include/private/SkFloatBits.h b/include/private/SkFloatBits.h
index 2740a25d04..bae1542a31 100644
--- a/include/private/SkFloatBits.h
+++ b/include/private/SkFloatBits.h
@@ -56,6 +56,18 @@ static inline float SkBits2Float(int32_t floatAsBits) {
return data.fFloat;
}
+constexpr int32_t gFloatBits_exponent_mask = 0x7F800000;
+constexpr int32_t gFloatBits_matissa_mask = 0x007FFFFF;
+
+static inline bool SkFloatBits_IsFinite(int32_t bits) {
+ return (bits & gFloatBits_exponent_mask) != gFloatBits_exponent_mask;
+}
+
+static inline bool SkFloatBits_IsInf(int32_t bits) {
+ return ((bits & gFloatBits_exponent_mask) == gFloatBits_exponent_mask) &&
+ (bits & gFloatBits_matissa_mask) == 0;
+}
+
/** Return the float as a 2s compliment int. Just to be used to compare floats
to each other or against positive float-bit-constants (like 0). This does
not return the int equivalent of the float, just something cheaper for