add debugging SkFloatToFixed_Check() which asserts that the float is in range of...
authorreed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Fri, 3 Aug 2012 12:45:14 +0000 (12:45 +0000)
committerreed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Fri, 3 Aug 2012 12:45:14 +0000 (12:45 +0000)
git-svn-id: http://skia.googlecode.com/svn/trunk@4942 2bbb7eff-a529-9590-31e7-b0007b416f81

include/core/SkFixed.h

index 96225e2..0fdfad8 100644 (file)
@@ -41,6 +41,17 @@ typedef int32_t             SkFixed;
     }
 #endif
 
+#ifdef SK_DEBUG
+    static inline SkFixed SkFloatToFixed_Check(float x) {
+        int64_t n64 = x * SK_Fixed1;
+        SkFixed n32 = (SkFixed)n64;
+        SkASSERT(n64 == n32);
+        return n32;
+    }
+#else
+    #define SkFloatToFixed_Check(x) SkFloatToFixed(x)
+#endif
+
 #define SkFixedToDouble(x)  ((x) * 1.5258789e-5)
 #define SkDoubleToFixed(x)  ((SkFixed)((x) * SK_Fixed1))