aboutsummaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorGravatar reed <reed@chromium.org>2015-02-10 08:46:22 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2015-02-10 08:46:22 -0800
commit454fa71cc31bf45c14e4c0b25502d5332d76c51c (patch)
tree54f5bc37eaa2ba3cf69b1f5c386e7881b3f03885 /include
parent88f0a99fd48cfb30ca5596182f8932d76cd76f17 (diff)
check for nonfinites in rrects
Diffstat (limited to 'include')
-rw-r--r--include/core/SkScalar.h18
1 files changed, 17 insertions, 1 deletions
diff --git a/include/core/SkScalar.h b/include/core/SkScalar.h
index e8c7a7fb65..3c1787ed2d 100644
--- a/include/core/SkScalar.h
+++ b/include/core/SkScalar.h
@@ -128,7 +128,23 @@ static inline bool SkScalarIsFinite(SkScalar x) {
// 0 * NaN --> NaN
SkScalar prod = x * 0;
// At this point, prod will either be NaN or 0
- // Therefore we can return (prod == prod) or (0 == prod).
+ return !SkScalarIsNaN(prod);
+}
+
+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);
+}
+
+static inline bool SkScalarsAreFinite(const SkScalar array[], int count) {
+ SkScalar prod = 0;
+ for (int i = 0; i < count; ++i) {
+ prod *= array[i];
+ }
+ // At this point, prod will either be NaN or 0
return !SkScalarIsNaN(prod);
}