Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Unified Diff: include/core/SkScalar.h

Issue 913743002: check for nonfinites in rrects (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: update test for nonfinites Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/core/SkRRect.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkScalar.h
diff --git a/include/core/SkScalar.h b/include/core/SkScalar.h
index e8c7a7fb651b1aa7643b14aa322f10e26e605356..3c1787ed2da5ead04788b16ba50cbb8e9116b127 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);
}
« no previous file with comments | « no previous file | src/core/SkRRect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698