added CLUTTER_FLOAT_TO_UINT

This commit is contained in:
Tomas Frydrych 2007-07-04 15:30:44 +00:00
parent d7caae7f6a
commit cbf2830e5f
2 changed files with 21 additions and 3 deletions

View 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

View 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 */