added CLUTTER_FLOAT_TO_UINT
authorTomas Frydrych <tf@openedhand.com>
Wed, 4 Jul 2007 15:30:44 +0000 (15:30 +0000)
committerTomas Frydrych <tf@openedhand.com>
Wed, 4 Jul 2007 15:30:44 +0000 (15:30 +0000)
clutter/clutter-fixed.c
clutter/clutter-fixed.h

index 884088d..824e5d5 100644 (file)
@@ -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
 
index 32f69a0..3a2be5e 100644 (file)
@@ -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 */