add debugging SkFloatToFixed_Check() which asserts that the float is in range of a fixed

git-svn-id: http://skia.googlecode.com/svn/trunk@4942 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
reed@google.com 2012-08-03 12:45:14 +00:00
parent d3fa63847d
commit c9af5d8d8a

View 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))