From c29a3b4deefaf9e4a71cf4cd9b582489de9d67c4 Mon Sep 17 00:00:00 2001
From: Robert Bragg <robert@linux.intel.com>
Date: Tue, 20 Jan 2009 16:20:55 +0000
Subject: [PATCH] [Automatic fixed-to-float.sh change] Hand coded changes for
 clutter-{fixed,units}

To avoid clashing with all the scripted changes, clutter-fixed.h and
clutter-units.h were manually converted to internally use floats instead of
16.16 fixed numbers.

Note: again no API changes were made in Clutter.
---
 clutter/clutter-fixed.h | 104 +++++++++++-----------------------------
 clutter/clutter-units.h |  26 +++++-----
 2 files changed, 40 insertions(+), 90 deletions(-)

diff --git a/clutter/clutter-fixed.h b/clutter/clutter-fixed.h
index feffc09a4..61e2fd4be 100644
--- a/clutter/clutter-fixed.h
+++ b/clutter/clutter-fixed.h
@@ -44,27 +44,19 @@ 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 float 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:
  *
@@ -84,14 +76,14 @@ typedef float ClutterAngle;    /* angle such that 1024 == 2*PI */
  *
  * 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:
@@ -104,19 +96,19 @@ typedef float ClutterAngle;    /* angle such that 1024 == 2*PI */
  *
  * 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        G_PI_2
+#define CFX_PI_2        (G_PI / 2)
 /**
  * CFX_PI_4:
  *
  * Fixed point representation of Pi/4
  */
-#define CFX_PI_4        G_PI_4
+#define CFX_PI_4        (G_PI / 4)
 /**
  * CFX_360:
  *
@@ -152,7 +144,7 @@ typedef float ClutterAngle;    /* angle such that 1024 == 2*PI */
  *
  * 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:
  *
@@ -166,7 +158,7 @@ typedef float ClutterAngle;    /* angle such that 1024 == 2*PI */
  *
  * Convert a fixed point value to float.
  */
-#define CLUTTER_FIXED_TO_FLOAT(x)        ((x))
+#define CLUTTER_FIXED_TO_FLOAT(x)       (x)
 
 /**
  * CLUTTER_FIXED_TO_DOUBLE:
@@ -174,7 +166,7 @@ typedef float ClutterAngle;    /* angle such that 1024 == 2*PI */
  *
  * Convert a fixed point value to double.
  */
-#define CLUTTER_FIXED_TO_DOUBLE(x)      (double)((x))
+#define CLUTTER_FIXED_TO_DOUBLE(x)      ((double)(x))
 
 /**
  * CLUTTER_FLOAT_TO_FIXED:
@@ -182,7 +174,7 @@ typedef float ClutterAngle;    /* angle such that 1024 == 2*PI */
  *
  * Convert a float value to fixed.
  */
-#define CLUTTER_FLOAT_TO_FIXED(x)        ((x))
+#define CLUTTER_FLOAT_TO_FIXED(x)       ((x))
 
 /**
  * CLUTTER_FLOAT_TO_INT:
@@ -190,7 +182,7 @@ typedef float 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 float 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 float ClutterAngle;    /* angle such that 1024 == 2*PI */
  *
  * Convert an integer value to fixed point.
  */
-#define CLUTTER_INT_TO_FIXED(x)         (float)((x))
+#define CLUTTER_INT_TO_FIXED(x)         ((float)(x))
 
 /**
  * CLUTTER_FIXED_TO_INT:
@@ -216,7 +208,7 @@ typedef float ClutterAngle;    /* angle such that 1024 == 2*PI */
  *
  * Since: 0.6
  */
-#define CLUTTER_FIXED_TO_INT(x)          ((x))
+#define CLUTTER_FIXED_TO_INT(x)         ((int)(x))
 
 /**
  * CLUTTER_FIXED_FRACTION:
@@ -224,7 +216,7 @@ typedef float 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 float ClutterAngle;    /* angle such that 1024 == 2*PI */
  *
  * Round down a fixed point value to an integer.
  */
-#define CLUTTER_FIXED_FLOOR(x)          floorf ((x))
+#define CLUTTER_FIXED_FLOOR(x)          (floorf (x))
 
 /**
  * CLUTTER_FIXED_CEIL:
@@ -240,7 +232,7 @@ typedef float ClutterAngle;    /* angle such that 1024 == 2*PI */
  *
  * Round up a fixed point value to an integer.
  */
-#define CLUTTER_FIXED_CEIL(x)           ceilf ((x))
+#define CLUTTER_FIXED_CEIL(x)           (ceilf (x))
 
 /**
  * CLUTTER_FIXED_MUL:
@@ -263,49 +255,11 @@ typedef float ClutterAngle;    /* angle such that 1024 == 2*PI */
 #define clutter_qmulx(x,y)              ((x) * (y))
 #define clutter_qdivx(x,y)              ((x) / (y))
 
