aboutsummaryrefslogtreecommitdiffstats
path: root/include/core/SkFixed.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/core/SkFixed.h')
-rw-r--r--include/core/SkFixed.h10
1 files changed, 9 insertions, 1 deletions
diff --git a/include/core/SkFixed.h b/include/core/SkFixed.h
index be4bf99..2a2456e 100644
--- a/include/core/SkFixed.h
+++ b/include/core/SkFixed.h
@@ -17,7 +17,7 @@
#ifndef SkFixed_DEFINED
#define SkFixed_DEFINED
-#include "SkTypes.h"
+#include "SkMath.h"
/** \file SkFixed.h
@@ -39,7 +39,15 @@ typedef int32_t SkFixed;
#ifdef SK_CAN_USE_FLOAT
#define SkFixedToFloat(x) ((x) * 1.5258789e-5f)
+#if 1
#define SkFloatToFixed(x) ((SkFixed)((x) * SK_Fixed1))
+#else
+ // pins over/under flows to max/min int32 (slower than just a cast)
+ static inline SkFixed SkFloatToFixed(float x) {
+ int64_t n = x * SK_Fixed1;
+ return (SkFixed)n;
+ }
+#endif
#define SkFixedToDouble(x) ((x) * 1.5258789e-5)
#define SkDoubleToFixed(x) ((SkFixed)((x) * SK_Fixed1))