diff options
author | reed <reed@chromium.org> | 2015-02-10 08:46:22 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-02-10 08:46:22 -0800 |
commit | 454fa71cc31bf45c14e4c0b25502d5332d76c51c (patch) | |
tree | 54f5bc37eaa2ba3cf69b1f5c386e7881b3f03885 /include | |
parent | 88f0a99fd48cfb30ca5596182f8932d76cd76f17 (diff) |
check for nonfinites in rrects
BUG=457128
Review URL: https://codereview.chromium.org/913743002
Diffstat (limited to 'include')
-rw-r--r-- | include/core/SkScalar.h | 18 |
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); } |