-#define clutter_sinx(a)                 sinf ((a))
-#define clutter_sini(a)                 sinf ((a * (G_PI/180.0)))
-#define clutter_tani(a)                 tanf ((a * (G_PI/180.0)))
-#define clutter_atani(a)                atanf ((a))
-#define clutter_atan2i(x,y)             atan2f ((x), (y))
-#define clutter_cosx(a)                 cosf ((a))
-#define clutter_cosi(a)                 cosf ((a * (G_PI/180.0)))
-
-/**
- * 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_sqrtx(x)                sqrtf ((x))
-#define clutter_sqrti(x)                cogl_sqrti ((x))
-
-#define clutter_log2x(x)                log2f ((x))
-#define clutter_pow2x(x)                pow2f ((x))
-#define clutter_powx(x,y)               powf ((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
diff --git a/clutter/clutter-units.h b/clutter/clutter-units.h
index 27d539cc4..1084095d9 100644
--- a/clutter/clutter-units.h
+++ b/clutter/clutter-units.h
@@ -42,7 +42,7 @@ G_BEGIN_DECLS
  *
  * Since: 0.4
  */
-typedef gint32 ClutterUnit;
+typedef float ClutterUnit;
 
 /*
  * Currently CLUTTER_UNIT maps directly onto ClutterFixed. Nevertheless, the
@@ -50,16 +50,16 @@ typedef gint32 ClutterUnit;
  * decide to change this relationship in the future.
  */
 
-#define CLUTTER_UNITS_FROM_INT(x)        ((float)((x)))
-#define CLUTTER_UNITS_TO_INT(x)          ( ((x)))
+#define CLUTTER_UNITS_FROM_INT(x)        ((float)(x))
+#define CLUTTER_UNITS_TO_INT(x)          ((int)(x))
 
-#define CLUTTER_UNITS_FROM_FLOAT(x)      ( ((x)))
-#define CLUTTER_UNITS_TO_FLOAT(x)        ( ((x)))
+#define CLUTTER_UNITS_FROM_FLOAT(x)      (x)
+#define CLUTTER_UNITS_TO_FLOAT(x)        (x)
 
 #define CLUTTER_UNITS_FROM_FIXED(x)      (x)
 #define CLUTTER_UNITS_TO_FIXED(x)        (x)
 
-#define CLUTTER_UNITS_FORMAT            "d"
+#define CLUTTER_UNITS_FORMAT             "f"
 
 /**
  * CLUTTER_UNITS_FROM_DEVICE:
@@ -92,7 +92,7 @@ typedef gint32 ClutterUnit;
  *
  * Since: 0.6
  */
-#define CLUTTER_UNITS_FROM_PANGO_UNIT(x) ((x) << 6)
+#define CLUTTER_UNITS_FROM_PANGO_UNIT(x) ((float)(x / 1024))
 
 /**
  * CLUTTER_UNITS_TO_PANGO_UNIT:
@@ -102,7 +102,7 @@ typedef gint32 ClutterUnit;
  *
  * Since: 0.6
  */
-#define CLUTTER_UNITS_TO_PANGO_UNIT(x)   ((x) >> 6)
+#define CLUTTER_UNITS_TO_PANGO_UNIT(x)   ((int)(x * 1024))
 
 #define CLUTTER_UNITS_FROM_STAGE_WIDTH_PERCENTAGE(x) \
   ((clutter_actor_get_widthu (clutter_stage_get_default ()) * x) / 100)
@@ -127,8 +127,7 @@ typedef gint32 ClutterUnit;
 #define CLUTTER_UNITS_FROM_MM(x) \
   (CLUTTER_UNITS_FROM_FLOAT ((((x) * clutter_stage_get_resolution ((ClutterStage *) clutter_stage_get_default ())) / 25.4)))
 
-#define CLUTTER_UNITS_FROM_MMX(x) \
-  (CFX_DIV (CFX_MUL ((x), clutter_stage_get_resolutionx ((ClutterStage *) clutter_stage_get_default ())), 0x196666))
+#define CLUTTER_UNITS_FROM_MMX(x) CLUTTER_UNITS_FROM_MM
 
 /**
  * CLUTTER_UNITS_FROM_POINTS:
@@ -141,9 +140,6 @@ typedef gint32 ClutterUnit;
 #define CLUTTER_UNITS_FROM_POINTS(x) \
   CLUTTER_UNITS_FROM_FLOAT ((((x) * clutter_stage_get_resolution ((ClutterStage *) clutter_stage_get_default ())) / 72.0))
 
-#define CLUTTER_UNITS_FROM_POINTSX(x) \
-  (CFX_MUL ((x), clutter_stage_get_resolutionx ((ClutterStage *) clutter_stage_get_default ())) / 72)
-
 #define CLUTTER_TYPE_UNIT                 (clutter_unit_get_type ())
 #define CLUTTER_TYPE_PARAM_UNIT           (clutter_param_unit_get_type ())
 #define CLUTTER_PARAM_SPEC_UNIT(pspec)    (G_TYPE_CHECK_INSTANCE_CAST ((pspec), CLUTTER_TYPE_PARAM_UNIT, ClutterParamSpecUnit))
@@ -156,7 +152,7 @@ typedef gint32 ClutterUnit;
  *
  * Since: 0.8
  */
-#define CLUTTER_MAXUNIT         (0x7fffffff)
+#define CLUTTER_MAXUNIT         (G_MAXFLOAT)
 
 /**
  * CLUTTER_MINUNIT:
@@ -165,7 +161,7 @@ typedef gint32 ClutterUnit;
  *
  * Since: 0.8
  */
-#define CLUTTER_MINUNIT         (0x80000000)
+#define CLUTTER_MINUNIT         (-G_MAXFLOAT)
 
 /**
  * CLUTTER_VALUE_HOLDS_UNIT: