diff --git a/clutter/clutter-fixed.c b/clutter/clutter-fixed.c index 884088d0f..824e5d534 100644 --- a/clutter/clutter-fixed.c +++ b/clutter/clutter-fixed.c @@ -787,7 +787,7 @@ clutter_pow2x (ClutterFixed x) union { float f; - ClutterFixed i; + guint32 i; } flt; ClutterFixed magic = 0x56f7; @@ -809,8 +809,8 @@ clutter_pow2x (ClutterFixed x) */ flt.i += (CLUTTER_INT_TO_FIXED (127) - y); flt.i <<= 7; - - return CLUTTER_FLOAT_TO_INT (flt.f); + + return CLUTTER_FLOAT_TO_UINT (flt.f); } @@ -892,5 +892,19 @@ _clutter_double_to_int (double val) return ((int)dbl.i[0]) >> 16; } +guint +_clutter_double_to_uint (double val) +{ + union + { + double d; + unsigned int i[2]; + } dbl; + + dbl.d = val; + dbl.d = dbl.d + _magic; + return (dbl.i[0]) >> 16; +} + #undef _CFX_MAN diff --git a/clutter/clutter-fixed.h b/clutter/clutter-fixed.h index 32f69a005..3a2be5e14 100644 --- a/clutter/clutter-fixed.h +++ b/clutter/clutter-fixed.h @@ -127,6 +127,7 @@ typedef gint32 ClutterAngle; /* angle such that 1024 == 2*PI */ #define CLUTTER_FLOAT_TO_FIXED(x) (_clutter_double_to_fixed ((x))) #define CLUTTER_FLOAT_TO_INT(x) (_clutter_double_to_int ((x))) +#define CLUTTER_FLOAT_TO_UINT(x) (_clutter_double_to_uint ((x))) #define CLUTTER_INT_TO_FIXED(x) ((x) << CFX_Q) #define CLUTTER_FIXED_INT(x) ((x) >> CFX_Q) @@ -201,6 +202,9 @@ ClutterFixed _clutter_double_to_fixed (double value); extern inline gint _clutter_double_to_int (double value); +extern inline +guint _clutter_double_to_uint (double value); + G_END_DECLS #endif /* _HAVE_CLUTTER_FIXED_H */