diff --git a/clutter/clutter-fixed.h b/clutter/clutter-fixed.h index 3ae0916..5d150da 100644 --- a/clutter/clutter-fixed.h +++ b/clutter/clutter-fixed.h @@ -39,126 +39,118 @@ G_BEGIN_DECLS * * Fixed point number (16.16) */ -typedef CoglFixed ClutterFixed; +typedef float ClutterFixed; /** * ClutterAngle: * - * Integer representation of an angle such that 1024 corresponds to - * full circle (i.e., 2*Pi). + * An abstract representation of an angle. */ -typedef CoglAngle ClutterAngle; /* angle such that 1024 == 2*PI */ +typedef float ClutterAngle; -#define CLUTTER_ANGLE_FROM_DEG(x) (COGL_ANGLE_FROM_DEG (x)) -#define CLUTTER_ANGLE_FROM_DEGX(x) (COGL_ANGLE_FROM_DEGX (x)) -#define CLUTTER_ANGLE_TO_DEG(x) (COGL_ANGLE_TO_DEG (x)) -#define CLUTTER_ANGLE_TO_DEGX(x) (COGL_ANGLE_TO_DEGX (x)) +#define CLUTTER_ANGLE_FROM_DEG(x) ((float)(x)) +#define CLUTTER_ANGLE_FROM_DEGX(x) (CLUTTER_FIXED_TO_FLOAT (x)) +#define CLUTTER_ANGLE_TO_DEG(x) ((float)(x)) +#define CLUTTER_ANGLE_TO_DEGX(x) (CLUTTER_FLOAT_TO_FIXED (x)) /* * some commonly used constants */ /** - * CFX_Q: - * - * Size in bits of decimal part of floating point value. - */ -#define CFX_Q COGL_FIXED_Q - -/** * CFX_ONE: * * 1.0 represented as a fixed point value. */ -#define CFX_ONE COGL_FIXED_1 +#define CFX_ONE 1.0 /** * CFX_HALF: * * 0.5 represented as a fixed point value. */ -#define CFX_HALF COGL_FIXED_0_5 +#define CFX_HALF 0.5 /** * CFX_MAX: * * Maximum fixed point value. */ -#define CFX_MAX COGL_FIXED_MAX +#define CFX_MAX G_MAXFLOAT /** * CFX_MIN: * * Minimum fixed point value. */ -#define CFX_MIN COGL_FIXED_MIN +#define CFX_MIN (-G_MAXFLOAT) /** * CFX_PI: * * Fixed point representation of Pi */ -#define CFX_PI COGL_FIXED_PI +#define CFX_PI G_PI /** * CFX_2PI: * * Fixed point representation of Pi*2 */ -#define CFX_2PI COGL_FIXED_2_PI +#define CFX_2PI (G_PI * 2) /** * CFX_PI_2: * * Fixed point representation of Pi/2 */ -#define CFX_PI_2 COGL_FIXED_PI_2 +#define CFX_PI_2 (G_PI / 2) /** * CFX_PI_4: * * Fixed point representation of Pi/4 */ -#define CFX_PI_4 COGL_FIXED_PI_4 +#define CFX_PI_4 (G_PI / 4) /** * CFX_360: * * Fixed point representation of the number 360 */ -#define CFX_360 COGL_FIXED_360 +#define CFX_360 360.0 /** * CFX_240: * * Fixed point representation of the number 240 */ -#define CFX_240 COGL_FIXED_240 +#define CFX_240 240.0 /** * CFX_180: * * Fixed point representation of the number 180 */ -#define CFX_180 COGL_FIXED_180 +#define CFX_180 180.0 /** * CFX_120: * * Fixed point representation of the number 120 */ -#define CFX_120 COGL_FIXED_120 +#define CFX_120 120.0 /** * CFX_60: * * Fixed point representation of the number 60 */ -#define CFX_60 COGL_FIXED_60 +#define CFX_60 60.0 /** * CFX_RADIANS_TO_DEGREES: * * Fixed point representation of the number 180 / pi */ -#define CFX_RADIANS_TO_DEGREES COGL_RADIANS_TO_DEGREES +#define CFX_RADIANS_TO_DEGREES (180.0 / G_PI) /** * CFX_255: * * Fixed point representation of the number 255 */ -#define CFX_255 COGL_FIXED_255 +#define CFX_255 255.0 /** * CLUTTER_FIXED_TO_FLOAT: @@ -166,7 +158,7 @@ typedef CoglAngle ClutterAngle; /* angle such that 1024 == 2*PI */ * * Convert a fixed point value to float. */ -#define CLUTTER_FIXED_TO_FLOAT(x) COGL_FIXED_TO_FLOAT ((x)) +#define CLUTTER_FIXED_TO_FLOAT(x) (x) /** * CLUTTER_FIXED_TO_DOUBLE: @@ -174,7 +166,7 @@ typedef CoglAngle ClutterAngle; /* angle such that 1024 == 2*PI */ * * Convert a fixed point value to double. */ -#define CLUTTER_FIXED_TO_DOUBLE(x) COGL_FIXED_TO_DOUBLE ((x)) +#define CLUTTER_FIXED_TO_DOUBLE(x) ((double)(x)) /** * CLUTTER_FLOAT_TO_FIXED: @@ -182,7 +174,7 @@ typedef CoglAngle ClutterAngle; /* angle such that 1024 == 2*PI */ * * Convert a float value to fixed. */ -#define CLUTTER_FLOAT_TO_FIXED(x) COGL_FIXED_FROM_FLOAT ((x)) +#define CLUTTER_FLOAT_TO_FIXED(x) ((x)) /** * CLUTTER_FLOAT_TO_INT: @@ -190,7 +182,7 @@ typedef CoglAngle ClutterAngle; /* angle such that 1024 == 2*PI */ * * Convert a float value to int. */ -#define CLUTTER_FLOAT_TO_INT(x) COGL_FLOAT_TO_INT ((x)) +#define CLUTTER_FLOAT_TO_INT(x) ((int)(x)) /** * CLUTTER_FLOAT_TO_UINT: @@ -198,7 +190,7 @@ typedef CoglAngle ClutterAngle; /* angle such that 1024 == 2*PI */ * * Convert a float value to unsigned int. */ -#define CLUTTER_FLOAT_TO_UINT(x) COGL_FLOAT_TO_UINT ((x)) +#define CLUTTER_FLOAT_TO_UINT(x) ((unsigned int)(x)) /** * CLUTTER_INT_TO_FIXED: @@ -206,7 +198,7 @@ typedef CoglAngle ClutterAngle; /* angle such that 1024 == 2*PI */ * * Convert an integer value to fixed point. */ -#define CLUTTER_INT_TO_FIXED(x) COGL_FIXED_FROM_INT ((x)) +#define CLUTTER_INT_TO_FIXED(x) ((float)(x)) /** * CLUTTER_FIXED_TO_INT: @@ -216,7 +208,7 @@ typedef CoglAngle ClutterAngle; /* angle such that 1024 == 2*PI */ * * Since: 0.6 */ -#define CLUTTER_FIXED_TO_INT(x) COGL_FIXED_TO_INT ((x)) +#define CLUTTER_FIXED_TO_INT(x) ((int)(x)) /** * CLUTTER_FIXED_FRACTION: @@ -224,7 +216,7 @@ typedef CoglAngle ClutterAngle; /* angle such that 1024 == 2*PI */ * * Retrieves the fractionary part of a fixed point value */ -#define CLUTTER_FIXED_FRACTION(x) COGL_FIXED_FRACTION ((x)) +#define CLUTTER_FIXED_FRACTION(x) ((x)-floorf (x)) /** * CLUTTER_FIXED_FLOOR: @@ -232,7 +224,7 @@ typedef CoglAngle ClutterAngle; /* angle such that 1024 == 2*PI */ * * Round down a fixed point value to an integer. */ -#define CLUTTER_FIXED_FLOOR(x) COGL_FIXED_FLOOR ((x)) +#define CLUTTER_FIXED_FLOOR(x) (floorf (x)) /** * CLUTTER_FIXED_CEIL: @@ -240,7 +232,7 @@ typedef CoglAngle ClutterAngle; /* angle such that 1024 == 2*PI */ * * Round up a fixed point value to an integer. */ -#define CLUTTER_FIXED_CEIL(x) COGL_FIXED_CEIL ((x)) +#define CLUTTER_FIXED_CEIL(x) (ceilf (x)) /** * CLUTTER_FIXED_MUL: @@ -249,7 +241,7 @@ typedef CoglAngle ClutterAngle; /* angle such that 1024 == 2*PI */ * * Multiply two fixed point values */ -#define CLUTTER_FIXED_MUL(x,y) COGL_FIXED_MUL ((x), (y)) +#define CLUTTER_FIXED_MUL(x,y) ((x) * (y)) /** * CLUTTER_FIXED_DIV: @@ -258,54 +250,16 @@ typedef CoglAngle ClutterAngle; /* angle such that 1024 == 2*PI */ * * Divide two fixed point values */ -#define CLUTTER_FIXED_DIV(x,y) COGL_FIXED_DIV ((x), (y)) - -#define clutter_qmulx(x,y) cogl_fixed_mul ((x), (y)) -#define clutter_qdivx(x,y) cogl_fixed_div ((x), (y)) - -#define clutter_sinx(a) cogl_fixed_sin ((a)) -#define clutter_sini(a) cogl_angle_sin ((a)) -#define clutter_tani(a) cogl_angle_tan ((a)) -#define clutter_atani(a) cogl_fixed_atan ((a)) -#define clutter_atan2i(x,y) cogl_fixed_atan2 ((x), (y)) -#define clutter_cosx(a) cogl_fixed_cos ((a)) -#define clutter_cosi(a) cogl_angle_cos ((a)) - -/** - * CLUTTER_SQRTI_ARG_MAX - * - * Maximum argument that can be passed to #clutter_sqrti function. - * - * Since: 0.6 - */ -#define CLUTTER_SQRTI_ARG_MAX COGL_SQRTI_ARG_MAX - -/** - * CLUTTER_SQRTI_ARG_5_PERCENT - * - * Maximum argument that can be passed to #clutter_sqrti for which the - * resulting error is < 5% - * - * Since: 0.6 - */ -#define CLUTTER_SQRTI_ARG_5_PERCENT COGL_SQRTI_ARG_5_PERCENT - -/** - * CLUTTER_SQRTI_ARG_10_PERCENT - * - * Maximum argument that can be passed to #clutter_sqrti for which the - * resulting error is < 10% - * - * Since: 0.6 - */ -#define CLUTTER_SQRTI_ARG_10_PERCENT COGL_SQRTI_ARG_10_PERCENT +#define CLUTTER_FIXED_DIV(x,y) ((x) / (y)) -#define clutter_sqrtx(x) cogl_fixed_sqrt ((x)) -#define clutter_sqrti(x) cogl_sqrti ((x)) +#define clutter_qmulx(x,y) ((x) * (y)) +#define clutter_qdivx(x,y) ((x) / (y)) -#define clutter_log2x(x) cogl_fixed_log2 ((x)) -#define clutter_pow2x(x) cogl_fixed_pow2 ((x)) -#define clutter_powx(x,y) cogl_fixed_pow ((x), (y)) +#define clutter_sinx(a) sinf (a * (G_PI/180.0)) +#define clutter_tanx(a) tanf (a * (G_PI/180.0)) +#define clutter_atanx(a) atanf (a * (G_PI/180.0)) +#define clutter_atan2x(x,y) atan2f (x, y) +#define clutter_cosx(a) cosf (a * (G_PI/180.0)) #define CLUTTER_TYPE_FIXED (clutter_fixed_get_type ()) #define CLUTTER_TYPE_PARAM_FIXED (clutter_param_fixed_get_type ()) @@ -331,7 +285,7 @@ typedef struct _ClutterParamSpecFixed ClutterParamSpecFixed; * * Since: 0.8 */ -#define CLUTTER_MAXFIXED COGL_FIXED_MAX +#define CLUTTER_MAXFIXED G_MAXFLOAT /** * CLUTTER_MINFIXED: @@ -340,7 +294,7 @@ typedef struct _ClutterParamSpecFixed ClutterParamSpecFixed; * * Since: 0.8 */ -#define CLUTTER_MINFIXED COGL_FIXED_MIN +#define CLUTTER_MINFIXED (-G_MAXFLOAT) /** * ClutterParamSpecFixed