From e8915fcb12cd402cadcdb5e2cfa28a5fc9765a71 Mon Sep 17 00:00:00 2001 From: Robert Bragg Date: Fri, 19 Dec 2008 21:55:35 +0000 Subject: [PATCH 01/26] First cut at a fixed point to floating point conversion script + patches This commit doesn't actually include any direct changes to source; you have to run ./fixed-to-float.sh. Note: the script will make a number of commits itself to your git repository a various stages of the script. You will need to reset these if you want to re-run the script. * NB: Be carefull about how you reset your tree, if you are making changes to the script and patches, so you don't loose your changes * This aims to remove all use of fixed point within Clutter and Cogl. It aims to not break the Clutter API, including maintaining the CLUTTER_FIXED macros, (though they now handle floats not 16.16 fixed) It maintains cogl-fixed.[ch] as a utility API that can be used by applications (and potentially for focused internal optimisations), but all Cogl interfaces now accept floats in place of CoglFixed. Note: the choice to to use single precision floats, not doubles is very intentional. GPUs are basically all single precision; only this year have high end cards started adding double precision - aimed mostly at the GPGPU market. This means if you pass doubles into any GL[ES] driver, you can expect those numbers to be cast to a float. (Certainly this is true of Mesa wich casts most things to floats internally) It can be a noteable performance issue to cast from double->float frequently, and if we were to have an api defined in terms of doubles, that would imply a *lot* of unneeded casting. One of the noteable issues with fixed point was the amount of casting required, so I don't want to overshoot the mark and require just as much casting still. Double precision arithmatic is also slower, so it usually makes sense to minimize its use if the extra precision isn't needed. In the same way that the fast/low precision fixed API can be used sparingly for optimisations; if needs be in certain situations we can promote to doubles internally for higher precision. E.g. quoting Brian Paul (talking about performance optimisations for GL programmers): "Avoid double precision valued functions Mesa does all internal floating point computations in single precision floating point. API functions which take double precision floating point values must convert them to single precision. This can be expensive in the case of glVertex, glNormal, etc. " --- .../clutter-actor.c.0.patch | 40 ++ .../clutter-alpha.c.0.patch | 263 +++++++++++ .../clutter-alpha.h.0.patch | 13 + .../clutter-behaviour-ellipse.c.0.patch | 445 ++++++++++++++++++ .../clutter-bezier.c.0.patch | 13 + .../clutter-fixed.c.0.patch | 15 + .../clutter-fixed.h.0.patch | 333 +++++++++++++ fixed-to-float-patches/clutter-path.c.0.patch | 18 + .../clutter-texture.c.0.patch | 13 + .../clutter-units.h.0.patch | 85 ++++ fixed-to-float-patches/cogl-fixed.c.0.patch | 17 + fixed-to-float-patches/cogl-fixed.h.0.patch | 23 + .../cogl-pango-render.c.0.patch | 24 + .../cogl-primitives.c.0.patch | 12 + .../gl-cogl-primitives.c.0.patch | 12 + .../gl-cogl-texture.c.0.patch | 30 ++ fixed-to-float-patches/gl-cogl.c | 92 ++++ fixed-to-float-patches/mtx_transform.0.patch | 19 + .../test-cogl-tex-tile.c.0.patch | 35 ++ fixed-to-float.sh | 150 ++++++ 20 files changed, 1652 insertions(+) create mode 100644 fixed-to-float-patches/clutter-actor.c.0.patch create mode 100644 fixed-to-float-patches/clutter-alpha.c.0.patch create mode 100644 fixed-to-float-patches/clutter-alpha.h.0.patch create mode 100644 fixed-to-float-patches/clutter-behaviour-ellipse.c.0.patch create mode 100644 fixed-to-float-patches/clutter-bezier.c.0.patch create mode 100644 fixed-to-float-patches/clutter-fixed.c.0.patch create mode 100644 fixed-to-float-patches/clutter-fixed.h.0.patch create mode 100644 fixed-to-float-patches/clutter-path.c.0.patch create mode 100644 fixed-to-float-patches/clutter-texture.c.0.patch create mode 100644 fixed-to-float-patches/clutter-units.h.0.patch create mode 100644 fixed-to-float-patches/cogl-fixed.c.0.patch create mode 100644 fixed-to-float-patches/cogl-fixed.h.0.patch create mode 100644 fixed-to-float-patches/cogl-pango-render.c.0.patch create mode 100644 fixed-to-float-patches/cogl-primitives.c.0.patch create mode 100644 fixed-to-float-patches/gl-cogl-primitives.c.0.patch create mode 100644 fixed-to-float-patches/gl-cogl-texture.c.0.patch create mode 100644 fixed-to-float-patches/gl-cogl.c create mode 100644 fixed-to-float-patches/mtx_transform.0.patch create mode 100644 fixed-to-float-patches/test-cogl-tex-tile.c.0.patch create mode 100755 fixed-to-float.sh diff --git a/fixed-to-float-patches/clutter-actor.c.0.patch b/fixed-to-float-patches/clutter-actor.c.0.patch new file mode 100644 index 000000000..c1d76a4b3 --- /dev/null +++ b/fixed-to-float-patches/clutter-actor.c.0.patch @@ -0,0 +1,40 @@ +diff --git a/clutter/clutter-actor.c b/clutter/clutter-actor.c +index ac9a2f6..42da2a5 100644 +--- a/clutter/clutter-actor.c ++++ b/clutter/clutter-actor.c +@@ -866,8 +866,11 @@ clutter_actor_transform_point (ClutterActor *actor, + /* Help macros to scale from OpenGL <-1,1> coordinates system to our + * X-window based <0,window-size> coordinates + */ +-#define MTX_GL_SCALE_X(x,w,v1,v2) (CLUTTER_FIXED_MUL (((CLUTTER_FIXED_DIV ((x), (w)) + 1.0) >> 1), (v1)) + (v2)) +-#define MTX_GL_SCALE_Y(y,w,v1,v2) ((v1) - CLUTTER_FIXED_MUL (((CLUTTER_FIXED_DIV ((y), (w)) + 1.0) >> 1), (v1)) + (v2)) ++#define MTX_GL_SCALE_X(x,w,v1,v2) \ ++ (CLUTTER_FIXED_MUL (((CLUTTER_FIXED_DIV ((x), (w)) + 1.0) / 2), (v1)) + (v2)) ++#define MTX_GL_SCALE_Y(y,w,v1,v2) \ ++ ((v1) - CLUTTER_FIXED_MUL (((CLUTTER_FIXED_DIV ((y), (w)) + 1.0) / 2), \ ++ (v1)) + (v2)) + #define MTX_GL_SCALE_Z(z,w,v1,v2) (MTX_GL_SCALE_X ((z), (w), (v1), (v2))) + + /** +@@ -3213,8 +3214,8 @@ clutter_actor_get_preferred_width (ClutterActor *self, + + if (natural_width < min_width) + { +- g_warning ("Actor of type %s reported a natural width of %d (%d px) " +- "lower than min width %d (%d px)", ++ g_warning ("Actor of type %s reported a natural width of %f (%d px) " ++ "lower than min width %f (%d px)", + G_OBJECT_TYPE_NAME (self), + natural_width, CLUTTER_UNITS_TO_DEVICE (natural_width), + min_width, CLUTTER_UNITS_TO_DEVICE (min_width)); +@@ -3283,8 +3284,8 @@ clutter_actor_get_preferred_height (ClutterActor *self, + + if (natural_height < min_height) + { +- g_warning ("Actor of type %s reported a natural height of %d " +- "(%d px) lower than min height %d (%d px)", ++ g_warning ("Actor of type %s reported a natural height of %f " ++ "(%d px) lower than min height %f (%d px)", + G_OBJECT_TYPE_NAME (self), + natural_height, CLUTTER_UNITS_TO_DEVICE (natural_height), + min_height, CLUTTER_UNITS_TO_DEVICE (min_height)); diff --git a/fixed-to-float-patches/clutter-alpha.c.0.patch b/fixed-to-float-patches/clutter-alpha.c.0.patch new file mode 100644 index 000000000..f466a9588 --- /dev/null +++ b/fixed-to-float-patches/clutter-alpha.c.0.patch @@ -0,0 +1,263 @@ +diff --git a/clutter/clutter-alpha.c b/clutter/clutter-alpha.c +index 3e4df4d..74a5c7a 100644 +--- a/clutter/clutter-alpha.c ++++ b/clutter/clutter-alpha.c +@@ -694,6 +694,11 @@ clutter_ramp_func (ClutterAlpha *alpha, + } + } + ++#if 0 ++/* ++ * The following three functions are left in place for reference ++ * purposes. ++ */ + static guint32 + sincx1024_func (ClutterAlpha *alpha, + ClutterAngle angle, +@@ -713,7 +718,7 @@ sincx1024_func (ClutterAlpha *alpha, + + x -= (512 * 512 / angle); + +- sine = ((sinf (x) + offset) / 2) ++ sine = ((cogl_angle_sin (x) + offset) / 2) + * CLUTTER_ALPHA_MAX_ALPHA; + + sine = sine >> COGL_FIXED_Q; +@@ -721,11 +726,6 @@ sincx1024_func (ClutterAlpha *alpha, + return sine; + } + +-#if 0 +-/* +- * The following two functions are left in place for reference +- * purposes. +- */ + static guint32 + sincx_func (ClutterAlpha *alpha, + ClutterFixed angle, +@@ -744,7 +744,7 @@ sincx_func (ClutterAlpha *alpha, + x = CLUTTER_FIXED_MUL (x, CFX_PI) + - CLUTTER_FIXED_DIV (CFX_PI, angle); + +- sine = (sinf (x) + offset) / 2; ++ sine = (cogl_angle_sin (x) + offset) / 2; + + CLUTTER_NOTE (ALPHA, "sine: %2f\n", CLUTTER_FIXED_TO_DOUBLE (sine)); + +@@ -803,9 +803,25 @@ guint32 + clutter_sine_func (ClutterAlpha *alpha, + gpointer dummy) + { +-#if 0 ++#if 1 ++ ClutterTimeline *timeline; ++ gint current_frame_num, n_frames; ++ float radians, sine; ++ ++ timeline = clutter_alpha_get_timeline (alpha); ++ ++ current_frame_num = clutter_timeline_get_current_frame (timeline); ++ n_frames = clutter_timeline_get_n_frames (timeline); ++ ++ radians = ((float)current_frame_num / n_frames) * (2.0 * G_PI); ++ sine = sinf (radians); ++ ++ CLUTTER_NOTE (ALPHA, "sine: %2f\n", sine); ++ ++ return COGL_FLOAT_TO_INT ((sine * CLUTTER_ALPHA_MAX_ALPHA)); ++#elif 0 + return sinc_func (alpha, 2.0, 1.0); +-#else ++#elif 0 + /* 2.0 above represents full circle */ + return sincx1024_func (alpha, 1024, 1.0); + #endif +@@ -839,18 +855,17 @@ clutter_sine_inc_func (ClutterAlpha *alpha, + ClutterTimeline * timeline; + gint frame; + gint n_frames; +- ClutterAngle x; +- ClutterFixed sine; ++ float radians; ++ float sine; + + timeline = clutter_alpha_get_timeline (alpha); + frame = clutter_timeline_get_current_frame (timeline); + n_frames = clutter_timeline_get_n_frames (timeline); + +- x = 256 * frame / n_frames; +- +- sine = sinf (x) * CLUTTER_ALPHA_MAX_ALPHA; ++ radians = ((float)frame / n_frames) * (G_PI / 2); ++ sine = sinf (radians); + +- return ((guint32) sine) >> COGL_FIXED_Q; ++ return (guint32) (sine * CLUTTER_ALPHA_MAX_ALPHA); + } + + /** +@@ -881,18 +896,17 @@ clutter_sine_dec_func (ClutterAlpha *alpha, + ClutterTimeline * timeline; + gint frame; + gint n_frames; +- ClutterAngle x; +- ClutterFixed sine; ++ float radians; ++ float sine; + + timeline = clutter_alpha_get_timeline (alpha); + frame = clutter_timeline_get_current_frame (timeline); + n_frames = clutter_timeline_get_n_frames (timeline); + +- x = 256 * frame / n_frames + 256; +- +- sine = sinf (x) * CLUTTER_ALPHA_MAX_ALPHA; ++ radians = ((float)frame / n_frames) * (G_PI / 2); ++ sine = sinf (radians + (G_PI / 2)); + +- return ((guint32) sine) >> COGL_FIXED_Q; ++ return (guint32) (sine * CLUTTER_ALPHA_MAX_ALPHA); + } + + /** +@@ -923,18 +937,17 @@ clutter_sine_half_func (ClutterAlpha *alpha, + ClutterTimeline *timeline; + gint frame; + gint n_frames; +- ClutterAngle x; +- ClutterFixed sine; ++ float radians; ++ float sine; + + timeline = clutter_alpha_get_timeline (alpha); + frame = clutter_timeline_get_current_frame (timeline); + n_frames = clutter_timeline_get_n_frames (timeline); + +- x = 512 * frame / n_frames; ++ radians = ((float)frame / n_frames) * G_PI; ++ sine = sinf (radians); + +- sine = sinf (x) * CLUTTER_ALPHA_MAX_ALPHA; +- +- return ((guint32) sine) >> COGL_FIXED_Q; ++ return (guint32) (sine * CLUTTER_ALPHA_MAX_ALPHA); + } + + /** +@@ -959,19 +972,17 @@ clutter_sine_in_func (ClutterAlpha *alpha, + ClutterTimeline *timeline; + gint frame; + gint n_frames; +- ClutterAngle x; +- ClutterFixed sine; ++ float radians; ++ float sine; + + timeline = clutter_alpha_get_timeline (alpha); + frame = clutter_timeline_get_current_frame (timeline); + n_frames = clutter_timeline_get_n_frames (timeline); + +- /* XXX- if we use 768 we overflow */ +- x = 256 * frame / n_frames + 767; +- +- sine = (sinf (x) + 1) * CLUTTER_ALPHA_MAX_ALPHA; ++ radians = ((float)frame / n_frames) * (G_PI / 2); ++ sine = sinf (radians - (G_PI / 2)) + 1.0; + +- return ((guint32) sine) >> COGL_FIXED_Q; ++ return (guint32) (sine * CLUTTER_ALPHA_MAX_ALPHA); + } + + /** +@@ -995,18 +1006,17 @@ clutter_sine_out_func (ClutterAlpha *alpha, + ClutterTimeline *timeline; + gint frame; + gint n_frames; +- ClutterAngle x; +- ClutterFixed sine; ++ float radians; ++ float sine; + + timeline = clutter_alpha_get_timeline (alpha); + frame = clutter_timeline_get_current_frame (timeline); + n_frames = clutter_timeline_get_n_frames (timeline); + +- x = 256 * frame / n_frames; +- +- sine = sinf (x) * CLUTTER_ALPHA_MAX_ALPHA; ++ radians = ((float)frame / n_frames) * (G_PI / 2); ++ sine = sinf (radians); + +- return ((guint32) sine) >> COGL_FIXED_Q; ++ return (guint32) (sine * CLUTTER_ALPHA_MAX_ALPHA); + } + + /** +@@ -1031,18 +1041,17 @@ clutter_sine_in_out_func (ClutterAlpha *alpha, + ClutterTimeline *timeline; + gint frame; + gint n_frames; +- ClutterAngle x; +- ClutterFixed sine; ++ float radians; ++ float sine; + + timeline = clutter_alpha_get_timeline (alpha); + frame = clutter_timeline_get_current_frame (timeline); + n_frames = clutter_timeline_get_n_frames (timeline); + +- x = -256 * frame / n_frames + 256; ++ radians = ((float)frame / n_frames) * G_PI; ++ sine = (sinf (radians - (G_PI / 2)) + 1.0) / 2.0; + +- sine = (sinf (x) + 1) / 2 * CLUTTER_ALPHA_MAX_ALPHA; +- +- return ((guint32) sine) >> COGL_FIXED_Q; ++ return (guint32) (sine * CLUTTER_ALPHA_MAX_ALPHA); + } + + /** +@@ -1201,9 +1210,9 @@ clutter_exp_inc_func (ClutterAlpha *alpha, + * + * (2^x_alpha_max) - 1 == CLUTTER_ALPHA_MAX_ALPHA + */ +-#if CLUTTER_ALPHA_MAX_ALPHA != 0xffff +-#error Adjust x_alpha_max to match CLUTTER_ALPHA_MAX_ALPHA +-#endif ++ /* XXX: If this fails: ++ * Adjust x_alpha_max to match CLUTTER_ALPHA_MAX_ALPHA */ ++ g_assert (CLUTTER_ALPHA_MAX_ALPHA == 65535.0); + + timeline = clutter_alpha_get_timeline (alpha); + frame = clutter_timeline_get_current_frame (timeline); +@@ -1211,7 +1220,7 @@ clutter_exp_inc_func (ClutterAlpha *alpha, + + x = x_alpha_max * frame / n_frames; + +- result = CLAMP (pow2f (x) - 1, 0, CLUTTER_ALPHA_MAX_ALPHA); ++ result = CLAMP (powf (2, x) - 1, 0, CLUTTER_ALPHA_MAX_ALPHA); + + return result; + } +@@ -1252,9 +1261,9 @@ clutter_exp_dec_func (ClutterAlpha *alpha, + * + * (2^x_alpha_max) - 1 == CLUTTER_ALPHA_MAX_ALPHA + */ +-#if CLUTTER_ALPHA_MAX_ALPHA != 0xffff +-#error Adjust x_alpha_max to match CLUTTER_ALPHA_MAX_ALPHA +-#endif ++ /* XXX: If this fails: ++ * Adjust x_alpha_max to match CLUTTER_ALPHA_MAX_ALPHA */ ++ g_assert (CLUTTER_ALPHA_MAX_ALPHA == 65535.0); + + timeline = clutter_alpha_get_timeline (alpha); + frame = clutter_timeline_get_current_frame (timeline); +@@ -1262,7 +1271,7 @@ clutter_exp_dec_func (ClutterAlpha *alpha, + + x = (x_alpha_max * (n_frames - frame)) / n_frames; + +- result = CLAMP (pow2f (x) - 1, 0, CLUTTER_ALPHA_MAX_ALPHA); ++ result = CLAMP (powf (2, x) - 1, 0, CLUTTER_ALPHA_MAX_ALPHA); + + return result; + } diff --git a/fixed-to-float-patches/clutter-alpha.h.0.patch b/fixed-to-float-patches/clutter-alpha.h.0.patch new file mode 100644 index 000000000..d4c974f8f --- /dev/null +++ b/fixed-to-float-patches/clutter-alpha.h.0.patch @@ -0,0 +1,13 @@ +diff --git a/clutter/clutter-alpha.h b/clutter/clutter-alpha.h +index eba9e3f..e409d77 100644 +--- a/clutter/clutter-alpha.h ++++ b/clutter/clutter-alpha.h +@@ -106,7 +106,7 @@ struct _ClutterAlphaClass + * + * Since: 0.2 + */ +-#define CLUTTER_ALPHA_MAX_ALPHA (0xffff) ++#define CLUTTER_ALPHA_MAX_ALPHA (65535.0f) + + GType clutter_alpha_get_type (void) G_GNUC_CONST; + diff --git a/fixed-to-float-patches/clutter-behaviour-ellipse.c.0.patch b/fixed-to-float-patches/clutter-behaviour-ellipse.c.0.patch new file mode 100644 index 000000000..a3a42dd76 --- /dev/null +++ b/fixed-to-float-patches/clutter-behaviour-ellipse.c.0.patch @@ -0,0 +1,445 @@ +diff --git a/clutter/clutter-behaviour-ellipse.c b/clutter/clutter-behaviour-ellipse.c +index b9f493b..5524032 100644 +--- a/clutter/clutter-behaviour-ellipse.c ++++ b/clutter/clutter-behaviour-ellipse.c +@@ -86,11 +86,11 @@ struct _ClutterBehaviourEllipsePrivate + gint a; + gint b; + +- ClutterAngle angle_start; +- ClutterAngle angle_end; +- ClutterAngle angle_tilt_x; +- ClutterAngle angle_tilt_y; +- ClutterAngle angle_tilt_z; ++ float angle_start; ++ float angle_end; ++ float angle_tilt_x; ++ float angle_tilt_y; ++ float angle_tilt_z; + + ClutterRotateDirection direction; + }; +@@ -104,7 +104,7 @@ typedef struct _knot3d + + static void + clutter_behaviour_ellipse_advance (ClutterBehaviourEllipse *e, +- ClutterAngle angle, ++ float angle, + knot3d *knot) + { + ClutterBehaviourEllipsePrivate *priv = e->priv; +@@ -187,20 +187,16 @@ actor_apply_knot_foreach (ClutterBehaviour *behave, + clutter_actor_set_depth (actor, knot->z); + } + +-static inline ClutterAngle +-clamp_angle (ClutterAngle a) ++static float ++clamp_angle (float a) + { +- ClutterAngle a1, a2; + gint rounds; ++ ++ rounds = a / 360; ++ if (a < 0) ++ rounds--; + +- /* Need to add the 256 offset here, since the user space 0 maps to our +- * -256 +- */ +- rounds = (a + 256) / 1024; +- a1 = rounds * 1024; +- a2 = a - a1; +- +- return a2; ++ return a - 360 * rounds; + } + + static void +@@ -209,7 +205,7 @@ clutter_behaviour_ellipse_alpha_notify (ClutterBehaviour *behave, + { + ClutterBehaviourEllipse *self = CLUTTER_BEHAVIOUR_ELLIPSE (behave); + ClutterBehaviourEllipsePrivate *priv = self->priv; +- ClutterAngle start, end; ++ float start, end; + knot3d knot; + ClutterAngle angle = 0; + +@@ -218,11 +214,11 @@ clutter_behaviour_ellipse_alpha_notify (ClutterBehaviour *behave, + + if (priv->direction == CLUTTER_ROTATE_CW && start >= end) + { +- end += 1024; ++ end += 360; + } + else if (priv->direction == CLUTTER_ROTATE_CCW && start <= end) + { +- end -= 1024; ++ end -= 360; + } + + angle = (end - start) * alpha / CLUTTER_ALPHA_MAX_ALPHA + start; +@@ -247,30 +243,25 @@ clutter_behaviour_ellipse_set_property (GObject *gobject, + switch (prop_id) + { + case PROP_ANGLE_START: +- priv->angle_start = +- COGL_ANGLE_FROM_DEG (g_value_get_double (value)) - 256; ++ priv->angle_start = g_value_get_double (value); + break; + case PROP_ANGLE_END: +- priv->angle_end = +- COGL_ANGLE_FROM_DEG (g_value_get_double (value)) - 256; ++ priv->angle_end = g_value_get_double (value); + break; + case PROP_ANGLE_TILT_X: +- priv->angle_tilt_x = +- COGL_ANGLE_FROM_DEG (g_value_get_double (value)); ++ priv->angle_tilt_x = g_value_get_double (value); + break; + case PROP_ANGLE_TILT_Y: +- priv->angle_tilt_y = +- COGL_ANGLE_FROM_DEG (g_value_get_double (value)); ++ priv->angle_tilt_y = g_value_get_double (value); + break; + case PROP_ANGLE_TILT_Z: +- priv->angle_tilt_z = +- COGL_ANGLE_FROM_DEG (g_value_get_double (value)); ++ priv->angle_tilt_z = g_value_get_double (value); + break; + case PROP_WIDTH: +- priv->a = g_value_get_int (value) >> 1; ++ priv->a = g_value_get_int (value) / 2; + break; + case PROP_HEIGHT: +- priv->b = g_value_get_int (value) >> 1; ++ priv->b = g_value_get_int (value) / 2; + break; + case PROP_CENTER: + { +@@ -301,30 +292,25 @@ clutter_behaviour_ellipse_get_property (GObject *gobject, + switch (prop_id) + { + case PROP_ANGLE_START: +- g_value_set_double (value, +- COGL_ANGLE_TO_DEG (priv->angle_start + 256)); ++ g_value_set_double (value, priv->angle_start); + break; + case PROP_ANGLE_END: +- g_value_set_double (value, +- COGL_ANGLE_TO_DEG (priv->angle_end + 256)); ++ g_value_set_double (value, priv->angle_end); + break; + case PROP_ANGLE_TILT_X: +- g_value_set_double (value, +- COGL_ANGLE_TO_DEG (priv->angle_tilt_x)); ++ g_value_set_double (value, priv->angle_tilt_x); + break; + case PROP_ANGLE_TILT_Y: +- g_value_set_double (value, +- COGL_ANGLE_TO_DEG (priv->angle_tilt_y)); ++ g_value_set_double (value, priv->angle_tilt_y); + break; + case PROP_ANGLE_TILT_Z: +- g_value_set_double (value, +- COGL_ANGLE_TO_DEG (priv->angle_tilt_z)); ++ g_value_set_double (value, priv->angle_tilt_z); + break; + case PROP_WIDTH: +- g_value_set_int (value, (priv->a << 1)); ++ g_value_set_int (value, (priv->a * 2)); + break; + case PROP_HEIGHT: +- g_value_set_int (value, (priv->b << 1)); ++ g_value_set_int (value, (priv->b * 2)); + break; + case PROP_CENTER: + g_value_set_boxed (value, &priv->center); +@@ -513,12 +499,8 @@ clutter_behaviour_ellipse_init (ClutterBehaviourEllipse * self) + + priv->direction = CLUTTER_ROTATE_CW; + +- /* The inital values have to reflect the 90 degree offset between the normal +- * mathematical space and the clutter clock-based space; the default end +- * value of 360 is clamped to 0. +- */ +- priv->angle_start = -256; +- priv->angle_end = -256; ++ priv->angle_start = 0; ++ priv->angle_end = 0; + } + + /** +@@ -611,8 +593,8 @@ clutter_behaviour_ellipse_newx (ClutterAlpha * alpha, + "width", width, + "height", height, + "direction", direction, +- "angle-start", COGL_ANGLE_FROM_DEGX (start), +- "angle-end", COGL_ANGLE_FROM_DEGX (end), ++ "angle-start", (double)CLUTTER_FIXED_TO_FLOAT (start), ++ "angle-end", (double)CLUTTER_FIXED_TO_FLOAT (end), + NULL); + } + +@@ -695,9 +677,9 @@ clutter_behaviour_ellipse_set_width (ClutterBehaviourEllipse * self, + + priv = self->priv; + +- if (priv->a != width >> 1) ++ if (priv->a != width / 2) + { +- priv->a = width >> 1; ++ priv->a = width / 2; + + g_object_notify (G_OBJECT (self), "width"); + } +@@ -718,7 +700,7 @@ clutter_behaviour_ellipse_get_width (ClutterBehaviourEllipse *self) + { + g_return_val_if_fail (CLUTTER_IS_BEHAVIOUR_ELLIPSE (self), 0); + +- return self->priv->a << 1; ++ return self->priv->a * 2; + } + + /** +@@ -740,9 +722,9 @@ clutter_behaviour_ellipse_set_height (ClutterBehaviourEllipse *self, + + priv = self->priv; + +- if (priv->b != height >> 1) ++ if (priv->b != height / 2) + { +- priv->b = height >> 1; ++ priv->b = height / 2; + + g_object_notify (G_OBJECT (self), "height"); + } +@@ -763,7 +745,7 @@ clutter_behaviour_ellipse_get_height (ClutterBehaviourEllipse *self) + { + g_return_val_if_fail (CLUTTER_IS_BEHAVIOUR_ELLIPSE (self), 0); + +- return self->priv->b << 1; ++ return self->priv->b * 2; + } + + /** +@@ -780,10 +762,11 @@ void + clutter_behaviour_ellipse_set_angle_start (ClutterBehaviourEllipse *self, + gdouble angle_start) + { ++ ClutterFixed new_angle = CLUTTER_FLOAT_TO_FIXED (angle_start); ++ + g_return_if_fail (CLUTTER_IS_BEHAVIOUR_ELLIPSE (self)); + +- clutter_behaviour_ellipse_set_angle_startx (self, +- CLUTTER_FLOAT_TO_FIXED (angle_start)); ++ clutter_behaviour_ellipse_set_angle_startx (self, new_angle); + } + + /** +@@ -802,10 +785,10 @@ clutter_behaviour_ellipse_set_angle_startx (ClutterBehaviourEllipse *self, + ClutterFixed angle_start) + { + ClutterBehaviourEllipsePrivate *priv; +- ClutterAngle new_angle; ++ float new_angle; + g_return_if_fail (CLUTTER_IS_BEHAVIOUR_ELLIPSE (self)); + +- new_angle = clamp_angle (COGL_ANGLE_FROM_DEGX (angle_start) - 256); ++ new_angle = clamp_angle (CLUTTER_FIXED_TO_FLOAT (angle_start)); + + priv = self->priv; + if (priv->angle_start != new_angle) +@@ -830,7 +813,7 @@ clutter_behaviour_ellipse_get_angle_start (ClutterBehaviourEllipse *self) + { + g_return_val_if_fail (CLUTTER_IS_BEHAVIOUR_ELLIPSE (self), 0.0); + +- return COGL_ANGLE_TO_DEG (self->priv->angle_start + 256); ++ return (double)self->priv->angle_start; + } + + /** +@@ -848,7 +831,7 @@ clutter_behaviour_ellipse_get_angle_startx (ClutterBehaviourEllipse *self) + { + g_return_val_if_fail (CLUTTER_IS_BEHAVIOUR_ELLIPSE (self), 0); + +- return COGL_ANGLE_TO_DEGX (self->priv->angle_start); ++ return CLUTTER_FLOAT_TO_FIXED (self->priv->angle_start); + } + + /** +@@ -865,10 +848,11 @@ void + clutter_behaviour_ellipse_set_angle_end (ClutterBehaviourEllipse *self, + gdouble angle_end) + { ++ ClutterFixed new_angle = CLUTTER_FLOAT_TO_FIXED (angle_end); ++ + g_return_if_fail (CLUTTER_IS_BEHAVIOUR_ELLIPSE (self)); + +- clutter_behaviour_ellipse_set_angle_endx (self, +- CLUTTER_FLOAT_TO_FIXED (angle_end)); ++ clutter_behaviour_ellipse_set_angle_endx (self, new_angle); + } + + /** +@@ -887,11 +871,11 @@ clutter_behaviour_ellipse_set_angle_endx (ClutterBehaviourEllipse *self, + ClutterFixed angle_end) + { + ClutterBehaviourEllipsePrivate *priv; +- ClutterAngle new_angle; ++ float new_angle; + + g_return_if_fail (CLUTTER_IS_BEHAVIOUR_ELLIPSE (self)); + +- new_angle = clamp_angle (COGL_ANGLE_FROM_DEGX (angle_end) - 256); ++ new_angle = clamp_angle (CLUTTER_FIXED_TO_FLOAT (angle_end)); + + priv = self->priv; + +@@ -918,7 +902,7 @@ clutter_behaviour_ellipse_get_angle_end (ClutterBehaviourEllipse *self) + { + g_return_val_if_fail (CLUTTER_IS_BEHAVIOUR_ELLIPSE (self), 0.0); + +- return COGL_ANGLE_TO_DEG (self->priv->angle_end + 256); ++ return self->priv->angle_end; + } + + /** +@@ -936,7 +920,7 @@ clutter_behaviour_ellipse_get_angle_endx (ClutterBehaviourEllipse *self) + { + g_return_val_if_fail (CLUTTER_IS_BEHAVIOUR_ELLIPSE (self), 0); + +- return COGL_ANGLE_TO_DEGX (self->priv->angle_end); ++ return CLUTTER_FLOAT_TO_FIXED (self->priv->angle_end); + } + + /** +@@ -955,11 +939,11 @@ clutter_behaviour_ellipse_set_angle_tilt (ClutterBehaviourEllipse *self, + ClutterRotateAxis axis, + gdouble angle_tilt) + { ++ ClutterFixed new_angle = CLUTTER_FLOAT_TO_FIXED (angle_tilt); ++ + g_return_if_fail (CLUTTER_IS_BEHAVIOUR_ELLIPSE (self)); + +- clutter_behaviour_ellipse_set_angle_tiltx (self, +- axis, +- CLUTTER_FLOAT_TO_FIXED (angle_tilt)); ++ clutter_behaviour_ellipse_set_angle_tiltx (self, axis, new_angle); + } + + /** +@@ -979,11 +963,11 @@ clutter_behaviour_ellipse_set_angle_tiltx (ClutterBehaviourEllipse *self, + ClutterFixed angle_tilt) + { + ClutterBehaviourEllipsePrivate *priv; +- ClutterAngle new_angle; ++ float new_angle; + + g_return_if_fail (CLUTTER_IS_BEHAVIOUR_ELLIPSE (self)); + +- new_angle = COGL_ANGLE_FROM_DEGX (angle_tilt); ++ new_angle = CLUTTER_FIXED_TO_FLOAT (angle_tilt); + + priv = self->priv; + +@@ -1038,11 +1022,11 @@ clutter_behaviour_ellipse_get_angle_tilt (ClutterBehaviourEllipse *self, + switch (axis) + { + case CLUTTER_X_AXIS: +- return COGL_ANGLE_TO_DEG (self->priv->angle_tilt_x); ++ return self->priv->angle_tilt_x; + case CLUTTER_Y_AXIS: +- return COGL_ANGLE_TO_DEG (self->priv->angle_tilt_y); ++ return self->priv->angle_tilt_y; + case CLUTTER_Z_AXIS: +- return COGL_ANGLE_TO_DEG (self->priv->angle_tilt_z); ++ return self->priv->angle_tilt_z; + } + + return 0; +@@ -1068,11 +1052,11 @@ clutter_behaviour_ellipse_get_angle_tiltx (ClutterBehaviourEllipse *self, + switch (axis) + { + case CLUTTER_X_AXIS: +- return COGL_ANGLE_TO_DEGX (self->priv->angle_tilt_x); ++ return CLUTTER_FLOAT_TO_FIXED (self->priv->angle_tilt_x); + case CLUTTER_Y_AXIS: +- return COGL_ANGLE_TO_DEGX (self->priv->angle_tilt_y); ++ return CLUTTER_FLOAT_TO_FIXED (self->priv->angle_tilt_y); + case CLUTTER_Z_AXIS: +- return COGL_ANGLE_TO_DEGX (self->priv->angle_tilt_z); ++ return CLUTTER_FLOAT_TO_FIXED (self->priv->angle_tilt_z); + } + + return 0; +@@ -1096,13 +1080,13 @@ clutter_behaviour_ellipse_set_tilt (ClutterBehaviourEllipse *self, + gdouble angle_tilt_z) + { + ClutterBehaviourEllipsePrivate *priv; +- ClutterAngle new_angle_x, new_angle_y, new_angle_z; ++ float new_angle_x, new_angle_y, new_angle_z; + + g_return_if_fail (CLUTTER_IS_BEHAVIOUR_ELLIPSE (self)); + +- new_angle_x = COGL_ANGLE_FROM_DEG (angle_tilt_x); +- new_angle_y = COGL_ANGLE_FROM_DEG (angle_tilt_y); +- new_angle_z = COGL_ANGLE_FROM_DEG (angle_tilt_z); ++ new_angle_x = angle_tilt_x; ++ new_angle_y = angle_tilt_y; ++ new_angle_z = angle_tilt_z; + + priv = self->priv; + +@@ -1150,13 +1134,13 @@ clutter_behaviour_ellipse_set_tiltx (ClutterBehaviourEllipse *self, + ClutterFixed angle_tilt_z) + { + ClutterBehaviourEllipsePrivate *priv; +- ClutterAngle new_angle_x, new_angle_y, new_angle_z; ++ float new_angle_x, new_angle_y, new_angle_z; + + g_return_if_fail (CLUTTER_IS_BEHAVIOUR_ELLIPSE (self)); + +- new_angle_x = COGL_ANGLE_FROM_DEGX (angle_tilt_x); +- new_angle_y = COGL_ANGLE_FROM_DEGX (angle_tilt_y); +- new_angle_z = COGL_ANGLE_FROM_DEGX (angle_tilt_z); ++ new_angle_x = angle_tilt_x; ++ new_angle_y = angle_tilt_y; ++ new_angle_z = angle_tilt_z; + + priv = self->priv; + +@@ -1210,13 +1194,13 @@ clutter_behaviour_ellipse_get_tilt (ClutterBehaviourEllipse *self, + priv = self->priv; + + if (angle_tilt_x) +- *angle_tilt_x = COGL_ANGLE_TO_DEG (priv->angle_tilt_x); ++ *angle_tilt_x = priv->angle_tilt_x; + + if (angle_tilt_y) +- *angle_tilt_y = COGL_ANGLE_TO_DEG (priv->angle_tilt_y); ++ *angle_tilt_y = priv->angle_tilt_y; + + if (angle_tilt_z) +- *angle_tilt_z = COGL_ANGLE_TO_DEG (priv->angle_tilt_z); ++ *angle_tilt_z = priv->angle_tilt_z; + } + + /** +@@ -1246,13 +1230,13 @@ clutter_behaviour_ellipse_get_tiltx (ClutterBehaviourEllipse *self, + priv = self->priv; + + if (angle_tilt_x) +- *angle_tilt_x = COGL_ANGLE_TO_DEGX (priv->angle_tilt_x); ++ *angle_tilt_x = priv->angle_tilt_x; + + if (angle_tilt_y) +- *angle_tilt_y = COGL_ANGLE_TO_DEGX (priv->angle_tilt_y); ++ *angle_tilt_y = priv->angle_tilt_y; + + if (angle_tilt_z) +- *angle_tilt_z = COGL_ANGLE_TO_DEGX (priv->angle_tilt_z); ++ *angle_tilt_z = priv->angle_tilt_z; + } + + /** diff --git a/fixed-to-float-patches/clutter-bezier.c.0.patch b/fixed-to-float-patches/clutter-bezier.c.0.patch new file mode 100644 index 000000000..4f2a163f3 --- /dev/null +++ b/fixed-to-float-patches/clutter-bezier.c.0.patch @@ -0,0 +1,13 @@ +diff --git a/clutter/clutter-bezier.c b/clutter/clutter-bezier.c +index 6a47626..66c4ddf 100644 +--- a/clutter/clutter-bezier.c ++++ b/clutter/clutter-bezier.c +@@ -252,7 +252,7 @@ _clutter_bezier_init (ClutterBezier *b, + int x = _clutter_bezier_t2x (b, t); + int y = _clutter_bezier_t2y (b, t); + +- guint l = clutter_sqrti ((y - yp)*(y - yp) + (x - xp)*(x - xp)); ++ guint l = cogl_sqrti ((y - yp)*(y - yp) + (x - xp)*(x - xp)); + + l += length[i-1]; + diff --git a/fixed-to-float-patches/clutter-fixed.c.0.patch b/fixed-to-float-patches/clutter-fixed.c.0.patch new file mode 100644 index 000000000..d1d4bc3e5 --- /dev/null +++ b/fixed-to-float-patches/clutter-fixed.c.0.patch @@ -0,0 +1,15 @@ +diff --git a/clutter/clutter-fixed.c b/clutter/clutter-fixed.c +index 89f43c2..6d5bf01 100644 +--- a/clutter/clutter-fixed.c ++++ b/clutter/clutter-fixed.c +@@ -251,8 +251,8 @@ param_fixed_init (GParamSpec *pspec) + { + ClutterParamSpecFixed *fspec = CLUTTER_PARAM_SPEC_FIXED (pspec); + +- fspec->minimum = COGL_FIXED_MIN; +- fspec->maximum = COGL_FIXED_MAX; ++ fspec->minimum = CLUTTER_MAXFIXED; ++ fspec->maximum = CLUTTER_MINFIXED; + fspec->default_value = 0; + } + diff --git a/fixed-to-float-patches/clutter-fixed.h.0.patch b/fixed-to-float-patches/clutter-fixed.h.0.patch new file mode 100644 index 000000000..0b4cc2f03 --- /dev/null +++ b/fixed-to-float-patches/clutter-fixed.h.0.patch @@ -0,0 +1,333 @@ +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) ++#define clutter_tanx(a) tanf (a) ++#define clutter_atanx(a) atanf (a) ++#define clutter_atan2x(x,y) atan2f (x, y) ++#define clutter_cosx(a) cosf (a) + + #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/fixed-to-float-patches/clutter-path.c.0.patch b/fixed-to-float-patches/clutter-path.c.0.patch new file mode 100644 index 000000000..89a1901f2 --- /dev/null +++ b/fixed-to-float-patches/clutter-path.c.0.patch @@ -0,0 +1,18 @@ +diff --git a/clutter/clutter-path.c b/clutter/clutter-path.c +index 973d861..d3eff11 100644 +--- a/clutter/clutter-path.c ++++ b/clutter/clutter-path.c +@@ -1081,11 +1081,11 @@ clutter_path_node_distance (const ClutterKnot *start, + * If we are using limited precision sqrti implementation, fallback on + * clib sqrt if the precission would be less than 10% + */ +-#if INT_MAX > CLUTTER_SQRTI_ARG_10_PERCENT ++#if INT_MAX > COGL_SQRTI_ARG_10_PERCENT + if (t <= COGL_SQRTI_ARG_10_PERCENT) + return cogl_sqrti (t); + else +- return COGL_FLOAT_TO_INT (sqrt(t)); ++ return COGL_FLOAT_TO_INT (sqrtf(t)); + #else + return cogl_sqrti (t); + #endif diff --git a/fixed-to-float-patches/clutter-texture.c.0.patch b/fixed-to-float-patches/clutter-texture.c.0.patch new file mode 100644 index 000000000..f511a0487 --- /dev/null +++ b/fixed-to-float-patches/clutter-texture.c.0.patch @@ -0,0 +1,13 @@ +diff --git a/clutter/clutter-texture.c b/clutter/clutter-texture.c +index fc5541b..0f1a77e 100644 +--- a/clutter/clutter-texture.c ++++ b/clutter/clutter-texture.c +@@ -457,7 +457,7 @@ clutter_texture_set_fbo_projection (ClutterActor *self) + + /* Set up a projection matrix so that the actor will be projected as + if it was drawn at its original location */ +- tan_angle = clutter_tani (CLUTTER_ANGLE_FROM_DEGX (perspective.fovy / 2)); ++ tan_angle = clutter_tanx (perspective.fovy / 2); + near_size = CLUTTER_FIXED_MUL (perspective.z_near, tan_angle); + + cogl_frustum (CLUTTER_FIXED_MUL (x_min, near_size), diff --git a/fixed-to-float-patches/clutter-units.h.0.patch b/fixed-to-float-patches/clutter-units.h.0.patch new file mode 100644 index 000000000..52ac9606a --- /dev/null +++ b/fixed-to-float-patches/clutter-units.h.0.patch @@ -0,0 +1,85 @@ +diff --git a/clutter/clutter-units.h b/clutter/clutter-units.h +index 8337d19..2a8ef65 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,11 +50,11 @@ typedef gint32 ClutterUnit; + * decide to change this relationship in the future. + */ + +-#define CLUTTER_UNITS_FROM_INT(x) (COGL_FIXED_FROM_INT ((x))) +-#define CLUTTER_UNITS_TO_INT(x) (COGL_FIXED_TO_INT ((x))) ++#define CLUTTER_UNITS_FROM_INT(x) ((float)(x)) ++#define CLUTTER_UNITS_TO_INT(x) ((int)(x)) + +-#define CLUTTER_UNITS_FROM_FLOAT(x) (COGL_FIXED_FROM_FLOAT ((x))) +-#define CLUTTER_UNITS_TO_FLOAT(x) (COGL_FIXED_TO_FLOAT ((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) +@@ -90,7 +90,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: +@@ -100,7 +100,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) +@@ -125,8 +125,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: +@@ -139,9 +138,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)) +@@ -154,7 +150,7 @@ typedef gint32 ClutterUnit; + * + * Since: 0.8 + */ +-#define CLUTTER_MAXUNIT (0x7fffffff) ++#define CLUTTER_MAXUNIT (G_MAXFLOAT) + + /** + * CLUTTER_MINUNIT: +@@ -163,7 +159,7 @@ typedef gint32 ClutterUnit; + * + * Since: 0.8 + */ +-#define CLUTTER_MINUNIT (0x80000000) ++#define CLUTTER_MINUNIT (-G_MAXFLOAT) + + /** + * CLUTTER_VALUE_HOLDS_UNIT: diff --git a/fixed-to-float-patches/cogl-fixed.c.0.patch b/fixed-to-float-patches/cogl-fixed.c.0.patch new file mode 100644 index 000000000..db5882bc5 --- /dev/null +++ b/fixed-to-float-patches/cogl-fixed.c.0.patch @@ -0,0 +1,17 @@ +diff --git a/clutter/cogl/common/cogl-fixed.c b/clutter/cogl/common/cogl-fixed.c +index 348d2ce..2e27da1 100644 +--- a/clutter/cogl/common/cogl-fixed.c ++++ b/clutter/cogl/common/cogl-fixed.c +@@ -482,6 +482,12 @@ cogl_angle_sin (CoglAngle angle) + } + + CoglFixed ++cogl_fixed_tan (CoglFixed angle) ++{ ++ return cogl_angle_tan (COGL_ANGLE_FROM_DEGX (angle)); ++} ++ ++CoglFixed + cogl_angle_tan (CoglAngle angle) + { + int sign = 1; diff --git a/fixed-to-float-patches/cogl-fixed.h.0.patch b/fixed-to-float-patches/cogl-fixed.h.0.patch new file mode 100644 index 000000000..ab0dcf876 --- /dev/null +++ b/fixed-to-float-patches/cogl-fixed.h.0.patch @@ -0,0 +1,23 @@ +diff --git a/clutter/cogl/cogl-fixed.h b/clutter/cogl/cogl-fixed.h +index a521074..8d7c9e9 100644 +--- a/clutter/cogl/cogl-fixed.h ++++ b/clutter/cogl/cogl-fixed.h +@@ -456,6 +456,18 @@ G_BEGIN_DECLS + CoglFixed cogl_fixed_sin (CoglFixed angle); + + /** ++ * cogl_fixed_tan: ++ * @angle: a #CoglFixed number ++ * ++ * Computes the tangent of @angle. ++ * ++ * Return value: the tangent of the passed angle, in fixed point notation ++ * ++ * Since: 1.0 ++ */ ++CoglFixed cogl_fixed_tan (CoglFixed angle); ++ ++/** + * cogl_fixed_cos: + * @angle: a #CoglFixed number + * diff --git a/fixed-to-float-patches/cogl-pango-render.c.0.patch b/fixed-to-float-patches/cogl-pango-render.c.0.patch new file mode 100644 index 000000000..625a8c1ca --- /dev/null +++ b/fixed-to-float-patches/cogl-pango-render.c.0.patch @@ -0,0 +1,24 @@ +diff --git a/clutter/pango/cogl-pango-render.c b/clutter/pango/cogl-pango-render.c +index 9d1da77..12dfe72 100644 +--- a/clutter/pango/cogl-pango-render.c ++++ b/clutter/pango/cogl-pango-render.c +@@ -58,8 +58,6 @@ struct _CoglPangoRendererClass + PangoRendererClass class_instance; + }; + +-#define COGL_PANGO_UNIT_TO_FIXED(x) ((x) << (COGL_FIXED_Q - 10)) +- + static void cogl_pango_renderer_finalize (GObject *object); + static void cogl_pango_renderer_draw_glyphs (PangoRenderer *renderer, + PangoFont *font, +@@ -393,8 +391,8 @@ cogl_pango_renderer_get_device_units (PangoRenderer *renderer, + } + else + { +- *xout = COGL_PANGO_UNIT_TO_FIXED (xin); +- *yout = COGL_PANGO_UNIT_TO_FIXED (yin); ++ *xout = PANGO_PIXELS (xin); ++ *yout = PANGO_PIXELS (yin); + } + } + diff --git a/fixed-to-float-patches/cogl-primitives.c.0.patch b/fixed-to-float-patches/cogl-primitives.c.0.patch new file mode 100644 index 000000000..ea09ab582 --- /dev/null +++ b/fixed-to-float-patches/cogl-primitives.c.0.patch @@ -0,0 +1,12 @@ +diff --git a/clutter/cogl/common/cogl-primitives.c b/clutter/cogl/common/cogl-primitives.c +index 7dfc78e..c9578db 100644 +--- a/clutter/cogl/common/cogl-primitives.c ++++ b/clutter/cogl/common/cogl-primitives.c +@@ -33,6 +33,7 @@ + + #include + #include ++#include + + #define _COGL_MAX_BEZ_RECURSE_DEPTH 16 + diff --git a/fixed-to-float-patches/gl-cogl-primitives.c.0.patch b/fixed-to-float-patches/gl-cogl-primitives.c.0.patch new file mode 100644 index 000000000..b1602e78b --- /dev/null +++ b/fixed-to-float-patches/gl-cogl-primitives.c.0.patch @@ -0,0 +1,12 @@ +diff --git a/clutter/cogl/gl/cogl-primitives.c b/clutter/cogl/gl/cogl-primitives.c +index 98d247a..ec9593b 100644 +--- a/clutter/cogl/gl/cogl-primitives.c ++++ b/clutter/cogl/gl/cogl-primitives.c +@@ -34,6 +34,7 @@ + + #include + #include ++#include + + #define _COGL_MAX_BEZ_RECURSE_DEPTH 16 + diff --git a/fixed-to-float-patches/gl-cogl-texture.c.0.patch b/fixed-to-float-patches/gl-cogl-texture.c.0.patch new file mode 100644 index 000000000..8e99de198 --- /dev/null +++ b/fixed-to-float-patches/gl-cogl-texture.c.0.patch @@ -0,0 +1,30 @@ +diff --git a/clutter/cogl/gl/cogl-texture.c b/clutter/cogl/gl/cogl-texture.c +index 1bbaaa4..612c417 100644 +--- a/clutter/cogl/gl/cogl-texture.c ++++ b/clutter/cogl/gl/cogl-texture.c +@@ -37,6 +37,7 @@ + + #include + #include ++#include + + /* + #define COGL_DEBUG 1 +@@ -555,7 +556,7 @@ _cogl_texture_upload_subregion_to_gl (CoglTexture *tex, + guint wx, wy; + + src = source_bmp->data +- + (src_y + (y_iter.intersect_start) ++ + (src_y + ((int)y_iter.intersect_start) + - dst_y) + * source_bmp->rowstride + + (src_x + x_span->start + x_span->size - x_span->waste +@@ -600,7 +601,7 @@ _cogl_texture_upload_subregion_to_gl (CoglTexture *tex, + guint copy_width; + + src = source_bmp->data +- + (src_x + (x_iter.intersect_start) ++ + (src_x + ((int)x_iter.intersect_start) + - dst_x) + * bpp + + (src_y + y_span->start + y_span->size - y_span->waste diff --git a/fixed-to-float-patches/gl-cogl.c b/fixed-to-float-patches/gl-cogl.c new file mode 100644 index 000000000..6ec4ac153 --- /dev/null +++ b/fixed-to-float-patches/gl-cogl.c @@ -0,0 +1,92 @@ +diff --git a/clutter/cogl/gl/cogl.c b/clutter/cogl/gl/cogl.c +index 7b61b63..dcded98 100644 +--- a/clutter/cogl/gl/cogl.c ++++ b/clutter/cogl/gl/cogl.c +@@ -211,17 +211,17 @@ cogl_pop_matrix (void) + void + cogl_scale (float x, float y) + { +- glScaled ((double)(x), +- (double)(y), ++ glScalef ((float)(x), ++ (float)(y), + 1.0); + } + + void + cogl_translatex (float x, float y, float z) + { +- glTranslated ((double)(x), +- (double)(y), +- (double)(z)); ++ glTranslatef ((float)(x), ++ (float)(y), ++ (float)(z)); + } + + void +@@ -233,10 +233,10 @@ cogl_translate (gint x, gint y, gint z) + void + cogl_rotatex (float angle, gint x, gint y, gint z) + { +- glRotated ((double)(angle), +- (double)(x), +- (double)(y), +- (double)(z)); ++ glRotatef ((float)(angle), ++ (float)(x), ++ (float)(y), ++ (float)(z)); + } + + void +@@ -645,17 +645,13 @@ cogl_perspective (float fovy, + * 2) When working with small numbers, we are loosing significant + * precision + */ +- ymax = +- (zNear * +- (sinf (fovy_rad_half) / +- cosf (fovy_rad_half))); +- ++ ymax = (zNear * (sinf (fovy_rad_half) / cosf (fovy_rad_half))); + xmax = (ymax * aspect); + + x = (zNear / xmax); + y = (zNear / ymax); + c = (-(zFar + zNear) / ( zFar - zNear)); +- d = cogl_fixed_mul_div (-(2 * zFar), zNear, (zFar - zNear)); ++ d = (-(2 * zFar) * zNear) / (zFar - zNear); + + #define M(row,col) m[col*4+row] + M(0,0) = (x); +@@ -696,12 +692,12 @@ cogl_frustum (float left, + GE( glMatrixMode (GL_PROJECTION) ); + GE( glLoadIdentity () ); + +- GE( glFrustum ((double)(left), +- (double)(right), +- (double)(bottom), +- (double)(top), +- (double)(z_near), +- (double)(z_far)) ); ++ GE( glFrustum ((GLdouble)(left), ++ (GLdouble)(right), ++ (GLdouble)(bottom), ++ (GLdouble)(top), ++ (GLdouble)(z_near), ++ (GLdouble)(z_far)) ); + + GE( glMatrixMode (GL_MODELVIEW) ); + +@@ -773,9 +769,7 @@ cogl_setup_viewport (guint width, + { + float fovy_rad = (fovy * G_PI) / 180; + +- z_camera = +- ((sinf (fovy_rad) / +- cosf (fovy_rad)) >> 1); ++ z_camera = ((sinf (fovy_rad) / cosf (fovy_rad)) / 2); + } + + GE( glTranslatef (-0.5f, -0.5f, -z_camera) ); diff --git a/fixed-to-float-patches/mtx_transform.0.patch b/fixed-to-float-patches/mtx_transform.0.patch new file mode 100644 index 000000000..5c8359ff7 --- /dev/null +++ b/fixed-to-float-patches/mtx_transform.0.patch @@ -0,0 +1,19 @@ +diff --git a/clutter/clutter-actor.c b/clutter/clutter-actor.c +index cc56310..4c89c0f 100644 +--- a/clutter/clutter-actor.c ++++ b/clutter/clutter-actor.c +@@ -781,11 +781,10 @@ clutter_actor_real_allocate (ClutterActor *self, + + /* Transform point (x,y,z) by matrix */ + static void +-mtx_transform (ClutterFixed m[16], +- ClutterFixed *x, ClutterFixed *y, ClutterFixed *z, +- ClutterFixed *w) ++mtx_transform (float m[16], ++ float *x, float *y, float *z, float *w) + { +- ClutterFixed _x, _y, _z, _w; ++ float _x, _y, _z, _w; + _x = *x; + _y = *y; + _z = *z; diff --git a/fixed-to-float-patches/test-cogl-tex-tile.c.0.patch b/fixed-to-float-patches/test-cogl-tex-tile.c.0.patch new file mode 100644 index 000000000..45aa82337 --- /dev/null +++ b/fixed-to-float-patches/test-cogl-tex-tile.c.0.patch @@ -0,0 +1,35 @@ +diff --git a/tests/interactive/test-cogl-tex-tile.c b/tests/interactive/test-cogl-tex-tile.c +index fe7138a..5be6dd5 100644 +--- a/tests/interactive/test-cogl-tex-tile.c ++++ b/tests/interactive/test-cogl-tex-tile.c +@@ -90,22 +90,22 @@ test_coglbox_paint(ClutterActor *self) + ClutterFixed sin_frame, cos_frame; + ClutterFixed frac_frame; + gint t; +- sin_frame = clutter_sini (CLUTTER_ANGLE_FROM_DEG (priv->frame)); +- cos_frame = clutter_cosi (CLUTTER_ANGLE_FROM_DEG (priv->frame)); ++ sin_frame = clutter_sinx (CLUTTER_INT_TO_FIXED (priv->frame)); ++ cos_frame = clutter_cosx (CLUTTER_INT_TO_FIXED (priv->frame)); + + pingpong_frame = (priv->frame <= 180 ? priv->frame : 360 - priv->frame); +- frac_frame = COGL_FIXED_DIV (CLUTTER_INT_TO_FIXED (pingpong_frame), +- CLUTTER_INT_TO_FIXED (180)); +- frac_frame += (COGL_FIXED_1 >> 1); +- frac_frame <<= 1; ++ frac_frame = CLUTTER_FIXED_DIV (CLUTTER_INT_TO_FIXED (pingpong_frame), ++ CLUTTER_INT_TO_FIXED (180)); ++ frac_frame += 0.5; ++ frac_frame *= 2; + + for (t=0; t<4; t+=2) + { + texcoords[t] += cos_frame; + texcoords[t+1] += sin_frame; + +- texcoords[t] = COGL_FIXED_MUL (texcoords[t], frac_frame); +- texcoords[t+1] = COGL_FIXED_MUL (texcoords[t+1], frac_frame); ++ texcoords[t] = CLUTTER_FIXED_MUL (texcoords[t], frac_frame); ++ texcoords[t+1] = CLUTTER_FIXED_MUL (texcoords[t+1], frac_frame); + } + + priv = TEST_COGLBOX_GET_PRIVATE (self); diff --git a/fixed-to-float.sh b/fixed-to-float.sh new file mode 100755 index 000000000..a38f3363c --- /dev/null +++ b/fixed-to-float.sh @@ -0,0 +1,150 @@ +#!/bin/sh + +# The ClutterFixed type and macros now use floats, but we are keeping the +# CoglFixed type + macros using fixed point so now we convert all uses of +# the Cogl fixed point macros within Clutter proper to use the ClutterFixed +# macros instead. +find ./clutter -maxdepth 1 -iname '*.c' -exec sed -i 's/COGL_FIXED_MUL/CLUTTER_FIXED_MUL/g' {} \; +find ./clutter -maxdepth 1 -iname '*.c' -exec sed -i 's/COGL_FIXED_DIV/CLUTTER_FIXED_DIV/g' {} \; +find ./clutter -maxdepth 1 -iname '*.c' -exec sed -i 's/COGL_FIXED_FAST_MUL/CLUTTER_FIXED_MUL/g' {} \; +find ./clutter -maxdepth 1 -iname '*.c' -exec sed -i 's/COGL_FIXED_FAST_DIV/CLUTTER_FIXED_DIV/g' {} \; +find ./clutter -maxdepth 1 -iname '*.c' -exec sed -i 's/COGL_FIXED_FROM_FLOAT/CLUTTER_FLOAT_TO_FIXED/g' {} \; +find ./clutter -maxdepth 1 -iname '*.c' -exec sed -i 's/COGL_FIXED_TO_FLOAT/CLUTTER_FIXED_TO_FLOAT/g' {} \; +find ./clutter -maxdepth 1 -iname '*.c' -exec sed -i 's/COGL_FIXED_TO_DOUBLE/CLUTTER_FIXED_TO_DOUBLE/g' {} \; +find ./clutter -maxdepth 1 -iname '*.c' -exec sed -i 's/COGL_FIXED_PI/CFX_PI/g' {} \; + +# All remaining uses of the Cogl fixed point API now get expanded out to simply +# use float calculations... (we will restore the cogl-fixed code itself later) + +# XXX: This assumes that no nested function - with multiple arguments - is ever +# found as the RHS argument to COGL_FIXED_MUL. This is because we simply replace +# the last ',' with the * operator. If you want to double check that's still true: +# $ grep -r --include=*.c COGL_FIXED_MUL *|less +find ./clutter -iname '*.[ch]' -exec sed -i -r 's/COGL_FIXED_MUL (.*),/\1 */g' {} \; +# XXX: We use the same assumption here... +find ./clutter -iname '*.[ch]' -exec sed -i -r 's|COGL_FIXED_FAST_DIV (.*),|\1 /|g' {} \; +# XXX: And again here. (Note in this case there were examples of COGL_FIXED_MUL +# being used as the RHS argument, but since we have already replaced instances +# of COGL_FIXED_MUL, that works out ok. +find ./clutter -iname '*.[ch]' -exec sed -i -r 's|COGL_FIXED_DIV (.*),|\1 /|g' {} \; + +# A fix due to the assumptions used above +sed -i 's/#define DET2X(a,b,c,d).*/#define DET2X(a,b,c,d) ((a * d) - (b * c))/g' ./clutter/clutter-actor.c + +#we get some redundant brackets like this, but C's automatic type promotion +#works out fine for most cases... +find ./clutter -iname '*.[ch]' -exec sed -i 's/COGL_FIXED_TO_INT//g' {} \; +find ./clutter -iname '*.[ch]' -exec sed -i 's/COGL_FIXED_FROM_INT//g' {} \; +find ./clutter -iname '*.[ch]' -exec sed -i 's/COGL_FIXED_TO_FLOAT//g' {} \; +find ./clutter -iname '*.[ch]' -exec sed -i 's/COGL_FIXED_FROM_FLOAT//g' {} \; +find ./clutter -iname '*.[ch]' -exec sed -i 's/COGL_FIXED_TO_DOUBLE /(double)/g' {} \; + +find ./clutter -iname '*.[ch]' -exec sed -i 's/COGL_FIXED_FLOOR/floorf/g' {} \; +find ./clutter -iname '*.[ch]' -exec sed -i 's/COGL_FIXED_CEIL/ceilf/g' {} \; +find ./clutter -iname '*.[ch]' -exec sed -i 's/COGL_FIXED_360/360.0/g' {} \; +find ./clutter -iname '*.[ch]' -exec sed -i 's/COGL_FIXED_240/240.0/g' {} \; +find ./clutter -iname '*.[ch]' -exec sed -i 's/COGL_FIXED_255/255.0/g' {} \; +find ./clutter -iname '*.[ch]' -exec sed -i 's/COGL_FIXED_180/180.0/g' {} \; +find ./clutter -iname '*.[ch]' -exec sed -i 's/COGL_FIXED_120/120.0/g' {} \; +find ./clutter -iname '*.[ch]' -exec sed -i 's/COGL_FIXED_60/60.0/g' {} \; +find ./clutter -iname '*.[ch]' -exec sed -i 's/COGL_FIXED_1/1.0/g' {} \; +find ./clutter -iname '*.[ch]' -exec sed -i 's/COGL_FIXED_0_5/0.5/g' {} \; +find ./clutter -iname '*.[ch]' -exec sed -i 's/COGL_FIXED_PI/G_PI/g' {} \; + +find ./clutter -iname '*.[ch]' -exec sed -i 's/cogl_angle_cos/cosf/g' {} \; +find ./clutter -iname '*.[ch]' -exec sed -i 's/cogl_angle_sin/sinf/g' {} \; +find ./clutter -iname '*.[ch]' -exec sed -i 's/cogl_angle_tan/tanf/g' {} \; + +#XXX: NB: cogl_fixed_div must be done before mul since there is a case were they +#are nested which would otherwise break the assumption used here that the last +#coma of the line can simply be replaced with the corresponding operator +find ./clutter -iname '*.[ch]' -exec sed -i -r 's|cogl_fixed_div (.*),|\1 /|g' {} \; +find ./clutter -iname '*.[ch]' -exec sed -i -r 's|cogl_fixed_mul (.*),|\1 *|g' {} \; +find ./clutter -iname '*.[ch]' -exec sed -i 's/cogl_fixed_pow2/pow2f/g' {} \; +find ./clutter -iname '*.[ch]' -exec sed -i 's/cogl_fixed_pow/powf/g' {} \; +find ./clutter -iname '*.[ch]' -exec sed -i 's/cogl_fixed_log2/log2f/g' {} \; +find ./clutter -iname '*.[ch]' -exec sed -i 's/cogl_fixed_sqrt/sqrtf/g' {} \; +find ./clutter -iname '*.[ch]' -exec sed -i 's/cogl_fixed_cos/cosf/g' {} \; +find ./clutter -iname '*.[ch]' -exec sed -i 's/cogl_fixed_sin/sinf/g' {} \; +find ./clutter -iname '*.[ch]' -exec sed -i 's/cogl_fixed_atan2/atan2f/g' {} \; +find ./clutter -iname '*.[ch]' -exec sed -i 's/cogl_fixed_atan/atanf/g' {} \; +find ./clutter -iname '*.[ch]' -exec sed -i 's/cogl_fixed_tan/tanf/g' {} \; + +#TODO: fixup gles/cogl.c set_clip_plane + +cat clutter/cogl/common/cogl-primitives.c| \ + grep -v '#define CFX_MUL2'| \ + grep -v '#undef CFX_MUL2'| \ + grep -v '#define CFX_MUL3'| \ + grep -v '#undef CFX_MUL3'| \ + grep -v '#define CFX_SQ'| \ + grep -v '#undef CFX_SQ'| \ + sed -r 's/CFX_MUL2 \((.{7})\)/(\1 * 2)/g' | \ + sed -r 's/CFX_MUL3 \((.{7})\)/(\1 * 3)/g' | \ + sed -r 's/CFX_SQ \((.{7})\)/(\1 * \1)/g' \ + >./tmp +mv ./tmp clutter/cogl/common/cogl-primitives.c + +#this has too many false positives... +#find ./clutter -iname '*.[ch]' -exec sed -i 's|>> 1|/ 2|g' {} \; +#find ./clutter -iname '*.[ch]' -exec sed -i 's|<< 1|* 2|g' {} \; + +sed -i 's|>> 1|/ 2|g' ./clutter/cogl/common/cogl-primitives.c +sed -i 's|<< 1|* 2|g' ./clutter/cogl/common/cogl-primitives.c +#find ./clutter -iname '*.[ch]' -exec sed -i 's|<< 1|* 2|g' {} \; + + +find ./clutter -iname '*.[ch]' -exec sed -i 's/CoglFixed/float/g' {} \; +#XXX: This might need changing later... +find ./clutter -iname '*.[ch]' -exec sed -i 's/CoglFixedVec2/CoglVec2/g' {} \; +sed -i 's/CoglFixed/float/g' ./clutter/cogl/cogl.h.in + +# maintain the existing CoglFixed code as utility code for applications: +sed -i 's/float:/CoglFixed:/g' clutter/cogl/cogl-types.h +sed -i 's/gint32 float/gint32 CoglFixed/g' clutter/cogl/cogl-types.h +git-checkout clutter/cogl/cogl-fixed.h clutter/cogl/common/cogl-fixed.c + +echo "Cogl API to remove/replace with float versions:" +find ./clutter/ -iname '*.c' -exec grep '^cogl_[a-zA-Z_]*x ' {} \; | cut -d' ' -f1|grep -v 'box$'|grep -v 'matrix$' +echo "Clutter API to remove/replace with float versions:" +find ./clutter/ -iname '*.c' -exec grep '^clutter_[a-zA-Z_]*x ' {} \; | cut -d' ' -f1|grep -v 'box$'|grep -v 'matrix$'|grep -v '_x$' + +# +# Now the last mile is dealt with manually with a bunch of patches... +# + +git-commit -a -m "[By fixed-to-float.sh] Fixed to Float automatic changes" --no-verify + +patch -p1 Date: Tue, 6 Jan 2009 18:45:34 +0000 Subject: [PATCH 02/26] [clutter-alpha.c.0.patch] Normalizes sine values [0,1] before calculating alpha The previous patch broke some of the normalization done before the sine value gets multiplied with CLUTTER_ALPHA_MAX. This e.g. broke test-actors when sine values went through to -1, as the o-hands were scaled so large all you saw was the red 'O'. --- .../clutter-alpha.c.0.patch | 55 +++++++++++-------- 1 file changed, 31 insertions(+), 24 deletions(-) diff --git a/fixed-to-float-patches/clutter-alpha.c.0.patch b/fixed-to-float-patches/clutter-alpha.c.0.patch index f466a9588..457be3007 100644 --- a/fixed-to-float-patches/clutter-alpha.c.0.patch +++ b/fixed-to-float-patches/clutter-alpha.c.0.patch @@ -1,5 +1,5 @@ diff --git a/clutter/clutter-alpha.c b/clutter/clutter-alpha.c -index 3e4df4d..74a5c7a 100644 +index 3e4df4d..d508631 100644 --- a/clutter/clutter-alpha.c +++ b/clutter/clutter-alpha.c @@ -694,6 +694,11 @@ clutter_ramp_func (ClutterAlpha *alpha, @@ -44,7 +44,7 @@ index 3e4df4d..74a5c7a 100644 CLUTTER_NOTE (ALPHA, "sine: %2f\n", CLUTTER_FIXED_TO_DOUBLE (sine)); -@@ -803,9 +803,25 @@ guint32 +@@ -803,9 +803,28 @@ guint32 clutter_sine_func (ClutterAlpha *alpha, gpointer dummy) { @@ -62,9 +62,12 @@ index 3e4df4d..74a5c7a 100644 + radians = ((float)current_frame_num / n_frames) * (2.0 * G_PI); + sine = sinf (radians); + ++ /* shift from range [-1, 1] -> [0, 1] */ ++ sine = (sine + 1.0) / 2.0; ++ + CLUTTER_NOTE (ALPHA, "sine: %2f\n", sine); + -+ return COGL_FLOAT_TO_INT ((sine * CLUTTER_ALPHA_MAX_ALPHA)); ++ return sine * CLUTTER_ALPHA_MAX_ALPHA; +#elif 0 return sinc_func (alpha, 2.0, 1.0); -#else @@ -72,7 +75,7 @@ index 3e4df4d..74a5c7a 100644 /* 2.0 above represents full circle */ return sincx1024_func (alpha, 1024, 1.0); #endif -@@ -839,18 +855,17 @@ clutter_sine_inc_func (ClutterAlpha *alpha, +@@ -839,18 +858,17 @@ clutter_sine_inc_func (ClutterAlpha *alpha, ClutterTimeline * timeline; gint frame; gint n_frames; @@ -86,17 +89,17 @@ index 3e4df4d..74a5c7a 100644 n_frames = clutter_timeline_get_n_frames (timeline); - x = 256 * frame / n_frames; -- -- sine = sinf (x) * CLUTTER_ALPHA_MAX_ALPHA; + radians = ((float)frame / n_frames) * (G_PI / 2); + sine = sinf (radians); +- sine = sinf (x) * CLUTTER_ALPHA_MAX_ALPHA; +- - return ((guint32) sine) >> COGL_FIXED_Q; + return (guint32) (sine * CLUTTER_ALPHA_MAX_ALPHA); } /** -@@ -881,18 +896,17 @@ clutter_sine_dec_func (ClutterAlpha *alpha, +@@ -881,18 +899,17 @@ clutter_sine_dec_func (ClutterAlpha *alpha, ClutterTimeline * timeline; gint frame; gint n_frames; @@ -120,7 +123,7 @@ index 3e4df4d..74a5c7a 100644 } /** -@@ -923,18 +937,17 @@ clutter_sine_half_func (ClutterAlpha *alpha, +@@ -923,18 +940,17 @@ clutter_sine_half_func (ClutterAlpha *alpha, ClutterTimeline *timeline; gint frame; gint n_frames; @@ -134,17 +137,17 @@ index 3e4df4d..74a5c7a 100644 n_frames = clutter_timeline_get_n_frames (timeline); - x = 512 * frame / n_frames; +- +- sine = sinf (x) * CLUTTER_ALPHA_MAX_ALPHA; + radians = ((float)frame / n_frames) * G_PI; + sine = sinf (radians); -- sine = sinf (x) * CLUTTER_ALPHA_MAX_ALPHA; -- - return ((guint32) sine) >> COGL_FIXED_Q; + return (guint32) (sine * CLUTTER_ALPHA_MAX_ALPHA); } /** -@@ -959,19 +972,17 @@ clutter_sine_in_func (ClutterAlpha *alpha, +@@ -959,19 +975,20 @@ clutter_sine_in_func (ClutterAlpha *alpha, ClutterTimeline *timeline; gint frame; gint n_frames; @@ -159,17 +162,19 @@ index 3e4df4d..74a5c7a 100644 - /* XXX- if we use 768 we overflow */ - x = 256 * frame / n_frames + 767; -- -- sine = (sinf (x) + 1) * CLUTTER_ALPHA_MAX_ALPHA; + radians = ((float)frame / n_frames) * (G_PI / 2); -+ sine = sinf (radians - (G_PI / 2)) + 1.0; ++ sine = sinf (radians - (G_PI / 2)); + +- sine = (sinf (x) + 1) * CLUTTER_ALPHA_MAX_ALPHA; ++ /* shift from range [-1, 0] -> [0, 1] */ ++ sine = sine + 1.0; - return ((guint32) sine) >> COGL_FIXED_Q; + return (guint32) (sine * CLUTTER_ALPHA_MAX_ALPHA); } /** -@@ -995,18 +1006,17 @@ clutter_sine_out_func (ClutterAlpha *alpha, +@@ -995,18 +1012,17 @@ clutter_sine_out_func (ClutterAlpha *alpha, ClutterTimeline *timeline; gint frame; gint n_frames; @@ -183,17 +188,17 @@ index 3e4df4d..74a5c7a 100644 n_frames = clutter_timeline_get_n_frames (timeline); - x = 256 * frame / n_frames; -- -- sine = sinf (x) * CLUTTER_ALPHA_MAX_ALPHA; + radians = ((float)frame / n_frames) * (G_PI / 2); + sine = sinf (radians); +- sine = sinf (x) * CLUTTER_ALPHA_MAX_ALPHA; +- - return ((guint32) sine) >> COGL_FIXED_Q; + return (guint32) (sine * CLUTTER_ALPHA_MAX_ALPHA); } /** -@@ -1031,18 +1041,17 @@ clutter_sine_in_out_func (ClutterAlpha *alpha, +@@ -1031,18 +1047,20 @@ clutter_sine_in_out_func (ClutterAlpha *alpha, ClutterTimeline *timeline; gint frame; gint n_frames; @@ -208,16 +213,18 @@ index 3e4df4d..74a5c7a 100644 - x = -256 * frame / n_frames + 256; + radians = ((float)frame / n_frames) * G_PI; -+ sine = (sinf (radians - (G_PI / 2)) + 1.0) / 2.0; ++ sine = sinf (radians - (G_PI / 2)); - sine = (sinf (x) + 1) / 2 * CLUTTER_ALPHA_MAX_ALPHA; -- ++ /* shift from range [-1, 1] -> [0, 1] */ ++ sine = (sine + 1.0) / 2.0; + - return ((guint32) sine) >> COGL_FIXED_Q; + return (guint32) (sine * CLUTTER_ALPHA_MAX_ALPHA); } /** -@@ -1201,9 +1210,9 @@ clutter_exp_inc_func (ClutterAlpha *alpha, +@@ -1201,9 +1219,9 @@ clutter_exp_inc_func (ClutterAlpha *alpha, * * (2^x_alpha_max) - 1 == CLUTTER_ALPHA_MAX_ALPHA */ @@ -230,7 +237,7 @@ index 3e4df4d..74a5c7a 100644 timeline = clutter_alpha_get_timeline (alpha); frame = clutter_timeline_get_current_frame (timeline); -@@ -1211,7 +1220,7 @@ clutter_exp_inc_func (ClutterAlpha *alpha, +@@ -1211,7 +1229,7 @@ clutter_exp_inc_func (ClutterAlpha *alpha, x = x_alpha_max * frame / n_frames; @@ -239,7 +246,7 @@ index 3e4df4d..74a5c7a 100644 return result; } -@@ -1252,9 +1261,9 @@ clutter_exp_dec_func (ClutterAlpha *alpha, +@@ -1252,9 +1270,9 @@ clutter_exp_dec_func (ClutterAlpha *alpha, * * (2^x_alpha_max) - 1 == CLUTTER_ALPHA_MAX_ALPHA */ @@ -252,7 +259,7 @@ index 3e4df4d..74a5c7a 100644 timeline = clutter_alpha_get_timeline (alpha); frame = clutter_timeline_get_current_frame (timeline); -@@ -1262,7 +1271,7 @@ clutter_exp_dec_func (ClutterAlpha *alpha, +@@ -1262,7 +1280,7 @@ clutter_exp_dec_func (ClutterAlpha *alpha, x = (x_alpha_max * (n_frames - frame)) / n_frames; From 1eeb21c155882497f7b0f76b0fbdc84a13e1f4ab Mon Sep 17 00:00:00 2001 From: Robert Bragg Date: Tue, 6 Jan 2009 16:32:42 +0000 Subject: [PATCH 03/26] [fixed-to-float.sh] COGL_FIXED_FROM_INT wasn't casting to a float It's necissary to replace COGL_FIXED_FROM_INT with a (float) cast otherwise the replacement maths may end up with integer rounding errors. This was causing text to not be displayed due to the texture coordinate calculation always rounding to (0,0) --- fixed-to-float.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fixed-to-float.sh b/fixed-to-float.sh index a38f3363c..61088b23b 100755 --- a/fixed-to-float.sh +++ b/fixed-to-float.sh @@ -34,7 +34,7 @@ sed -i 's/#define DET2X(a,b,c,d).*/#define DET2X(a,b,c,d) ((a * d) - (b * c))/ #we get some redundant brackets like this, but C's automatic type promotion #works out fine for most cases... find ./clutter -iname '*.[ch]' -exec sed -i 's/COGL_FIXED_TO_INT//g' {} \; -find ./clutter -iname '*.[ch]' -exec sed -i 's/COGL_FIXED_FROM_INT//g' {} \; +find ./clutter -iname '*.[ch]' -exec sed -i 's/COGL_FIXED_FROM_INT /(float)/g' {} \; find ./clutter -iname '*.[ch]' -exec sed -i 's/COGL_FIXED_TO_FLOAT//g' {} \; find ./clutter -iname '*.[ch]' -exec sed -i 's/COGL_FIXED_FROM_FLOAT//g' {} \; find ./clutter -iname '*.[ch]' -exec sed -i 's/COGL_FIXED_TO_DOUBLE /(double)/g' {} \; From 65e7bc636394f12e6f11cc6c5ba0c113c3a11bc1 Mon Sep 17 00:00:00 2001 From: Robert Bragg Date: Wed, 7 Jan 2009 15:33:24 +0000 Subject: [PATCH 04/26] Replaces uses of CoglAngle with floats (Though the CoglAngle type remains) The CoglAngle type can still be used for focused optimisations since the type and macros remain. Uses of CoglAngle within Cogl have been replaced with floats; COGL_ANGLE_FROM_DEG is no longer used anywhere and the replacements for cogl_angle_cos -> cosf (same for sin) have been fixed to convert float values in degrees to radians. This fixes the cogl-primitives API. --- fixed-to-float.sh | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/fixed-to-float.sh b/fixed-to-float.sh index 61088b23b..49cc14594 100755 --- a/fixed-to-float.sh +++ b/fixed-to-float.sh @@ -51,9 +51,11 @@ find ./clutter -iname '*.[ch]' -exec sed -i 's/COGL_FIXED_1/1.0/g' {} \; find ./clutter -iname '*.[ch]' -exec sed -i 's/COGL_FIXED_0_5/0.5/g' {} \; find ./clutter -iname '*.[ch]' -exec sed -i 's/COGL_FIXED_PI/G_PI/g' {} \; -find ./clutter -iname '*.[ch]' -exec sed -i 's/cogl_angle_cos/cosf/g' {} \; -find ./clutter -iname '*.[ch]' -exec sed -i 's/cogl_angle_sin/sinf/g' {} \; -find ./clutter -iname '*.[ch]' -exec sed -i 's/cogl_angle_tan/tanf/g' {} \; +find ./clutter -iname '*.[ch]' -exec sed -i -r 's/COGL_ANGLE_FROM_DEG \((.*)\),/\1,/g' {} \; + +find ./clutter -iname '*.[ch]' -exec perl -p -i -e "s|cogl_angle_cos \((.*?)\)|cosf (\1 * (G_PI/180.0))|;" {} \; +find ./clutter -iname '*.[ch]' -exec perl -p -i -e "s|cogl_angle_sin \((.*?)\)|sinf (\1 * (G_PI/180.0))|;" {} \; +find ./clutter -iname '*.[ch]' -exec perl -p -i -e "s|cogl_angle_tan \((.*?)\)|tanf (\1 * (G_PI/180.0))|;" {} \; #XXX: NB: cogl_fixed_div must be done before mul since there is a case were they #are nested which would otherwise break the assumption used here that the last @@ -104,6 +106,15 @@ sed -i 's/float:/CoglFixed:/g' clutter/cogl/cogl-types.h sed -i 's/gint32 float/gint32 CoglFixed/g' clutter/cogl/cogl-types.h git-checkout clutter/cogl/cogl-fixed.h clutter/cogl/common/cogl-fixed.c +find ./clutter -iname '*.[ch]' -exec sed -i 's/CoglAngle/float/g' {} \; + +# maintain the existing CoglAngle code as utility code for applications: +sed -i 's/float:/CoglAngle:/g' clutter/cogl/cogl-types.h +sed -i 's/gint32 float/gint32 CoglAngle/g' clutter/cogl/cogl-types.h +git-checkout clutter/cogl/cogl-fixed.h clutter/cogl/common/cogl-fixed.c + +find ./clutter -iname '*.[ch]' ! -iname 'clutter-fixed.h' -exec sed -i 's/ClutterAngle/float/g' {} \; + echo "Cogl API to remove/replace with float versions:" find ./clutter/ -iname '*.c' -exec grep '^cogl_[a-zA-Z_]*x ' {} \; | cut -d' ' -f1|grep -v 'box$'|grep -v 'matrix$' echo "Clutter API to remove/replace with float versions:" From 0ffb6f7aa5de917e474df305c64e84581cf31fc1 Mon Sep 17 00:00:00 2001 From: Robert Bragg Date: Wed, 7 Jan 2009 16:22:45 +0000 Subject: [PATCH 05/26] [clutter-alpha.c.0.patch] replace ClutterAngle with float This is just an update of the patch to reflect that fixed-to-float.sh now replaces ClutterAngle usage with float. --- .../clutter-alpha.c.0.patch | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/fixed-to-float-patches/clutter-alpha.c.0.patch b/fixed-to-float-patches/clutter-alpha.c.0.patch index 457be3007..e55dd7d34 100644 --- a/fixed-to-float-patches/clutter-alpha.c.0.patch +++ b/fixed-to-float-patches/clutter-alpha.c.0.patch @@ -18,7 +18,7 @@ index 3e4df4d..d508631 100644 x -= (512 * 512 / angle); -- sine = ((sinf (x) + offset) / 2) +- sine = ((sinf (x * (G_PI/180.0)) + offset) / 2) + sine = ((cogl_angle_sin (x) + offset) / 2) * CLUTTER_ALPHA_MAX_ALPHA; @@ -79,7 +79,7 @@ index 3e4df4d..d508631 100644 ClutterTimeline * timeline; gint frame; gint n_frames; -- ClutterAngle x; +- float x; - ClutterFixed sine; + float radians; + float sine; @@ -92,7 +92,7 @@ index 3e4df4d..d508631 100644 + radians = ((float)frame / n_frames) * (G_PI / 2); + sine = sinf (radians); -- sine = sinf (x) * CLUTTER_ALPHA_MAX_ALPHA; +- sine = sinf (x * (G_PI/180.0)) * CLUTTER_ALPHA_MAX_ALPHA; - - return ((guint32) sine) >> COGL_FIXED_Q; + return (guint32) (sine * CLUTTER_ALPHA_MAX_ALPHA); @@ -103,7 +103,7 @@ index 3e4df4d..d508631 100644 ClutterTimeline * timeline; gint frame; gint n_frames; -- ClutterAngle x; +- float x; - ClutterFixed sine; + float radians; + float sine; @@ -114,7 +114,7 @@ index 3e4df4d..d508631 100644 - x = 256 * frame / n_frames + 256; - -- sine = sinf (x) * CLUTTER_ALPHA_MAX_ALPHA; +- sine = sinf (x * (G_PI/180.0)) * CLUTTER_ALPHA_MAX_ALPHA; + radians = ((float)frame / n_frames) * (G_PI / 2); + sine = sinf (radians + (G_PI / 2)); @@ -127,7 +127,7 @@ index 3e4df4d..d508631 100644 ClutterTimeline *timeline; gint frame; gint n_frames; -- ClutterAngle x; +- float x; - ClutterFixed sine; + float radians; + float sine; @@ -138,7 +138,7 @@ index 3e4df4d..d508631 100644 - x = 512 * frame / n_frames; - -- sine = sinf (x) * CLUTTER_ALPHA_MAX_ALPHA; +- sine = sinf (x * (G_PI/180.0)) * CLUTTER_ALPHA_MAX_ALPHA; + radians = ((float)frame / n_frames) * G_PI; + sine = sinf (radians); @@ -151,7 +151,7 @@ index 3e4df4d..d508631 100644 ClutterTimeline *timeline; gint frame; gint n_frames; -- ClutterAngle x; +- float x; - ClutterFixed sine; + float radians; + float sine; @@ -165,7 +165,7 @@ index 3e4df4d..d508631 100644 + radians = ((float)frame / n_frames) * (G_PI / 2); + sine = sinf (radians - (G_PI / 2)); -- sine = (sinf (x) + 1) * CLUTTER_ALPHA_MAX_ALPHA; +- sine = (sinf (x * (G_PI/180.0)) + 1) * CLUTTER_ALPHA_MAX_ALPHA; + /* shift from range [-1, 0] -> [0, 1] */ + sine = sine + 1.0; @@ -178,7 +178,7 @@ index 3e4df4d..d508631 100644 ClutterTimeline *timeline; gint frame; gint n_frames; -- ClutterAngle x; +- float x; - ClutterFixed sine; + float radians; + float sine; @@ -191,7 +191,7 @@ index 3e4df4d..d508631 100644 + radians = ((float)frame / n_frames) * (G_PI / 2); + sine = sinf (radians); -- sine = sinf (x) * CLUTTER_ALPHA_MAX_ALPHA; +- sine = sinf (x * (G_PI/180.0)) * CLUTTER_ALPHA_MAX_ALPHA; - - return ((guint32) sine) >> COGL_FIXED_Q; + return (guint32) (sine * CLUTTER_ALPHA_MAX_ALPHA); @@ -202,7 +202,7 @@ index 3e4df4d..d508631 100644 ClutterTimeline *timeline; gint frame; gint n_frames; -- ClutterAngle x; +- float x; - ClutterFixed sine; + float radians; + float sine; @@ -215,7 +215,7 @@ index 3e4df4d..d508631 100644 + radians = ((float)frame / n_frames) * G_PI; + sine = sinf (radians - (G_PI / 2)); -- sine = (sinf (x) + 1) / 2 * CLUTTER_ALPHA_MAX_ALPHA; +- sine = (sinf (x * (G_PI/180.0)) + 1) / 2 * CLUTTER_ALPHA_MAX_ALPHA; + /* shift from range [-1, 1] -> [0, 1] */ + sine = (sine + 1.0) / 2.0; From c1866858dd43c550f95da0840b9fb4225c12f3cc Mon Sep 17 00:00:00 2001 From: Robert Bragg Date: Wed, 7 Jan 2009 19:39:31 +0000 Subject: [PATCH 06/26] fixes for clutter-behaviour-ellipse.c.0.patch --- .../clutter-behaviour-ellipse.c.0.patch | 107 ++++-------------- 1 file changed, 21 insertions(+), 86 deletions(-) diff --git a/fixed-to-float-patches/clutter-behaviour-ellipse.c.0.patch b/fixed-to-float-patches/clutter-behaviour-ellipse.c.0.patch index a3a42dd76..9aee3c39a 100644 --- a/fixed-to-float-patches/clutter-behaviour-ellipse.c.0.patch +++ b/fixed-to-float-patches/clutter-behaviour-ellipse.c.0.patch @@ -1,48 +1,13 @@ diff --git a/clutter/clutter-behaviour-ellipse.c b/clutter/clutter-behaviour-ellipse.c -index b9f493b..5524032 100644 +index 162a949..4212b95 100644 --- a/clutter/clutter-behaviour-ellipse.c +++ b/clutter/clutter-behaviour-ellipse.c -@@ -86,11 +86,11 @@ struct _ClutterBehaviourEllipsePrivate - gint a; - gint b; - -- ClutterAngle angle_start; -- ClutterAngle angle_end; -- ClutterAngle angle_tilt_x; -- ClutterAngle angle_tilt_y; -- ClutterAngle angle_tilt_z; -+ float angle_start; -+ float angle_end; -+ float angle_tilt_x; -+ float angle_tilt_y; -+ float angle_tilt_z; - - ClutterRotateDirection direction; - }; -@@ -104,7 +104,7 @@ typedef struct _knot3d - - static void - clutter_behaviour_ellipse_advance (ClutterBehaviourEllipse *e, -- ClutterAngle angle, -+ float angle, - knot3d *knot) +@@ -190,17 +190,13 @@ actor_apply_knot_foreach (ClutterBehaviour *behave, + static inline float + clamp_angle (float a) { - ClutterBehaviourEllipsePrivate *priv = e->priv; -@@ -187,20 +187,16 @@ actor_apply_knot_foreach (ClutterBehaviour *behave, - clutter_actor_set_depth (actor, knot->z); - } - --static inline ClutterAngle --clamp_angle (ClutterAngle a) -+static float -+clamp_angle (float a) - { -- ClutterAngle a1, a2; +- float a1, a2; gint rounds; -+ -+ rounds = a / 360; -+ if (a < 0) -+ rounds--; - /* Need to add the 256 offset here, since the user space 0 maps to our - * -256 @@ -50,21 +15,15 @@ index b9f493b..5524032 100644 - rounds = (a + 256) / 1024; - a1 = rounds * 1024; - a2 = a - a1; -- ++ rounds = a / 360; ++ if (a < 0) ++ rounds--; + - return a2; + return a - 360 * rounds; } static void -@@ -209,7 +205,7 @@ clutter_behaviour_ellipse_alpha_notify (ClutterBehaviour *behave, - { - ClutterBehaviourEllipse *self = CLUTTER_BEHAVIOUR_ELLIPSE (behave); - ClutterBehaviourEllipsePrivate *priv = self->priv; -- ClutterAngle start, end; -+ float start, end; - knot3d knot; - ClutterAngle angle = 0; - @@ -218,11 +214,11 @@ clutter_behaviour_ellipse_alpha_notify (ClutterBehaviour *behave, if (priv->direction == CLUTTER_ROTATE_CW && start >= end) @@ -237,12 +196,8 @@ index b9f493b..5524032 100644 } /** -@@ -802,10 +785,10 @@ clutter_behaviour_ellipse_set_angle_startx (ClutterBehaviourEllipse *self, - ClutterFixed angle_start) - { - ClutterBehaviourEllipsePrivate *priv; -- ClutterAngle new_angle; -+ float new_angle; +@@ -805,7 +788,7 @@ clutter_behaviour_ellipse_set_angle_startx (ClutterBehaviourEllipse *self, + float new_angle; g_return_if_fail (CLUTTER_IS_BEHAVIOUR_ELLIPSE (self)); - new_angle = clamp_angle (COGL_ANGLE_FROM_DEGX (angle_start) - 256); @@ -282,12 +237,7 @@ index b9f493b..5524032 100644 } /** -@@ -887,11 +871,11 @@ clutter_behaviour_ellipse_set_angle_endx (ClutterBehaviourEllipse *self, - ClutterFixed angle_end) - { - ClutterBehaviourEllipsePrivate *priv; -- ClutterAngle new_angle; -+ float new_angle; +@@ -891,7 +875,7 @@ clutter_behaviour_ellipse_set_angle_endx (ClutterBehaviourEllipse *self, g_return_if_fail (CLUTTER_IS_BEHAVIOUR_ELLIPSE (self)); @@ -329,12 +279,7 @@ index b9f493b..5524032 100644 } /** -@@ -979,11 +963,11 @@ clutter_behaviour_ellipse_set_angle_tiltx (ClutterBehaviourEllipse *self, - ClutterFixed angle_tilt) - { - ClutterBehaviourEllipsePrivate *priv; -- ClutterAngle new_angle; -+ float new_angle; +@@ -983,7 +967,7 @@ clutter_behaviour_ellipse_set_angle_tiltx (ClutterBehaviourEllipse *self, g_return_if_fail (CLUTTER_IS_BEHAVIOUR_ELLIPSE (self)); @@ -373,39 +318,29 @@ index b9f493b..5524032 100644 } return 0; -@@ -1096,13 +1080,13 @@ clutter_behaviour_ellipse_set_tilt (ClutterBehaviourEllipse *self, - gdouble angle_tilt_z) - { - ClutterBehaviourEllipsePrivate *priv; -- ClutterAngle new_angle_x, new_angle_y, new_angle_z; -+ float new_angle_x, new_angle_y, new_angle_z; +@@ -1100,9 +1084,9 @@ clutter_behaviour_ellipse_set_tilt (ClutterBehaviourEllipse *self, g_return_if_fail (CLUTTER_IS_BEHAVIOUR_ELLIPSE (self)); - new_angle_x = COGL_ANGLE_FROM_DEG (angle_tilt_x); - new_angle_y = COGL_ANGLE_FROM_DEG (angle_tilt_y); - new_angle_z = COGL_ANGLE_FROM_DEG (angle_tilt_z); -+ new_angle_x = angle_tilt_x; -+ new_angle_y = angle_tilt_y; -+ new_angle_z = angle_tilt_z; ++ new_angle_x = (float)angle_tilt_x; ++ new_angle_y = (float)angle_tilt_y; ++ new_angle_z = (float)angle_tilt_z; priv = self->priv; -@@ -1150,13 +1134,13 @@ clutter_behaviour_ellipse_set_tiltx (ClutterBehaviourEllipse *self, - ClutterFixed angle_tilt_z) - { - ClutterBehaviourEllipsePrivate *priv; -- ClutterAngle new_angle_x, new_angle_y, new_angle_z; -+ float new_angle_x, new_angle_y, new_angle_z; +@@ -1154,9 +1138,9 @@ clutter_behaviour_ellipse_set_tiltx (ClutterBehaviourEllipse *self, g_return_if_fail (CLUTTER_IS_BEHAVIOUR_ELLIPSE (self)); - new_angle_x = COGL_ANGLE_FROM_DEGX (angle_tilt_x); - new_angle_y = COGL_ANGLE_FROM_DEGX (angle_tilt_y); - new_angle_z = COGL_ANGLE_FROM_DEGX (angle_tilt_z); -+ new_angle_x = angle_tilt_x; -+ new_angle_y = angle_tilt_y; -+ new_angle_z = angle_tilt_z; ++ new_angle_x = CLUTTER_FIXED_TO_FLOAT (angle_tilt_x); ++ new_angle_y = CLUTTER_FIXED_TO_FLOAT (angle_tilt_y); ++ new_angle_z = CLUTTER_FIXED_TO_FLOAT (angle_tilt_z); priv = self->priv; From 012b169a731fb278ac8f55122ebf572c6cca4a70 Mon Sep 17 00:00:00 2001 From: Robert Bragg Date: Thu, 8 Jan 2009 13:10:32 +0000 Subject: [PATCH 07/26] [fixed-to-float-patches] Updates the patches in line with the last merge Most of the patches updated weren't failing but there were a number of hunk offsets when applying so it tidies that up. The change in mtx_transform.0.patch has been moved to clutter-actor.c.0.patch. --- .../clutter-actor.c.0.patch | 19 +++-- .../clutter-alpha.c.0.patch | 82 +++++++++++++------ fixed-to-float-patches/clutter-path.c.0.patch | 4 +- .../clutter-texture.c.0.patch | 10 +-- .../cogl-pango-render.c.0.patch | 10 +-- fixed-to-float-patches/mtx_transform.0.patch | 19 ----- 6 files changed, 85 insertions(+), 59 deletions(-) delete mode 100644 fixed-to-float-patches/mtx_transform.0.patch diff --git a/fixed-to-float-patches/clutter-actor.c.0.patch b/fixed-to-float-patches/clutter-actor.c.0.patch index c1d76a4b3..91fcd853b 100644 --- a/fixed-to-float-patches/clutter-actor.c.0.patch +++ b/fixed-to-float-patches/clutter-actor.c.0.patch @@ -1,8 +1,17 @@ diff --git a/clutter/clutter-actor.c b/clutter/clutter-actor.c -index ac9a2f6..42da2a5 100644 +index 8db8206..f4cec66 100644 --- a/clutter/clutter-actor.c +++ b/clutter/clutter-actor.c -@@ -866,8 +866,11 @@ clutter_actor_transform_point (ClutterActor *actor, +@@ -806,7 +806,7 @@ static inline void + mtx_transform (const ClutterFixed m[], + fixed_vertex_t *vertex) + { +- ClutterFixed _x, _y, _z, _w; ++ float _x, _y, _z, _w; + + _x = vertex->x; + _y = vertex->y; +@@ -846,8 +846,11 @@ mtx_transform (const ClutterFixed m[], /* Help macros to scale from OpenGL <-1,1> coordinates system to our * X-window based <0,window-size> coordinates */ @@ -15,8 +24,8 @@ index ac9a2f6..42da2a5 100644 + (v1)) + (v2)) #define MTX_GL_SCALE_Z(z,w,v1,v2) (MTX_GL_SCALE_X ((z), (w), (v1), (v2))) - /** -@@ -3213,8 +3214,8 @@ clutter_actor_get_preferred_width (ClutterActor *self, + /* transforms a 4-tuple of coordinates using @matrix and +@@ -3244,8 +3247,8 @@ clutter_actor_get_preferred_width (ClutterActor *self, if (natural_width < min_width) { @@ -27,7 +36,7 @@ index ac9a2f6..42da2a5 100644 G_OBJECT_TYPE_NAME (self), natural_width, CLUTTER_UNITS_TO_DEVICE (natural_width), min_width, CLUTTER_UNITS_TO_DEVICE (min_width)); -@@ -3283,8 +3284,8 @@ clutter_actor_get_preferred_height (ClutterActor *self, +@@ -3314,8 +3317,8 @@ clutter_actor_get_preferred_height (ClutterActor *self, if (natural_height < min_height) { diff --git a/fixed-to-float-patches/clutter-alpha.c.0.patch b/fixed-to-float-patches/clutter-alpha.c.0.patch index e55dd7d34..faf790c8d 100644 --- a/fixed-to-float-patches/clutter-alpha.c.0.patch +++ b/fixed-to-float-patches/clutter-alpha.c.0.patch @@ -1,8 +1,8 @@ diff --git a/clutter/clutter-alpha.c b/clutter/clutter-alpha.c -index 3e4df4d..d508631 100644 +index 60ef0d3..dda0f6c 100644 --- a/clutter/clutter-alpha.c +++ b/clutter/clutter-alpha.c -@@ -694,6 +694,11 @@ clutter_ramp_func (ClutterAlpha *alpha, +@@ -697,6 +697,11 @@ clutter_ramp_func (ClutterAlpha *alpha, } } @@ -13,8 +13,8 @@ index 3e4df4d..d508631 100644 + */ static guint32 sincx1024_func (ClutterAlpha *alpha, - ClutterAngle angle, -@@ -713,7 +718,7 @@ sincx1024_func (ClutterAlpha *alpha, + float angle, +@@ -716,7 +721,7 @@ sincx1024_func (ClutterAlpha *alpha, x -= (512 * 512 / angle); @@ -23,7 +23,7 @@ index 3e4df4d..d508631 100644 * CLUTTER_ALPHA_MAX_ALPHA; sine = sine >> COGL_FIXED_Q; -@@ -721,11 +726,6 @@ sincx1024_func (ClutterAlpha *alpha, +@@ -724,11 +729,6 @@ sincx1024_func (ClutterAlpha *alpha, return sine; } @@ -35,7 +35,7 @@ index 3e4df4d..d508631 100644 static guint32 sincx_func (ClutterAlpha *alpha, ClutterFixed angle, -@@ -744,7 +744,7 @@ sincx_func (ClutterAlpha *alpha, +@@ -747,7 +747,7 @@ sincx_func (ClutterAlpha *alpha, x = CLUTTER_FIXED_MUL (x, CFX_PI) - CLUTTER_FIXED_DIV (CFX_PI, angle); @@ -44,7 +44,7 @@ index 3e4df4d..d508631 100644 CLUTTER_NOTE (ALPHA, "sine: %2f\n", CLUTTER_FIXED_TO_DOUBLE (sine)); -@@ -803,9 +803,28 @@ guint32 +@@ -806,9 +806,28 @@ guint32 clutter_sine_func (ClutterAlpha *alpha, gpointer dummy) { @@ -75,7 +75,7 @@ index 3e4df4d..d508631 100644 /* 2.0 above represents full circle */ return sincx1024_func (alpha, 1024, 1.0); #endif -@@ -839,18 +858,17 @@ clutter_sine_inc_func (ClutterAlpha *alpha, +@@ -842,18 +861,17 @@ clutter_sine_inc_func (ClutterAlpha *alpha, ClutterTimeline * timeline; gint frame; gint n_frames; @@ -89,17 +89,17 @@ index 3e4df4d..d508631 100644 n_frames = clutter_timeline_get_n_frames (timeline); - x = 256 * frame / n_frames; +- +- sine = sinf (x * (G_PI/180.0)) * CLUTTER_ALPHA_MAX_ALPHA; + radians = ((float)frame / n_frames) * (G_PI / 2); + sine = sinf (radians); -- sine = sinf (x * (G_PI/180.0)) * CLUTTER_ALPHA_MAX_ALPHA; -- - return ((guint32) sine) >> COGL_FIXED_Q; + return (guint32) (sine * CLUTTER_ALPHA_MAX_ALPHA); } /** -@@ -881,18 +899,17 @@ clutter_sine_dec_func (ClutterAlpha *alpha, +@@ -884,18 +902,17 @@ clutter_sine_dec_func (ClutterAlpha *alpha, ClutterTimeline * timeline; gint frame; gint n_frames; @@ -123,7 +123,7 @@ index 3e4df4d..d508631 100644 } /** -@@ -923,18 +940,17 @@ clutter_sine_half_func (ClutterAlpha *alpha, +@@ -926,18 +943,17 @@ clutter_sine_half_func (ClutterAlpha *alpha, ClutterTimeline *timeline; gint frame; gint n_frames; @@ -137,17 +137,17 @@ index 3e4df4d..d508631 100644 n_frames = clutter_timeline_get_n_frames (timeline); - x = 512 * frame / n_frames; -- -- sine = sinf (x * (G_PI/180.0)) * CLUTTER_ALPHA_MAX_ALPHA; + radians = ((float)frame / n_frames) * G_PI; + sine = sinf (radians); +- sine = sinf (x * (G_PI/180.0)) * CLUTTER_ALPHA_MAX_ALPHA; +- - return ((guint32) sine) >> COGL_FIXED_Q; + return (guint32) (sine * CLUTTER_ALPHA_MAX_ALPHA); } /** -@@ -959,19 +975,20 @@ clutter_sine_in_func (ClutterAlpha *alpha, +@@ -962,19 +978,20 @@ clutter_sine_in_func (ClutterAlpha *alpha, ClutterTimeline *timeline; gint frame; gint n_frames; @@ -174,7 +174,7 @@ index 3e4df4d..d508631 100644 } /** -@@ -995,18 +1012,17 @@ clutter_sine_out_func (ClutterAlpha *alpha, +@@ -998,18 +1015,17 @@ clutter_sine_out_func (ClutterAlpha *alpha, ClutterTimeline *timeline; gint frame; gint n_frames; @@ -188,17 +188,17 @@ index 3e4df4d..d508631 100644 n_frames = clutter_timeline_get_n_frames (timeline); - x = 256 * frame / n_frames; +- +- sine = sinf (x * (G_PI/180.0)) * CLUTTER_ALPHA_MAX_ALPHA; + radians = ((float)frame / n_frames) * (G_PI / 2); + sine = sinf (radians); -- sine = sinf (x * (G_PI/180.0)) * CLUTTER_ALPHA_MAX_ALPHA; -- - return ((guint32) sine) >> COGL_FIXED_Q; + return (guint32) (sine * CLUTTER_ALPHA_MAX_ALPHA); } /** -@@ -1031,18 +1047,20 @@ clutter_sine_in_out_func (ClutterAlpha *alpha, +@@ -1034,18 +1050,20 @@ clutter_sine_in_out_func (ClutterAlpha *alpha, ClutterTimeline *timeline; gint frame; gint n_frames; @@ -224,7 +224,43 @@ index 3e4df4d..d508631 100644 } /** -@@ -1201,9 +1219,9 @@ clutter_exp_inc_func (ClutterAlpha *alpha, +@@ -1113,30 +1131,23 @@ clutter_smoothstep_inc_func (ClutterAlpha *alpha, + ClutterTimeline *timeline; + gint frame; + gint n_frames; +- guint32 r; +- guint32 x; ++ float r; ++ float x; + + /* + * The smoothstep function uses f(x) = -2x^3 + 3x^2 where x is from <0,1>, +- * and precission is critical -- we use 8.24 fixed format for this operation. +- * The earlier operations involve division, which we cannot do in 8.24 for +- * numbers in <0,1> we use ClutterFixed. ++ * and precission is critical. + */ + timeline = clutter_alpha_get_timeline (alpha); + frame = clutter_timeline_get_current_frame (timeline); + n_frames = clutter_timeline_get_n_frames (timeline); + +- /* +- * Convert x to 8.24 for next step. +- */ +- x = CLUTTER_FIXED_DIV (frame, n_frames) << 8; ++ x = (float)frame / n_frames; + + /* + * f(x) = -2x^3 + 3x^2 +- * +- * Convert result to ClutterFixed to avoid overflow in next step. + */ +- r = ((x >> 12) * (x >> 12) * 3 - (x >> 15) * (x >> 16) * (x >> 16)) >> 8; ++ r = -2 * x * x * x + 3 * x * x; + + return (r * CLUTTER_ALPHA_MAX_ALPHA); + } +@@ -1204,9 +1215,9 @@ clutter_exp_inc_func (ClutterAlpha *alpha, * * (2^x_alpha_max) - 1 == CLUTTER_ALPHA_MAX_ALPHA */ @@ -237,7 +273,7 @@ index 3e4df4d..d508631 100644 timeline = clutter_alpha_get_timeline (alpha); frame = clutter_timeline_get_current_frame (timeline); -@@ -1211,7 +1229,7 @@ clutter_exp_inc_func (ClutterAlpha *alpha, +@@ -1214,7 +1225,7 @@ clutter_exp_inc_func (ClutterAlpha *alpha, x = x_alpha_max * frame / n_frames; @@ -246,7 +282,7 @@ index 3e4df4d..d508631 100644 return result; } -@@ -1252,9 +1270,9 @@ clutter_exp_dec_func (ClutterAlpha *alpha, +@@ -1255,9 +1266,9 @@ clutter_exp_dec_func (ClutterAlpha *alpha, * * (2^x_alpha_max) - 1 == CLUTTER_ALPHA_MAX_ALPHA */ @@ -259,7 +295,7 @@ index 3e4df4d..d508631 100644 timeline = clutter_alpha_get_timeline (alpha); frame = clutter_timeline_get_current_frame (timeline); -@@ -1262,7 +1280,7 @@ clutter_exp_dec_func (ClutterAlpha *alpha, +@@ -1265,7 +1276,7 @@ clutter_exp_dec_func (ClutterAlpha *alpha, x = (x_alpha_max * (n_frames - frame)) / n_frames; diff --git a/fixed-to-float-patches/clutter-path.c.0.patch b/fixed-to-float-patches/clutter-path.c.0.patch index 89a1901f2..b24618cd5 100644 --- a/fixed-to-float-patches/clutter-path.c.0.patch +++ b/fixed-to-float-patches/clutter-path.c.0.patch @@ -1,8 +1,8 @@ diff --git a/clutter/clutter-path.c b/clutter/clutter-path.c -index 973d861..d3eff11 100644 +index 6f93402..c459cdf 100644 --- a/clutter/clutter-path.c +++ b/clutter/clutter-path.c -@@ -1081,11 +1081,11 @@ clutter_path_node_distance (const ClutterKnot *start, +@@ -1217,11 +1217,11 @@ clutter_path_node_distance (const ClutterKnot *start, * If we are using limited precision sqrti implementation, fallback on * clib sqrt if the precission would be less than 10% */ diff --git a/fixed-to-float-patches/clutter-texture.c.0.patch b/fixed-to-float-patches/clutter-texture.c.0.patch index f511a0487..1340c0f24 100644 --- a/fixed-to-float-patches/clutter-texture.c.0.patch +++ b/fixed-to-float-patches/clutter-texture.c.0.patch @@ -1,13 +1,13 @@ diff --git a/clutter/clutter-texture.c b/clutter/clutter-texture.c -index fc5541b..0f1a77e 100644 +index 42be677..7273946 100644 --- a/clutter/clutter-texture.c +++ b/clutter/clutter-texture.c -@@ -457,7 +457,7 @@ clutter_texture_set_fbo_projection (ClutterActor *self) +@@ -463,7 +463,7 @@ clutter_texture_set_fbo_projection (ClutterActor *self) /* Set up a projection matrix so that the actor will be projected as if it was drawn at its original location */ -- tan_angle = clutter_tani (CLUTTER_ANGLE_FROM_DEGX (perspective.fovy / 2)); -+ tan_angle = clutter_tanx (perspective.fovy / 2); +- tan_angle = tanf (COGL_ANGLE_FROM_DEGX (perspective.fovy / 2 * (G_PI/180.0))); ++ tan_angle = tanf ((perspective.fovy / 2) * (G_PI/180.0)); near_size = CLUTTER_FIXED_MUL (perspective.z_near, tan_angle); - cogl_frustum (CLUTTER_FIXED_MUL (x_min, near_size), + cogl_frustum (CLUTTER_FIXED_MUL (tx_min, near_size), diff --git a/fixed-to-float-patches/cogl-pango-render.c.0.patch b/fixed-to-float-patches/cogl-pango-render.c.0.patch index 625a8c1ca..04fcc164e 100644 --- a/fixed-to-float-patches/cogl-pango-render.c.0.patch +++ b/fixed-to-float-patches/cogl-pango-render.c.0.patch @@ -1,17 +1,17 @@ diff --git a/clutter/pango/cogl-pango-render.c b/clutter/pango/cogl-pango-render.c -index 9d1da77..12dfe72 100644 +index d8f87fb..3e23309 100644 --- a/clutter/pango/cogl-pango-render.c +++ b/clutter/pango/cogl-pango-render.c -@@ -58,8 +58,6 @@ struct _CoglPangoRendererClass - PangoRendererClass class_instance; - }; +@@ -102,8 +102,6 @@ cogl_pango_renderer_draw_glyph (CoglPangoRenderer *priv, + *(p++) = cache_value->tx2; *(p++) = cache_value->ty2; + } -#define COGL_PANGO_UNIT_TO_FIXED(x) ((x) << (COGL_FIXED_Q - 10)) - static void cogl_pango_renderer_finalize (GObject *object); static void cogl_pango_renderer_draw_glyphs (PangoRenderer *renderer, PangoFont *font, -@@ -393,8 +391,8 @@ cogl_pango_renderer_get_device_units (PangoRenderer *renderer, +@@ -439,8 +437,8 @@ cogl_pango_renderer_get_device_units (PangoRenderer *renderer, } else { diff --git a/fixed-to-float-patches/mtx_transform.0.patch b/fixed-to-float-patches/mtx_transform.0.patch deleted file mode 100644 index 5c8359ff7..000000000 --- a/fixed-to-float-patches/mtx_transform.0.patch +++ /dev/null @@ -1,19 +0,0 @@ -diff --git a/clutter/clutter-actor.c b/clutter/clutter-actor.c -index cc56310..4c89c0f 100644 ---- a/clutter/clutter-actor.c -+++ b/clutter/clutter-actor.c -@@ -781,11 +781,10 @@ clutter_actor_real_allocate (ClutterActor *self, - - /* Transform point (x,y,z) by matrix */ - static void --mtx_transform (ClutterFixed m[16], -- ClutterFixed *x, ClutterFixed *y, ClutterFixed *z, -- ClutterFixed *w) -+mtx_transform (float m[16], -+ float *x, float *y, float *z, float *w) - { -- ClutterFixed _x, _y, _z, _w; -+ float _x, _y, _z, _w; - _x = *x; - _y = *y; - _z = *z; From ec403b280544497f4153b756ebb1beee52e0ecc8 Mon Sep 17 00:00:00 2001 From: Robert Bragg Date: Thu, 8 Jan 2009 22:00:56 +0000 Subject: [PATCH 08/26] converts clutter_{sin,cos,tan,atan}x angles to radians before calling math.h func These functions are defined to take an angle in degrees, so the angle needs converting before calling the corresponding {sin,cos,tan,atan}f() This fixes test-cogl-tex-tile. --- fixed-to-float-patches/clutter-fixed.h.0.patch | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fixed-to-float-patches/clutter-fixed.h.0.patch b/fixed-to-float-patches/clutter-fixed.h.0.patch index 0b4cc2f03..fc7bb5590 100644 --- a/fixed-to-float-patches/clutter-fixed.h.0.patch +++ b/fixed-to-float-patches/clutter-fixed.h.0.patch @@ -305,11 +305,11 @@ index 3ae0916..5d150da 100644 -#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) -+#define clutter_tanx(a) tanf (a) -+#define clutter_atanx(a) atanf (a) ++#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) ++#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 ()) From f658d8b5cffeb36e7d28fca3bb3e370cd712fdd5 Mon Sep 17 00:00:00 2001 From: Robert Bragg Date: Thu, 8 Jan 2009 22:38:33 +0000 Subject: [PATCH 09/26] [fixed-to-float.sh] Replace uses of COGL_FIXED_FROM_INT not followed by a space Previously the script assumed a space before the open bracket, so it missed a few cases in clutter/cogl/gles/cogl.c --- fixed-to-float.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/fixed-to-float.sh b/fixed-to-float.sh index 49cc14594..86dd0169d 100755 --- a/fixed-to-float.sh +++ b/fixed-to-float.sh @@ -35,6 +35,7 @@ sed -i 's/#define DET2X(a,b,c,d).*/#define DET2X(a,b,c,d) ((a * d) - (b * c))/ #works out fine for most cases... find ./clutter -iname '*.[ch]' -exec sed -i 's/COGL_FIXED_TO_INT//g' {} \; find ./clutter -iname '*.[ch]' -exec sed -i 's/COGL_FIXED_FROM_INT /(float)/g' {} \; +find ./clutter -iname '*.[ch]' -exec sed -i 's/COGL_FIXED_FROM_INT/(float)/g' {} \; find ./clutter -iname '*.[ch]' -exec sed -i 's/COGL_FIXED_TO_FLOAT//g' {} \; find ./clutter -iname '*.[ch]' -exec sed -i 's/COGL_FIXED_FROM_FLOAT//g' {} \; find ./clutter -iname '*.[ch]' -exec sed -i 's/COGL_FIXED_TO_DOUBLE /(double)/g' {} \; From de27da0e5be8a27a0743fd9b62e2da04ed91dc82 Mon Sep 17 00:00:00 2001 From: Robert Bragg Date: Thu, 8 Jan 2009 22:56:17 +0000 Subject: [PATCH 10/26] [cogl/gles] Fixes for building for GLES 1 using floats * This adds GLfixed -> GLfloat conversion * redefines cogl_wrap_glBlahx macros as glBlahf * Other misc fixes (mostly corresponding to cogl/gl equivalents) --- clutter/cogl/gles/cogl-gles2-wrapper.h | 24 ++++---- .../gles-cogl-gles2-wrapper.h.0.patch | 13 ++++ .../gles-cogl-primitives.c.0.patch | 12 ++++ .../gles-cogl-texture.c.0.patch | 30 ++++++++++ fixed-to-float-patches/gles-cogl.c.0.patch | 60 +++++++++++++++++++ fixed-to-float.sh | 6 ++ 6 files changed, 133 insertions(+), 12 deletions(-) create mode 100644 fixed-to-float-patches/gles-cogl-gles2-wrapper.h.0.patch create mode 100644 fixed-to-float-patches/gles-cogl-primitives.c.0.patch create mode 100644 fixed-to-float-patches/gles-cogl-texture.c.0.patch create mode 100644 fixed-to-float-patches/gles-cogl.c.0.patch diff --git a/clutter/cogl/gles/cogl-gles2-wrapper.h b/clutter/cogl/gles/cogl-gles2-wrapper.h index ddf181e92..514b89cc4 100644 --- a/clutter/cogl/gles/cogl-gles2-wrapper.h +++ b/clutter/cogl/gles/cogl-gles2-wrapper.h @@ -272,34 +272,34 @@ void _cogl_gles2_clear_cache_for_program (CoglHandle program); /* If we're not using GL ES 2 then just use the GL functions directly */ -#define cogl_wrap_glClearColorx glClearColorx +#define cogl_wrap_glClearColorx glClearColor #define cogl_wrap_glDrawArrays glDrawArrays #define cogl_wrap_glPushMatrix glPushMatrix #define cogl_wrap_glPopMatrix glPopMatrix #define cogl_wrap_glMatrixMode glMatrixMode #define cogl_wrap_glLoadIdentity glLoadIdentity -#define cogl_wrap_glMultMatrixx glMultMatrixx -#define cogl_wrap_glFrustumx glFrustumx -#define cogl_wrap_glScalex glScalex -#define cogl_wrap_glTranslatex glTranslatex -#define cogl_wrap_glRotatex glRotatex -#define cogl_wrap_glOrthox glOrthox +#define cogl_wrap_glMultMatrixx glMultMatrixf +#define cogl_wrap_glFrustumx glFrustumf +#define cogl_wrap_glScalex glScalef +#define cogl_wrap_glTranslatex glTranslatef +#define cogl_wrap_glRotatex glRotatef +#define cogl_wrap_glOrthox glOrthof #define cogl_wrap_glEnable glEnable #define cogl_wrap_glDisable glDisable #define cogl_wrap_glTexCoordPointer glTexCoordPointer #define cogl_wrap_glVertexPointer glVertexPointer #define cogl_wrap_glColorPointer glColorPointer #define cogl_wrap_glNormalPointer glNormalPointer -#define cogl_wrap_glTexEnvx glTexEnvx +#define cogl_wrap_glTexEnvx glTexEnvf #define cogl_wrap_glEnableClientState glEnableClientState #define cogl_wrap_glDisableClientState glDisableClientState #define cogl_wrap_glAlphaFunc glAlphaFunc -#define cogl_wrap_glColor4x glColor4x -#define cogl_wrap_glClipPlanex glClipPlanex +#define cogl_wrap_glColor4x glColor4f +#define cogl_wrap_glClipPlanex glClipPlanef #define cogl_wrap_glGetIntegerv glGetIntegerv #define cogl_wrap_glGetFixedv glGetFixedv -#define cogl_wrap_glFogx glFogx -#define cogl_wrap_glFogxv glFogxv +#define cogl_wrap_glFogx glFogf +#define cogl_wrap_glFogxv glFogfv #define cogl_wrap_glTexParameteri glTexParameteri /* The extra third parameter of the bind texture wrapper isn't needed diff --git a/fixed-to-float-patches/gles-cogl-gles2-wrapper.h.0.patch b/fixed-to-float-patches/gles-cogl-gles2-wrapper.h.0.patch new file mode 100644 index 000000000..03deb1638 --- /dev/null +++ b/fixed-to-float-patches/gles-cogl-gles2-wrapper.h.0.patch @@ -0,0 +1,13 @@ +diff --git a/clutter/cogl/gles/cogl-gles2-wrapper.h b/clutter/cogl/gles/cogl-gles2-wrapper.h +index 265da78..2e61121 100644 +--- a/clutter/cogl/gles/cogl-gles2-wrapper.h ++++ b/clutter/cogl/gles/cogl-gles2-wrapper.h +@@ -297,7 +297,7 @@ void _cogl_gles2_clear_cache_for_program (CoglHandle program); + #define cogl_wrap_glColor4x glColor4f + #define cogl_wrap_glClipPlanex glClipPlanef + #define cogl_wrap_glGetIntegerv glGetIntegerv +-#define cogl_wrap_glGetFixedv glGetFixedv ++#define cogl_wrap_glGetFixedv glGetFloatv + #define cogl_wrap_glFogx glFogf + #define cogl_wrap_glFogxv glFogfv + #define cogl_wrap_glTexParameteri glTexParameteri diff --git a/fixed-to-float-patches/gles-cogl-primitives.c.0.patch b/fixed-to-float-patches/gles-cogl-primitives.c.0.patch new file mode 100644 index 000000000..d6b35ebaa --- /dev/null +++ b/fixed-to-float-patches/gles-cogl-primitives.c.0.patch @@ -0,0 +1,12 @@ +diff --git a/clutter/cogl/gles/cogl-primitives.c b/clutter/cogl/gles/cogl-primitives.c +index 901fa5d..d8fe121 100644 +--- a/clutter/cogl/gles/cogl-primitives.c ++++ b/clutter/cogl/gles/cogl-primitives.c +@@ -34,6 +34,7 @@ + + #include + #include ++#include + + #define _COGL_MAX_BEZ_RECURSE_DEPTH 16 + diff --git a/fixed-to-float-patches/gles-cogl-texture.c.0.patch b/fixed-to-float-patches/gles-cogl-texture.c.0.patch new file mode 100644 index 000000000..d1d6b00f9 --- /dev/null +++ b/fixed-to-float-patches/gles-cogl-texture.c.0.patch @@ -0,0 +1,30 @@ +diff --git a/clutter/cogl/gles/cogl-texture.c b/clutter/cogl/gles/cogl-texture.c +index fb628b0..85bfc2b 100644 +--- a/clutter/cogl/gles/cogl-texture.c ++++ b/clutter/cogl/gles/cogl-texture.c +@@ -39,6 +39,7 @@ + + #include + #include ++#include + + #define glVertexPointer cogl_wrap_glVertexPointer + #define glTexCoordPointer cogl_wrap_glTexCoordPointer +@@ -767,7 +768,7 @@ _cogl_texture_upload_subregion_to_gl (CoglTexture *tex, + guint wx, wy; + + src = source_bmp->data +- + (src_y + (y_iter.intersect_start) ++ + (src_y + ((int)y_iter.intersect_start) + - dst_y) + * source_bmp->rowstride + + (src_x + x_span->start + x_span->size - x_span->waste +@@ -812,7 +813,7 @@ _cogl_texture_upload_subregion_to_gl (CoglTexture *tex, + guint copy_width; + + src = source_bmp->data +- + (src_x + (x_iter.intersect_start) ++ + (src_x + ((int)x_iter.intersect_start) + - dst_x) + * bpp + + (src_y + y_span->start + y_span->size - y_span->waste diff --git a/fixed-to-float-patches/gles-cogl.c.0.patch b/fixed-to-float-patches/gles-cogl.c.0.patch new file mode 100644 index 000000000..bf1daac0a --- /dev/null +++ b/fixed-to-float-patches/gles-cogl.c.0.patch @@ -0,0 +1,60 @@ +diff --git a/clutter/cogl/gles/cogl.c b/clutter/cogl/gles/cogl.c +index 422d8b6..16cf666 100644 +--- a/clutter/cogl/gles/cogl.c ++++ b/clutter/cogl/gles/cogl.c +@@ -37,6 +37,7 @@ + #include "cogl-context.h" + + #include "cogl-gles2-wrapper.h" ++#include + + /* GL error to string conversion */ + #if COGL_DEBUG +@@ -365,9 +366,8 @@ set_clip_plane (GLint plane_num, + + /* Calculate the angle between the axes and the line crossing the + two points */ +- angle = (atan2f (vertex_b[1] - vertex_a[1] * +- vertex_b[0] - vertex_a[0]), +- COGL_RADIANS_TO_DEGREES); ++ angle = atan2f (vertex_b[1] - vertex_a[1], ++ vertex_b[0] - vertex_a[0]) * (180.0/G_PI); + + GE( cogl_wrap_glPushMatrix () ); + /* Load the identity matrix and multiply by the reverse of the +@@ -558,15 +558,13 @@ cogl_perspective (float fovy, + * 2) When working with small numbers, we can are loosing significant + * precision + */ +- ymax = (zNear * +- (sinf (fovy_rad_half) / +- cosf (fovy_rad_half))); ++ ymax = (zNear * (sinf (fovy_rad_half) / cosf (fovy_rad_half))); + xmax = (ymax * aspect); + + x = (zNear / xmax); + y = (zNear / ymax); + c = (-(zFar + zNear) / ( zFar - zNear)); +- d = (-((2 * zFar * zNear)) / (zFar - zNear)); ++ d = (-(2 * zFar) * zNear) / (zFar - zNear); + + #define M(row,col) m[col*4+row] + M(0,0) = x; +@@ -671,13 +669,13 @@ cogl_setup_viewport (guint w, + if (fovy != 60.0) + { + float fovy_rad = (fovy * G_PI) / 180; +- +- z_camera = (sinf (fovy_rad) / +- cosf (fovy_rad)) >> 1; ++ ++ z_camera = (sinf (fovy_rad) / cosf (fovy_rad)) / 2; + } + + +- GE( cogl_wrap_glTranslatex (-1 << 15, -1 << 15, -z_camera) ); ++ ++ GE( cogl_wrap_glTranslatex (-0.5f, -0.5f, -z_camera) ); + + GE( cogl_wrap_glScalex ( 1.0 / width, + -1.0 / height, diff --git a/fixed-to-float.sh b/fixed-to-float.sh index 86dd0169d..4cd34f6a0 100755 --- a/fixed-to-float.sh +++ b/fixed-to-float.sh @@ -31,6 +31,8 @@ find ./clutter -iname '*.[ch]' -exec sed -i -r 's|COGL_FIXED_DIV (.*),|\1 /|g' { # A fix due to the assumptions used above sed -i 's/#define DET2X(a,b,c,d).*/#define DET2X(a,b,c,d) ((a * d) - (b * c))/g' ./clutter/clutter-actor.c +find ./clutter/cogl/gles -iname '*.[ch]' -exec sed -i 's/GLfixed/GLfloat/g' {} \; + #we get some redundant brackets like this, but C's automatic type promotion #works out fine for most cases... find ./clutter -iname '*.[ch]' -exec sed -i 's/COGL_FIXED_TO_INT//g' {} \; @@ -144,6 +146,10 @@ patch -p1 Date: Mon, 12 Jan 2009 17:07:55 +0000 Subject: [PATCH 11/26] [cogl.h.in.0.patch] Fixes the cogl_rotatex prototype to take float x,y,z params The cogl_rotatex was incorrectly defined to take gint x,y,z params as opposed to CoglFixed. This patch changes them directly to floats. --- fixed-to-float-patches/cogl.h.in.0.patch | 26 ++++++++++++++++++++++++ fixed-to-float.sh | 1 + 2 files changed, 27 insertions(+) create mode 100644 fixed-to-float-patches/cogl.h.in.0.patch diff --git a/fixed-to-float-patches/cogl.h.in.0.patch b/fixed-to-float-patches/cogl.h.in.0.patch new file mode 100644 index 000000000..75a9b0f21 --- /dev/null +++ b/fixed-to-float-patches/cogl.h.in.0.patch @@ -0,0 +1,26 @@ +diff --git a/clutter/cogl/cogl.h.in b/clutter/cogl/cogl.h.in +index cc26f88..f37d54d 100644 +--- a/clutter/cogl/cogl.h.in ++++ b/clutter/cogl/cogl.h.in +@@ -271,9 +271,9 @@ void cogl_translate (gint x, + * rotation. + */ + void cogl_rotatex (float angle, +- gint x, +- gint y, +- gint z); ++ float x, ++ float y, ++ float z); + + /** + * cogl_rotate: +@@ -442,7 +442,7 @@ void cogl_enable_backface_culling (gboolean setting); + * comparing with the value in @ref. The default function is CGL_ALWAYS the + * initial reference value is 1.0. + */ +-void cogl_alpha_func (COGLenum func, ++void cogl_alpha_func (COGLenum func, + float ref); + + /** diff --git a/fixed-to-float.sh b/fixed-to-float.sh index 4cd34f6a0..2c5efdcfb 100755 --- a/fixed-to-float.sh +++ b/fixed-to-float.sh @@ -150,6 +150,7 @@ patch -p1 Date: Mon, 12 Jan 2009 18:15:40 +0000 Subject: [PATCH 12/26] [gl/cogl.c] Updates the cogl_rotatex prototype to take float x,y,z params I missed this in my last commit; it just updates the prototype in gl/cogl.c in line with the change made in cogl.h.in --- fixed-to-float-patches/{gl-cogl.c => gl-cogl.c.0.patch} | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) rename fixed-to-float-patches/{gl-cogl.c => gl-cogl.c.0.patch} (91%) diff --git a/fixed-to-float-patches/gl-cogl.c b/fixed-to-float-patches/gl-cogl.c.0.patch similarity index 91% rename from fixed-to-float-patches/gl-cogl.c rename to fixed-to-float-patches/gl-cogl.c.0.patch index 6ec4ac153..898f94d48 100644 --- a/fixed-to-float-patches/gl-cogl.c +++ b/fixed-to-float-patches/gl-cogl.c.0.patch @@ -1,5 +1,5 @@ diff --git a/clutter/cogl/gl/cogl.c b/clutter/cogl/gl/cogl.c -index 7b61b63..dcded98 100644 +index 7b61b63..5100a08 100644 --- a/clutter/cogl/gl/cogl.c +++ b/clutter/cogl/gl/cogl.c @@ -211,17 +211,17 @@ cogl_pop_matrix (void) @@ -25,9 +25,12 @@ index 7b61b63..dcded98 100644 } void -@@ -233,10 +233,10 @@ cogl_translate (gint x, gint y, gint z) +@@ -231,12 +231,12 @@ cogl_translate (gint x, gint y, gint z) + } + void - cogl_rotatex (float angle, gint x, gint y, gint z) +-cogl_rotatex (float angle, gint x, gint y, gint z) ++cogl_rotatex (float angle, float x, float y, float z) { - glRotated ((double)(angle), - (double)(x), From 66afd41868a702555c917122a38dfd87db91cf7a Mon Sep 17 00:00:00 2001 From: Robert Bragg Date: Tue, 13 Jan 2009 11:38:55 +0000 Subject: [PATCH 13/26] Remove cogl_blahx Cogl interfaces that used to take CoglFixed parameters. Since they are no longer actually taking fixed point parameters the 'x' suffix is no longer appropriate. To maintain support for sub-pixel precision the corresponding interfaces that were taking integer parameters now get patched to take float parameters instead. --- ...move_cogl_apis_taking_fixed_params.0.patch | 569 ++++++++++++++++++ ...move_cogl_apis_taking_fixed_params.1.patch | 52 ++ fixed-to-float.sh | 8 +- 3 files changed, 628 insertions(+), 1 deletion(-) create mode 100644 fixed-to-float-patches/remove_cogl_apis_taking_fixed_params.0.patch create mode 100644 fixed-to-float-patches/remove_cogl_apis_taking_fixed_params.1.patch diff --git a/fixed-to-float-patches/remove_cogl_apis_taking_fixed_params.0.patch b/fixed-to-float-patches/remove_cogl_apis_taking_fixed_params.0.patch new file mode 100644 index 000000000..d51cd9eb1 --- /dev/null +++ b/fixed-to-float-patches/remove_cogl_apis_taking_fixed_params.0.patch @@ -0,0 +1,569 @@ +diff --git a/clutter/clutter-actor.c b/clutter/clutter-actor.c +index f4cec66..a8fc882 100644 +--- a/clutter/clutter-actor.c ++++ b/clutter/clutter-actor.c +@@ -1342,8 +1342,8 @@ _clutter_actor_apply_modelview_transform (ClutterActor *self) + gboolean is_stage = CLUTTER_IS_STAGE (self); + + if (!is_stage) +- cogl_translatex (CLUTTER_UNITS_TO_FIXED (priv->allocation.x1), +- CLUTTER_UNITS_TO_FIXED (priv->allocation.y1), ++ cogl_translate (CLUTTER_UNITS_TO_FLOAT (priv->allocation.x1), ++ CLUTTER_UNITS_TO_FLOAT (priv->allocation.y1), + 0); + + /* +@@ -1357,50 +1357,50 @@ _clutter_actor_apply_modelview_transform (ClutterActor *self) + + if (priv->rzang) + { +- cogl_translatex (CLUTTER_UNITS_TO_FIXED (priv->rzx), +- CLUTTER_UNITS_TO_FIXED (priv->rzy), ++ cogl_translate (CLUTTER_UNITS_TO_FLOAT (priv->rzx), ++ CLUTTER_UNITS_TO_FLOAT (priv->rzy), + 0); + +- cogl_rotatex (priv->rzang, 0, 0, 1.0); ++ cogl_rotate (priv->rzang, 0, 0, 1.0); + +- cogl_translatex (CLUTTER_UNITS_TO_FIXED (-priv->rzx), +- CLUTTER_UNITS_TO_FIXED (-priv->rzy), ++ cogl_translate (CLUTTER_UNITS_TO_FLOAT (-priv->rzx), ++ CLUTTER_UNITS_TO_FLOAT (-priv->rzy), + 0); + } + + if (priv->ryang) + { +- cogl_translatex (CLUTTER_UNITS_TO_FIXED (priv->ryx), ++ cogl_translate (CLUTTER_UNITS_TO_FLOAT (priv->ryx), + 0, +- CLUTTER_UNITS_TO_FIXED (priv->z + priv->ryz)); ++ CLUTTER_UNITS_TO_FLOAT (priv->z + priv->ryz)); + +- cogl_rotatex (priv->ryang, 0, 1.0, 0); ++ cogl_rotate (priv->ryang, 0, 1.0, 0); + +- cogl_translatex (CLUTTER_UNITS_TO_FIXED (-priv->ryx), ++ cogl_translate (CLUTTER_UNITS_TO_FLOAT (-priv->ryx), + 0, +- CLUTTER_UNITS_TO_FIXED (-(priv->z + priv->ryz))); ++ CLUTTER_UNITS_TO_FLOAT (-(priv->z + priv->ryz))); + } + + if (priv->rxang) + { +- cogl_translatex (0, +- CLUTTER_UNITS_TO_FIXED (priv->rxy), +- CLUTTER_UNITS_TO_FIXED (priv->z + priv->rxz)); ++ cogl_translate (0, ++ CLUTTER_UNITS_TO_FLOAT (priv->rxy), ++ CLUTTER_UNITS_TO_FLOAT (priv->z + priv->rxz)); + +- cogl_rotatex (priv->rxang, 1.0, 0, 0); ++ cogl_rotate (priv->rxang, 1.0, 0, 0); + +- cogl_translatex (0, +- CLUTTER_UNITS_TO_FIXED (-priv->rxy), +- CLUTTER_UNITS_TO_FIXED (-(priv->z + priv->rxz))); ++ cogl_translate (0, ++ CLUTTER_UNITS_TO_FLOAT (-priv->rxy), ++ CLUTTER_UNITS_TO_FLOAT (-(priv->z + priv->rxz))); + } + + if (!is_stage && (priv->anchor_x || priv->anchor_y)) +- cogl_translatex (CLUTTER_UNITS_TO_FIXED (-priv->anchor_x), +- CLUTTER_UNITS_TO_FIXED (-priv->anchor_y), ++ cogl_translate (CLUTTER_UNITS_TO_FLOAT (-priv->anchor_x), ++ CLUTTER_UNITS_TO_FLOAT (-priv->anchor_y), + 0); + + if (priv->z) +- cogl_translatex (0, 0, priv->z); ++ cogl_translate (0, 0, priv->z); + } + + /* Recursively applies the transforms associated with this actor and +diff --git a/clutter/cogl/cogl-path.h b/clutter/cogl/cogl-path.h +index 0d29829..aa37864 100644 +--- a/clutter/cogl/cogl-path.h ++++ b/clutter/cogl/cogl-path.h +@@ -60,24 +60,10 @@ G_BEGIN_DECLS + * Fills a rectangle at the given coordinates with the current + * drawing color in a highly optimizied fashion. + **/ +-void cogl_rectangle (gint x, +- gint y, +- guint width, +- guint height); +- +-/** +- * cogl_rectanglex: +- * @x: X coordinate of the top-left corner +- * @y: Y coordinate of the top-left corner +- * @width: Width of the rectangle +- * @height: Height of the rectangle +- * +- * A fixed-point version of cogl_fast_fill_rectangle. +- **/ +-void cogl_rectanglex (float x, +- float y, +- float width, +- float height); ++void cogl_rectangle (float x, ++ float y, ++ float width, ++ float height); + + /** + * cogl_path_fill: +diff --git a/clutter/cogl/cogl.h.in b/clutter/cogl/cogl.h.in +index f37d54d..f8d5745 100644 +--- a/clutter/cogl/cogl.h.in ++++ b/clutter/cogl/cogl.h.in +@@ -231,7 +231,7 @@ void cogl_scale (float x, + float y); + + /** +- * cogl_translatex: ++ * cogl_translate: + * @x: Distance to translate along the x-axis + * @y: Distance to translate along the y-axis + * @z: Distance to translate along the z-axis +@@ -239,26 +239,12 @@ void cogl_scale (float x, + * Multiplies the current model-view matrix by one that translates the + * model along all three axes according to the given values. + */ +-void cogl_translatex (float x, +- float y, +- float z); +- +-/** +- * cogl_translate: +- * @x: Distance to translate along the x-axis +- * @y: Distance to translate along the y-axis +- * @z: Distance to translate along the z-axis +- * +- * Integer version of cogl_translatex(). Multiplies the current +- * model-view matrix by one that translates the model along all three +- * axes according to the given values. +- */ +-void cogl_translate (gint x, +- gint y, +- gint z); ++void cogl_translate (float x, ++ float y, ++ float z); + + /** +- * cogl_rotatex: ++ * cogl_rotate: + * @angle: Angle in degrees to rotate. + * @x: X-component of vertex to rotate around. + * @y: Y-component of vertex to rotate around. +@@ -270,26 +256,10 @@ void cogl_translate (gint x, + * degrees about the vertex (0, 0, 1) causes a small counter-clockwise + * rotation. + */ +-void cogl_rotatex (float angle, +- float x, +- float y, +- float z); +- +-/** +- * cogl_rotate: +- * @angle: Angle in degrees to rotate. +- * @x: X-component of vertex to rotate around. +- * @y: Y-component of vertex to rotate around. +- * @z: Z-component of vertex to rotate around. +- * +- * Integer version of cogl_rotatex(). Multiplies the current +- * model-view matrix by one that rotates the model around the vertex +- * specified by @x, @y and @z. +- */ +-void cogl_rotate (gint angle, +- gint x, +- gint y, +- gint z); ++void cogl_rotate (float angle, ++ float x, ++ float y, ++ float z); + + /** + * cogl_get_modelview_matrix: +diff --git a/clutter/cogl/common/cogl-primitives.c b/clutter/cogl/common/cogl-primitives.c +index 27834f7..7e9b1b9 100644 +--- a/clutter/cogl/common/cogl-primitives.c ++++ b/clutter/cogl/common/cogl-primitives.c +@@ -43,19 +43,15 @@ void _cogl_path_add_node (gboolean new_sub_path, + float y); + void _cogl_path_fill_nodes (); + void _cogl_path_stroke_nodes (); +-void _cogl_rectangle (gint x, +- gint y, +- guint width, +- guint height); +-void _cogl_rectanglex (float x, +- float y, +- float width, +- float height); ++void _cogl_rectangle (float x, ++ float y, ++ float width, ++ float height); + void +-cogl_rectangle (gint x, +- gint y, +- guint width, +- guint height) ++cogl_rectangle (float x, ++ float y, ++ float width, ++ float height) + { + cogl_clip_ensure (); + +@@ -63,18 +59,6 @@ cogl_rectangle (gint x, + } + + void +-cogl_rectanglex (float x, +- float y, +- float width, +- float height) +-{ +- cogl_clip_ensure (); +- +- _cogl_rectanglex (x, y, width, height); +-} +- +- +-void + cogl_path_fill (void) + { + cogl_path_fill_preserve (); +diff --git a/clutter/cogl/gl/cogl-primitives.c b/clutter/cogl/gl/cogl-primitives.c +index 8a0843d..e445657 100644 +--- a/clutter/cogl/gl/cogl-primitives.c ++++ b/clutter/cogl/gl/cogl-primitives.c +@@ -39,35 +39,17 @@ + #define _COGL_MAX_BEZ_RECURSE_DEPTH 16 + + void +-_cogl_rectangle (gint x, +- gint y, +- guint width, +- guint height) ++_cogl_rectangle (float x, ++ float y, ++ float width, ++ float height) + { + _COGL_GET_CONTEXT (ctx, NO_RETVAL); + + cogl_enable (ctx->color_alpha < 255 + ? COGL_ENABLE_BLEND : 0); + +- GE( glRecti (x, y, x + width, y + height) ); +-} +- +- +-void +-_cogl_rectanglex (float x, +- float y, +- float width, +- float height) +-{ +- _COGL_GET_CONTEXT (ctx, NO_RETVAL); +- +- cogl_enable (ctx->color_alpha < 255 +- ? COGL_ENABLE_BLEND : 0); +- +- GE( glRectf ( (x), +- (y), +- (x + width), +- (y + height)) ); ++ GE( glRectf (x, y, x + width, y + height) ); + } + + void +@@ -132,17 +114,15 @@ _cogl_path_stroke_nodes () + static void + _cogl_path_get_bounds (floatVec2 nodes_min, + floatVec2 nodes_max, +- gint *bounds_x, +- gint *bounds_y, +- guint *bounds_w, +- guint *bounds_h) ++ float *bounds_x, ++ float *bounds_y, ++ float *bounds_w, ++ float *bounds_h) + { +- *bounds_x = floorf (nodes_min.x); +- *bounds_y = floorf (nodes_min.y); +- *bounds_w = ceilf (nodes_max.x +- - (float)(*bounds_x)); +- *bounds_h = ceilf (nodes_max.y +- - (float)(*bounds_y)); ++ *bounds_x = nodes_min.x; ++ *bounds_y = nodes_min.y; ++ *bounds_w = nodes_max.x - *bounds_x; ++ *bounds_h = nodes_max.y - *bounds_y; + } + + void +@@ -154,10 +134,10 @@ _cogl_add_path_to_stencil_buffer (floatVec2 nodes_min, + { + guint path_start = 0; + guint sub_path_num = 0; +- gint bounds_x; +- gint bounds_y; +- guint bounds_w; +- guint bounds_h; ++ float bounds_x; ++ float bounds_y; ++ float bounds_w; ++ float bounds_h; + + _cogl_path_get_bounds (nodes_min, nodes_max, + &bounds_x, &bounds_y, &bounds_w, &bounds_h); +@@ -239,10 +219,10 @@ _cogl_add_path_to_stencil_buffer (floatVec2 nodes_min, + void + _cogl_path_fill_nodes () + { +- gint bounds_x; +- gint bounds_y; +- guint bounds_w; +- guint bounds_h; ++ float bounds_x; ++ float bounds_y; ++ float bounds_w; ++ float bounds_h; + + _COGL_GET_CONTEXT (ctx, NO_RETVAL); + +diff --git a/clutter/cogl/gl/cogl.c b/clutter/cogl/gl/cogl.c +index 5100a08..bef567f 100644 +--- a/clutter/cogl/gl/cogl.c ++++ b/clutter/cogl/gl/cogl.c +@@ -217,32 +217,15 @@ cogl_scale (float x, float y) + } + + void +-cogl_translatex (float x, float y, float z) ++cogl_translate (float x, float y, float z) + { +- glTranslatef ((float)(x), +- (float)(y), +- (float)(z)); ++ glTranslatef (x, y, z); + } + + void +-cogl_translate (gint x, gint y, gint z) ++cogl_rotate (float angle, float x, float y, float z) + { +- glTranslatef ((float)x, (float)y, (float)z); +-} +- +-void +-cogl_rotatex (float angle, float x, float y, float z) +-{ +- glRotatef ((float)(angle), +- (float)(x), +- (float)(y), +- (float)(z)); +-} +- +-void +-cogl_rotate (gint angle, gint x, gint y, gint z) +-{ +- glRotatef ((float)angle, (float)x, (float)y, (float)z); ++ glRotatef (angle, x, y, z); + } + + static inline gboolean +diff --git a/clutter/cogl/gles/cogl-primitives.c b/clutter/cogl/gles/cogl-primitives.c +index d8fe121..cf305a8 100644 +--- a/clutter/cogl/gles/cogl-primitives.c ++++ b/clutter/cogl/gles/cogl-primitives.c +@@ -39,55 +39,26 @@ + #define _COGL_MAX_BEZ_RECURSE_DEPTH 16 + + void +-_cogl_rectangle (gint x, +- gint y, +- guint width, +- guint height) ++_cogl_rectangle (float x, ++ float y, ++ float width, ++ float height) + { +- /* 32-bit integers are not supported as coord types +- in GLES . Fixed type has got 16 bits left of the +- point which is equal to short anyway. */ +- +- GLshort rect_verts[8] = { +- (GLshort) x, (GLshort) y, +- (GLshort) (x + width), (GLshort) y, +- (GLshort) x, (GLshort) (y + height), +- (GLshort) (x + width), (GLshort) (y + height) ++ GLfloat rect_verts[8] = { ++ (GLfloat) x, (GLfloat) y, ++ (GLfloat) (x + width), (GLfloat) y, ++ (GLfloat) x, (GLfloat) (y + height), ++ (GLfloat) (x + width), (GLfloat) (y + height) + }; + + _COGL_GET_CONTEXT (ctx, NO_RETVAL); + + cogl_enable (COGL_ENABLE_VERTEX_ARRAY + | (ctx->color_alpha < 255 ? COGL_ENABLE_BLEND : 0)); +- GE ( cogl_wrap_glVertexPointer (2, GL_SHORT, 0, rect_verts ) ); ++ GE ( cogl_wrap_glVertexPointer (2, GL_FLOAT, 0, rect_verts ) ); + GE ( cogl_wrap_glDrawArrays (GL_TRIANGLE_STRIP, 0, 4) ); + } + +- +-void +-_cogl_rectanglex (float x, +- float y, +- float width, +- float height) +-{ +- GLfloat rect_verts[8] = { +- x, y, +- x + width, y, +- x, y + height, +- x + width, y + height +- }; +- +- _COGL_GET_CONTEXT (ctx, NO_RETVAL); +- +- cogl_enable (COGL_ENABLE_VERTEX_ARRAY +- | (ctx->color_alpha < 255 +- ? COGL_ENABLE_BLEND : 0)); +- +- GE( cogl_wrap_glVertexPointer (2, GL_FIXED, 0, rect_verts) ); +- GE( cogl_wrap_glDrawArrays (GL_TRIANGLE_STRIP, 0, 4) ); +- +-} +- + void + _cogl_path_add_node (gboolean new_sub_path, + float x, +@@ -150,17 +121,15 @@ _cogl_path_stroke_nodes () + static void + _cogl_path_get_bounds (floatVec2 nodes_min, + floatVec2 nodes_max, +- gint *bounds_x, +- gint *bounds_y, +- guint *bounds_w, +- guint *bounds_h) ++ float *bounds_x, ++ float *bounds_y, ++ float *bounds_w, ++ float *bounds_h) + { +- *bounds_x = floorf (nodes_min.x); +- *bounds_y = floorf (nodes_min.y); +- *bounds_w = ceilf (nodes_max.x +- - (float)(*bounds_x)); +- *bounds_h = ceilf (nodes_max.y +- - (float)(*bounds_y)); ++ *bounds_x = nodes_min.x; ++ *bounds_y = nodes_min.y; ++ *bounds_w = nodes_max.x - *bounds_x; ++ *bounds_h = nodes_max.y - *bounds_y; + } + + static gint compare_ints (gconstpointer a, +@@ -178,10 +147,10 @@ _cogl_add_path_to_stencil_buffer (floatVec2 nodes_min, + { + guint path_start = 0; + guint sub_path_num = 0; +- gint bounds_x; +- gint bounds_y; +- guint bounds_w; +- guint bounds_h; ++ float bounds_x; ++ float bounds_y; ++ float bounds_w; ++ float bounds_h; + + _cogl_path_get_bounds (nodes_min, nodes_max, + &bounds_x, &bounds_y, &bounds_w, &bounds_h); +@@ -436,10 +405,10 @@ _cogl_path_fill_nodes_scanlines (CoglPathNode *path, + void + _cogl_path_fill_nodes () + { +- gint bounds_x; +- gint bounds_y; +- guint bounds_w; +- guint bounds_h; ++ float bounds_x; ++ float bounds_y; ++ float bounds_w; ++ float bounds_h; + + _COGL_GET_CONTEXT (ctx, NO_RETVAL); + +diff --git a/clutter/cogl/gles/cogl.c b/clutter/cogl/gles/cogl.c +index 16cf666..dc2c339 100644 +--- a/clutter/cogl/gles/cogl.c ++++ b/clutter/cogl/gles/cogl.c +@@ -123,35 +123,15 @@ cogl_scale (float x, float y) + } + + void +-cogl_translatex (float x, float y, float z) ++cogl_translate (float x, float y, float z) + { + GE( cogl_wrap_glTranslatex (x, y, z) ); + } + + void +-cogl_translate (gint x, gint y, gint z) ++cogl_rotate (float angle, float x, float y, float z) + { +- GE( cogl_wrap_glTranslatex ((float)(x), +- (float)(y), +- (float)(z)) ); +-} +- +-void +-cogl_rotatex (float angle, +- float x, +- float y, +- float z) +-{ +- GE( cogl_wrap_glRotatex (angle,x,y,z) ); +-} +- +-void +-cogl_rotate (gint angle, gint x, gint y, gint z) +-{ +- GE( cogl_wrap_glRotatex ((float)(angle), +- (float)(x), +- (float)(y), +- (float)(z)) ); ++ GE( cogl_wrap_glRotatex (angle, x, y, z) ); + } + + static inline gboolean +diff --git a/clutter/pango/cogl-pango-render.c b/clutter/pango/cogl-pango-render.c +index 3e23309..3cafc81 100644 +--- a/clutter/pango/cogl-pango-render.c ++++ b/clutter/pango/cogl-pango-render.c +@@ -461,7 +461,7 @@ cogl_pango_renderer_draw_rectangle (PangoRenderer *renderer, + x + width, y + height, + &x2, &y2); + +- cogl_rectanglex (x1, y1, x2 - x1, y2 - y1); ++ cogl_rectangle (x1, y1, x2 - x1, y2 - y1); + } + + static void diff --git a/fixed-to-float-patches/remove_cogl_apis_taking_fixed_params.1.patch b/fixed-to-float-patches/remove_cogl_apis_taking_fixed_params.1.patch new file mode 100644 index 000000000..e51bf864a --- /dev/null +++ b/fixed-to-float-patches/remove_cogl_apis_taking_fixed_params.1.patch @@ -0,0 +1,52 @@ +diff --git a/clutter/cogl/gles/cogl-primitives.c b/clutter/cogl/gles/cogl-primitives.c +index cf305a8..1a58805 100644 +--- a/clutter/cogl/gles/cogl-primitives.c ++++ b/clutter/cogl/gles/cogl-primitives.c +@@ -214,12 +214,8 @@ _cogl_add_path_to_stencil_buffer (floatVec2 nodes_min, + GE( cogl_wrap_glMatrixMode (GL_PROJECTION) ); + GE( cogl_wrap_glPushMatrix () ); + GE( cogl_wrap_glLoadIdentity () ); +- cogl_rectanglex (-1.0, -1.0, +- (float)(2), +- (float)(2)); +- cogl_rectanglex (-1.0, -1.0, +- (float)(2), +- (float)(2)); ++ cogl_rectangle (-1.0, -1.0, 2, 2); ++ cogl_rectangle (-1.0, -1.0, 2, 2); + GE( cogl_wrap_glPopMatrix () ); + GE( cogl_wrap_glMatrixMode (GL_MODELVIEW) ); + GE( cogl_wrap_glPopMatrix () ); +diff --git a/clutter/cogl/gles/cogl.c b/clutter/cogl/gles/cogl.c +index dc2c339..9065eb2 100644 +--- a/clutter/cogl/gles/cogl.c ++++ b/clutter/cogl/gles/cogl.c +@@ -437,7 +437,7 @@ _cogl_add_stencil_clip (float x_offset, + GE( glStencilFunc (GL_NEVER, 0x1, 0x1) ); + GE( glStencilOp (GL_REPLACE, GL_REPLACE, GL_REPLACE) ); + +- cogl_rectanglex (x_offset, y_offset, width, height); ++ cogl_rectangle (x_offset, y_offset, width, height); + } + else + { +@@ -445,7 +445,7 @@ _cogl_add_stencil_clip (float x_offset, + rectangle */ + GE( glStencilFunc (GL_NEVER, 0x1, 0x3) ); + GE( glStencilOp (GL_INCR, GL_INCR, GL_INCR) ); +- cogl_rectanglex (x_offset, y_offset, width, height); ++ cogl_rectangle (x_offset, y_offset, width, height); + + /* Subtract one from all pixels in the stencil buffer so that + only pixels where both the original stencil buffer and the +@@ -456,9 +456,7 @@ _cogl_add_stencil_clip (float x_offset, + GE( cogl_wrap_glMatrixMode (GL_PROJECTION) ); + GE( cogl_wrap_glPushMatrix () ); + GE( cogl_wrap_glLoadIdentity () ); +- cogl_rectanglex (-1.0, -1.0, +- (float)(2), +- (float)(2)); ++ cogl_rectangle (-1.0, -1.0, 2, 2); + GE( cogl_wrap_glPopMatrix () ); + GE( cogl_wrap_glMatrixMode (GL_MODELVIEW) ); + GE( cogl_wrap_glPopMatrix () ); diff --git a/fixed-to-float.sh b/fixed-to-float.sh index 2c5efdcfb..d362344e1 100755 --- a/fixed-to-float.sh +++ b/fixed-to-float.sh @@ -142,7 +142,7 @@ patch -p1 Date: Thu, 15 Jan 2009 15:24:05 +0000 Subject: [PATCH 14/26] [fixed-to-float-patches] Fix some of the matrix getters and setters The GL versions of get_modelview_matrix, get_projection_matrix and get_viewport were using glGetDoublev and then converting them to floats, but it might as well just call glGetFloatv directly. The GL ES versions were using glGetFixedv but this was being replaced with glGetFloatv by the #define in the GLES 2 wrappers. The patch also replaces the glGetFixedv wrapper with glGetFloatv. Previously this was calling cogl_gles2_float_array_to_fixed which actually converted to float. That function has been removed and memcpy is used instead. --- fixed-to-float-patches/gl-cogl.c.0.patch | 79 ++++++++++++++++++- .../gles-cogl-gles2-wrapper.c.0.patch | 58 ++++++++++++++ .../gles-cogl-gles2-wrapper.h.0.patch | 13 ++- fixed-to-float-patches/gles-cogl.c.0.patch | 29 ++++++- fixed-to-float.sh | 1 + 5 files changed, 176 insertions(+), 4 deletions(-) create mode 100644 fixed-to-float-patches/gles-cogl-gles2-wrapper.c.0.patch diff --git a/fixed-to-float-patches/gl-cogl.c.0.patch b/fixed-to-float-patches/gl-cogl.c.0.patch index 898f94d48..6db7cee11 100644 --- a/fixed-to-float-patches/gl-cogl.c.0.patch +++ b/fixed-to-float-patches/gl-cogl.c.0.patch @@ -1,5 +1,5 @@ diff --git a/clutter/cogl/gl/cogl.c b/clutter/cogl/gl/cogl.c -index 7b61b63..5100a08 100644 +index 7b61b63..d815e3b 100644 --- a/clutter/cogl/gl/cogl.c +++ b/clutter/cogl/gl/cogl.c @@ -211,17 +211,17 @@ cogl_pop_matrix (void) @@ -93,3 +93,80 @@ index 7b61b63..5100a08 100644 } GE( glTranslatef (-0.5f, -0.5f, -z_camera) ); +@@ -1166,73 +1160,19 @@ cogl_features_available (CoglFeatureFlags features) + void + cogl_get_modelview_matrix (float m[16]) + { +- GLdouble md[16]; +- +- glGetDoublev(GL_MODELVIEW_MATRIX, &md[0]); +- +-#define M(m,row,col) m[col*4+row] +- M(m,0,0) = (M(md,0,0)); +- M(m,0,1) = (M(md,0,1)); +- M(m,0,2) = (M(md,0,2)); +- M(m,0,3) = (M(md,0,3)); +- +- M(m,1,0) = (M(md,1,0)); +- M(m,1,1) = (M(md,1,1)); +- M(m,1,2) = (M(md,1,2)); +- M(m,1,3) = (M(md,1,3)); +- +- M(m,2,0) = (M(md,2,0)); +- M(m,2,1) = (M(md,2,1)); +- M(m,2,2) = (M(md,2,2)); +- M(m,2,3) = (M(md,2,3)); +- +- M(m,3,0) = (M(md,3,0)); +- M(m,3,1) = (M(md,3,1)); +- M(m,3,2) = (M(md,3,2)); +- M(m,3,3) = (M(md,3,3)); +-#undef M ++ glGetFloatv (GL_MODELVIEW_MATRIX, m); + } + + void + cogl_get_projection_matrix (float m[16]) + { +- GLdouble md[16]; +- +- glGetDoublev(GL_PROJECTION_MATRIX, &md[0]); +- +-#define M(m,row,col) m[col*4+row] +- M(m,0,0) = (M(md,0,0)); +- M(m,0,1) = (M(md,0,1)); +- M(m,0,2) = (M(md,0,2)); +- M(m,0,3) = (M(md,0,3)); +- +- M(m,1,0) = (M(md,1,0)); +- M(m,1,1) = (M(md,1,1)); +- M(m,1,2) = (M(md,1,2)); +- M(m,1,3) = (M(md,1,3)); +- +- M(m,2,0) = (M(md,2,0)); +- M(m,2,1) = (M(md,2,1)); +- M(m,2,2) = (M(md,2,2)); +- M(m,2,3) = (M(md,2,3)); +- +- M(m,3,0) = (M(md,3,0)); +- M(m,3,1) = (M(md,3,1)); +- M(m,3,2) = (M(md,3,2)); +- M(m,3,3) = (M(md,3,3)); +-#undef M ++ glGetFloatv (GL_PROJECTION_MATRIX, m); + } + + void + cogl_get_viewport (float v[4]) + { +- GLdouble vd[4]; +- glGetDoublev(GL_VIEWPORT, &vd[0]); +- +- v[0] = (vd[0]); +- v[1] = (vd[1]); +- v[2] = (vd[2]); +- v[3] = (vd[3]); ++ glGetFloatv (GL_VIEWPORT, v); + } + + void diff --git a/fixed-to-float-patches/gles-cogl-gles2-wrapper.c.0.patch b/fixed-to-float-patches/gles-cogl-gles2-wrapper.c.0.patch new file mode 100644 index 000000000..9cebe5b34 --- /dev/null +++ b/fixed-to-float-patches/gles-cogl-gles2-wrapper.c.0.patch @@ -0,0 +1,58 @@ +diff --git a/clutter/cogl/gles/cogl-gles2-wrapper.c b/clutter/cogl/gles/cogl-gles2-wrapper.c +index 859c895..8a2fd24 100644 +--- a/clutter/cogl/gles/cogl-gles2-wrapper.c ++++ b/clutter/cogl/gles/cogl-gles2-wrapper.c +@@ -1142,15 +1142,6 @@ cogl_wrap_glClipPlanex (GLenum plane, GLfloat *equation) + /* FIXME */ + } + +-static void +-cogl_gles2_float_array_to_fixed (int size, +- const GLfloat *floats, +- GLfloat *fixeds) +-{ +- while (size-- > 0) +- *(fixeds++) = (*(floats++)); +-} +- + void + cogl_wrap_glGetIntegerv (GLenum pname, GLint *params) + { +@@ -1169,31 +1160,24 @@ cogl_wrap_glGetIntegerv (GLenum pname, GLint *params) + } + + void +-cogl_wrap_glGetFixedv (GLenum pname, GLfloat *params) ++cogl_wrap_glGetFloatv (GLenum pname, GLfloat *params) + { + _COGL_GET_GLES2_WRAPPER (w, NO_RETVAL); + + switch (pname) + { + case GL_MODELVIEW_MATRIX: +- cogl_gles2_float_array_to_fixed (16, w->modelview_stack +- + w->modelview_stack_pos * 16, +- params); ++ memcpy (params, w->modelview_stack + w->modelview_stack_pos * 16, ++ sizeof (GLfloat) * 16); + break; + + case GL_PROJECTION_MATRIX: +- cogl_gles2_float_array_to_fixed (16, w->projection_stack +- + w->projection_stack_pos * 16, +- params); ++ memcpy (params, w->projection_stack + w->projection_stack_pos * 16, ++ sizeof (GLfloat) * 16); + break; + + case GL_VIEWPORT: +- { +- GLfloat v[4]; +- +- glGetFloatv (GL_VIEWPORT, v); +- cogl_gles2_float_array_to_fixed (4, v, params); +- } ++ glGetFloatv (GL_VIEWPORT, params); + break; + } + } diff --git a/fixed-to-float-patches/gles-cogl-gles2-wrapper.h.0.patch b/fixed-to-float-patches/gles-cogl-gles2-wrapper.h.0.patch index 03deb1638..f67d98c15 100644 --- a/fixed-to-float-patches/gles-cogl-gles2-wrapper.h.0.patch +++ b/fixed-to-float-patches/gles-cogl-gles2-wrapper.h.0.patch @@ -1,13 +1,22 @@ diff --git a/clutter/cogl/gles/cogl-gles2-wrapper.h b/clutter/cogl/gles/cogl-gles2-wrapper.h -index 265da78..2e61121 100644 +index 265da78..2493b81 100644 --- a/clutter/cogl/gles/cogl-gles2-wrapper.h +++ b/clutter/cogl/gles/cogl-gles2-wrapper.h +@@ -244,7 +244,7 @@ void cogl_wrap_glColor4x (GLclampx r, GLclampx g, GLclampx b, GLclampx a); + void cogl_wrap_glClipPlanex (GLenum plane, GLfloat *equation); + + void cogl_wrap_glGetIntegerv (GLenum pname, GLint *params); +-void cogl_wrap_glGetFixedv (GLenum pname, GLfloat *params); ++void cogl_wrap_glGetFloatv (GLenum pname, GLfloat *params); + + void cogl_wrap_glFogx (GLenum pname, GLfloat param); + void cogl_wrap_glFogxv (GLenum pname, const GLfloat *params); @@ -297,7 +297,7 @@ void _cogl_gles2_clear_cache_for_program (CoglHandle program); #define cogl_wrap_glColor4x glColor4f #define cogl_wrap_glClipPlanex glClipPlanef #define cogl_wrap_glGetIntegerv glGetIntegerv -#define cogl_wrap_glGetFixedv glGetFixedv -+#define cogl_wrap_glGetFixedv glGetFloatv ++#define cogl_wrap_glGetFloatv glGetFloatv #define cogl_wrap_glFogx glFogf #define cogl_wrap_glFogxv glFogfv #define cogl_wrap_glTexParameteri glTexParameteri diff --git a/fixed-to-float-patches/gles-cogl.c.0.patch b/fixed-to-float-patches/gles-cogl.c.0.patch index bf1daac0a..291b7eff2 100644 --- a/fixed-to-float-patches/gles-cogl.c.0.patch +++ b/fixed-to-float-patches/gles-cogl.c.0.patch @@ -1,5 +1,5 @@ diff --git a/clutter/cogl/gles/cogl.c b/clutter/cogl/gles/cogl.c -index 422d8b6..16cf666 100644 +index 422d8b6..aa4e4fc 100644 --- a/clutter/cogl/gles/cogl.c +++ b/clutter/cogl/gles/cogl.c @@ -37,6 +37,7 @@ @@ -22,6 +22,17 @@ index 422d8b6..16cf666 100644 GE( cogl_wrap_glPushMatrix () ); /* Load the identity matrix and multiply by the reverse of the +@@ -405,8 +405,8 @@ _cogl_set_clip_planes (float x_offset, + float vertex_br[4] = { x_offset + width, y_offset + height, + 0, 1.0 }; + +- GE( cogl_wrap_glGetFixedv (GL_MODELVIEW_MATRIX, modelview) ); +- GE( cogl_wrap_glGetFixedv (GL_PROJECTION_MATRIX, projection) ); ++ GE( cogl_wrap_glGetFloatv (GL_MODELVIEW_MATRIX, modelview) ); ++ GE( cogl_wrap_glGetFloatv (GL_PROJECTION_MATRIX, projection) ); + + project_vertex (modelview, projection, vertex_tl); + project_vertex (modelview, projection, vertex_tr); @@ -558,15 +558,13 @@ cogl_perspective (float fovy, * 2) When working with small numbers, we can are loosing significant * precision @@ -58,3 +69,19 @@ index 422d8b6..16cf666 100644 GE( cogl_wrap_glScalex ( 1.0 / width, -1.0 / height, +@@ -737,13 +735,13 @@ cogl_features_available (CoglFeatureFlags features) + void + cogl_get_modelview_matrix (float m[16]) + { +- cogl_wrap_glGetFixedv(GL_MODELVIEW_MATRIX, &m[0]); ++ cogl_wrap_glGetFloatv (GL_MODELVIEW_MATRIX, m); + } + + void + cogl_get_projection_matrix (float m[16]) + { +- cogl_wrap_glGetFixedv(GL_PROJECTION_MATRIX, &m[0]); ++ cogl_wrap_glGetFloatv (GL_PROJECTION_MATRIX, m); + } + + void diff --git a/fixed-to-float.sh b/fixed-to-float.sh index d362344e1..cd967843d 100755 --- a/fixed-to-float.sh +++ b/fixed-to-float.sh @@ -148,6 +148,7 @@ patch -p1 Date: Thu, 15 Jan 2009 16:35:46 +0000 Subject: [PATCH 15/26] [fixed-to-float.sh] Remove the mtx_transform patch from the script The patch got deleted and merged into the clutter-actor.c patch in commit 012b16 so it was just causing unnecessary errors. --- fixed-to-float.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/fixed-to-float.sh b/fixed-to-float.sh index cd967843d..b3eb48f85 100755 --- a/fixed-to-float.sh +++ b/fixed-to-float.sh @@ -130,7 +130,6 @@ find ./clutter/ -iname '*.c' -exec grep '^clutter_[a-zA-Z_]*x ' {} \; | cut -d' git-commit -a -m "[By fixed-to-float.sh] Fixed to Float automatic changes" --no-verify patch -p1 Date: Thu, 15 Jan 2009 18:53:52 +0000 Subject: [PATCH 16/26] [fixed-to-float-patches] Fix use of glClearColor and glColor under GLES 2 The wrapper for glClearColor was taking fixed arguments but was given floating point values so it ended up always setting the clear color to black. Now that GLES 1.1 is using the floating point version, there is no need for the wrapper so both versions now just use glClearColor directly. A similar problem was happening for glColor but this does still need a wrapper because it needs to set the vertex attribute. --- .../gles-cogl-gles2-wrapper.c.0.patch | 38 +++++++++++++++++-- .../gles-cogl-gles2-wrapper.h.0.patch | 35 +++++++++++++++-- fixed-to-float-patches/gles-cogl.c.0.patch | 26 ++++++++++++- 3 files changed, 91 insertions(+), 8 deletions(-) diff --git a/fixed-to-float-patches/gles-cogl-gles2-wrapper.c.0.patch b/fixed-to-float-patches/gles-cogl-gles2-wrapper.c.0.patch index 83d1490bc..127ff886f 100644 --- a/fixed-to-float-patches/gles-cogl-gles2-wrapper.c.0.patch +++ b/fixed-to-float-patches/gles-cogl-gles2-wrapper.c.0.patch @@ -1,8 +1,40 @@ diff --git a/clutter/cogl/gles/cogl-gles2-wrapper.c b/clutter/cogl/gles/cogl-gles2-wrapper.c -index b2e19eb..9435131 100644 +index b2e19eb..a7800c5 100644 --- a/clutter/cogl/gles/cogl-gles2-wrapper.c +++ b/clutter/cogl/gles/cogl-gles2-wrapper.c -@@ -1158,15 +1158,6 @@ cogl_wrap_glClipPlanex (GLenum plane, GLfloat *equation) +@@ -515,15 +515,6 @@ cogl_gles2_wrapper_update_matrix (CoglGles2Wrapper *wrapper, GLenum matrix_num) + } + + void +-cogl_wrap_glClearColorx (GLclampx r, GLclampx g, GLclampx b, GLclampx a) +-{ +- glClearColor ( (r), +- (g), +- (b), +- (a)); +-} +- +-void + cogl_wrap_glPushMatrix () + { + const float *src; +@@ -1143,13 +1134,9 @@ cogl_wrap_glAlphaFunc (GLenum func, GLclampf ref) + } + + void +-cogl_wrap_glColor4x (GLclampx r, GLclampx g, GLclampx b, GLclampx a) ++cogl_wrap_glColor4f (GLclampf r, GLclampf g, GLclampf b, GLclampf a) + { +- glVertexAttrib4f (COGL_GLES2_WRAPPER_COLOR_ATTRIB, +- (r), +- (g), +- (b), +- (a)); ++ glVertexAttrib4f (COGL_GLES2_WRAPPER_COLOR_ATTRIB, r, g, b, a); + } + + void +@@ -1158,15 +1145,6 @@ cogl_wrap_glClipPlanex (GLenum plane, GLfloat *equation) /* FIXME */ } @@ -18,7 +50,7 @@ index b2e19eb..9435131 100644 void cogl_wrap_glGetIntegerv (GLenum pname, GLint *params) { -@@ -1185,31 +1176,24 @@ cogl_wrap_glGetIntegerv (GLenum pname, GLint *params) +@@ -1185,31 +1163,24 @@ cogl_wrap_glGetIntegerv (GLenum pname, GLint *params) } void diff --git a/fixed-to-float-patches/gles-cogl-gles2-wrapper.h.0.patch b/fixed-to-float-patches/gles-cogl-gles2-wrapper.h.0.patch index 9d74af73f..5a670c3b7 100644 --- a/fixed-to-float-patches/gles-cogl-gles2-wrapper.h.0.patch +++ b/fixed-to-float-patches/gles-cogl-gles2-wrapper.h.0.patch @@ -1,8 +1,23 @@ diff --git a/clutter/cogl/gles/cogl-gles2-wrapper.h b/clutter/cogl/gles/cogl-gles2-wrapper.h -index 8cb9e8b..a194157 100644 +index 8cb9e8b..561cb66 100644 --- a/clutter/cogl/gles/cogl-gles2-wrapper.h +++ b/clutter/cogl/gles/cogl-gles2-wrapper.h -@@ -244,7 +244,7 @@ void cogl_wrap_glColor4x (GLclampx r, GLclampx g, GLclampx b, GLclampx a); +@@ -203,8 +203,6 @@ struct _CoglGles2WrapperShader + void cogl_gles2_wrapper_init (CoglGles2Wrapper *wrapper); + void cogl_gles2_wrapper_deinit (CoglGles2Wrapper *wrapper); + +-void cogl_wrap_glClearColorx (GLclampx r, GLclampx g, GLclampx b, GLclampx a); +- + void cogl_wrap_glPushMatrix (); + void cogl_wrap_glPopMatrix (); + void cogl_wrap_glMatrixMode (GLenum mode); +@@ -239,12 +237,12 @@ void cogl_wrap_glDisableClientState (GLenum array); + + void cogl_wrap_glAlphaFunc (GLenum func, GLclampf ref); + +-void cogl_wrap_glColor4x (GLclampx r, GLclampx g, GLclampx b, GLclampx a); ++void cogl_wrap_glColor4f (GLclampf r, GLclampf g, GLclampf b, GLclampf a); + void cogl_wrap_glClipPlanex (GLenum plane, GLfloat *equation); void cogl_wrap_glGetIntegerv (GLenum pname, GLint *params); @@ -11,8 +26,20 @@ index 8cb9e8b..a194157 100644 void cogl_wrap_glFogx (GLenum pname, GLfloat param); void cogl_wrap_glFogxv (GLenum pname, const GLfloat *params); -@@ -299,7 +299,7 @@ void _cogl_gles2_clear_cache_for_program (CoglHandle program); - #define cogl_wrap_glColor4x glColor4f +@@ -273,7 +271,6 @@ void _cogl_gles2_clear_cache_for_program (CoglHandle program); + /* If we're not using GL ES 2 then just use the GL functions + directly */ + +-#define cogl_wrap_glClearColorx glClearColor + #define cogl_wrap_glDrawArrays glDrawArrays + #define cogl_wrap_glDrawElements glDrawElements + #define cogl_wrap_glPushMatrix glPushMatrix +@@ -296,10 +293,10 @@ void _cogl_gles2_clear_cache_for_program (CoglHandle program); + #define cogl_wrap_glEnableClientState glEnableClientState + #define cogl_wrap_glDisableClientState glDisableClientState + #define cogl_wrap_glAlphaFunc glAlphaFunc +-#define cogl_wrap_glColor4x glColor4f ++#define cogl_wrap_glColor4f glColor4f #define cogl_wrap_glClipPlanex glClipPlanef #define cogl_wrap_glGetIntegerv glGetIntegerv -#define cogl_wrap_glGetFixedv glGetFixedv diff --git a/fixed-to-float-patches/gles-cogl.c.0.patch b/fixed-to-float-patches/gles-cogl.c.0.patch index 291b7eff2..37662d0be 100644 --- a/fixed-to-float-patches/gles-cogl.c.0.patch +++ b/fixed-to-float-patches/gles-cogl.c.0.patch @@ -1,5 +1,5 @@ diff --git a/clutter/cogl/gles/cogl.c b/clutter/cogl/gles/cogl.c -index 422d8b6..aa4e4fc 100644 +index 422d8b6..cb7aa8e 100644 --- a/clutter/cogl/gles/cogl.c +++ b/clutter/cogl/gles/cogl.c @@ -37,6 +37,7 @@ @@ -10,6 +10,30 @@ index 422d8b6..aa4e4fc 100644 /* GL error to string conversion */ #if COGL_DEBUG +@@ -92,10 +93,10 @@ cogl_paint_init (const CoglColor *color) + fprintf(stderr, "\n ============== Paint Start ================ \n"); + #endif + +- cogl_wrap_glClearColorx (cogl_color_get_red (color), +- cogl_color_get_green (color), +- cogl_color_get_blue (color), +- 0); ++ glClearColor (cogl_color_get_red (color), ++ cogl_color_get_green (color), ++ cogl_color_get_blue (color), ++ 0); + + glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); + cogl_wrap_glDisable (GL_LIGHTING); +@@ -315,7 +316,7 @@ cogl_set_source_color (const CoglColor *color) + + #else + /* conversion can cause issues with picking on some gles implementations */ +- GE( cogl_wrap_glColor4x (cogl_color_get_red (color), ++ GE( cogl_wrap_glColor4f (cogl_color_get_red (color), + cogl_color_get_green (color), + cogl_color_get_blue (color), + cogl_color_get_alpha (color)) ); @@ -365,9 +366,8 @@ set_clip_plane (GLint plane_num, /* Calculate the angle between the axes and the line crossing the From 52d7b7be7366faa74a1ba5f8756a77a90019eaa3 Mon Sep 17 00:00:00 2001 From: Neil Roberts Date: Fri, 16 Jan 2009 10:50:53 +0000 Subject: [PATCH 17/26] [fixed-to-float-patches] Move the changes to gles2-wrapper.h into the patch It looks like the changes to cogl-gles2-wrapper.h were accidentally committed to the actual file instead of the patch in commit de27da0e. This commit moves the changes back into the patch so cogl-gles2-wrapper.h is reverted back to master. --- clutter/cogl/gles/cogl-gles2-wrapper.h | 24 +++++------ .../gles-cogl-gles2-wrapper.h.0.patch | 43 +++++++++++++++---- 2 files changed, 47 insertions(+), 20 deletions(-) diff --git a/clutter/cogl/gles/cogl-gles2-wrapper.h b/clutter/cogl/gles/cogl-gles2-wrapper.h index 05f7c600f..7e7472c58 100644 --- a/clutter/cogl/gles/cogl-gles2-wrapper.h +++ b/clutter/cogl/gles/cogl-gles2-wrapper.h @@ -273,35 +273,35 @@ void _cogl_gles2_clear_cache_for_program (CoglHandle program); /* If we're not using GL ES 2 then just use the GL functions directly */ -#define cogl_wrap_glClearColorx glClearColor +#define cogl_wrap_glClearColorx glClearColorx #define cogl_wrap_glDrawArrays glDrawArrays #define cogl_wrap_glDrawElements glDrawElements #define cogl_wrap_glPushMatrix glPushMatrix #define cogl_wrap_glPopMatrix glPopMatrix #define cogl_wrap_glMatrixMode glMatrixMode #define cogl_wrap_glLoadIdentity glLoadIdentity -#define cogl_wrap_glMultMatrixx glMultMatrixf -#define cogl_wrap_glFrustumx glFrustumf -#define cogl_wrap_glScalex glScalef -#define cogl_wrap_glTranslatex glTranslatef -#define cogl_wrap_glRotatex glRotatef -#define cogl_wrap_glOrthox glOrthof +#define cogl_wrap_glMultMatrixx glMultMatrixx +#define cogl_wrap_glFrustumx glFrustumx +#define cogl_wrap_glScalex glScalex +#define cogl_wrap_glTranslatex glTranslatex +#define cogl_wrap_glRotatex glRotatex +#define cogl_wrap_glOrthox glOrthox #define cogl_wrap_glEnable glEnable #define cogl_wrap_glDisable glDisable #define cogl_wrap_glTexCoordPointer glTexCoordPointer #define cogl_wrap_glVertexPointer glVertexPointer #define cogl_wrap_glColorPointer glColorPointer #define cogl_wrap_glNormalPointer glNormalPointer -#define cogl_wrap_glTexEnvx glTexEnvf +#define cogl_wrap_glTexEnvx glTexEnvx #define cogl_wrap_glEnableClientState glEnableClientState #define cogl_wrap_glDisableClientState glDisableClientState #define cogl_wrap_glAlphaFunc glAlphaFunc -#define cogl_wrap_glColor4x glColor4f -#define cogl_wrap_glClipPlanex glClipPlanef +#define cogl_wrap_glColor4x glColor4x +#define cogl_wrap_glClipPlanex glClipPlanex #define cogl_wrap_glGetIntegerv glGetIntegerv #define cogl_wrap_glGetFixedv glGetFixedv -#define cogl_wrap_glFogx glFogf -#define cogl_wrap_glFogxv glFogfv +#define cogl_wrap_glFogx glFogx +#define cogl_wrap_glFogxv glFogxv #define cogl_wrap_glTexParameteri glTexParameteri /* The extra third parameter of the bind texture wrapper isn't needed diff --git a/fixed-to-float-patches/gles-cogl-gles2-wrapper.h.0.patch b/fixed-to-float-patches/gles-cogl-gles2-wrapper.h.0.patch index 5a670c3b7..5bd7c72f1 100644 --- a/fixed-to-float-patches/gles-cogl-gles2-wrapper.h.0.patch +++ b/fixed-to-float-patches/gles-cogl-gles2-wrapper.h.0.patch @@ -1,5 +1,5 @@ diff --git a/clutter/cogl/gles/cogl-gles2-wrapper.h b/clutter/cogl/gles/cogl-gles2-wrapper.h -index 8cb9e8b..561cb66 100644 +index ad741be..561cb66 100644 --- a/clutter/cogl/gles/cogl-gles2-wrapper.h +++ b/clutter/cogl/gles/cogl-gles2-wrapper.h @@ -203,8 +203,6 @@ struct _CoglGles2WrapperShader @@ -26,24 +26,51 @@ index 8cb9e8b..561cb66 100644 void cogl_wrap_glFogx (GLenum pname, GLfloat param); void cogl_wrap_glFogxv (GLenum pname, const GLfloat *params); -@@ -273,7 +271,6 @@ void _cogl_gles2_clear_cache_for_program (CoglHandle program); +@@ -273,35 +271,34 @@ void _cogl_gles2_clear_cache_for_program (CoglHandle program); /* If we're not using GL ES 2 then just use the GL functions directly */ --#define cogl_wrap_glClearColorx glClearColor +-#define cogl_wrap_glClearColorx glClearColorx #define cogl_wrap_glDrawArrays glDrawArrays #define cogl_wrap_glDrawElements glDrawElements #define cogl_wrap_glPushMatrix glPushMatrix -@@ -296,10 +293,10 @@ void _cogl_gles2_clear_cache_for_program (CoglHandle program); + #define cogl_wrap_glPopMatrix glPopMatrix + #define cogl_wrap_glMatrixMode glMatrixMode + #define cogl_wrap_glLoadIdentity glLoadIdentity +-#define cogl_wrap_glMultMatrixx glMultMatrixx +-#define cogl_wrap_glFrustumx glFrustumx +-#define cogl_wrap_glScalex glScalex +-#define cogl_wrap_glTranslatex glTranslatex +-#define cogl_wrap_glRotatex glRotatex +-#define cogl_wrap_glOrthox glOrthox ++#define cogl_wrap_glMultMatrixx glMultMatrixf ++#define cogl_wrap_glFrustumx glFrustumf ++#define cogl_wrap_glScalex glScalef ++#define cogl_wrap_glTranslatex glTranslatef ++#define cogl_wrap_glRotatex glRotatef ++#define cogl_wrap_glOrthox glOrthof + #define cogl_wrap_glEnable glEnable + #define cogl_wrap_glDisable glDisable + #define cogl_wrap_glTexCoordPointer glTexCoordPointer + #define cogl_wrap_glVertexPointer glVertexPointer + #define cogl_wrap_glColorPointer glColorPointer + #define cogl_wrap_glNormalPointer glNormalPointer +-#define cogl_wrap_glTexEnvx glTexEnvx ++#define cogl_wrap_glTexEnvx glTexEnvf #define cogl_wrap_glEnableClientState glEnableClientState #define cogl_wrap_glDisableClientState glDisableClientState #define cogl_wrap_glAlphaFunc glAlphaFunc --#define cogl_wrap_glColor4x glColor4f +-#define cogl_wrap_glColor4x glColor4x +-#define cogl_wrap_glClipPlanex glClipPlanex +#define cogl_wrap_glColor4f glColor4f - #define cogl_wrap_glClipPlanex glClipPlanef ++#define cogl_wrap_glClipPlanex glClipPlanef #define cogl_wrap_glGetIntegerv glGetIntegerv -#define cogl_wrap_glGetFixedv glGetFixedv +-#define cogl_wrap_glFogx glFogx +-#define cogl_wrap_glFogxv glFogxv +#define cogl_wrap_glGetFloatv glGetFloatv - #define cogl_wrap_glFogx glFogf - #define cogl_wrap_glFogxv glFogfv ++#define cogl_wrap_glFogx glFogf ++#define cogl_wrap_glFogxv glFogfv #define cogl_wrap_glTexParameteri glTexParameteri + + /* The extra third parameter of the bind texture wrapper isn't needed From 18378fe180d2bf64631efa9a6ce99e4d770b793d Mon Sep 17 00:00:00 2001 From: Neil Roberts Date: Fri, 16 Jan 2009 12:16:28 +0000 Subject: [PATCH 18/26] [fixed-to-float.sh] Use float names for the GLES2 wrappers For example cogl_wrap_glFrustumx -> cogl_wrap_glFrustumf. The wrappers get #defined to the float versions anyway but it helps avoid some confusion. The conversion is done using a regular expression in the upgrade script. Some of the patches had to be updated to apply cleanly. --- .../gles-cogl-gles2-wrapper.c.0.patch | 2 +- .../gles-cogl-gles2-wrapper.h.0.patch | 52 +++++++++---------- fixed-to-float-patches/gles-cogl.c.0.patch | 15 ++---- ...move_cogl_apis_taking_fixed_params.0.patch | 10 ++-- fixed-to-float.sh | 7 +++ 5 files changed, 42 insertions(+), 44 deletions(-) diff --git a/fixed-to-float-patches/gles-cogl-gles2-wrapper.c.0.patch b/fixed-to-float-patches/gles-cogl-gles2-wrapper.c.0.patch index 127ff886f..2268e56a3 100644 --- a/fixed-to-float-patches/gles-cogl-gles2-wrapper.c.0.patch +++ b/fixed-to-float-patches/gles-cogl-gles2-wrapper.c.0.patch @@ -22,7 +22,7 @@ index b2e19eb..a7800c5 100644 } void --cogl_wrap_glColor4x (GLclampx r, GLclampx g, GLclampx b, GLclampx a) +-cogl_wrap_glColor4f (GLclampx r, GLclampx g, GLclampx b, GLclampx a) +cogl_wrap_glColor4f (GLclampf r, GLclampf g, GLclampf b, GLclampf a) { - glVertexAttrib4f (COGL_GLES2_WRAPPER_COLOR_ATTRIB, diff --git a/fixed-to-float-patches/gles-cogl-gles2-wrapper.h.0.patch b/fixed-to-float-patches/gles-cogl-gles2-wrapper.h.0.patch index 5bd7c72f1..46d78114e 100644 --- a/fixed-to-float-patches/gles-cogl-gles2-wrapper.h.0.patch +++ b/fixed-to-float-patches/gles-cogl-gles2-wrapper.h.0.patch @@ -1,5 +1,5 @@ diff --git a/clutter/cogl/gles/cogl-gles2-wrapper.h b/clutter/cogl/gles/cogl-gles2-wrapper.h -index ad741be..561cb66 100644 +index cb700cc..f126993 100644 --- a/clutter/cogl/gles/cogl-gles2-wrapper.h +++ b/clutter/cogl/gles/cogl-gles2-wrapper.h @@ -203,8 +203,6 @@ struct _CoglGles2WrapperShader @@ -15,17 +15,17 @@ index ad741be..561cb66 100644 void cogl_wrap_glAlphaFunc (GLenum func, GLclampf ref); --void cogl_wrap_glColor4x (GLclampx r, GLclampx g, GLclampx b, GLclampx a); +-void cogl_wrap_glColor4f (GLclampx r, GLclampx g, GLclampx b, GLclampx a); +void cogl_wrap_glColor4f (GLclampf r, GLclampf g, GLclampf b, GLclampf a); - void cogl_wrap_glClipPlanex (GLenum plane, GLfloat *equation); + void cogl_wrap_glClipPlanef (GLenum plane, GLfloat *equation); void cogl_wrap_glGetIntegerv (GLenum pname, GLint *params); -void cogl_wrap_glGetFixedv (GLenum pname, GLfloat *params); +void cogl_wrap_glGetFloatv (GLenum pname, GLfloat *params); - void cogl_wrap_glFogx (GLenum pname, GLfloat param); - void cogl_wrap_glFogxv (GLenum pname, const GLfloat *params); + void cogl_wrap_glFogf (GLenum pname, GLfloat param); + void cogl_wrap_glFogfv (GLenum pname, const GLfloat *params); @@ -273,35 +271,34 @@ void _cogl_gles2_clear_cache_for_program (CoglHandle program); /* If we're not using GL ES 2 then just use the GL functions directly */ @@ -37,40 +37,40 @@ index ad741be..561cb66 100644 #define cogl_wrap_glPopMatrix glPopMatrix #define cogl_wrap_glMatrixMode glMatrixMode #define cogl_wrap_glLoadIdentity glLoadIdentity --#define cogl_wrap_glMultMatrixx glMultMatrixx --#define cogl_wrap_glFrustumx glFrustumx --#define cogl_wrap_glScalex glScalex --#define cogl_wrap_glTranslatex glTranslatex --#define cogl_wrap_glRotatex glRotatex --#define cogl_wrap_glOrthox glOrthox -+#define cogl_wrap_glMultMatrixx glMultMatrixf -+#define cogl_wrap_glFrustumx glFrustumf -+#define cogl_wrap_glScalex glScalef -+#define cogl_wrap_glTranslatex glTranslatef -+#define cogl_wrap_glRotatex glRotatef -+#define cogl_wrap_glOrthox glOrthof +-#define cogl_wrap_glMultMatrixf glMultMatrixx +-#define cogl_wrap_glFrustumf glFrustumx +-#define cogl_wrap_glScalef glScalex +-#define cogl_wrap_glTranslatef glTranslatex +-#define cogl_wrap_glRotatef glRotatex +-#define cogl_wrap_glOrthof glOrthox ++#define cogl_wrap_glMultMatrixf glMultMatrixf ++#define cogl_wrap_glFrustumf glFrustumf ++#define cogl_wrap_glScalef glScalef ++#define cogl_wrap_glTranslatef glTranslatef ++#define cogl_wrap_glRotatef glRotatef ++#define cogl_wrap_glOrthof glOrthof #define cogl_wrap_glEnable glEnable #define cogl_wrap_glDisable glDisable #define cogl_wrap_glTexCoordPointer glTexCoordPointer #define cogl_wrap_glVertexPointer glVertexPointer #define cogl_wrap_glColorPointer glColorPointer #define cogl_wrap_glNormalPointer glNormalPointer --#define cogl_wrap_glTexEnvx glTexEnvx -+#define cogl_wrap_glTexEnvx glTexEnvf +-#define cogl_wrap_glTexEnvf glTexEnvx ++#define cogl_wrap_glTexEnvf glTexEnvf #define cogl_wrap_glEnableClientState glEnableClientState #define cogl_wrap_glDisableClientState glDisableClientState #define cogl_wrap_glAlphaFunc glAlphaFunc --#define cogl_wrap_glColor4x glColor4x --#define cogl_wrap_glClipPlanex glClipPlanex +-#define cogl_wrap_glColor4f glColor4x +-#define cogl_wrap_glClipPlanef glClipPlanex +#define cogl_wrap_glColor4f glColor4f -+#define cogl_wrap_glClipPlanex glClipPlanef ++#define cogl_wrap_glClipPlanef glClipPlanef #define cogl_wrap_glGetIntegerv glGetIntegerv -#define cogl_wrap_glGetFixedv glGetFixedv --#define cogl_wrap_glFogx glFogx --#define cogl_wrap_glFogxv glFogxv +-#define cogl_wrap_glFogf glFogx +-#define cogl_wrap_glFogfv glFogxv +#define cogl_wrap_glGetFloatv glGetFloatv -+#define cogl_wrap_glFogx glFogf -+#define cogl_wrap_glFogxv glFogfv ++#define cogl_wrap_glFogf glFogf ++#define cogl_wrap_glFogfv glFogfv #define cogl_wrap_glTexParameteri glTexParameteri /* The extra third parameter of the bind texture wrapper isn't needed diff --git a/fixed-to-float-patches/gles-cogl.c.0.patch b/fixed-to-float-patches/gles-cogl.c.0.patch index 37662d0be..cd7d442e6 100644 --- a/fixed-to-float-patches/gles-cogl.c.0.patch +++ b/fixed-to-float-patches/gles-cogl.c.0.patch @@ -25,15 +25,6 @@ index 422d8b6..cb7aa8e 100644 glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); cogl_wrap_glDisable (GL_LIGHTING); -@@ -315,7 +316,7 @@ cogl_set_source_color (const CoglColor *color) - - #else - /* conversion can cause issues with picking on some gles implementations */ -- GE( cogl_wrap_glColor4x (cogl_color_get_red (color), -+ GE( cogl_wrap_glColor4f (cogl_color_get_red (color), - cogl_color_get_green (color), - cogl_color_get_blue (color), - cogl_color_get_alpha (color)) ); @@ -365,9 +366,8 @@ set_clip_plane (GLint plane_num, /* Calculate the angle between the axes and the line crossing the @@ -87,11 +78,11 @@ index 422d8b6..cb7aa8e 100644 } -- GE( cogl_wrap_glTranslatex (-1 << 15, -1 << 15, -z_camera) ); +- GE( cogl_wrap_glTranslatef (-1 << 15, -1 << 15, -z_camera) ); + -+ GE( cogl_wrap_glTranslatex (-0.5f, -0.5f, -z_camera) ); ++ GE( cogl_wrap_glTranslatef (-0.5f, -0.5f, -z_camera) ); - GE( cogl_wrap_glScalex ( 1.0 / width, + GE( cogl_wrap_glScalef ( 1.0 / width, -1.0 / height, @@ -737,13 +735,13 @@ cogl_features_available (CoglFeatureFlags features) void diff --git a/fixed-to-float-patches/remove_cogl_apis_taking_fixed_params.0.patch b/fixed-to-float-patches/remove_cogl_apis_taking_fixed_params.0.patch index 7a84920ed..3afceaf72 100644 --- a/fixed-to-float-patches/remove_cogl_apis_taking_fixed_params.0.patch +++ b/fixed-to-float-patches/remove_cogl_apis_taking_fixed_params.0.patch @@ -522,14 +522,14 @@ index aa4e4fc..e835085 100644 -cogl_translatex (float x, float y, float z) +cogl_translate (float x, float y, float z) { - GE( cogl_wrap_glTranslatex (x, y, z) ); + GE( cogl_wrap_glTranslatef (x, y, z) ); } void -cogl_translate (gint x, gint y, gint z) +cogl_rotate (float angle, float x, float y, float z) { -- GE( cogl_wrap_glTranslatex ((float)(x), +- GE( cogl_wrap_glTranslatef ((float)(x), - (float)(y), - (float)(z)) ); -} @@ -540,17 +540,17 @@ index aa4e4fc..e835085 100644 - float y, - float z) -{ -- GE( cogl_wrap_glRotatex (angle,x,y,z) ); +- GE( cogl_wrap_glRotatef (angle,x,y,z) ); -} - -void -cogl_rotate (gint angle, gint x, gint y, gint z) -{ -- GE( cogl_wrap_glRotatex ((float)(angle), +- GE( cogl_wrap_glRotatef ((float)(angle), - (float)(x), - (float)(y), - (float)(z)) ); -+ GE( cogl_wrap_glRotatex (angle, x, y, z) ); ++ GE( cogl_wrap_glRotatef (angle, x, y, z) ); } static inline gboolean diff --git a/fixed-to-float.sh b/fixed-to-float.sh index b3eb48f85..feaa2b6ea 100755 --- a/fixed-to-float.sh +++ b/fixed-to-float.sh @@ -118,6 +118,13 @@ git-checkout clutter/cogl/cogl-fixed.h clutter/cogl/common/cogl-fixed.c find ./clutter -iname '*.[ch]' ! -iname 'clutter-fixed.h' -exec sed -i 's/ClutterAngle/float/g' {} \; +# use the floating point names for GL ES functions instead of the +# fixed. These get #define'd to the float versions in one of the +# patches anyway but the names should be fixed up to avoid confusion +find ./clutter/cogl -iname '*.[ch]' -exec perl -p -i -e \ +'s/\b(cogl_wrap_(?:glMultMatrix|glFrustum|glScale|glTranslate +|glRotate|glOrtho|glTexEnv|glClipPlane|glFog|glColor4))x(v?)\b/$1f$2/gx' {} \; + echo "Cogl API to remove/replace with float versions:" find ./clutter/ -iname '*.c' -exec grep '^cogl_[a-zA-Z_]*x ' {} \; | cut -d' ' -f1|grep -v 'box$'|grep -v 'matrix$' echo "Clutter API to remove/replace with float versions:" From 7b93cc068db5bfeba999e633a2b23b3b4c494bd5 Mon Sep 17 00:00:00 2001 From: Neil Roberts Date: Fri, 16 Jan 2009 13:56:42 +0000 Subject: [PATCH 19/26] [fixed-to-float-patches] Merge the two patches to remove cogl fixed params The two patches for removing cogl apis taking fixed params have been merged into one patch. --- ...move_cogl_apis_taking_fixed_params.0.patch | 50 ++++++++++++++++-- ...move_cogl_apis_taking_fixed_params.1.patch | 52 ------------------- fixed-to-float.sh | 1 - 3 files changed, 47 insertions(+), 56 deletions(-) delete mode 100644 fixed-to-float-patches/remove_cogl_apis_taking_fixed_params.1.patch diff --git a/fixed-to-float-patches/remove_cogl_apis_taking_fixed_params.0.patch b/fixed-to-float-patches/remove_cogl_apis_taking_fixed_params.0.patch index 3afceaf72..42e81d2bf 100644 --- a/fixed-to-float-patches/remove_cogl_apis_taking_fixed_params.0.patch +++ b/fixed-to-float-patches/remove_cogl_apis_taking_fixed_params.0.patch @@ -386,7 +386,7 @@ index d815e3b..aa0ec78 100644 static inline gboolean diff --git a/clutter/cogl/gles/cogl-primitives.c b/clutter/cogl/gles/cogl-primitives.c -index d8fe121..cf305a8 100644 +index d8fe121..1a58805 100644 --- a/clutter/cogl/gles/cogl-primitives.c +++ b/clutter/cogl/gles/cogl-primitives.c @@ -39,55 +39,26 @@ @@ -496,7 +496,22 @@ index d8fe121..cf305a8 100644 _cogl_path_get_bounds (nodes_min, nodes_max, &bounds_x, &bounds_y, &bounds_w, &bounds_h); -@@ -436,10 +405,10 @@ _cogl_path_fill_nodes_scanlines (CoglPathNode *path, +@@ -245,12 +214,8 @@ _cogl_add_path_to_stencil_buffer (floatVec2 nodes_min, + GE( cogl_wrap_glMatrixMode (GL_PROJECTION) ); + GE( cogl_wrap_glPushMatrix () ); + GE( cogl_wrap_glLoadIdentity () ); +- cogl_rectanglex (-1.0, -1.0, +- (float)(2), +- (float)(2)); +- cogl_rectanglex (-1.0, -1.0, +- (float)(2), +- (float)(2)); ++ cogl_rectangle (-1.0, -1.0, 2, 2); ++ cogl_rectangle (-1.0, -1.0, 2, 2); + GE( cogl_wrap_glPopMatrix () ); + GE( cogl_wrap_glMatrixMode (GL_MODELVIEW) ); + GE( cogl_wrap_glPopMatrix () ); +@@ -436,10 +401,10 @@ _cogl_path_fill_nodes_scanlines (CoglPathNode *path, void _cogl_path_fill_nodes () { @@ -512,7 +527,7 @@ index d8fe121..cf305a8 100644 _COGL_GET_CONTEXT (ctx, NO_RETVAL); diff --git a/clutter/cogl/gles/cogl.c b/clutter/cogl/gles/cogl.c -index aa4e4fc..e835085 100644 +index f8c5413..997f24a 100644 --- a/clutter/cogl/gles/cogl.c +++ b/clutter/cogl/gles/cogl.c @@ -123,35 +123,15 @@ cogl_scale (float x, float y) @@ -554,6 +569,35 @@ index aa4e4fc..e835085 100644 } static inline gboolean +@@ -457,7 +437,7 @@ _cogl_add_stencil_clip (float x_offset, + GE( glStencilFunc (GL_NEVER, 0x1, 0x1) ); + GE( glStencilOp (GL_REPLACE, GL_REPLACE, GL_REPLACE) ); + +- cogl_rectanglex (x_offset, y_offset, width, height); ++ cogl_rectangle (x_offset, y_offset, width, height); + } + else + { +@@ -465,7 +445,7 @@ _cogl_add_stencil_clip (float x_offset, + rectangle */ + GE( glStencilFunc (GL_NEVER, 0x1, 0x3) ); + GE( glStencilOp (GL_INCR, GL_INCR, GL_INCR) ); +- cogl_rectanglex (x_offset, y_offset, width, height); ++ cogl_rectangle (x_offset, y_offset, width, height); + + /* Subtract one from all pixels in the stencil buffer so that + only pixels where both the original stencil buffer and the +@@ -476,9 +456,7 @@ _cogl_add_stencil_clip (float x_offset, + GE( cogl_wrap_glMatrixMode (GL_PROJECTION) ); + GE( cogl_wrap_glPushMatrix () ); + GE( cogl_wrap_glLoadIdentity () ); +- cogl_rectanglex (-1.0, -1.0, +- (float)(2), +- (float)(2)); ++ cogl_rectangle (-1.0, -1.0, 2, 2); + GE( cogl_wrap_glPopMatrix () ); + GE( cogl_wrap_glMatrixMode (GL_MODELVIEW) ); + GE( cogl_wrap_glPopMatrix () ); diff --git a/clutter/pango/cogl-pango-render.c b/clutter/pango/cogl-pango-render.c index 3e23309..3cafc81 100644 --- a/clutter/pango/cogl-pango-render.c diff --git a/fixed-to-float-patches/remove_cogl_apis_taking_fixed_params.1.patch b/fixed-to-float-patches/remove_cogl_apis_taking_fixed_params.1.patch deleted file mode 100644 index f04f60a7d..000000000 --- a/fixed-to-float-patches/remove_cogl_apis_taking_fixed_params.1.patch +++ /dev/null @@ -1,52 +0,0 @@ -diff --git a/clutter/cogl/gles/cogl-primitives.c b/clutter/cogl/gles/cogl-primitives.c -index cf305a8..1a58805 100644 ---- a/clutter/cogl/gles/cogl-primitives.c -+++ b/clutter/cogl/gles/cogl-primitives.c -@@ -214,12 +214,8 @@ _cogl_add_path_to_stencil_buffer (floatVec2 nodes_min, - GE( cogl_wrap_glMatrixMode (GL_PROJECTION) ); - GE( cogl_wrap_glPushMatrix () ); - GE( cogl_wrap_glLoadIdentity () ); -- cogl_rectanglex (-1.0, -1.0, -- (float)(2), -- (float)(2)); -- cogl_rectanglex (-1.0, -1.0, -- (float)(2), -- (float)(2)); -+ cogl_rectangle (-1.0, -1.0, 2, 2); -+ cogl_rectangle (-1.0, -1.0, 2, 2); - GE( cogl_wrap_glPopMatrix () ); - GE( cogl_wrap_glMatrixMode (GL_MODELVIEW) ); - GE( cogl_wrap_glPopMatrix () ); -diff --git a/clutter/cogl/gles/cogl.c b/clutter/cogl/gles/cogl.c -index e835085..fc73e44 100644 ---- a/clutter/cogl/gles/cogl.c -+++ b/clutter/cogl/gles/cogl.c -@@ -437,7 +437,7 @@ _cogl_add_stencil_clip (float x_offset, - GE( glStencilFunc (GL_NEVER, 0x1, 0x1) ); - GE( glStencilOp (GL_REPLACE, GL_REPLACE, GL_REPLACE) ); - -- cogl_rectanglex (x_offset, y_offset, width, height); -+ cogl_rectangle (x_offset, y_offset, width, height); - } - else - { -@@ -445,7 +445,7 @@ _cogl_add_stencil_clip (float x_offset, - rectangle */ - GE( glStencilFunc (GL_NEVER, 0x1, 0x3) ); - GE( glStencilOp (GL_INCR, GL_INCR, GL_INCR) ); -- cogl_rectanglex (x_offset, y_offset, width, height); -+ cogl_rectangle (x_offset, y_offset, width, height); - - /* Subtract one from all pixels in the stencil buffer so that - only pixels where both the original stencil buffer and the -@@ -456,9 +456,7 @@ _cogl_add_stencil_clip (float x_offset, - GE( cogl_wrap_glMatrixMode (GL_PROJECTION) ); - GE( cogl_wrap_glPushMatrix () ); - GE( cogl_wrap_glLoadIdentity () ); -- cogl_rectanglex (-1.0, -1.0, -- (float)(2), -- (float)(2)); -+ cogl_rectangle (-1.0, -1.0, 2, 2); - GE( cogl_wrap_glPopMatrix () ); - GE( cogl_wrap_glMatrixMode (GL_MODELVIEW) ); - GE( cogl_wrap_glPopMatrix () ); diff --git a/fixed-to-float.sh b/fixed-to-float.sh index feaa2b6ea..d52d16e2f 100755 --- a/fixed-to-float.sh +++ b/fixed-to-float.sh @@ -163,7 +163,6 @@ patch -p1 Date: Fri, 16 Jan 2009 14:55:48 +0000 Subject: [PATCH 20/26] [fixed-to-float-patches] Replace the cogl_color_*x functions with *f cogl_set_source_color4x and cogl_color_set_from_4x actually take float values now so they are renamed to *4f. --- ...move_cogl_apis_taking_fixed_params.0.patch | 123 ++++++++++++++++++ 1 file changed, 123 insertions(+) diff --git a/fixed-to-float-patches/remove_cogl_apis_taking_fixed_params.0.patch b/fixed-to-float-patches/remove_cogl_apis_taking_fixed_params.0.patch index 42e81d2bf..90749c565 100644 --- a/fixed-to-float-patches/remove_cogl_apis_taking_fixed_params.0.patch +++ b/fixed-to-float-patches/remove_cogl_apis_taking_fixed_params.0.patch @@ -84,6 +84,55 @@ index 9cbee04..e0903fe 100644 } /* Recursively applies the transforms associated with this actor and +diff --git a/clutter/cogl/cogl-color.h b/clutter/cogl/cogl-color.h +index 6cdf52b..05650d3 100644 +--- a/clutter/cogl/cogl-color.h ++++ b/clutter/cogl/cogl-color.h +@@ -68,7 +68,7 @@ void cogl_color_set_from_4d (CoglColor *dest, + gdouble alpha); + + /** +- * cogl_color_set_from_4x: ++ * cogl_color_set_from_4f: + * @dest: return location for a #CoglColor + * @red: value of the red channel, between 0 and %1.0 + * @green: value of the green channel, between 0 and %1.0 +@@ -79,7 +79,7 @@ void cogl_color_set_from_4d (CoglColor *dest, + * + * Since: 1.0 + */ +-void cogl_color_set_from_4x (CoglColor *dest, ++void cogl_color_set_from_4f (CoglColor *dest, + float red, + float green, + float blue, +@@ -248,7 +248,7 @@ float cogl_color_get_alpha (const CoglColor *color); + * Sets the source color using normalized values for each component. + * This color will be used for any subsequent drawing operation. + * +- * See also cogl_set_source_color4ub() and cogl_set_source_color4x() ++ * See also cogl_set_source_color4ub() and cogl_set_source_color4f() + * if you already have the color components. + * + * Since: 1.0 +@@ -276,7 +276,7 @@ void cogl_set_source_color4ub (guint8 red, + guint8 alpha); + + /** +- * cogl_set_source_color4x: ++ * cogl_set_source_color4f: + * @red: value of the red channel, between 0 and %1.0 + * @green: value of the green channel, between 0 and %1.0 + * @blue: value of the blue channel, between 0 and %1.0 +@@ -291,7 +291,7 @@ void cogl_set_source_color4ub (guint8 red, + * + * Since: 1.0 + */ +-void cogl_set_source_color4x (float red, ++void cogl_set_source_color4f (float red, + float green, + float blue, + float alpha); diff --git a/clutter/cogl/cogl-path.h b/clutter/cogl/cogl-path.h index 0d29829..aa37864 100644 --- a/clutter/cogl/cogl-path.h @@ -192,6 +241,35 @@ index f37d54d..f8d5745 100644 /** * cogl_get_modelview_matrix: +diff --git a/clutter/cogl/common/cogl-color.c b/clutter/cogl/common/cogl-color.c +index dac3584..e4b74c6 100644 +--- a/clutter/cogl/common/cogl-color.c ++++ b/clutter/cogl/common/cogl-color.c +@@ -58,7 +58,7 @@ cogl_color_set_from_4d (CoglColor *dest, + } + + void +-cogl_color_set_from_4x (CoglColor *dest, ++cogl_color_set_from_4f (CoglColor *dest, + float red, + float green, + float blue, +@@ -157,13 +157,13 @@ cogl_set_source_color4ub (guint8 red, + } + + void +-cogl_set_source_color4x (float red, ++cogl_set_source_color4f (float red, + float green, + float blue, + float alpha) + { + CoglColor c = { 0, }; + +- cogl_color_set_from_4x (&c, red, green, blue, alpha); ++ cogl_color_set_from_4f (&c, red, green, blue, alpha); + cogl_set_source_color (&c); + } diff --git a/clutter/cogl/common/cogl-primitives.c b/clutter/cogl/common/cogl-primitives.c index 27834f7..7e9b1b9 100644 --- a/clutter/cogl/common/cogl-primitives.c @@ -611,3 +689,48 @@ index 3e23309..3cafc81 100644 } static void +diff --git a/doc/reference/cogl/cogl-sections.txt b/doc/reference/cogl/cogl-sections.txt +index dcd7c93..db4e16a 100644 +--- a/doc/reference/cogl/cogl-sections.txt ++++ b/doc/reference/cogl/cogl-sections.txt +@@ -89,7 +89,7 @@ cogl_path_stroke + cogl_path_stroke_preserve + cogl_set_source_color + cogl_set_source_color4ub +-cogl_set_source_color4x ++cogl_set_source_color4f + + + cogl_rectangle +@@ -257,7 +257,7 @@ cogl_color_copy + cogl_color_free + cogl_color_set_from_4ub + cogl_color_set_from_4d +-cogl_color_set_from_4x ++cogl_color_set_from_4f + + + cogl_color_get_red +diff --git a/tests/conform/test-backface-culling.c b/tests/conform/test-backface-culling.c +index 3b7948e..b22228b 100644 +--- a/tests/conform/test-backface-culling.c ++++ b/tests/conform/test-backface-culling.c +@@ -121,8 +121,7 @@ on_paint (ClutterActor *actor, TestState *state) + + /* Set the color to white so that all the textures will be drawn + at their own color */ +- cogl_set_source_color4x (COGL_FIXED_1, COGL_FIXED_1, +- COGL_FIXED_1, COGL_FIXED_1); ++ cogl_set_source_color4f (1.0f, 1.0f, 1.0f, 1.0f); + + x2 = x1 + COGL_FIXED_FROM_INT (TEXTURE_SIZE); + +@@ -173,7 +172,7 @@ on_paint (ClutterActor *actor, TestState *state) + x2 = x1 + COGL_FIXED_FROM_INT (TEXTURE_SIZE); + + /* Draw a regular rectangle (this should always show) */ +- cogl_set_source_color4x (COGL_FIXED_1, 0, 0, COGL_FIXED_1); ++ cogl_set_source_color4f (1.0f, 0.0f, 0.0f, 1.0f); + cogl_rectangle (COGL_FIXED_TO_INT (x1), COGL_FIXED_TO_INT (y1), + COGL_FIXED_TO_INT (x2 - x1), COGL_FIXED_TO_INT (y2 - y1)); + From 7a96ea925515916f946147fd0fee5fcac7fe6c36 Mon Sep 17 00:00:00 2001 From: Neil Roberts Date: Fri, 16 Jan 2009 17:52:26 +0000 Subject: [PATCH 21/26] [fixed-to-float.sh] Group some of the sed expressions into one command This has no effect other than to make the script run faster. --- fixed-to-float.sh | 121 +++++++++++++++++++++++++--------------------- 1 file changed, 66 insertions(+), 55 deletions(-) diff --git a/fixed-to-float.sh b/fixed-to-float.sh index d52d16e2f..b9c2bf1d0 100755 --- a/fixed-to-float.sh +++ b/fixed-to-float.sh @@ -4,29 +4,34 @@ # CoglFixed type + macros using fixed point so now we convert all uses of # the Cogl fixed point macros within Clutter proper to use the ClutterFixed # macros instead. -find ./clutter -maxdepth 1 -iname '*.c' -exec sed -i 's/COGL_FIXED_MUL/CLUTTER_FIXED_MUL/g' {} \; -find ./clutter -maxdepth 1 -iname '*.c' -exec sed -i 's/COGL_FIXED_DIV/CLUTTER_FIXED_DIV/g' {} \; -find ./clutter -maxdepth 1 -iname '*.c' -exec sed -i 's/COGL_FIXED_FAST_MUL/CLUTTER_FIXED_MUL/g' {} \; -find ./clutter -maxdepth 1 -iname '*.c' -exec sed -i 's/COGL_FIXED_FAST_DIV/CLUTTER_FIXED_DIV/g' {} \; -find ./clutter -maxdepth 1 -iname '*.c' -exec sed -i 's/COGL_FIXED_FROM_FLOAT/CLUTTER_FLOAT_TO_FIXED/g' {} \; -find ./clutter -maxdepth 1 -iname '*.c' -exec sed -i 's/COGL_FIXED_TO_FLOAT/CLUTTER_FIXED_TO_FLOAT/g' {} \; -find ./clutter -maxdepth 1 -iname '*.c' -exec sed -i 's/COGL_FIXED_TO_DOUBLE/CLUTTER_FIXED_TO_DOUBLE/g' {} \; -find ./clutter -maxdepth 1 -iname '*.c' -exec sed -i 's/COGL_FIXED_PI/CFX_PI/g' {} \; +find ./clutter -maxdepth 1 -iname '*.c' -exec sed -i \ +-e 's/COGL_FIXED_MUL/CLUTTER_FIXED_MUL/g' \ +-e 's/COGL_FIXED_DIV/CLUTTER_FIXED_DIV/g' \ +-e 's/COGL_FIXED_FAST_MUL/CLUTTER_FIXED_MUL/g' \ +-e 's/COGL_FIXED_FAST_DIV/CLUTTER_FIXED_DIV/g' \ +-e 's/COGL_FIXED_FROM_FLOAT/CLUTTER_FLOAT_TO_FIXED/g' \ +-e 's/COGL_FIXED_TO_FLOAT/CLUTTER_FIXED_TO_FLOAT/g' \ +-e 's/COGL_FIXED_TO_DOUBLE/CLUTTER_FIXED_TO_DOUBLE/g' \ +-e 's/COGL_FIXED_PI/CFX_PI/g' \ +{} \; # All remaining uses of the Cogl fixed point API now get expanded out to simply # use float calculations... (we will restore the cogl-fixed code itself later) -# XXX: This assumes that no nested function - with multiple arguments - is ever -# found as the RHS argument to COGL_FIXED_MUL. This is because we simply replace -# the last ',' with the * operator. If you want to double check that's still true: +# XXX: The following three assume that no nested function - with +# multiple arguments - is ever found as the RHS argument to +# COGL_FIXED_MUL. This is because we simply replace the last ',' with +# the * operator. If you want to double check that's still true: # $ grep -r --include=*.c COGL_FIXED_MUL *|less -find ./clutter -iname '*.[ch]' -exec sed -i -r 's/COGL_FIXED_MUL (.*),/\1 */g' {} \; -# XXX: We use the same assumption here... -find ./clutter -iname '*.[ch]' -exec sed -i -r 's|COGL_FIXED_FAST_DIV (.*),|\1 /|g' {} \; -# XXX: And again here. (Note in this case there were examples of COGL_FIXED_MUL -# being used as the RHS argument, but since we have already replaced instances -# of COGL_FIXED_MUL, that works out ok. -find ./clutter -iname '*.[ch]' -exec sed -i -r 's|COGL_FIXED_DIV (.*),|\1 /|g' {} \; +# +# XXX: (Note in the third regexp there were examples of COGL_FIXED_MUL +# being used as the RHS argument, but since we have already replaced +# instances of COGL_FIXED_MUL, that works out ok. +find ./clutter -iname '*.[ch]' -exec sed -i -r \ +-e 's/COGL_FIXED_MUL (.*),/\1 */g' \ +-e 's|COGL_FIXED_FAST_DIV (.*),|\1 /|g' \ +-e 's|COGL_FIXED_DIV (.*),|\1 /|g' \ +{} \; # A fix due to the assumptions used above sed -i 's/#define DET2X(a,b,c,d).*/#define DET2X(a,b,c,d) ((a * d) - (b * c))/g' ./clutter/clutter-actor.c @@ -35,45 +40,51 @@ find ./clutter/cogl/gles -iname '*.[ch]' -exec sed -i 's/GLfixed/GLfloat/g' {} \ #we get some redundant brackets like this, but C's automatic type promotion #works out fine for most cases... -find ./clutter -iname '*.[ch]' -exec sed -i 's/COGL_FIXED_TO_INT//g' {} \; -find ./clutter -iname '*.[ch]' -exec sed -i 's/COGL_FIXED_FROM_INT /(float)/g' {} \; -find ./clutter -iname '*.[ch]' -exec sed -i 's/COGL_FIXED_FROM_INT/(float)/g' {} \; -find ./clutter -iname '*.[ch]' -exec sed -i 's/COGL_FIXED_TO_FLOAT//g' {} \; -find ./clutter -iname '*.[ch]' -exec sed -i 's/COGL_FIXED_FROM_FLOAT//g' {} \; -find ./clutter -iname '*.[ch]' -exec sed -i 's/COGL_FIXED_TO_DOUBLE /(double)/g' {} \; - -find ./clutter -iname '*.[ch]' -exec sed -i 's/COGL_FIXED_FLOOR/floorf/g' {} \; -find ./clutter -iname '*.[ch]' -exec sed -i 's/COGL_FIXED_CEIL/ceilf/g' {} \; -find ./clutter -iname '*.[ch]' -exec sed -i 's/COGL_FIXED_360/360.0/g' {} \; -find ./clutter -iname '*.[ch]' -exec sed -i 's/COGL_FIXED_240/240.0/g' {} \; -find ./clutter -iname '*.[ch]' -exec sed -i 's/COGL_FIXED_255/255.0/g' {} \; -find ./clutter -iname '*.[ch]' -exec sed -i 's/COGL_FIXED_180/180.0/g' {} \; -find ./clutter -iname '*.[ch]' -exec sed -i 's/COGL_FIXED_120/120.0/g' {} \; -find ./clutter -iname '*.[ch]' -exec sed -i 's/COGL_FIXED_60/60.0/g' {} \; -find ./clutter -iname '*.[ch]' -exec sed -i 's/COGL_FIXED_1/1.0/g' {} \; -find ./clutter -iname '*.[ch]' -exec sed -i 's/COGL_FIXED_0_5/0.5/g' {} \; -find ./clutter -iname '*.[ch]' -exec sed -i 's/COGL_FIXED_PI/G_PI/g' {} \; - -find ./clutter -iname '*.[ch]' -exec sed -i -r 's/COGL_ANGLE_FROM_DEG \((.*)\),/\1,/g' {} \; - -find ./clutter -iname '*.[ch]' -exec perl -p -i -e "s|cogl_angle_cos \((.*?)\)|cosf (\1 * (G_PI/180.0))|;" {} \; -find ./clutter -iname '*.[ch]' -exec perl -p -i -e "s|cogl_angle_sin \((.*?)\)|sinf (\1 * (G_PI/180.0))|;" {} \; -find ./clutter -iname '*.[ch]' -exec perl -p -i -e "s|cogl_angle_tan \((.*?)\)|tanf (\1 * (G_PI/180.0))|;" {} \; +find ./clutter -iname '*.[ch]' -exec sed -r -i \ +-e 's/COGL_FIXED_TO_INT//g' \ +-e 's/COGL_FIXED_FROM_INT /(float)/g' \ +-e 's/COGL_FIXED_FROM_INT/(float)/g' \ +-e 's/COGL_FIXED_TO_FLOAT//g' \ +-e 's/COGL_FIXED_FROM_FLOAT//g' \ +-e 's/COGL_FIXED_TO_DOUBLE /(double)/g' \ +\ +-e 's/COGL_FIXED_FLOOR/floorf/g' \ +-e 's/COGL_FIXED_CEIL/ceilf/g' \ +-e 's/COGL_FIXED_360/360.0/g' \ +-e 's/COGL_FIXED_240/240.0/g' \ +-e 's/COGL_FIXED_255/255.0/g' \ +-e 's/COGL_FIXED_180/180.0/g' \ +-e 's/COGL_FIXED_120/120.0/g' \ +-e 's/COGL_FIXED_60/60.0/g' \ +-e 's/COGL_FIXED_1/1.0/g' \ +-e 's/COGL_FIXED_0_5/0.5/g' \ +-e 's/COGL_FIXED_PI/G_PI/g' \ +\ +-e 's/COGL_ANGLE_FROM_DEG \((.*)\),/\1,/g' \ +{} \; \ +\ +-exec perl -p -i \ +-e "s|cogl_angle_cos \((.*?)\)|cosf (\1 * (G_PI/180.0))|;" \ +-e "s|cogl_angle_sin \((.*?)\)|sinf (\1 * (G_PI/180.0))|;" \ +-e "s|cogl_angle_tan \((.*?)\)|tanf (\1 * (G_PI/180.0))|;" \ +{} \; #XXX: NB: cogl_fixed_div must be done before mul since there is a case were they #are nested which would otherwise break the assumption used here that the last #coma of the line can simply be replaced with the corresponding operator -find ./clutter -iname '*.[ch]' -exec sed -i -r 's|cogl_fixed_div (.*),|\1 /|g' {} \; -find ./clutter -iname '*.[ch]' -exec sed -i -r 's|cogl_fixed_mul (.*),|\1 *|g' {} \; -find ./clutter -iname '*.[ch]' -exec sed -i 's/cogl_fixed_pow2/pow2f/g' {} \; -find ./clutter -iname '*.[ch]' -exec sed -i 's/cogl_fixed_pow/powf/g' {} \; -find ./clutter -iname '*.[ch]' -exec sed -i 's/cogl_fixed_log2/log2f/g' {} \; -find ./clutter -iname '*.[ch]' -exec sed -i 's/cogl_fixed_sqrt/sqrtf/g' {} \; -find ./clutter -iname '*.[ch]' -exec sed -i 's/cogl_fixed_cos/cosf/g' {} \; -find ./clutter -iname '*.[ch]' -exec sed -i 's/cogl_fixed_sin/sinf/g' {} \; -find ./clutter -iname '*.[ch]' -exec sed -i 's/cogl_fixed_atan2/atan2f/g' {} \; -find ./clutter -iname '*.[ch]' -exec sed -i 's/cogl_fixed_atan/atanf/g' {} \; -find ./clutter -iname '*.[ch]' -exec sed -i 's/cogl_fixed_tan/tanf/g' {} \; +find ./clutter -iname '*.[ch]' -exec sed -i -r \ +-e 's|cogl_fixed_div (.*),|\1 /|g' \ +-e 's|cogl_fixed_mul (.*),|\1 *|g' \ +-e 's/cogl_fixed_pow2/pow2f/g' \ +-e 's/cogl_fixed_pow/powf/g' \ +-e 's/cogl_fixed_log2/log2f/g' \ +-e 's/cogl_fixed_sqrt/sqrtf/g' \ +-e 's/cogl_fixed_cos/cosf/g' \ +-e 's/cogl_fixed_sin/sinf/g' \ +-e 's/cogl_fixed_atan2/atan2f/g' \ +-e 's/cogl_fixed_atan/atanf/g' \ +-e 's/cogl_fixed_tan/tanf/g' \ +{} \; #TODO: fixup gles/cogl.c set_clip_plane @@ -94,8 +105,8 @@ mv ./tmp clutter/cogl/common/cogl-primitives.c #find ./clutter -iname '*.[ch]' -exec sed -i 's|>> 1|/ 2|g' {} \; #find ./clutter -iname '*.[ch]' -exec sed -i 's|<< 1|* 2|g' {} \; -sed -i 's|>> 1|/ 2|g' ./clutter/cogl/common/cogl-primitives.c -sed -i 's|<< 1|* 2|g' ./clutter/cogl/common/cogl-primitives.c +sed -i -e 's|>> 1|/ 2|g' -e 's|<< 1|* 2|g' \ + ./clutter/cogl/common/cogl-primitives.c #find ./clutter -iname '*.[ch]' -exec sed -i 's|<< 1|* 2|g' {} \; From ae3615cfe3efa8c36fdfcfe1b00c1cedac785829 Mon Sep 17 00:00:00 2001 From: Neil Roberts Date: Fri, 16 Jan 2009 18:29:29 +0000 Subject: [PATCH 22/26] [fixed-to-float.sh] Apply the automatic changes to the tests as well Some of the tests are using the Cogl API so they should be updated to float as well. The patches have been updated to apply cleanly. --- ...move_cogl_apis_taking_fixed_params.0.patch | 25 +++++++++---------- .../test-cogl-tex-tile.c.0.patch | 25 ++++++------------- fixed-to-float.sh | 23 +++++++++-------- 3 files changed, 32 insertions(+), 41 deletions(-) diff --git a/fixed-to-float-patches/remove_cogl_apis_taking_fixed_params.0.patch b/fixed-to-float-patches/remove_cogl_apis_taking_fixed_params.0.patch index 90749c565..1d8f96e35 100644 --- a/fixed-to-float-patches/remove_cogl_apis_taking_fixed_params.0.patch +++ b/fixed-to-float-patches/remove_cogl_apis_taking_fixed_params.0.patch @@ -712,25 +712,24 @@ index dcd7c93..db4e16a 100644 cogl_color_get_red diff --git a/tests/conform/test-backface-culling.c b/tests/conform/test-backface-culling.c -index 3b7948e..b22228b 100644 +index 50c19fd..6303949 100644 --- a/tests/conform/test-backface-culling.c +++ b/tests/conform/test-backface-culling.c -@@ -121,8 +121,7 @@ on_paint (ClutterActor *actor, TestState *state) +@@ -121,7 +121,7 @@ on_paint (ClutterActor *actor, TestState *state) /* Set the color to white so that all the textures will be drawn at their own color */ -- cogl_set_source_color4x (COGL_FIXED_1, COGL_FIXED_1, -- COGL_FIXED_1, COGL_FIXED_1); -+ cogl_set_source_color4f (1.0f, 1.0f, 1.0f, 1.0f); +- cogl_set_source_color4x (1.0, 1.0, ++ cogl_set_source_color4f (1.0, 1.0, + 1.0, 1.0); - x2 = x1 + COGL_FIXED_FROM_INT (TEXTURE_SIZE); - -@@ -173,7 +172,7 @@ on_paint (ClutterActor *actor, TestState *state) - x2 = x1 + COGL_FIXED_FROM_INT (TEXTURE_SIZE); + x2 = x1 + (float)(TEXTURE_SIZE); +@@ -173,7 +173,7 @@ on_paint (ClutterActor *actor, TestState *state) + x2 = x1 + (float)(TEXTURE_SIZE); /* Draw a regular rectangle (this should always show) */ -- cogl_set_source_color4x (COGL_FIXED_1, 0, 0, COGL_FIXED_1); -+ cogl_set_source_color4f (1.0f, 0.0f, 0.0f, 1.0f); - cogl_rectangle (COGL_FIXED_TO_INT (x1), COGL_FIXED_TO_INT (y1), - COGL_FIXED_TO_INT (x2 - x1), COGL_FIXED_TO_INT (y2 - y1)); +- cogl_set_source_color4x (1.0, 0, 0, 1.0); ++ cogl_set_source_color4f (1.0, 0, 0, 1.0); + cogl_rectangle ( (x1), (y1), + (x2 - x1), (y2 - y1)); diff --git a/fixed-to-float-patches/test-cogl-tex-tile.c.0.patch b/fixed-to-float-patches/test-cogl-tex-tile.c.0.patch index 45aa82337..aa2ec683a 100644 --- a/fixed-to-float-patches/test-cogl-tex-tile.c.0.patch +++ b/fixed-to-float-patches/test-cogl-tex-tile.c.0.patch @@ -1,35 +1,24 @@ diff --git a/tests/interactive/test-cogl-tex-tile.c b/tests/interactive/test-cogl-tex-tile.c -index fe7138a..5be6dd5 100644 +index 5063dff..177d60e 100644 --- a/tests/interactive/test-cogl-tex-tile.c +++ b/tests/interactive/test-cogl-tex-tile.c -@@ -90,22 +90,22 @@ test_coglbox_paint(ClutterActor *self) +@@ -90,14 +90,14 @@ test_coglbox_paint(ClutterActor *self) ClutterFixed sin_frame, cos_frame; ClutterFixed frac_frame; gint t; - sin_frame = clutter_sini (CLUTTER_ANGLE_FROM_DEG (priv->frame)); - cos_frame = clutter_cosi (CLUTTER_ANGLE_FROM_DEG (priv->frame)); -+ sin_frame = clutter_sinx (CLUTTER_INT_TO_FIXED (priv->frame)); -+ cos_frame = clutter_cosx (CLUTTER_INT_TO_FIXED (priv->frame)); ++ sin_frame = clutter_sinx (priv->frame); ++ cos_frame = clutter_cosx (priv->frame); pingpong_frame = (priv->frame <= 180 ? priv->frame : 360 - priv->frame); -- frac_frame = COGL_FIXED_DIV (CLUTTER_INT_TO_FIXED (pingpong_frame), + frac_frame = (CLUTTER_INT_TO_FIXED (pingpong_frame) / - CLUTTER_INT_TO_FIXED (180)); -- frac_frame += (COGL_FIXED_1 >> 1); +- frac_frame += (1.0 >> 1); - frac_frame <<= 1; -+ frac_frame = CLUTTER_FIXED_DIV (CLUTTER_INT_TO_FIXED (pingpong_frame), -+ CLUTTER_INT_TO_FIXED (180)); ++ CLUTTER_INT_TO_FIXED (180)); + frac_frame += 0.5; + frac_frame *= 2; for (t=0; t<4; t+=2) { - texcoords[t] += cos_frame; - texcoords[t+1] += sin_frame; - -- texcoords[t] = COGL_FIXED_MUL (texcoords[t], frac_frame); -- texcoords[t+1] = COGL_FIXED_MUL (texcoords[t+1], frac_frame); -+ texcoords[t] = CLUTTER_FIXED_MUL (texcoords[t], frac_frame); -+ texcoords[t+1] = CLUTTER_FIXED_MUL (texcoords[t+1], frac_frame); - } - - priv = TEST_COGLBOX_GET_PRIVATE (self); diff --git a/fixed-to-float.sh b/fixed-to-float.sh index b9c2bf1d0..520b4d893 100755 --- a/fixed-to-float.sh +++ b/fixed-to-float.sh @@ -4,7 +4,7 @@ # CoglFixed type + macros using fixed point so now we convert all uses of # the Cogl fixed point macros within Clutter proper to use the ClutterFixed # macros instead. -find ./clutter -maxdepth 1 -iname '*.c' -exec sed -i \ +find ./clutter ./tests -maxdepth 1 -iname '*.c' -exec sed -i \ -e 's/COGL_FIXED_MUL/CLUTTER_FIXED_MUL/g' \ -e 's/COGL_FIXED_DIV/CLUTTER_FIXED_DIV/g' \ -e 's/COGL_FIXED_FAST_MUL/CLUTTER_FIXED_MUL/g' \ @@ -27,7 +27,7 @@ find ./clutter -maxdepth 1 -iname '*.c' -exec sed -i \ # XXX: (Note in the third regexp there were examples of COGL_FIXED_MUL # being used as the RHS argument, but since we have already replaced # instances of COGL_FIXED_MUL, that works out ok. -find ./clutter -iname '*.[ch]' -exec sed -i -r \ +find ./clutter ./tests -iname '*.[ch]' -exec sed -i -r \ -e 's/COGL_FIXED_MUL (.*),/\1 */g' \ -e 's|COGL_FIXED_FAST_DIV (.*),|\1 /|g' \ -e 's|COGL_FIXED_DIV (.*),|\1 /|g' \ @@ -40,7 +40,7 @@ find ./clutter/cogl/gles -iname '*.[ch]' -exec sed -i 's/GLfixed/GLfloat/g' {} \ #we get some redundant brackets like this, but C's automatic type promotion #works out fine for most cases... -find ./clutter -iname '*.[ch]' -exec sed -r -i \ +find ./clutter ./tests -iname '*.[ch]' -exec sed -r -i \ -e 's/COGL_FIXED_TO_INT//g' \ -e 's/COGL_FIXED_FROM_INT /(float)/g' \ -e 's/COGL_FIXED_FROM_INT/(float)/g' \ @@ -72,7 +72,7 @@ find ./clutter -iname '*.[ch]' -exec sed -r -i \ #XXX: NB: cogl_fixed_div must be done before mul since there is a case were they #are nested which would otherwise break the assumption used here that the last #coma of the line can simply be replaced with the corresponding operator -find ./clutter -iname '*.[ch]' -exec sed -i -r \ +find ./clutter ./tests -iname '*.[ch]' -exec sed -i -r \ -e 's|cogl_fixed_div (.*),|\1 /|g' \ -e 's|cogl_fixed_mul (.*),|\1 *|g' \ -e 's/cogl_fixed_pow2/pow2f/g' \ @@ -110,9 +110,11 @@ sed -i -e 's|>> 1|/ 2|g' -e 's|<< 1|* 2|g' \ #find ./clutter -iname '*.[ch]' -exec sed -i 's|<< 1|* 2|g' {} \; -find ./clutter -iname '*.[ch]' -exec sed -i 's/CoglFixed/float/g' {} \; +find ./clutter ./tests -iname '*.[ch]' \ +-exec sed -i 's/CoglFixed/float/g' {} \; #XXX: This might need changing later... -find ./clutter -iname '*.[ch]' -exec sed -i 's/CoglFixedVec2/CoglVec2/g' {} \; +find ./clutter ./tests -iname '*.[ch]' \ +-exec sed -i 's/CoglFixedVec2/CoglVec2/g' {} \; sed -i 's/CoglFixed/float/g' ./clutter/cogl/cogl.h.in # maintain the existing CoglFixed code as utility code for applications: @@ -120,14 +122,15 @@ sed -i 's/float:/CoglFixed:/g' clutter/cogl/cogl-types.h sed -i 's/gint32 float/gint32 CoglFixed/g' clutter/cogl/cogl-types.h git-checkout clutter/cogl/cogl-fixed.h clutter/cogl/common/cogl-fixed.c -find ./clutter -iname '*.[ch]' -exec sed -i 's/CoglAngle/float/g' {} \; +find ./clutter ./tests -iname '*.[ch]' -exec sed -i 's/CoglAngle/float/g' {} \; # maintain the existing CoglAngle code as utility code for applications: sed -i 's/float:/CoglAngle:/g' clutter/cogl/cogl-types.h sed -i 's/gint32 float/gint32 CoglAngle/g' clutter/cogl/cogl-types.h git-checkout clutter/cogl/cogl-fixed.h clutter/cogl/common/cogl-fixed.c -find ./clutter -iname '*.[ch]' ! -iname 'clutter-fixed.h' -exec sed -i 's/ClutterAngle/float/g' {} \; +find ./clutter ./tests -iname '*.[ch]' ! -iname 'clutter-fixed.h' \ +-exec sed -i 's/ClutterAngle/float/g' {} \; # use the floating point names for GL ES functions instead of the # fixed. These get #define'd to the float versions in one of the @@ -137,9 +140,9 @@ find ./clutter/cogl -iname '*.[ch]' -exec perl -p -i -e \ |glRotate|glOrtho|glTexEnv|glClipPlane|glFog|glColor4))x(v?)\b/$1f$2/gx' {} \; echo "Cogl API to remove/replace with float versions:" -find ./clutter/ -iname '*.c' -exec grep '^cogl_[a-zA-Z_]*x ' {} \; | cut -d' ' -f1|grep -v 'box$'|grep -v 'matrix$' +find ./clutter/ ./tests -iname '*.c' -exec grep '^cogl_[a-zA-Z_]*x ' {} \; | cut -d' ' -f1|grep -v 'box$'|grep -v 'matrix$' echo "Clutter API to remove/replace with float versions:" -find ./clutter/ -iname '*.c' -exec grep '^clutter_[a-zA-Z_]*x ' {} \; | cut -d' ' -f1|grep -v 'box$'|grep -v 'matrix$'|grep -v '_x$' +find ./clutter/ ./tests -iname '*.c' -exec grep '^clutter_[a-zA-Z_]*x ' {} \; | cut -d' ' -f1|grep -v 'box$'|grep -v 'matrix$'|grep -v '_x$' # # Now the last mile is dealt with manually with a bunch of patches... From abc2a359ea5981989ec7c3c793e4bb5b7c5b5d55 Mon Sep 17 00:00:00 2001 From: Robert Bragg Date: Tue, 20 Jan 2009 14:52:47 +0000 Subject: [PATCH 23/26] Improves the git commit messages used by fixed-to-float.sh In preperation for commiting a final conversion into master --- fixed-to-float.sh | 50 ++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 47 insertions(+), 3 deletions(-) diff --git a/fixed-to-float.sh b/fixed-to-float.sh index 520b4d893..7652349a5 100755 --- a/fixed-to-float.sh +++ b/fixed-to-float.sh @@ -148,7 +148,34 @@ find ./clutter/ ./tests -iname '*.c' -exec grep '^clutter_[a-zA-Z_]*x ' {} \; | # Now the last mile is dealt with manually with a bunch of patches... # -git-commit -a -m "[By fixed-to-float.sh] Fixed to Float automatic changes" --no-verify +cat > log_message < log_message < log_message < Date: Tue, 20 Jan 2009 16:20:54 +0000 Subject: [PATCH 24/26] [Automatic fixed-to-float.sh change] Applies all scripted changes This is the result of running a number of sed and perl scripts over the code to do 90% of the work in converting from 16.16 fixed to single precision floating point. Note: A pristine cogl-fixed.c has been maintained as a standalone utility API so that applications may still take advantage of fixed point if they desire for certain optimisations where lower precision may be acceptable. Note: no API changes were made in Clutter, only in Cogl. Overview of changes: - Within clutter/* all usage of the COGL_FIXED_ macros have been changed to use the CLUTTER_FIXED_ macros. - Within cogl/* all usage of the COGL_FIXED_ macros have been completly stripped and expanded into code that works with single precision floats instead. - Uses of cogl_fixed_* have been replaced with single precision math.h alternatives. - Uses of COGL_ANGLE_* and cogl_angle_* have been replaced so we use a float for angles and math.h replacements. --- clutter/clutter-actor.c | 174 +++++++-------- clutter/clutter-alpha.c | 50 ++--- clutter/clutter-backend.c | 4 +- clutter/clutter-behaviour-depth.c | 4 +- clutter/clutter-behaviour-ellipse.c | 74 +++---- clutter/clutter-behaviour-rotate.c | 32 +-- clutter/clutter-behaviour-scale.c | 50 ++--- clutter/clutter-clone-texture.c | 16 +- clutter/clutter-color.c | 152 ++++++------- clutter/clutter-fixed.c | 16 +- clutter/clutter-fixed.h | 70 +++--- clutter/clutter-interval.c | 2 +- clutter/clutter-stage.c | 44 ++-- clutter/clutter-texture.c | 56 ++--- clutter/clutter-timeline.c | 8 +- clutter/clutter-units.h | 8 +- clutter/cogl/cogl-color.h | 50 ++--- clutter/cogl/cogl-path.h | 100 ++++----- clutter/cogl/cogl-texture.h | 20 +- clutter/cogl/cogl-types.h | 4 +- clutter/cogl/cogl.h.in | 68 +++--- clutter/cogl/common/cogl-clip-stack.c | 46 ++-- clutter/cogl/common/cogl-color.c | 40 ++-- clutter/cogl/common/cogl-primitives.c | 292 ++++++++++++------------- clutter/cogl/common/cogl-primitives.h | 22 +- clutter/cogl/gl/cogl-context.h | 8 +- clutter/cogl/gl/cogl-primitives.c | 44 ++-- clutter/cogl/gl/cogl-texture.c | 226 +++++++++---------- clutter/cogl/gl/cogl.c | 278 +++++++++++------------ clutter/cogl/gles/cogl-context.c | 2 +- clutter/cogl/gles/cogl-context.h | 10 +- clutter/cogl/gles/cogl-fbo.c | 12 +- clutter/cogl/gles/cogl-gles2-wrapper.c | 126 +++++------ clutter/cogl/gles/cogl-gles2-wrapper.h | 54 ++--- clutter/cogl/gles/cogl-primitives.c | 70 +++--- clutter/cogl/gles/cogl-texture.c | 240 ++++++++++---------- clutter/cogl/gles/cogl.c | 256 +++++++++++----------- clutter/pango/cogl-pango-glyph-cache.c | 8 +- clutter/pango/cogl-pango-glyph-cache.h | 8 +- clutter/pango/cogl-pango-render.c | 70 +++--- tests/conform/test-backface-culling.c | 38 ++-- tests/interactive/test-cogl-tex-tile.c | 8 +- tests/interactive/test-text-field.c | 2 +- 43 files changed, 1428 insertions(+), 1434 deletions(-) diff --git a/clutter/clutter-actor.c b/clutter/clutter-actor.c index 2f39c4f0c..1e481cd2b 100644 --- a/clutter/clutter-actor.c +++ b/clutter/clutter-actor.c @@ -774,12 +774,12 @@ clutter_actor_real_allocate (ClutterActor *self, g_object_thaw_notify (G_OBJECT (self)); } -/* like ClutterVertex, but using CoglFixed and with a w component */ +/* like ClutterVertex, but using float and with a w component */ typedef struct { - CoglFixed x; - CoglFixed y; - CoglFixed z; - CoglFixed w; + float x; + float y; + float z; + float w; } fixed_vertex_t; /* copies a fixed vertex into a ClutterVertex */ @@ -816,25 +816,25 @@ mtx_transform (const ClutterFixed m[], /* We care lot about precision here, so have to use MUL instead * of FAST_MUL */ - vertex->x = COGL_FIXED_MUL (M (m, 0, 0), _x) - + COGL_FIXED_MUL (M (m, 0, 1), _y) - + COGL_FIXED_MUL (M (m, 0, 2), _z) - + COGL_FIXED_MUL (M (m, 0, 3), _w); + vertex->x = CLUTTER_FIXED_MUL (M (m, 0, 0), _x) + + CLUTTER_FIXED_MUL (M (m, 0, 1), _y) + + CLUTTER_FIXED_MUL (M (m, 0, 2), _z) + + CLUTTER_FIXED_MUL (M (m, 0, 3), _w); - vertex->y = COGL_FIXED_MUL (M (m, 1, 0), _x) - + COGL_FIXED_MUL (M (m, 1, 1), _y) - + COGL_FIXED_MUL (M (m, 1, 2), _z) - + COGL_FIXED_MUL (M (m, 1, 3), _w); + vertex->y = CLUTTER_FIXED_MUL (M (m, 1, 0), _x) + + CLUTTER_FIXED_MUL (M (m, 1, 1), _y) + + CLUTTER_FIXED_MUL (M (m, 1, 2), _z) + + CLUTTER_FIXED_MUL (M (m, 1, 3), _w); - vertex->z = COGL_FIXED_MUL (M (m, 2, 0), _x) - + COGL_FIXED_MUL (M (m, 2, 1), _y) - + COGL_FIXED_MUL (M (m, 2, 2), _z) - + COGL_FIXED_MUL (M (m, 2, 3), _w); + vertex->z = CLUTTER_FIXED_MUL (M (m, 2, 0), _x) + + CLUTTER_FIXED_MUL (M (m, 2, 1), _y) + + CLUTTER_FIXED_MUL (M (m, 2, 2), _z) + + CLUTTER_FIXED_MUL (M (m, 2, 3), _w); - vertex->w = COGL_FIXED_MUL (M (m, 3, 0), _x) - + COGL_FIXED_MUL (M (m, 3, 1), _y) - + COGL_FIXED_MUL (M (m, 3, 2), _z) - + COGL_FIXED_MUL (M (m, 3, 3), _w); + vertex->w = CLUTTER_FIXED_MUL (M (m, 3, 0), _x) + + CLUTTER_FIXED_MUL (M (m, 3, 1), _y) + + CLUTTER_FIXED_MUL (M (m, 3, 2), _z) + + CLUTTER_FIXED_MUL (M (m, 3, 3), _w); /* Specially for Matthew: was going to put a comment here, but could not * think of anything at all to say ;) @@ -846,8 +846,8 @@ mtx_transform (const ClutterFixed m[], /* Help macros to scale from OpenGL <-1,1> coordinates system to our * X-window based <0,window-size> coordinates */ -#define MTX_GL_SCALE_X(x,w,v1,v2) (COGL_FIXED_MUL (((COGL_FIXED_DIV ((x), (w)) + COGL_FIXED_1) >> 1), (v1)) + (v2)) -#define MTX_GL_SCALE_Y(y,w,v1,v2) ((v1) - COGL_FIXED_MUL (((COGL_FIXED_DIV ((y), (w)) + COGL_FIXED_1) >> 1), (v1)) + (v2)) +#define MTX_GL_SCALE_X(x,w,v1,v2) (CLUTTER_FIXED_MUL (((CLUTTER_FIXED_DIV ((x), (w)) + 1.0) >> 1), (v1)) + (v2)) +#define MTX_GL_SCALE_Y(y,w,v1,v2) ((v1) - CLUTTER_FIXED_MUL (((CLUTTER_FIXED_DIV ((y), (w)) + 1.0) >> 1), (v1)) + (v2)) #define MTX_GL_SCALE_Z(z,w,v1,v2) (MTX_GL_SCALE_X ((z), (w), (v1), (v2))) /* transforms a 4-tuple of coordinates using @matrix and @@ -1024,7 +1024,7 @@ clutter_actor_apply_relative_transform_to_point (ClutterActor *self, x = CLUTTER_UNITS_TO_FIXED (vertex->x); y = CLUTTER_UNITS_TO_FIXED (vertex->y); z = CLUTTER_UNITS_TO_FIXED (vertex->z); - w = COGL_FIXED_1; + w = 1.0; /* First we tranform the point using the OpenGL modelview matrix */ clutter_actor_transform_point_relative (self, ancestor, &x, &y, &z, &w); @@ -1035,9 +1035,9 @@ clutter_actor_apply_relative_transform_to_point (ClutterActor *self, * The w[3] parameter should always be 1.0 here, so we ignore it; otherwise * we would have to divide the original verts with it. */ - tmp.x = COGL_FIXED_MUL (CLUTTER_UNITS_TO_FIXED (x) + COGL_FIXED_0_5, v[2]); - tmp.y = COGL_FIXED_MUL (COGL_FIXED_0_5 - CLUTTER_UNITS_TO_FIXED (y), v[3]); - tmp.z = COGL_FIXED_MUL (CLUTTER_UNITS_TO_FIXED (z) + COGL_FIXED_0_5, v[2]); + tmp.x = CLUTTER_FIXED_MUL (CLUTTER_UNITS_TO_FIXED (x) + 0.5, v[2]); + tmp.y = CLUTTER_FIXED_MUL (0.5 - CLUTTER_UNITS_TO_FIXED (y), v[3]); + tmp.z = CLUTTER_FIXED_MUL (CLUTTER_UNITS_TO_FIXED (z) + 0.5, v[2]); tmp.w = 0; fixed_vertex_to_units (&tmp, vertex); @@ -1119,10 +1119,10 @@ clutter_actor_transform_vertices_relative (ClutterActor *self, cogl_get_modelview_matrix (mtx); - fixed_vertex_transform (mtx, 0, 0, 0, COGL_FIXED_1, &vertices[0]); - fixed_vertex_transform (mtx, width, 0, 0, COGL_FIXED_1, &vertices[1]); - fixed_vertex_transform (mtx, 0, height, 0, COGL_FIXED_1, &vertices[2]); - fixed_vertex_transform (mtx, width, height, 0, COGL_FIXED_1, &vertices[3]); + fixed_vertex_transform (mtx, 0, 0, 0, 1.0, &vertices[0]); + fixed_vertex_transform (mtx, width, 0, 0, 1.0, &vertices[1]); + fixed_vertex_transform (mtx, 0, height, 0, 1.0, &vertices[2]); + fixed_vertex_transform (mtx, width, height, 0, 1.0, &vertices[3]); cogl_pop_matrix(); } @@ -1171,10 +1171,10 @@ clutter_actor_transform_and_project_box (ClutterActor *self, cogl_get_modelview_matrix (mtx); - fixed_vertex_transform (mtx, 0, 0, 0, COGL_FIXED_1, &vertices[0]); - fixed_vertex_transform (mtx, width, 0, 0, COGL_FIXED_1, &vertices[1]); - fixed_vertex_transform (mtx, 0, height, 0, COGL_FIXED_1, &vertices[2]); - fixed_vertex_transform (mtx, width, height, 0, COGL_FIXED_1, &vertices[3]); + fixed_vertex_transform (mtx, 0, 0, 0, 1.0, &vertices[0]); + fixed_vertex_transform (mtx, width, 0, 0, 1.0, &vertices[1]); + fixed_vertex_transform (mtx, 0, height, 0, 1.0, &vertices[2]); + fixed_vertex_transform (mtx, width, height, 0, 1.0, &vertices[3]); cogl_pop_matrix(); @@ -1261,24 +1261,24 @@ clutter_actor_get_allocation_vertices (ClutterActor *self, * The w[3] parameter should always be 1.0 here, so we ignore it; * otherwise we would have to divide the original verts with it. */ - tmp.x = COGL_FIXED_MUL ((vertices[0].x + COGL_FIXED_0_5), v[2]); - tmp.y = COGL_FIXED_MUL ((COGL_FIXED_0_5 - vertices[0].y), v[3]); - tmp.z = COGL_FIXED_MUL ((vertices[0].z + COGL_FIXED_0_5), v[2]); + tmp.x = CLUTTER_FIXED_MUL ((vertices[0].x + 0.5), v[2]); + tmp.y = CLUTTER_FIXED_MUL ((0.5 - vertices[0].y), v[3]); + tmp.z = CLUTTER_FIXED_MUL ((vertices[0].z + 0.5), v[2]); fixed_vertex_to_units (&tmp, &verts[0]); - tmp.x = COGL_FIXED_MUL ((vertices[1].x + COGL_FIXED_0_5), v[2]); - tmp.y = COGL_FIXED_MUL ((COGL_FIXED_0_5 - vertices[1].y), v[3]); - tmp.z = COGL_FIXED_MUL ((vertices[1].z + COGL_FIXED_0_5), v[2]); + tmp.x = CLUTTER_FIXED_MUL ((vertices[1].x + 0.5), v[2]); + tmp.y = CLUTTER_FIXED_MUL ((0.5 - vertices[1].y), v[3]); + tmp.z = CLUTTER_FIXED_MUL ((vertices[1].z + 0.5), v[2]); fixed_vertex_to_units (&tmp, &verts[1]); - tmp.x = COGL_FIXED_MUL ((vertices[2].x + COGL_FIXED_0_5), v[2]); - tmp.y = COGL_FIXED_MUL ((COGL_FIXED_0_5 - vertices[2].y), v[3]); - tmp.z = COGL_FIXED_MUL ((vertices[2].z + COGL_FIXED_0_5), v[2]); + tmp.x = CLUTTER_FIXED_MUL ((vertices[2].x + 0.5), v[2]); + tmp.y = CLUTTER_FIXED_MUL ((0.5 - vertices[2].y), v[3]); + tmp.z = CLUTTER_FIXED_MUL ((vertices[2].z + 0.5), v[2]); fixed_vertex_to_units (&tmp, &verts[2]); - tmp.x = COGL_FIXED_MUL ((vertices[3].x + COGL_FIXED_0_5), v[2]); - tmp.y = COGL_FIXED_MUL ((COGL_FIXED_0_5 - vertices[3].y), v[3]); - tmp.z = COGL_FIXED_MUL ((vertices[3].z + COGL_FIXED_0_5), v[2]); + tmp.x = CLUTTER_FIXED_MUL ((vertices[3].x + 0.5), v[2]); + tmp.y = CLUTTER_FIXED_MUL ((0.5 - vertices[3].y), v[3]); + tmp.z = CLUTTER_FIXED_MUL ((vertices[3].z + 0.5), v[2]); fixed_vertex_to_units (&tmp, &verts[3]); } @@ -1355,7 +1355,7 @@ _clutter_actor_apply_modelview_transform (ClutterActor *self) * the translations included in the rotation are not scaled and so the * entire object will move on the screen as a result of rotating it). */ - if (priv->scale_x != COGL_FIXED_1 || priv->scale_y != COGL_FIXED_1) + if (priv->scale_x != 1.0 || priv->scale_y != 1.0) cogl_scale (priv->scale_x, priv->scale_y); if (priv->rzang) @@ -1364,7 +1364,7 @@ _clutter_actor_apply_modelview_transform (ClutterActor *self) CLUTTER_UNITS_TO_FIXED (priv->rzy), 0); - cogl_rotatex (priv->rzang, 0, 0, COGL_FIXED_1); + cogl_rotatex (priv->rzang, 0, 0, 1.0); cogl_translatex (CLUTTER_UNITS_TO_FIXED (-priv->rzx), CLUTTER_UNITS_TO_FIXED (-priv->rzy), @@ -1377,7 +1377,7 @@ _clutter_actor_apply_modelview_transform (ClutterActor *self) 0, CLUTTER_UNITS_TO_FIXED (priv->z + priv->ryz)); - cogl_rotatex (priv->ryang, 0, COGL_FIXED_1, 0); + cogl_rotatex (priv->ryang, 0, 1.0, 0); cogl_translatex (CLUTTER_UNITS_TO_FIXED (-priv->ryx), 0, @@ -1390,7 +1390,7 @@ _clutter_actor_apply_modelview_transform (ClutterActor *self) CLUTTER_UNITS_TO_FIXED (priv->rxy), CLUTTER_UNITS_TO_FIXED (priv->z + priv->rxz)); - cogl_rotatex (priv->rxang, COGL_FIXED_1, 0, 0); + cogl_rotatex (priv->rxang, 1.0, 0, 0); cogl_translatex (0, CLUTTER_UNITS_TO_FIXED (-priv->rxy), @@ -1656,14 +1656,14 @@ clutter_actor_set_property (GObject *object, case PROP_SCALE_X: clutter_actor_set_scalex (actor, - COGL_FIXED_FROM_FLOAT (g_value_get_double (value)), + CLUTTER_FLOAT_TO_FIXED (g_value_get_double (value)), priv->scale_y); break; case PROP_SCALE_Y: clutter_actor_set_scalex (actor, priv->scale_x, - COGL_FIXED_FROM_FLOAT (g_value_get_double (value))); + CLUTTER_FLOAT_TO_FIXED (g_value_get_double (value))); break; case PROP_CLIP: { @@ -1681,7 +1681,7 @@ clutter_actor_set_property (GObject *object, { ClutterFixed angle; - angle = COGL_FIXED_FROM_FLOAT (g_value_get_double (value)); + angle = CLUTTER_FLOAT_TO_FIXED (g_value_get_double (value)); clutter_actor_set_rotation_internal (actor, CLUTTER_X_AXIS, angle, @@ -1694,7 +1694,7 @@ clutter_actor_set_property (GObject *object, { ClutterFixed angle; - angle = COGL_FIXED_FROM_FLOAT (g_value_get_double (value)); + angle = CLUTTER_FLOAT_TO_FIXED (g_value_get_double (value)); clutter_actor_set_rotation_internal (actor, CLUTTER_Y_AXIS, angle, @@ -1707,7 +1707,7 @@ clutter_actor_set_property (GObject *object, { ClutterFixed angle; - angle = COGL_FIXED_FROM_FLOAT (g_value_get_double (value)); + angle = CLUTTER_FLOAT_TO_FIXED (g_value_get_double (value)); clutter_actor_set_rotation_internal (actor, CLUTTER_Z_AXIS, angle, @@ -1877,22 +1877,22 @@ clutter_actor_get_property (GObject *object, } break; case PROP_SCALE_X: - g_value_set_double (value, COGL_FIXED_TO_DOUBLE (priv->scale_x)); + g_value_set_double (value, CLUTTER_FIXED_TO_DOUBLE (priv->scale_x)); break; case PROP_SCALE_Y: - g_value_set_double (value, COGL_FIXED_TO_DOUBLE (priv->scale_y)); + g_value_set_double (value, CLUTTER_FIXED_TO_DOUBLE (priv->scale_y)); break; case PROP_REACTIVE: g_value_set_boolean (value, clutter_actor_get_reactive (actor)); break; case PROP_ROTATION_ANGLE_X: - g_value_set_double (value, COGL_FIXED_TO_DOUBLE (priv->rxang)); + g_value_set_double (value, CLUTTER_FIXED_TO_DOUBLE (priv->rxang)); break; case PROP_ROTATION_ANGLE_Y: - g_value_set_double (value, COGL_FIXED_TO_DOUBLE (priv->ryang)); + g_value_set_double (value, CLUTTER_FIXED_TO_DOUBLE (priv->ryang)); break; case PROP_ROTATION_ANGLE_Z: - g_value_set_double (value, COGL_FIXED_TO_DOUBLE (priv->rzang)); + g_value_set_double (value, CLUTTER_FIXED_TO_DOUBLE (priv->rzang)); break; case PROP_ROTATION_CENTER_X: { @@ -3020,8 +3020,8 @@ clutter_actor_init (ClutterActor *self) priv->has_clip = FALSE; priv->opacity = 0xff; priv->id = clutter_id_pool_add (CLUTTER_CONTEXT()->id_pool, self); - priv->scale_x = COGL_FIXED_1; - priv->scale_y = COGL_FIXED_1; + priv->scale_x = 1.0; + priv->scale_y = 1.0; priv->shader_data = NULL; priv->show_on_set_parent = TRUE; @@ -4916,8 +4916,8 @@ clutter_actor_set_scale (ClutterActor *self, g_return_if_fail (CLUTTER_IS_ACTOR (self)); clutter_actor_set_scalex (self, - COGL_FIXED_FROM_FLOAT (scale_x), - COGL_FIXED_FROM_FLOAT (scale_y)); + CLUTTER_FLOAT_TO_FIXED (scale_x), + CLUTTER_FLOAT_TO_FIXED (scale_y)); } /** @@ -4964,10 +4964,10 @@ clutter_actor_get_scale (ClutterActor *self, g_return_if_fail (CLUTTER_IS_ACTOR (self)); if (scale_x) - *scale_x = COGL_FIXED_TO_FLOAT (self->priv->scale_x); + *scale_x = CLUTTER_FIXED_TO_FLOAT (self->priv->scale_x); if (scale_y) - *scale_y = COGL_FIXED_TO_FLOAT (self->priv->scale_y); + *scale_y = CLUTTER_FIXED_TO_FLOAT (self->priv->scale_y); } /** @@ -5224,7 +5224,7 @@ clutter_actor_set_rotationu (ClutterActor *self, g_return_if_fail (CLUTTER_IS_ACTOR (self)); clutter_actor_set_rotation_internal (self, axis, - COGL_FIXED_FROM_FLOAT (angle), + CLUTTER_FLOAT_TO_FIXED (angle), x, y, z); } @@ -5294,7 +5294,7 @@ clutter_actor_set_rotation (ClutterActor *self, g_return_if_fail (CLUTTER_IS_ACTOR (self)); clutter_actor_set_rotationx (self, axis, - COGL_FIXED_FROM_FLOAT (angle), + CLUTTER_FLOAT_TO_FIXED (angle), x, y, z); } @@ -5335,7 +5335,7 @@ clutter_actor_get_rotationu (ClutterActor *self, switch (axis) { case CLUTTER_X_AXIS: - retval = COGL_FIXED_TO_DOUBLE (priv->rxang); + retval = CLUTTER_FIXED_TO_DOUBLE (priv->rxang); if (y) *y = priv->rxy; if (z) @@ -5343,7 +5343,7 @@ clutter_actor_get_rotationu (ClutterActor *self, break; case CLUTTER_Y_AXIS: - retval = COGL_FIXED_TO_DOUBLE (priv->ryang); + retval = CLUTTER_FIXED_TO_DOUBLE (priv->ryang); if (x) *x = priv->ryx; if (z) @@ -5351,7 +5351,7 @@ clutter_actor_get_rotationu (ClutterActor *self, break; case CLUTTER_Z_AXIS: - retval = COGL_FIXED_TO_DOUBLE (priv->rzang); + retval = CLUTTER_FIXED_TO_DOUBLE (priv->rzang); if (x) *x = priv->rzx; if (y) @@ -5450,7 +5450,7 @@ clutter_actor_get_rotation (ClutterActor *self, { g_return_val_if_fail (CLUTTER_IS_ACTOR (self), 0.0); - return COGL_FIXED_TO_FLOAT (clutter_actor_get_rotationx (self, + return CLUTTER_FIXED_TO_FLOAT (clutter_actor_get_rotationx (self, axis, x, y, z)); } @@ -6612,7 +6612,7 @@ parse_rotation_array (ClutterActor *actor, /* angle */ element = json_array_get_element (array, 0); if (JSON_NODE_TYPE (element) == JSON_NODE_VALUE) - info->angle = COGL_FIXED_FROM_FLOAT (json_node_get_double (element)); + info->angle = CLUTTER_FLOAT_TO_FIXED (json_node_get_double (element)); else return FALSE; @@ -6918,12 +6918,12 @@ clutter_actor_transform_stage_point (ClutterActor *self, if (!du || !dv) return FALSE; -#define FP2FX COGL_FIXED_FROM_FLOAT -#define FX2FP COGL_FIXED_TO_DOUBLE +#define FP2FX CLUTTER_FLOAT_TO_FIXED +#define FX2FP CLUTTER_FIXED_TO_DOUBLE #define UX2FP CLUTTER_UNITS_TO_FLOAT #define UX2FX CLUTTER_UNITS_TO_FIXED #define FP2INT CLUTTER_FLOAT_TO_INT -#define DET2X(a,b,c,d) (COGL_FIXED_MUL ((a), (d)) - COGL_FIXED_MUL ((b), (c))) +#define DET2X(a,b,c,d) ((a * d) - (b * c)) #define DET2FP(a,b,c,d) ((a) * (d) - (b) * (c)) /* @@ -6946,7 +6946,7 @@ clutter_actor_transform_stage_point (ClutterActor *self, RQ[2][1] = UX2FX (v[0].y); RQ[0][2] = 0; RQ[1][2] = 0; - RQ[2][2] = COGL_FIXED_1; + RQ[2][2] = 1.0; } else { @@ -6976,16 +6976,16 @@ clutter_actor_transform_stage_point (ClutterActor *self, RQ[0][2] = FP2FX (DET2FP (UX2FP (px), dx2, UX2FP (py), dy2) / del); RQ[1][2] = FP2FX (DET2FP (dx1, UX2FP (px), dy1, UX2FP (py)) / del); RQ[1][2] = FP2FX (DET2FP (dx1, UX2FP (px), dy1, UX2FP (py)) / del); - RQ[2][2] = COGL_FIXED_1; + RQ[2][2] = 1.0; RQ[0][0] = UX2FX (v[1].x - v[0].x) - + COGL_FIXED_MUL (RQ[0][2], UX2FX (v[1].x)); + + CLUTTER_FIXED_MUL (RQ[0][2], UX2FX (v[1].x)); RQ[1][0] = UX2FX (v[2].x - v[0].x) - + COGL_FIXED_MUL (RQ[1][2], UX2FX (v[2].x)); + + CLUTTER_FIXED_MUL (RQ[1][2], UX2FX (v[2].x)); RQ[2][0] = UX2FX (v[0].x); RQ[0][1] = UX2FX (v[1].y - v[0].y) - + COGL_FIXED_MUL (RQ[0][2], UX2FX (v[1].y)); + + CLUTTER_FIXED_MUL (RQ[0][2], UX2FX (v[1].y)); RQ[1][1] = UX2FX (v[2].y - v[0].y) - + COGL_FIXED_MUL (RQ[1][2], UX2FX (v[2].y)); + + CLUTTER_FIXED_MUL (RQ[1][2], UX2FX (v[2].y)); RQ[2][1] = UX2FX (v[0].y); } @@ -7017,9 +7017,9 @@ clutter_actor_transform_stage_point (ClutterActor *self, /* * Check the resutling martix is OK. */ - det = COGL_FIXED_MUL (RQ[0][0], ST[0][0]) - + COGL_FIXED_MUL (RQ[0][1], ST[0][1]) - + COGL_FIXED_MUL (RQ[0][2], ST[0][2]); + det = CLUTTER_FIXED_MUL (RQ[0][0], ST[0][0]) + + CLUTTER_FIXED_MUL (RQ[0][1], ST[0][1]) + + CLUTTER_FIXED_MUL (RQ[0][2], ST[0][2]); if (!det) return FALSE; @@ -7481,7 +7481,7 @@ clutter_actor_is_scaled (ClutterActor *self) priv = self->priv; - if (priv->scale_x != COGL_FIXED_1 || priv->scale_y != COGL_FIXED_1) + if (priv->scale_x != 1.0 || priv->scale_y != 1.0) return TRUE; return FALSE; diff --git a/clutter/clutter-alpha.c b/clutter/clutter-alpha.c index dc1dddeba..60ef0d396 100644 --- a/clutter/clutter-alpha.c +++ b/clutter/clutter-alpha.c @@ -699,12 +699,12 @@ clutter_ramp_func (ClutterAlpha *alpha, static guint32 sincx1024_func (ClutterAlpha *alpha, - ClutterAngle angle, + float angle, ClutterFixed offset) { ClutterTimeline *timeline; gint current_frame_num, n_frames; - ClutterAngle x; + float x; ClutterFixed sine; timeline = clutter_alpha_get_timeline (alpha); @@ -716,7 +716,7 @@ sincx1024_func (ClutterAlpha *alpha, x -= (512 * 512 / angle); - sine = ((cogl_angle_sin (x) + offset) / 2) + sine = ((sinf (x * (G_PI/180.0)) + offset) / 2) * CLUTTER_ALPHA_MAX_ALPHA; sine = sine >> COGL_FIXED_Q; @@ -744,14 +744,14 @@ sincx_func (ClutterAlpha *alpha, n_frames = clutter_timeline_get_n_frames (timeline); x = angle * current_frame_num / n_frames; - x = COGL_FIXED_FAST_MUL (x, COGL_FIXED_PI) - - COGL_FIXED_FAST_DIV (COGL_FIXED_PI, angle); + x = CLUTTER_FIXED_MUL (x, CFX_PI) + - CLUTTER_FIXED_DIV (CFX_PI, angle); - sine = (cogl_fixed_sin (x) + offset) / 2; + sine = (sinf (x) + offset) / 2; - CLUTTER_NOTE (ALPHA, "sine: %2f\n", COGL_FIXED_TO_DOUBLE (sine)); + CLUTTER_NOTE (ALPHA, "sine: %2f\n", CLUTTER_FIXED_TO_DOUBLE (sine)); - return COGL_FIXED_TO_INT (sine * CLUTTER_ALPHA_MAX_ALPHA); + return (sine * CLUTTER_ALPHA_MAX_ALPHA); } /* NB: angle is not in radians but in muliples of PI, i.e., 2.0 @@ -810,7 +810,7 @@ clutter_sine_func (ClutterAlpha *alpha, return sinc_func (alpha, 2.0, 1.0); #else /* 2.0 above represents full circle */ - return sincx1024_func (alpha, 1024, COGL_FIXED_1); + return sincx1024_func (alpha, 1024, 1.0); #endif } @@ -842,7 +842,7 @@ clutter_sine_inc_func (ClutterAlpha *alpha, ClutterTimeline * timeline; gint frame; gint n_frames; - ClutterAngle x; + float x; ClutterFixed sine; timeline = clutter_alpha_get_timeline (alpha); @@ -851,7 +851,7 @@ clutter_sine_inc_func (ClutterAlpha *alpha, x = 256 * frame / n_frames; - sine = cogl_angle_sin (x) * CLUTTER_ALPHA_MAX_ALPHA; + sine = sinf (x * (G_PI/180.0)) * CLUTTER_ALPHA_MAX_ALPHA; return ((guint32) sine) >> COGL_FIXED_Q; } @@ -884,7 +884,7 @@ clutter_sine_dec_func (ClutterAlpha *alpha, ClutterTimeline * timeline; gint frame; gint n_frames; - ClutterAngle x; + float x; ClutterFixed sine; timeline = clutter_alpha_get_timeline (alpha); @@ -893,7 +893,7 @@ clutter_sine_dec_func (ClutterAlpha *alpha, x = 256 * frame / n_frames + 256; - sine = cogl_angle_sin (x) * CLUTTER_ALPHA_MAX_ALPHA; + sine = sinf (x * (G_PI/180.0)) * CLUTTER_ALPHA_MAX_ALPHA; return ((guint32) sine) >> COGL_FIXED_Q; } @@ -926,7 +926,7 @@ clutter_sine_half_func (ClutterAlpha *alpha, ClutterTimeline *timeline; gint frame; gint n_frames; - ClutterAngle x; + float x; ClutterFixed sine; timeline = clutter_alpha_get_timeline (alpha); @@ -935,7 +935,7 @@ clutter_sine_half_func (ClutterAlpha *alpha, x = 512 * frame / n_frames; - sine = cogl_angle_sin (x) * CLUTTER_ALPHA_MAX_ALPHA; + sine = sinf (x * (G_PI/180.0)) * CLUTTER_ALPHA_MAX_ALPHA; return ((guint32) sine) >> COGL_FIXED_Q; } @@ -962,7 +962,7 @@ clutter_sine_in_func (ClutterAlpha *alpha, ClutterTimeline *timeline; gint frame; gint n_frames; - ClutterAngle x; + float x; ClutterFixed sine; timeline = clutter_alpha_get_timeline (alpha); @@ -972,7 +972,7 @@ clutter_sine_in_func (ClutterAlpha *alpha, /* XXX- if we use 768 we overflow */ x = 256 * frame / n_frames + 767; - sine = (cogl_angle_sin (x) + 1) * CLUTTER_ALPHA_MAX_ALPHA; + sine = (sinf (x * (G_PI/180.0)) + 1) * CLUTTER_ALPHA_MAX_ALPHA; return ((guint32) sine) >> COGL_FIXED_Q; } @@ -998,7 +998,7 @@ clutter_sine_out_func (ClutterAlpha *alpha, ClutterTimeline *timeline; gint frame; gint n_frames; - ClutterAngle x; + float x; ClutterFixed sine; timeline = clutter_alpha_get_timeline (alpha); @@ -1007,7 +1007,7 @@ clutter_sine_out_func (ClutterAlpha *alpha, x = 256 * frame / n_frames; - sine = cogl_angle_sin (x) * CLUTTER_ALPHA_MAX_ALPHA; + sine = sinf (x * (G_PI/180.0)) * CLUTTER_ALPHA_MAX_ALPHA; return ((guint32) sine) >> COGL_FIXED_Q; } @@ -1034,7 +1034,7 @@ clutter_sine_in_out_func (ClutterAlpha *alpha, ClutterTimeline *timeline; gint frame; gint n_frames; - ClutterAngle x; + float x; ClutterFixed sine; timeline = clutter_alpha_get_timeline (alpha); @@ -1043,7 +1043,7 @@ clutter_sine_in_out_func (ClutterAlpha *alpha, x = -256 * frame / n_frames + 256; - sine = (cogl_angle_sin (x) + 1) / 2 * CLUTTER_ALPHA_MAX_ALPHA; + sine = (sinf (x * (G_PI/180.0)) + 1) / 2 * CLUTTER_ALPHA_MAX_ALPHA; return ((guint32) sine) >> COGL_FIXED_Q; } @@ -1129,7 +1129,7 @@ clutter_smoothstep_inc_func (ClutterAlpha *alpha, /* * Convert x to 8.24 for next step. */ - x = COGL_FIXED_FAST_DIV (frame, n_frames) << 8; + x = CLUTTER_FIXED_DIV (frame, n_frames) << 8; /* * f(x) = -2x^3 + 3x^2 @@ -1138,7 +1138,7 @@ clutter_smoothstep_inc_func (ClutterAlpha *alpha, */ r = ((x >> 12) * (x >> 12) * 3 - (x >> 15) * (x >> 16) * (x >> 16)) >> 8; - return COGL_FIXED_TO_INT (r * CLUTTER_ALPHA_MAX_ALPHA); + return (r * CLUTTER_ALPHA_MAX_ALPHA); } /** @@ -1214,7 +1214,7 @@ clutter_exp_inc_func (ClutterAlpha *alpha, x = x_alpha_max * frame / n_frames; - result = CLAMP (cogl_fixed_pow2 (x) - 1, 0, CLUTTER_ALPHA_MAX_ALPHA); + result = CLAMP (pow2f (x) - 1, 0, CLUTTER_ALPHA_MAX_ALPHA); return result; } @@ -1265,7 +1265,7 @@ clutter_exp_dec_func (ClutterAlpha *alpha, x = (x_alpha_max * (n_frames - frame)) / n_frames; - result = CLAMP (cogl_fixed_pow2 (x) - 1, 0, CLUTTER_ALPHA_MAX_ALPHA); + result = CLAMP (pow2f (x) - 1, 0, CLUTTER_ALPHA_MAX_ALPHA); return result; } diff --git a/clutter/clutter-backend.c b/clutter/clutter-backend.c index efeeac185..2dd8a442e 100644 --- a/clutter/clutter-backend.c +++ b/clutter/clutter-backend.c @@ -416,7 +416,7 @@ clutter_backend_set_resolution (ClutterBackend *backend, priv = backend->priv; - fixed_dpi = COGL_FIXED_FROM_FLOAT (dpi); + fixed_dpi = CLUTTER_FLOAT_TO_FIXED (dpi); if (priv->resolution != fixed_dpi) priv->resolution = fixed_dpi; @@ -443,7 +443,7 @@ clutter_backend_get_resolution (ClutterBackend *backend) { g_return_val_if_fail (CLUTTER_IS_BACKEND (backend), -1.0); - return COGL_FIXED_TO_FLOAT (backend->priv->resolution); + return CLUTTER_FIXED_TO_FLOAT (backend->priv->resolution); } /** diff --git a/clutter/clutter-behaviour-depth.c b/clutter/clutter-behaviour-depth.c index 90fc456af..0749b8e4d 100644 --- a/clutter/clutter-behaviour-depth.c +++ b/clutter/clutter-behaviour-depth.c @@ -83,9 +83,9 @@ clutter_behaviour_depth_alpha_notify (ClutterBehaviour *behaviour, priv = CLUTTER_BEHAVIOUR_DEPTH (behaviour)->priv; /* Need to create factor as to avoid borking signedness */ - factor = COGL_FIXED_FROM_INT (alpha_value) / CLUTTER_ALPHA_MAX_ALPHA; + factor = (float)(alpha_value) / CLUTTER_ALPHA_MAX_ALPHA; depth = priv->depth_start - + COGL_FIXED_TO_INT (factor * (priv->depth_end - priv->depth_start)); + + (factor * (priv->depth_end - priv->depth_start)); CLUTTER_NOTE (BEHAVIOUR, "alpha: %d, depth: %d", alpha_value, depth); diff --git a/clutter/clutter-behaviour-ellipse.c b/clutter/clutter-behaviour-ellipse.c index a5d4bff35..162a9492d 100644 --- a/clutter/clutter-behaviour-ellipse.c +++ b/clutter/clutter-behaviour-ellipse.c @@ -86,11 +86,11 @@ struct _ClutterBehaviourEllipsePrivate gint a; gint b; - ClutterAngle angle_start; - ClutterAngle angle_end; - ClutterAngle angle_tilt_x; - ClutterAngle angle_tilt_y; - ClutterAngle angle_tilt_z; + float angle_start; + float angle_end; + float angle_tilt_x; + float angle_tilt_y; + float angle_tilt_z; ClutterRotateDirection direction; }; @@ -104,14 +104,14 @@ typedef struct _knot3d static void clutter_behaviour_ellipse_advance (ClutterBehaviourEllipse *e, - ClutterAngle angle, + float angle, knot3d *knot) { ClutterBehaviourEllipsePrivate *priv = e->priv; gint x, y, z; - x = COGL_FIXED_TO_INT (priv->a * cogl_angle_cos (angle)); - y = COGL_FIXED_TO_INT (priv->b * cogl_angle_sin (angle)); + x = (priv->a * cosf (angle * (G_PI/180.0))); + y = (priv->b * sinf (angle * (G_PI/180.0))); z = 0; if (priv->angle_tilt_z) @@ -126,40 +126,40 @@ clutter_behaviour_ellipse_advance (ClutterBehaviourEllipse *e, */ ClutterFixed x2, y2; - x2 = x * cogl_angle_cos (priv->angle_tilt_z) - - y * cogl_angle_sin (priv->angle_tilt_z); + x2 = x * cosf (priv->angle_tilt_z * (G_PI/180.0)) + - y * sinf (priv->angle_tilt_z * (G_PI/180.0)); - y2 = y * cogl_angle_cos (priv->angle_tilt_z) - + x * cogl_angle_sin (priv->angle_tilt_z); + y2 = y * cosf (priv->angle_tilt_z * (G_PI/180.0)) + + x * sinf (priv->angle_tilt_z * (G_PI/180.0)); - x = COGL_FIXED_TO_INT (x2); - y = COGL_FIXED_TO_INT (y2); + x = (x2); + y = (y2); } if (priv->angle_tilt_x) { ClutterFixed z2, y2; - z2 = - y * cogl_angle_sin (priv->angle_tilt_x); + z2 = - y * sinf (priv->angle_tilt_x * (G_PI/180.0)); - y2 = y * cogl_angle_cos (priv->angle_tilt_x); + y2 = y * cosf (priv->angle_tilt_x * (G_PI/180.0)); - z = COGL_FIXED_TO_INT (z2); - y = COGL_FIXED_TO_INT (y2); + z = (z2); + y = (y2); } if (priv->angle_tilt_y) { ClutterFixed x2, z2; - x2 = x * cogl_angle_cos (priv->angle_tilt_y) - - z * cogl_angle_sin (priv->angle_tilt_y); + x2 = x * cosf (priv->angle_tilt_y * (G_PI/180.0)) + - z * sinf (priv->angle_tilt_y * (G_PI/180.0)); - z2 = z * cogl_angle_cos (priv->angle_tilt_y) - + x * cogl_angle_sin (priv->angle_tilt_y); + z2 = z * cosf (priv->angle_tilt_y * (G_PI/180.0)) + + x * sinf (priv->angle_tilt_y * (G_PI/180.0)); - x = COGL_FIXED_TO_INT (x2); - z = COGL_FIXED_TO_INT (z2); + x = (x2); + z = (z2); } knot->x = x; @@ -187,10 +187,10 @@ actor_apply_knot_foreach (ClutterBehaviour *behave, clutter_actor_set_depth (actor, knot->z); } -static inline ClutterAngle -clamp_angle (ClutterAngle a) +static inline float +clamp_angle (float a) { - ClutterAngle a1, a2; + float a1, a2; gint rounds; /* Need to add the 256 offset here, since the user space 0 maps to our @@ -209,9 +209,9 @@ clutter_behaviour_ellipse_alpha_notify (ClutterBehaviour *behave, { ClutterBehaviourEllipse *self = CLUTTER_BEHAVIOUR_ELLIPSE (behave); ClutterBehaviourEllipsePrivate *priv = self->priv; - ClutterAngle start, end; + float start, end; knot3d knot; - ClutterAngle angle = 0; + float angle = 0; start = priv->angle_start; end = priv->angle_end; @@ -783,7 +783,7 @@ clutter_behaviour_ellipse_set_angle_start (ClutterBehaviourEllipse *self, g_return_if_fail (CLUTTER_IS_BEHAVIOUR_ELLIPSE (self)); clutter_behaviour_ellipse_set_angle_startx (self, - COGL_FIXED_FROM_FLOAT (angle_start)); + CLUTTER_FLOAT_TO_FIXED (angle_start)); } /** @@ -802,7 +802,7 @@ clutter_behaviour_ellipse_set_angle_startx (ClutterBehaviourEllipse *self, ClutterFixed angle_start) { ClutterBehaviourEllipsePrivate *priv; - ClutterAngle new_angle; + float new_angle; g_return_if_fail (CLUTTER_IS_BEHAVIOUR_ELLIPSE (self)); new_angle = clamp_angle (COGL_ANGLE_FROM_DEGX (angle_start) - 256); @@ -868,7 +868,7 @@ clutter_behaviour_ellipse_set_angle_end (ClutterBehaviourEllipse *self, g_return_if_fail (CLUTTER_IS_BEHAVIOUR_ELLIPSE (self)); clutter_behaviour_ellipse_set_angle_endx (self, - COGL_FIXED_FROM_FLOAT (angle_end)); + CLUTTER_FLOAT_TO_FIXED (angle_end)); } /** @@ -887,7 +887,7 @@ clutter_behaviour_ellipse_set_angle_endx (ClutterBehaviourEllipse *self, ClutterFixed angle_end) { ClutterBehaviourEllipsePrivate *priv; - ClutterAngle new_angle; + float new_angle; g_return_if_fail (CLUTTER_IS_BEHAVIOUR_ELLIPSE (self)); @@ -959,7 +959,7 @@ clutter_behaviour_ellipse_set_angle_tilt (ClutterBehaviourEllipse *self, clutter_behaviour_ellipse_set_angle_tiltx (self, axis, - COGL_FIXED_FROM_FLOAT (angle_tilt)); + CLUTTER_FLOAT_TO_FIXED (angle_tilt)); } /** @@ -979,7 +979,7 @@ clutter_behaviour_ellipse_set_angle_tiltx (ClutterBehaviourEllipse *self, ClutterFixed angle_tilt) { ClutterBehaviourEllipsePrivate *priv; - ClutterAngle new_angle; + float new_angle; g_return_if_fail (CLUTTER_IS_BEHAVIOUR_ELLIPSE (self)); @@ -1096,7 +1096,7 @@ clutter_behaviour_ellipse_set_tilt (ClutterBehaviourEllipse *self, gdouble angle_tilt_z) { ClutterBehaviourEllipsePrivate *priv; - ClutterAngle new_angle_x, new_angle_y, new_angle_z; + float new_angle_x, new_angle_y, new_angle_z; g_return_if_fail (CLUTTER_IS_BEHAVIOUR_ELLIPSE (self)); @@ -1150,7 +1150,7 @@ clutter_behaviour_ellipse_set_tiltx (ClutterBehaviourEllipse *self, ClutterFixed angle_tilt_z) { ClutterBehaviourEllipsePrivate *priv; - ClutterAngle new_angle_x, new_angle_y, new_angle_z; + float new_angle_x, new_angle_y, new_angle_z; g_return_if_fail (CLUTTER_IS_BEHAVIOUR_ELLIPSE (self)); diff --git a/clutter/clutter-behaviour-rotate.c b/clutter/clutter-behaviour-rotate.c index 3e13c6dab..8bfa16e14 100644 --- a/clutter/clutter-behaviour-rotate.c +++ b/clutter/clutter-behaviour-rotate.c @@ -108,8 +108,8 @@ ClutterFixed clamp_angle (ClutterFixed a) ClutterFixed a1, a2; gint rounds; - rounds = a / COGL_FIXED_360; - a1 = rounds * COGL_FIXED_360; + rounds = a / 360.0; + a1 = rounds * 360.0; a2 = a - a1; return a2; @@ -126,7 +126,7 @@ clutter_behaviour_rotate_alpha_notify (ClutterBehaviour *behaviour, rotate_behaviour = CLUTTER_BEHAVIOUR_ROTATE (behaviour); priv = rotate_behaviour->priv; - factor = COGL_FIXED_FROM_INT (alpha_value) / CLUTTER_ALPHA_MAX_ALPHA; + factor = (float)(alpha_value) / CLUTTER_ALPHA_MAX_ALPHA; angle = 0; start = priv->angle_start; @@ -134,14 +134,14 @@ clutter_behaviour_rotate_alpha_notify (ClutterBehaviour *behaviour, if (priv->direction == CLUTTER_ROTATE_CW && start >= end) { - end += COGL_FIXED_360; + end += 360.0; } else if (priv->direction == CLUTTER_ROTATE_CCW && start <= end) { - end -= COGL_FIXED_360; + end -= 360.0; } - angle = COGL_FIXED_FAST_MUL ((end - start), factor) + start; + angle = CLUTTER_FIXED_MUL ((end - start), factor) + start; clutter_behaviour_actors_foreach (behaviour, alpha_notify_foreach, @@ -163,10 +163,10 @@ clutter_behaviour_rotate_set_property (GObject *gobject, switch (prop_id) { case PROP_ANGLE_START: - priv->angle_start = COGL_FIXED_FROM_FLOAT (g_value_get_double (value)); + priv->angle_start = CLUTTER_FLOAT_TO_FIXED (g_value_get_double (value)); break; case PROP_ANGLE_END: - priv->angle_end = COGL_FIXED_FROM_FLOAT (g_value_get_double (value)); + priv->angle_end = CLUTTER_FLOAT_TO_FIXED (g_value_get_double (value)); break; case PROP_AXIS: priv->axis = g_value_get_enum (value); @@ -211,10 +211,10 @@ clutter_behaviour_rotate_get_property (GObject *gobject, switch (prop_id) { case PROP_ANGLE_START: - g_value_set_double (value, COGL_FIXED_TO_DOUBLE (priv->angle_start)); + g_value_set_double (value, CLUTTER_FIXED_TO_DOUBLE (priv->angle_start)); break; case PROP_ANGLE_END: - g_value_set_double (value, COGL_FIXED_TO_DOUBLE (priv->angle_end)); + g_value_set_double (value, CLUTTER_FIXED_TO_DOUBLE (priv->angle_end)); break; case PROP_AXIS: g_value_set_enum (value, priv->axis); @@ -367,8 +367,8 @@ clutter_behaviour_rotate_init (ClutterBehaviourRotate *rotate) rotate->priv = priv = CLUTTER_BEHAVIOUR_ROTATE_GET_PRIVATE (rotate); - priv->angle_start = COGL_FIXED_FROM_FLOAT (0.0); - priv->angle_end = COGL_FIXED_FROM_FLOAT (0.0); + priv->angle_start = CLUTTER_FLOAT_TO_FIXED (0.0); + priv->angle_end = CLUTTER_FLOAT_TO_FIXED (0.0); priv->axis = CLUTTER_Z_AXIS; priv->direction = CLUTTER_ROTATE_CW; priv->center_x = priv->center_y = priv->center_z = 0; @@ -568,10 +568,10 @@ clutter_behaviour_rotate_get_bounds (ClutterBehaviourRotate *rotate, priv = rotate->priv; if (angle_start) - *angle_start = COGL_FIXED_TO_DOUBLE (priv->angle_start); + *angle_start = CLUTTER_FIXED_TO_DOUBLE (priv->angle_start); if (angle_end) - *angle_end = COGL_FIXED_TO_DOUBLE (priv->angle_end); + *angle_end = CLUTTER_FIXED_TO_DOUBLE (priv->angle_end); } /** @@ -593,8 +593,8 @@ clutter_behaviour_rotate_set_bounds (ClutterBehaviourRotate *rotate, g_return_if_fail (CLUTTER_IS_BEHAVIOUR_ROTATE (rotate)); clutter_behaviour_rotate_set_boundsx (rotate, - COGL_FIXED_FROM_FLOAT (angle_start), - COGL_FIXED_FROM_FLOAT (angle_end)); + CLUTTER_FLOAT_TO_FIXED (angle_start), + CLUTTER_FLOAT_TO_FIXED (angle_end)); } /** diff --git a/clutter/clutter-behaviour-scale.c b/clutter/clutter-behaviour-scale.c index f358a71f0..66d4542d2 100644 --- a/clutter/clutter-behaviour-scale.c +++ b/clutter/clutter-behaviour-scale.c @@ -115,14 +115,14 @@ clutter_behaviour_scale_alpha_notify (ClutterBehaviour *behave, { ClutterFixed factor; - factor = COGL_FIXED_FROM_INT (alpha_value) / CLUTTER_ALPHA_MAX_ALPHA; + factor = (float)(alpha_value) / CLUTTER_ALPHA_MAX_ALPHA; scale_x = - COGL_FIXED_FAST_MUL (factor, (priv->x_scale_end - priv->x_scale_start)); + CLUTTER_FIXED_MUL (factor, (priv->x_scale_end - priv->x_scale_start)); scale_x += priv->x_scale_start; scale_y = - COGL_FIXED_FAST_MUL (factor, (priv->y_scale_end - priv->y_scale_start)); + CLUTTER_FIXED_MUL (factor, (priv->y_scale_end - priv->y_scale_start)); scale_y += priv->y_scale_start; } @@ -147,16 +147,16 @@ clutter_behaviour_scale_set_property (GObject *gobject, switch (prop_id) { case PROP_X_SCALE_START: - priv->x_scale_start = COGL_FIXED_FROM_FLOAT (g_value_get_double (value)); + priv->x_scale_start = CLUTTER_FLOAT_TO_FIXED (g_value_get_double (value)); break; case PROP_X_SCALE_END: - priv->x_scale_end = COGL_FIXED_FROM_FLOAT (g_value_get_double (value)); + priv->x_scale_end = CLUTTER_FLOAT_TO_FIXED (g_value_get_double (value)); break; case PROP_Y_SCALE_START: - priv->y_scale_start = COGL_FIXED_FROM_FLOAT (g_value_get_double (value)); + priv->y_scale_start = CLUTTER_FLOAT_TO_FIXED (g_value_get_double (value)); break; case PROP_Y_SCALE_END: - priv->y_scale_end = COGL_FIXED_FROM_FLOAT (g_value_get_double (value)); + priv->y_scale_end = CLUTTER_FLOAT_TO_FIXED (g_value_get_double (value)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec); @@ -177,16 +177,16 @@ clutter_behaviour_scale_get_property (GObject *gobject, switch (prop_id) { case PROP_X_SCALE_START: - g_value_set_double (value, COGL_FIXED_TO_FLOAT (priv->x_scale_start)); + g_value_set_double (value, CLUTTER_FIXED_TO_FLOAT (priv->x_scale_start)); break; case PROP_X_SCALE_END: - g_value_set_double (value, COGL_FIXED_TO_FLOAT (priv->x_scale_end)); + g_value_set_double (value, CLUTTER_FIXED_TO_FLOAT (priv->x_scale_end)); break; case PROP_Y_SCALE_START: - g_value_set_double (value, COGL_FIXED_TO_FLOAT (priv->y_scale_start)); + g_value_set_double (value, CLUTTER_FIXED_TO_FLOAT (priv->y_scale_start)); break; case PROP_Y_SCALE_END: - g_value_set_double (value, COGL_FIXED_TO_FLOAT (priv->y_scale_end)); + g_value_set_double (value, CLUTTER_FIXED_TO_FLOAT (priv->y_scale_end)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec); @@ -276,8 +276,8 @@ clutter_behaviour_scale_init (ClutterBehaviourScale *self) self->priv = priv = CLUTTER_BEHAVIOUR_SCALE_GET_PRIVATE (self); - priv->x_scale_start = priv->x_scale_end = COGL_FIXED_1; - priv->y_scale_start = priv->y_scale_end = COGL_FIXED_1; + priv->x_scale_start = priv->x_scale_end = 1.0; + priv->y_scale_start = priv->y_scale_end = 1.0; } /** @@ -304,10 +304,10 @@ clutter_behaviour_scale_new (ClutterAlpha *alpha, g_return_val_if_fail (alpha == NULL || CLUTTER_IS_ALPHA (alpha), NULL); return clutter_behaviour_scale_newx (alpha, - COGL_FIXED_FROM_FLOAT (x_scale_start), - COGL_FIXED_FROM_FLOAT (y_scale_start), - COGL_FIXED_FROM_FLOAT (x_scale_end), - COGL_FIXED_FROM_FLOAT (y_scale_end)); + CLUTTER_FLOAT_TO_FIXED (x_scale_start), + CLUTTER_FLOAT_TO_FIXED (y_scale_start), + CLUTTER_FLOAT_TO_FIXED (x_scale_end), + CLUTTER_FLOAT_TO_FIXED (y_scale_end)); } /** @@ -367,10 +367,10 @@ clutter_behaviour_scale_set_bounds (ClutterBehaviourScale *scale, g_return_if_fail (CLUTTER_IS_BEHAVIOUR_SCALE (scale)); clutter_behaviour_scale_set_boundsx (scale, - COGL_FIXED_FROM_FLOAT (x_scale_start), - COGL_FIXED_FROM_FLOAT (y_scale_start), - COGL_FIXED_FROM_FLOAT (x_scale_end), - COGL_FIXED_FROM_FLOAT (y_scale_end)); + CLUTTER_FLOAT_TO_FIXED (x_scale_start), + CLUTTER_FLOAT_TO_FIXED (y_scale_start), + CLUTTER_FLOAT_TO_FIXED (x_scale_end), + CLUTTER_FLOAT_TO_FIXED (y_scale_end)); } /** @@ -403,16 +403,16 @@ clutter_behaviour_scale_get_bounds (ClutterBehaviourScale *scale, priv = scale->priv; if (x_scale_start) - *x_scale_start = COGL_FIXED_TO_DOUBLE (priv->x_scale_start); + *x_scale_start = CLUTTER_FIXED_TO_DOUBLE (priv->x_scale_start); if (x_scale_end) - *x_scale_end = COGL_FIXED_TO_DOUBLE (priv->x_scale_end); + *x_scale_end = CLUTTER_FIXED_TO_DOUBLE (priv->x_scale_end); if (y_scale_start) - *y_scale_start = COGL_FIXED_TO_DOUBLE (priv->y_scale_start); + *y_scale_start = CLUTTER_FIXED_TO_DOUBLE (priv->y_scale_start); if (y_scale_end) - *y_scale_end = COGL_FIXED_TO_DOUBLE (priv->y_scale_end); + *y_scale_end = CLUTTER_FIXED_TO_DOUBLE (priv->y_scale_end); } /** diff --git a/clutter/clutter-clone-texture.c b/clutter/clutter-clone-texture.c index a2350cbab..f79dd673b 100644 --- a/clutter/clutter-clone-texture.c +++ b/clutter/clutter-clone-texture.c @@ -196,20 +196,20 @@ clutter_clone_texture_paint (ClutterActor *self) tex_height = cogl_texture_get_height (cogl_texture); if (priv->repeat_x && tex_width > 0) - t_w = COGL_FIXED_DIV (COGL_FIXED_FROM_INT (x_2 - x_1), - COGL_FIXED_FROM_INT (tex_width)); + t_w = CLUTTER_FIXED_DIV ((float)(x_2 - x_1), + (float)(tex_width)); else - t_w = COGL_FIXED_1; + t_w = 1.0; if (priv->repeat_y && tex_height > 0) - t_h = COGL_FIXED_DIV (COGL_FIXED_FROM_INT (y_2 - y_1), - COGL_FIXED_FROM_INT (tex_height)); + t_h = CLUTTER_FIXED_DIV ((float)(y_2 - y_1), + (float)(tex_height)); else - t_h = COGL_FIXED_1; + t_h = 1.0; /* Parent paint translated us into position */ cogl_texture_rectangle (cogl_texture, 0, 0, - COGL_FIXED_FROM_INT (x_2 - x_1), - COGL_FIXED_FROM_INT (y_2 - y_1), + (float)(x_2 - x_1), + (float)(y_2 - y_1), 0, 0, t_w, t_h); } diff --git a/clutter/clutter-color.c b/clutter/clutter-color.c index 411bb1377..b77b3a7f4 100644 --- a/clutter/clutter-color.c +++ b/clutter/clutter-color.c @@ -154,9 +154,9 @@ clutter_color_to_hlsx (const ClutterColor *src, g_return_if_fail (src != NULL); - red = COGL_FIXED_FROM_INT (src->red) / 255; - green = COGL_FIXED_FROM_INT (src->green) / 255; - blue = COGL_FIXED_FROM_INT (src->blue) / 255; + red = (float)(src->red) / 255; + green = (float)(src->green) / 255; + blue = (float)(src->blue) / 255; if (red > green) { @@ -189,31 +189,31 @@ clutter_color_to_hlsx (const ClutterColor *src, if (max != min) { - if (l <= COGL_FIXED_0_5) - s = COGL_FIXED_FAST_DIV ((max - min), (max + min)); + if (l <= 0.5) + s = CLUTTER_FIXED_DIV ((max - min), (max + min)); else - s = COGL_FIXED_FAST_DIV ((max - min), - (COGL_FIXED_FROM_INT (2) - max - min)); + s = CLUTTER_FIXED_DIV ((max - min), + ((float)(2) - max - min)); delta = max - min; if (red == max) - h = COGL_FIXED_FAST_DIV ((green - blue), delta); + h = CLUTTER_FIXED_DIV ((green - blue), delta); else if (green == max) { - h = COGL_FIXED_FROM_INT (2) - + COGL_FIXED_FAST_DIV ((blue - red), delta); + h = (float)(2) + + CLUTTER_FIXED_DIV ((blue - red), delta); } else if (blue == max) { - h = COGL_FIXED_FROM_INT (4) - + COGL_FIXED_FAST_DIV ((red - green), delta); + h = (float)(4) + + CLUTTER_FIXED_DIV ((red - green), delta); } h *= 60; if (h < 0) - h += COGL_FIXED_360; + h += 360.0; } if (hue) @@ -251,102 +251,102 @@ clutter_color_from_hlsx (ClutterColor *dest, l = luminance; s = saturation; - if (l <= COGL_FIXED_0_5) - m2 = COGL_FIXED_FAST_MUL (l, (COGL_FIXED_1 + s)); + if (l <= 0.5) + m2 = CLUTTER_FIXED_MUL (l, (1.0 + s)); else - m2 = l + s - COGL_FIXED_FAST_MUL (l, s); + m2 = l + s - CLUTTER_FIXED_MUL (l, s); m1 = 2 * l - m2; if (s == 0) { - dest->red = (guint8) COGL_FIXED_TO_INT (l * 255); - dest->green = (guint8) COGL_FIXED_TO_INT (l * 255); - dest->blue = (guint8) COGL_FIXED_TO_INT (l * 255); + dest->red = (guint8) (l * 255); + dest->green = (guint8) (l * 255); + dest->blue = (guint8) (l * 255); } else { - h = hue + COGL_FIXED_120; + h = hue + 120.0; - while (h > COGL_FIXED_360) - h -= COGL_FIXED_360; + while (h > 360.0) + h -= 360.0; while (h < 0) - h += COGL_FIXED_360; + h += 360.0; - if (h < COGL_FIXED_60) + if (h < 60.0) { - CoglFixed tmp; + float tmp; - tmp = (m1 + COGL_FIXED_FAST_MUL ((m2 - m1), h) / 60); - dest->red = (guint8) COGL_FIXED_TO_INT (tmp * 255); + tmp = (m1 + CLUTTER_FIXED_MUL ((m2 - m1), h) / 60); + dest->red = (guint8) (tmp * 255); } - else if (h < COGL_FIXED_180) - dest->red = (guint8) COGL_FIXED_TO_INT (m2 * 255); - else if (h < COGL_FIXED_240) + else if (h < 180.0) + dest->red = (guint8) (m2 * 255); + else if (h < 240.0) { - CoglFixed tmp; + float tmp; - tmp = (m1 + COGL_FIXED_FAST_MUL ((m2 - m1), (COGL_FIXED_240 - h))) + tmp = (m1 + CLUTTER_FIXED_MUL ((m2 - m1), (240.0 - h))) / 60; - dest->red = (guint8) COGL_FIXED_TO_INT (tmp * 255); + dest->red = (guint8) (tmp * 255); } else - dest->red = (guint8) COGL_FIXED_TO_INT (m1 * 255); + dest->red = (guint8) (m1 * 255); h = hue; - while (h > COGL_FIXED_360) - h -= COGL_FIXED_360; + while (h > 360.0) + h -= 360.0; while (h < 0) - h += COGL_FIXED_360; + h += 360.0; - if (h < COGL_FIXED_60) + if (h < 60.0) { - CoglFixed tmp; + float tmp; - tmp = (m1 + COGL_FIXED_FAST_MUL ((m2 - m1), h) / 60); - dest->green = (guint8) COGL_FIXED_TO_INT (tmp * 255); + tmp = (m1 + CLUTTER_FIXED_MUL ((m2 - m1), h) / 60); + dest->green = (guint8) (tmp * 255); } - else if (h < COGL_FIXED_180) - dest->green = (guint8) COGL_FIXED_TO_INT (m2 * 255); - else if (h < COGL_FIXED_240) + else if (h < 180.0) + dest->green = (guint8) (m2 * 255); + else if (h < 240.0) { - CoglFixed tmp; + float tmp; - tmp = (m1 + COGL_FIXED_FAST_MUL ((m2 - m1) , (COGL_FIXED_240 - h))) + tmp = (m1 + CLUTTER_FIXED_MUL ((m2 - m1) , (240.0 - h))) / 60; - dest->green = (guint8) COGL_FIXED_TO_INT (tmp * 255); + dest->green = (guint8) (tmp * 255); } else - dest->green = (guint8) COGL_FIXED_TO_INT (m1 * 255); + dest->green = (guint8) (m1 * 255); - h = hue - COGL_FIXED_120; + h = hue - 120.0; - while (h > COGL_FIXED_360) - h -= COGL_FIXED_360; + while (h > 360.0) + h -= 360.0; while (h < 0) - h += COGL_FIXED_360; + h += 360.0; - if (h < COGL_FIXED_60) + if (h < 60.0) { - CoglFixed tmp; + float tmp; - tmp = (m1 + COGL_FIXED_FAST_MUL ((m2 - m1), h) / 60); - dest->blue = (guint8) COGL_FIXED_TO_INT (tmp * 255); + tmp = (m1 + CLUTTER_FIXED_MUL ((m2 - m1), h) / 60); + dest->blue = (guint8) (tmp * 255); } - else if (h < COGL_FIXED_180) - dest->blue = (guint8) COGL_FIXED_TO_INT (m2 * 255); - else if (h < COGL_FIXED_240) + else if (h < 180.0) + dest->blue = (guint8) (m2 * 255); + else if (h < 240.0) { - CoglFixed tmp; + float tmp; - tmp = (m1 + COGL_FIXED_FAST_MUL ((m2 - m1), (COGL_FIXED_240 - h))) + tmp = (m1 + CLUTTER_FIXED_MUL ((m2 - m1), (240.0 - h))) / 60; - dest->blue = (guint8) COGL_FIXED_TO_INT (tmp * 255); + dest->blue = (guint8) (tmp * 255); } else - dest->blue = (guint8) COGL_FIXED_TO_INT (m1 * 255); + dest->blue = (guint8) (m1 * 255); } } @@ -371,13 +371,13 @@ clutter_color_to_hls (const ClutterColor *src, clutter_color_to_hlsx (src, &h, &l, &s); if (hue) - *hue = (guint8) COGL_FIXED_TO_INT (h * 255) / 360; + *hue = (guint8) (h * 255) / 360; if (luminance) - *luminance = (guint8) COGL_FIXED_TO_INT (l * 255); + *luminance = (guint8) (l * 255); if (saturation) - *saturation = (guint8) COGL_FIXED_TO_INT (s * 255); + *saturation = (guint8) (s * 255); } /** @@ -399,9 +399,9 @@ clutter_color_from_hls (ClutterColor *dest, { ClutterFixed h, l, s; - h = COGL_FIXED_FROM_INT (hue * 360) / 255; - l = COGL_FIXED_FROM_INT (luminance) / 255; - s = COGL_FIXED_FROM_INT (saturation) / 255; + h = (float)(hue * 360) / 255; + l = (float)(luminance) / 255; + s = (float)(saturation) / 255; clutter_color_from_hlsx (dest, h, l, s); } @@ -420,7 +420,7 @@ clutter_color_shade (const ClutterColor *src, ClutterColor *dest, gdouble shade) { - clutter_color_shadex (src, dest, COGL_FIXED_FROM_FLOAT (shade)); + clutter_color_shadex (src, dest, CLUTTER_FLOAT_TO_FIXED (shade)); } /** @@ -448,15 +448,15 @@ clutter_color_shadex (const ClutterColor *src, clutter_color_to_hlsx (src, &h, &l, &s); - l = COGL_FIXED_FAST_MUL (l, shade); - if (l > COGL_FIXED_1) - l = COGL_FIXED_1; + l = CLUTTER_FIXED_MUL (l, shade); + if (l > 1.0) + l = 1.0; else if (l < 0) l = 0; - s = COGL_FIXED_FAST_MUL (s, shade); - if (s > COGL_FIXED_1) - s = COGL_FIXED_1; + s = CLUTTER_FIXED_MUL (s, shade); + if (s > 1.0) + s = 1.0; else if (s < 0) s = 0; diff --git a/clutter/clutter-fixed.c b/clutter/clutter-fixed.c index af616e6fe..3027a7591 100644 --- a/clutter/clutter-fixed.c +++ b/clutter/clutter-fixed.c @@ -130,42 +130,42 @@ static void clutter_value_transform_fixed_int (const GValue *src, GValue *dest) { - dest->data[0].v_int = COGL_FIXED_TO_INT (src->data[0].v_int); + dest->data[0].v_int = (src->data[0].v_int); } static void clutter_value_transform_fixed_double (const GValue *src, GValue *dest) { - dest->data[0].v_double = COGL_FIXED_TO_DOUBLE (src->data[0].v_int); + dest->data[0].v_double = CLUTTER_FIXED_TO_DOUBLE (src->data[0].v_int); } static void clutter_value_transform_fixed_float (const GValue *src, GValue *dest) { - dest->data[0].v_float = COGL_FIXED_TO_FLOAT (src->data[0].v_int); + dest->data[0].v_float = CLUTTER_FIXED_TO_FLOAT (src->data[0].v_int); } static void clutter_value_transform_int_fixed (const GValue *src, GValue *dest) { - dest->data[0].v_int = COGL_FIXED_FROM_INT (src->data[0].v_int); + dest->data[0].v_int = (float)(src->data[0].v_int); } static void clutter_value_transform_double_fixed (const GValue *src, GValue *dest) { - dest->data[0].v_int = COGL_FIXED_FROM_FLOAT (src->data[0].v_double); + dest->data[0].v_int = CLUTTER_FLOAT_TO_FIXED (src->data[0].v_double); } static void clutter_value_transform_float_fixed (const GValue *src, GValue *dest) { - dest->data[0].v_int = COGL_FIXED_FROM_FLOAT (src->data[0].v_float); + dest->data[0].v_int = CLUTTER_FLOAT_TO_FIXED (src->data[0].v_float); } @@ -268,7 +268,7 @@ param_fixed_validate (GParamSpec *pspec, GValue *value) { ClutterParamSpecFixed *fspec = CLUTTER_PARAM_SPEC_FIXED (pspec); - gint oval = COGL_FIXED_TO_INT (value->data[0].v_int); + gint oval = (value->data[0].v_int); gint min, max, val; g_assert (CLUTTER_IS_PARAM_SPEC_FIXED (pspec)); @@ -279,7 +279,7 @@ param_fixed_validate (GParamSpec *pspec, min = fspec->minimum; max = fspec->maximum; - val = COGL_FIXED_TO_INT (value->data[0].v_int); + val = (value->data[0].v_int); val = CLAMP (val, min, max); if (val != oval) diff --git a/clutter/clutter-fixed.h b/clutter/clutter-fixed.h index 3ae0916df..feffc09a4 100644 --- a/clutter/clutter-fixed.h +++ b/clutter/clutter-fixed.h @@ -39,7 +39,7 @@ G_BEGIN_DECLS * * Fixed point number (16.16) */ -typedef CoglFixed ClutterFixed; +typedef float ClutterFixed; /** * ClutterAngle: @@ -47,7 +47,7 @@ typedef CoglFixed ClutterFixed; * Integer representation of an angle such that 1024 corresponds to * full circle (i.e., 2*Pi). */ -typedef CoglAngle ClutterAngle; /* angle such that 1024 == 2*PI */ +typedef float ClutterAngle; /* angle such that 1024 == 2*PI */ #define CLUTTER_ANGLE_FROM_DEG(x) (COGL_ANGLE_FROM_DEG (x)) #define CLUTTER_ANGLE_FROM_DEGX(x) (COGL_ANGLE_FROM_DEGX (x)) @@ -70,14 +70,14 @@ typedef CoglAngle ClutterAngle; /* angle such that 1024 == 2*PI */ * * 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: @@ -98,7 +98,7 @@ typedef CoglAngle ClutterAngle; /* angle such that 1024 == 2*PI */ * * Fixed point representation of Pi */ -#define CFX_PI COGL_FIXED_PI +#define CFX_PI G_PI /** * CFX_2PI: * @@ -110,43 +110,43 @@ typedef CoglAngle ClutterAngle; /* angle such that 1024 == 2*PI */ * * 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: * @@ -158,7 +158,7 @@ typedef CoglAngle ClutterAngle; /* angle such that 1024 == 2*PI */ * * Fixed point representation of the number 255 */ -#define CFX_255 COGL_FIXED_255 +#define CFX_255 255.0 /** * CLUTTER_FIXED_TO_FLOAT: @@ -166,7 +166,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 +174,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 +182,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: @@ -206,7 +206,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 +216,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) ((x)) /** * CLUTTER_FIXED_FRACTION: @@ -232,7 +232,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 +240,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 +249,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,18 +258,18 @@ 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_FIXED_DIV(x,y) ((x) / (y)) -#define clutter_qmulx(x,y) cogl_fixed_mul ((x), (y)) -#define clutter_qdivx(x,y) cogl_fixed_div ((x), (y)) +#define clutter_qmulx(x,y) ((x) * (y)) +#define clutter_qdivx(x,y) ((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)) +#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 @@ -300,12 +300,12 @@ typedef CoglAngle ClutterAngle; /* angle such that 1024 == 2*PI */ */ #define CLUTTER_SQRTI_ARG_10_PERCENT COGL_SQRTI_ARG_10_PERCENT -#define clutter_sqrtx(x) cogl_fixed_sqrt ((x)) +#define clutter_sqrtx(x) sqrtf ((x)) #define clutter_sqrti(x) cogl_sqrti ((x)) -#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_log2x(x) log2f ((x)) +#define clutter_pow2x(x) pow2f ((x)) +#define clutter_powx(x,y) powf ((x), (y)) #define CLUTTER_TYPE_FIXED (clutter_fixed_get_type ()) #define CLUTTER_TYPE_PARAM_FIXED (clutter_param_fixed_get_type ()) diff --git a/clutter/clutter-interval.c b/clutter/clutter-interval.c index efdf58dff..ea98ce113 100644 --- a/clutter/clutter-interval.c +++ b/clutter/clutter-interval.c @@ -280,7 +280,7 @@ clutter_interval_real_compute_value (ClutterInterval *interval, break; case G_TYPE_BOOLEAN: - if (COGL_FIXED_FROM_FLOAT (factor) > COGL_FIXED_0_5) + if (CLUTTER_FLOAT_TO_FIXED (factor) > 0.5) g_value_set_boolean (value, TRUE); else g_value_set_boolean (value, FALSE); diff --git a/clutter/clutter-stage.c b/clutter/clutter-stage.c index 6a4e850b8..e72a10d49 100644 --- a/clutter/clutter-stage.c +++ b/clutter/clutter-stage.c @@ -815,15 +815,15 @@ clutter_stage_init (ClutterStage *self) priv->color = default_stage_color; - priv->perspective.fovy = COGL_FIXED_60; /* 60 Degrees */ - priv->perspective.aspect = COGL_FIXED_1; - priv->perspective.z_near = COGL_FIXED_FROM_FLOAT (0.1); - priv->perspective.z_far = COGL_FIXED_FROM_FLOAT (100.0); + priv->perspective.fovy = 60.0; /* 60 Degrees */ + priv->perspective.aspect = 1.0; + priv->perspective.z_near = CLUTTER_FLOAT_TO_FIXED (0.1); + priv->perspective.z_far = CLUTTER_FLOAT_TO_FIXED (100.0); /* depth cueing */ - priv->fog.density = COGL_FIXED_FROM_FLOAT (0.1); - priv->fog.z_near = COGL_FIXED_FROM_FLOAT (1.0); - priv->fog.z_far = COGL_FIXED_FROM_FLOAT (2.0); + priv->fog.density = CLUTTER_FLOAT_TO_FIXED (0.1); + priv->fog.z_near = CLUTTER_FLOAT_TO_FIXED (1.0); + priv->fog.z_far = CLUTTER_FLOAT_TO_FIXED (2.0); clutter_actor_set_reactive (CLUTTER_ACTOR (self), TRUE); clutter_stage_set_key_focus (self, NULL); @@ -979,10 +979,10 @@ clutter_stage_set_perspective (ClutterStage *stage, priv = stage->priv; - priv->perspective.fovy = COGL_FIXED_FROM_FLOAT (fovy); - priv->perspective.aspect = COGL_FIXED_FROM_FLOAT (aspect); - priv->perspective.z_near = COGL_FIXED_FROM_FLOAT (z_near); - priv->perspective.z_far = COGL_FIXED_FROM_FLOAT (z_far); + priv->perspective.fovy = CLUTTER_FLOAT_TO_FIXED (fovy); + priv->perspective.aspect = CLUTTER_FLOAT_TO_FIXED (aspect); + priv->perspective.z_near = CLUTTER_FLOAT_TO_FIXED (z_near); + priv->perspective.z_far = CLUTTER_FLOAT_TO_FIXED (z_far); /* this will cause the viewport to be reset; see * clutter_maybe_setup_viewport() inside clutter-main.c @@ -1018,16 +1018,16 @@ clutter_stage_get_perspective (ClutterStage *stage, priv = stage->priv; if (fovy) - *fovy = COGL_FIXED_TO_FLOAT (priv->perspective.fovy); + *fovy = CLUTTER_FIXED_TO_FLOAT (priv->perspective.fovy); if (aspect) - *aspect = COGL_FIXED_TO_FLOAT (priv->perspective.aspect); + *aspect = CLUTTER_FIXED_TO_FLOAT (priv->perspective.aspect); if (z_near) - *z_near = COGL_FIXED_TO_FLOAT (priv->perspective.z_near); + *z_near = CLUTTER_FIXED_TO_FLOAT (priv->perspective.z_near); if (z_far) - *z_far = COGL_FIXED_TO_FLOAT (priv->perspective.z_far); + *z_far = CLUTTER_FIXED_TO_FLOAT (priv->perspective.z_far); } /** @@ -1627,11 +1627,11 @@ clutter_stage_get_fog (ClutterStage *stage, priv = stage->priv; if (density) - *density = COGL_FIXED_TO_FLOAT (priv->fog.density); + *density = CLUTTER_FIXED_TO_FLOAT (priv->fog.density); if (z_near) - *z_near = COGL_FIXED_TO_FLOAT (priv->fog.z_near); + *z_near = CLUTTER_FIXED_TO_FLOAT (priv->fog.z_near); if (z_far) - *z_far = COGL_FIXED_TO_FLOAT (priv->fog.z_far); + *z_far = CLUTTER_FIXED_TO_FLOAT (priv->fog.z_far); } /** @@ -1663,9 +1663,9 @@ clutter_stage_set_fog (ClutterStage *stage, priv = stage->priv; - priv->fog.density = COGL_FIXED_FROM_FLOAT (density); - priv->fog.z_near = COGL_FIXED_FROM_FLOAT (z_near); - priv->fog.z_far = COGL_FIXED_FROM_FLOAT (z_far); + priv->fog.density = CLUTTER_FLOAT_TO_FIXED (density); + priv->fog.z_near = CLUTTER_FLOAT_TO_FIXED (z_near); + priv->fog.z_far = CLUTTER_FLOAT_TO_FIXED (z_far); if (priv->use_fog && CLUTTER_ACTOR_IS_VISIBLE (stage)) clutter_actor_queue_redraw (CLUTTER_ACTOR (stage)); @@ -1761,7 +1761,7 @@ clutter_stage_get_resolutionx (ClutterStage *stage) res = clutter_backend_get_resolution (context->backend); - return COGL_FIXED_FROM_FLOAT (res); + return CLUTTER_FLOAT_TO_FIXED (res); } /*** Perspective boxed type ******/ diff --git a/clutter/clutter-texture.c b/clutter/clutter-texture.c index d081b3889..b0b46e430 100644 --- a/clutter/clutter-texture.c +++ b/clutter/clutter-texture.c @@ -343,13 +343,13 @@ clutter_texture_get_preferred_width (ClutterActor *self, /* Set the natural width so as to preserve the aspect ratio */ ClutterFixed ratio, height; - ratio = COGL_FIXED_DIV (COGL_FIXED_FROM_INT (priv->width), - COGL_FIXED_FROM_INT (priv->height)); + ratio = CLUTTER_FIXED_DIV ((float)(priv->width), + (float)(priv->height)); height = CLUTTER_UNITS_TO_FIXED (for_height); *natural_width_p = - CLUTTER_UNITS_FROM_FIXED (COGL_FIXED_MUL (ratio, height)); + CLUTTER_UNITS_FROM_FIXED (CLUTTER_FIXED_MUL (ratio, height)); } } } @@ -388,13 +388,13 @@ clutter_texture_get_preferred_height (ClutterActor *self, /* Set the natural height so as to preserve the aspect ratio */ ClutterFixed ratio, width; - ratio = COGL_FIXED_DIV (COGL_FIXED_FROM_INT (priv->height), - COGL_FIXED_FROM_INT (priv->width)); + ratio = CLUTTER_FIXED_DIV ((float)(priv->height), + (float)(priv->width)); width = CLUTTER_UNITS_TO_FIXED (for_width); *natural_height_p = - CLUTTER_UNITS_FROM_FIXED (COGL_FIXED_MUL (ratio, width)); + CLUTTER_UNITS_FROM_FIXED (CLUTTER_FIXED_MUL (ratio, width)); } } } @@ -463,24 +463,24 @@ clutter_texture_set_fbo_projection (ClutterActor *self) /* Convert the coordinates back to [-1,1] range */ cogl_get_viewport (viewport); - tx_min = COGL_FIXED_DIV (CLUTTER_UNITS_TO_FIXED (x_min), viewport[2]) - * 2 - COGL_FIXED_1; - tx_max = COGL_FIXED_DIV (CLUTTER_UNITS_TO_FIXED (x_max), viewport[2]) - * 2 - COGL_FIXED_1; - ty_min = COGL_FIXED_DIV (CLUTTER_UNITS_TO_FIXED (y_min), viewport[3]) - * 2 - COGL_FIXED_1; - ty_max = COGL_FIXED_DIV (CLUTTER_UNITS_TO_FIXED (y_max), viewport[3]) - * 2 - COGL_FIXED_1; + tx_min = CLUTTER_FIXED_DIV (CLUTTER_UNITS_TO_FIXED (x_min), viewport[2]) + * 2 - 1.0; + tx_max = CLUTTER_FIXED_DIV (CLUTTER_UNITS_TO_FIXED (x_max), viewport[2]) + * 2 - 1.0; + ty_min = CLUTTER_FIXED_DIV (CLUTTER_UNITS_TO_FIXED (y_min), viewport[3]) + * 2 - 1.0; + ty_max = CLUTTER_FIXED_DIV (CLUTTER_UNITS_TO_FIXED (y_max), viewport[3]) + * 2 - 1.0; /* Set up a projection matrix so that the actor will be projected as if it was drawn at its original location */ - tan_angle = cogl_angle_tan (COGL_ANGLE_FROM_DEGX (perspective.fovy / 2)); - near_size = COGL_FIXED_MUL (perspective.z_near, tan_angle); + tan_angle = tanf (COGL_ANGLE_FROM_DEGX (perspective.fovy / 2 * (G_PI/180.0))); + near_size = CLUTTER_FIXED_MUL (perspective.z_near, tan_angle); - cogl_frustum (COGL_FIXED_MUL (tx_min, near_size), - COGL_FIXED_MUL (tx_max, near_size), - COGL_FIXED_MUL (-ty_min, near_size), - COGL_FIXED_MUL (-ty_max, near_size), + cogl_frustum (CLUTTER_FIXED_MUL (tx_min, near_size), + CLUTTER_FIXED_MUL (tx_max, near_size), + CLUTTER_FIXED_MUL (-ty_min, near_size), + CLUTTER_FIXED_MUL (-ty_max, near_size), perspective.z_near, perspective.z_far); } @@ -594,21 +594,21 @@ clutter_texture_paint (ClutterActor *self) clutter_actor_get_opacity (self)); if (priv->repeat_x && priv->width > 0) - t_w = COGL_FIXED_DIV (COGL_FIXED_FROM_INT (x_2 - x_1), - COGL_FIXED_FROM_INT (priv->width)); + t_w = CLUTTER_FIXED_DIV ((float)(x_2 - x_1), + (float)(priv->width)); else - t_w = COGL_FIXED_1; + t_w = 1.0; if (priv->repeat_y && priv->height > 0) - t_h = COGL_FIXED_DIV (COGL_FIXED_FROM_INT (y_2 - y_1), - COGL_FIXED_FROM_INT (priv->height)); + t_h = CLUTTER_FIXED_DIV ((float)(y_2 - y_1), + (float)(priv->height)); else - t_h = COGL_FIXED_1; + t_h = 1.0; /* Paint will have translated us */ cogl_texture_rectangle (priv->texture, 0, 0, - COGL_FIXED_FROM_INT (x_2 - x_1), - COGL_FIXED_FROM_INT (y_2 - y_1), + (float)(x_2 - x_1), + (float)(y_2 - y_1), 0, 0, t_w, t_h); } diff --git a/clutter/clutter-timeline.c b/clutter/clutter-timeline.c index 0841a3077..b9df23b3f 100644 --- a/clutter/clutter-timeline.c +++ b/clutter/clutter-timeline.c @@ -1347,7 +1347,7 @@ clutter_timeline_get_progress (ClutterTimeline *timeline) { g_return_val_if_fail (CLUTTER_IS_TIMELINE (timeline), 0.); - return COGL_FIXED_TO_DOUBLE (clutter_timeline_get_progressx (timeline)); + return CLUTTER_FIXED_TO_DOUBLE (clutter_timeline_get_progressx (timeline)); } /** @@ -1370,11 +1370,11 @@ clutter_timeline_get_progressx (ClutterTimeline *timeline) priv = timeline->priv; - progress = COGL_FIXED_DIV (COGL_FIXED_FROM_INT (priv->current_frame_num), - COGL_FIXED_FROM_INT (priv->n_frames)); + progress = CLUTTER_FIXED_DIV ((float)(priv->current_frame_num), + (float)(priv->n_frames)); if (priv->direction == CLUTTER_TIMELINE_BACKWARD) - progress = COGL_FIXED_1 - progress; + progress = 1.0 - progress; return progress; } diff --git a/clutter/clutter-units.h b/clutter/clutter-units.h index b85375a98..27d539cc4 100644 --- a/clutter/clutter-units.h +++ b/clutter/clutter-units.h @@ -50,11 +50,11 @@ typedef gint32 ClutterUnit; * decide to change this relationship in the future. */ -#define CLUTTER_UNITS_FROM_INT(x) (COGL_FIXED_FROM_INT ((x))) -#define CLUTTER_UNITS_TO_INT(x) (COGL_FIXED_TO_INT ((x))) +#define CLUTTER_UNITS_FROM_INT(x) ((float)((x))) +#define CLUTTER_UNITS_TO_INT(x) ( ((x))) -#define CLUTTER_UNITS_FROM_FLOAT(x) (COGL_FIXED_FROM_FLOAT ((x))) -#define CLUTTER_UNITS_TO_FLOAT(x) (COGL_FIXED_TO_FLOAT ((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) diff --git a/clutter/cogl/cogl-color.h b/clutter/cogl/cogl-color.h index fbc49d5bb..6cdf52bd9 100644 --- a/clutter/cogl/cogl-color.h +++ b/clutter/cogl/cogl-color.h @@ -70,20 +70,20 @@ void cogl_color_set_from_4d (CoglColor *dest, /** * cogl_color_set_from_4x: * @dest: return location for a #CoglColor - * @red: value of the red channel, between 0 and %COGL_FIXED_1 - * @green: value of the green channel, between 0 and %COGL_FIXED_1 - * @blue: value of the blue channel, between 0 and %COGL_FIXED_1 - * @alpha: value of the alpha channel, between 0 and %COGL_FIXED_1 + * @red: value of the red channel, between 0 and %1.0 + * @green: value of the green channel, between 0 and %1.0 + * @blue: value of the blue channel, between 0 and %1.0 + * @alpha: value of the alpha channel, between 0 and %1.0 * * Sets the values of the passed channels into a #CoglColor * * Since: 1.0 */ void cogl_color_set_from_4x (CoglColor *dest, - CoglFixed red, - CoglFixed green, - CoglFixed blue, - CoglFixed alpha); + float red, + float green, + float blue, + float alpha); /** * cogl_color_get_red_byte: @@ -194,52 +194,52 @@ float cogl_color_get_alpha_float (const CoglColor *color); * @color: a #CoglColor * * Retrieves the red channel of @color as a fixed point - * value between 0 and %COGL_FIXED_1. + * value between 0 and %1.0. * * Return value: the red channel of the passed color * * Since: 1.0 */ -CoglFixed cogl_color_get_red (const CoglColor *color); +float cogl_color_get_red (const CoglColor *color); /** * cogl_color_get_green: * @color: a #CoglColor * * Retrieves the green channel of @color as a fixed point - * value between 0 and %COGL_FIXED_1. + * value between 0 and %1.0. * * Return value: the green channel of the passed color * * Since: 1.0 */ -CoglFixed cogl_color_get_green (const CoglColor *color); +float cogl_color_get_green (const CoglColor *color); /** * cogl_color_get_blue: * @color: a #CoglColor * * Retrieves the blue channel of @color as a fixed point - * value between 0 and %COGL_FIXED_1. + * value between 0 and %1.0. * * Return value: the blue channel of the passed color * * Since: 1.0 */ -CoglFixed cogl_color_get_blue (const CoglColor *color); +float cogl_color_get_blue (const CoglColor *color); /** * cogl_color_get_alpha: * @color: a #CoglColor * * Retrieves the alpha channel of @color as a fixed point - * value between 0 and %COGL_FIXED_1. + * value between 0 and %1.0. * * Return value: the alpha channel of the passed color * * Since: 1.0 */ -CoglFixed cogl_color_get_alpha (const CoglColor *color); +float cogl_color_get_alpha (const CoglColor *color); /** * cogl_set_source_color: @@ -277,24 +277,24 @@ void cogl_set_source_color4ub (guint8 red, /** * cogl_set_source_color4x: - * @red: value of the red channel, between 0 and %COGL_FIXED_1 - * @green: value of the green channel, between 0 and %COGL_FIXED_1 - * @blue: value of the blue channel, between 0 and %COGL_FIXED_1 - * @alpha: value of the alpha channel, between 0 and %COGL_FIXED_1 + * @red: value of the red channel, between 0 and %1.0 + * @green: value of the green channel, between 0 and %1.0 + * @blue: value of the blue channel, between 0 and %1.0 + * @alpha: value of the alpha channel, between 0 and %1.0 * * Sets the source color using normalized values for each component. * This color will be used for any subsequent drawing operation. * * The value for each component is a fixed point number in the range - * between 0 and %COGL_FIXED_1. If the values passed in are outside that + * between 0 and %1.0. If the values passed in are outside that * range, they will be clamped. * * Since: 1.0 */ -void cogl_set_source_color4x (CoglFixed red, - CoglFixed green, - CoglFixed blue, - CoglFixed alpha); +void cogl_set_source_color4x (float red, + float green, + float blue, + float alpha); G_END_DECLS diff --git a/clutter/cogl/cogl-path.h b/clutter/cogl/cogl-path.h index 20632da37..0d2982923 100644 --- a/clutter/cogl/cogl-path.h +++ b/clutter/cogl/cogl-path.h @@ -74,10 +74,10 @@ void cogl_rectangle (gint x, * * A fixed-point version of cogl_fast_fill_rectangle. **/ -void cogl_rectanglex (CoglFixed x, - CoglFixed y, - CoglFixed width, - CoglFixed height); +void cogl_rectanglex (float x, + float y, + float width, + float height); /** * cogl_path_fill: @@ -136,8 +136,8 @@ void cogl_path_new (void); * Moves the pen to the given location. If there is an existing path * this will start a new disjoint subpath. **/ -void cogl_path_move_to (CoglFixed x, - CoglFixed y); +void cogl_path_move_to (float x, + float y); /** @@ -149,8 +149,8 @@ void cogl_path_move_to (CoglFixed x, * location. If there is an existing path this will start a new * disjoint subpath. **/ -void cogl_path_rel_move_to (CoglFixed x, - CoglFixed y); +void cogl_path_rel_move_to (float x, + float y); /** * cogl_path_line_to: @@ -160,8 +160,8 @@ void cogl_path_rel_move_to (CoglFixed x, * Adds a straight line segment to the current path that ends at the * given coordinates. **/ -void cogl_path_line_to (CoglFixed x, - CoglFixed y); +void cogl_path_line_to (float x, + float y); /** * cogl_path_rel_line_to: @@ -171,8 +171,8 @@ void cogl_path_line_to (CoglFixed x, * Adds a straight line segment to the current path that ends at the * given coordinates relative to the current pen location. **/ -void cogl_path_rel_line_to (CoglFixed x, - CoglFixed y); +void cogl_path_rel_line_to (float x, + float y); /** @@ -189,12 +189,12 @@ void cogl_path_rel_line_to (CoglFixed x, * of the arc. If you perform a move_to to the arcs start just before * drawing it you create a free standing arc. **/ -void cogl_path_arc (CoglFixed center_x, - CoglFixed center_y, - CoglFixed radius_x, - CoglFixed radius_y, - CoglAngle angle_1, - CoglAngle angle_2); +void cogl_path_arc (float center_x, + float center_y, + float radius_x, + float radius_y, + float angle_1, + float angle_2); @@ -211,12 +211,12 @@ void cogl_path_arc (CoglFixed center_x, * second, third and fourth control points and using current pen location * as the first control point. **/ -void cogl_path_curve_to (CoglFixed x1, - CoglFixed y1, - CoglFixed x2, - CoglFixed y2, - CoglFixed x3, - CoglFixed y3); +void cogl_path_curve_to (float x1, + float y1, + float x2, + float y2, + float x3, + float y3); /** * cogl_path_rel_curve_to: @@ -232,12 +232,12 @@ void cogl_path_curve_to (CoglFixed x1, * as the first control point. The given coordinates are relative to the * current pen location. */ -void cogl_path_rel_curve_to (CoglFixed x1, - CoglFixed y1, - CoglFixed x2, - CoglFixed y2, - CoglFixed x3, - CoglFixed y3); +void cogl_path_rel_curve_to (float x1, + float y1, + float x2, + float y2, + float x3, + float y3); /** * cogl_path_close: @@ -258,10 +258,10 @@ void cogl_path_close (void); * coordinates. If there is an existing path this will start a new * disjoint sub-path. **/ -void cogl_path_line (CoglFixed x1, - CoglFixed y1, - CoglFixed x2, - CoglFixed y2); +void cogl_path_line (float x1, + float y1, + float x2, + float y2); /** * cogl_path_polyline: @@ -281,7 +281,7 @@ void cogl_path_line (CoglFixed x1, * fashion for the rest of the vertices. (num_points - 1) segments will * be constructed. **/ -void cogl_path_polyline (CoglFixed *coords, +void cogl_path_polyline (float *coords, gint num_points); @@ -299,7 +299,7 @@ void cogl_path_polyline (CoglFixed *coords, * represents the Y coordinate of the first vertex, continuing in the same * fashion for the rest of the vertices. **/ -void cogl_path_polygon (CoglFixed *coords, +void cogl_path_polygon (float *coords, gint num_points); @@ -313,10 +313,10 @@ void cogl_path_polygon (CoglFixed *coords, * Constructs a rectangular shape at the given coordinates. If there * is an existing path this will start a new disjoint sub-path. **/ -void cogl_path_rectangle (CoglFixed x, - CoglFixed y, - CoglFixed width, - CoglFixed height); +void cogl_path_rectangle (float x, + float y, + float width, + float height); /** * cogl_path_ellipse: @@ -328,10 +328,10 @@ void cogl_path_rectangle (CoglFixed x, * Constructs an ellipse shape. If there is an existing path this will * start a new disjoint sub-path. **/ -void cogl_path_ellipse (CoglFixed center_x, - CoglFixed center_y, - CoglFixed radius_x, - CoglFixed radius_y); +void cogl_path_ellipse (float center_x, + float center_y, + float radius_x, + float radius_y); /** * cogl_path_round_rectangle: @@ -346,12 +346,12 @@ void cogl_path_ellipse (CoglFixed center_x, * Constructs a rectangular shape with rounded corners. If there is an * existing path this will start a new disjoint sub-path. **/ -void cogl_path_round_rectangle (CoglFixed x, - CoglFixed y, - CoglFixed width, - CoglFixed height, - CoglFixed radius, - CoglAngle arc_step); +void cogl_path_round_rectangle (float x, + float y, + float width, + float height, + float radius, + float arc_step); G_END_DECLS diff --git a/clutter/cogl/cogl-texture.h b/clutter/cogl/cogl-texture.h index cee2f439e..5ae3e2839 100644 --- a/clutter/cogl/cogl-texture.h +++ b/clutter/cogl/cogl-texture.h @@ -368,14 +368,14 @@ void cogl_texture_unref (CoglHandle handle); * texture pass in @tx1=0.0 @ty1=0.0 @tx2=1.0 @ty2=1.0. */ void cogl_texture_rectangle (CoglHandle handle, - CoglFixed x1, - CoglFixed y1, - CoglFixed x2, - CoglFixed y2, - CoglFixed tx1, - CoglFixed ty1, - CoglFixed tx2, - CoglFixed ty2); + float x1, + float y1, + float x2, + float y2, + float tx1, + float ty1, + float tx2, + float ty2); /** * cogl_texture_polygon: @@ -455,7 +455,7 @@ void cogl_bitmap_free (CoglBitmap *bmp); * significant performance boost to use this function rather than * calling cogl_texture_rectangle() separately for each rectangle. * - * @verts should point to an array of #CoglFixeds with + * @verts should point to an array of #floats with * @n_rects * 8 elements. Each group of 8 values corresponds to the * parameters x1, y1, x2, y2, tx1, ty1, tx2 and ty2 and have the same * meaning as in cogl_texture_rectangle(). @@ -464,7 +464,7 @@ void cogl_bitmap_free (CoglBitmap *bmp); */ void cogl_texture_multiple_rectangles (CoglHandle handle, - const CoglFixed *verts, + const float *verts, guint n_rects); G_END_DECLS diff --git a/clutter/cogl/cogl-types.h b/clutter/cogl/cogl-types.h index ece3270b7..b11091a95 100644 --- a/clutter/cogl/cogl-types.h +++ b/clutter/cogl/cogl-types.h @@ -264,8 +264,8 @@ struct _CoglColor */ struct _CoglTextureVertex { - CoglFixed x, y, z; - CoglFixed tx, ty; + float x, y, z; + float tx, ty; CoglColor color; }; diff --git a/clutter/cogl/cogl.h.in b/clutter/cogl/cogl.h.in index ea81c7b2c..cc26f882f 100644 --- a/clutter/cogl/cogl.h.in +++ b/clutter/cogl/cogl.h.in @@ -143,10 +143,10 @@ void cogl_get_bitmasks (gint *red, * Replaces the current projection matrix with a perspective matrix * based on the provided values. */ -void cogl_perspective (CoglFixed fovy, - CoglFixed aspect, - CoglFixed z_near, - CoglFixed z_far); +void cogl_perspective (float fovy, + float aspect, + float z_near, + float z_far); /** * cogl_frustum: @@ -162,12 +162,12 @@ void cogl_perspective (CoglFixed fovy, * * Since: 0.8.2 */ -void cogl_frustum (CoglFixed left, - CoglFixed right, - CoglFixed bottom, - CoglFixed top, - CoglFixed z_near, - CoglFixed z_far); +void cogl_frustum (float left, + float right, + float bottom, + float top, + float z_near, + float z_far); /** * cogl_setup_viewport: @@ -187,10 +187,10 @@ void cogl_frustum (CoglFixed left, */ void cogl_setup_viewport (guint width, guint height, - CoglFixed fovy, - CoglFixed aspect, - CoglFixed z_near, - CoglFixed z_far); + float fovy, + float aspect, + float z_near, + float z_far); /** * cogl_viewport: @@ -227,8 +227,8 @@ void cogl_pop_matrix (void); * Multiplies the current model-view matrix by one that scales the x * and y axes by the given values. */ -void cogl_scale (CoglFixed x, - CoglFixed y); +void cogl_scale (float x, + float y); /** * cogl_translatex: @@ -239,9 +239,9 @@ void cogl_scale (CoglFixed x, * Multiplies the current model-view matrix by one that translates the * model along all three axes according to the given values. */ -void cogl_translatex (CoglFixed x, - CoglFixed y, - CoglFixed z); +void cogl_translatex (float x, + float y, + float z); /** * cogl_translate: @@ -270,7 +270,7 @@ void cogl_translate (gint x, * degrees about the vertex (0, 0, 1) causes a small counter-clockwise * rotation. */ -void cogl_rotatex (CoglFixed angle, +void cogl_rotatex (float angle, gint x, gint y, gint z); @@ -293,32 +293,32 @@ void cogl_rotate (gint angle, /** * cogl_get_modelview_matrix: - * @m: pointer to a 4x4 array of #CoglFixeds to receive the matrix + * @m: pointer to a 4x4 array of #floats to receive the matrix * * Stores the current model-view matrix in @m. The matrix is in * column-major order. */ -void cogl_get_modelview_matrix (CoglFixed m[16]); +void cogl_get_modelview_matrix (float m[16]); /** * cogl_get_projection_matrix: - * @m: pointer to a 4x4 array of #CoglFixeds to receive the matrix + * @m: pointer to a 4x4 array of #floats to receive the matrix * * Stores the current projection matrix in @m. The matrix is in * column-major order. */ -void cogl_get_projection_matrix (CoglFixed m[16]); +void cogl_get_projection_matrix (float m[16]); /** * cogl_get_viewport: - * @v: pointer to a 4 element array of #CoglFixeds to + * @v: pointer to a 4 element array of #floats to * receive the viewport dimensions. * * Stores the current viewport in @v. @v[0] and @v[1] get the x and y * position of the viewport and @v[2] and @v[3] get the width and * height. */ -void cogl_get_viewport (CoglFixed v[4]); +void cogl_get_viewport (float v[4]); /** * cogl_clip_set: @@ -336,10 +336,10 @@ void cogl_get_viewport (CoglFixed v[4]); * The rectangle is intersected with the current clip region. To undo * the effect of this function, call cogl_clip_unset(). */ -void cogl_clip_set (CoglFixed x_offset, - CoglFixed y_offset, - CoglFixed width, - CoglFixed height); +void cogl_clip_set (float x_offset, + float y_offset, + float width, + float height); /** * cogl_clip_set_from_path: @@ -443,7 +443,7 @@ void cogl_enable_backface_culling (gboolean setting); * initial reference value is 1.0. */ void cogl_alpha_func (COGLenum func, - CoglFixed ref); + float ref); /** * cogl_fog_set: @@ -460,9 +460,9 @@ void cogl_alpha_func (COGLenum func, * cogl_paint_init(). */ void cogl_fog_set (const CoglColor *fog_color, - CoglFixed density, - CoglFixed z_near, - CoglFixed z_far); + float density, + float z_near, + float z_far); /** * cogl_paint_init: diff --git a/clutter/cogl/common/cogl-clip-stack.c b/clutter/cogl/common/cogl-clip-stack.c index c533b0b4c..9d8a623e9 100644 --- a/clutter/cogl/common/cogl-clip-stack.c +++ b/clutter/cogl/common/cogl-clip-stack.c @@ -35,24 +35,24 @@ /* These are defined in the particular backend (float in GL vs fixed in GL ES) */ -void _cogl_set_clip_planes (CoglFixed x, - CoglFixed y, - CoglFixed width, - CoglFixed height); -void _cogl_add_stencil_clip (CoglFixed x, - CoglFixed y, - CoglFixed width, - CoglFixed height, +void _cogl_set_clip_planes (float x, + float y, + float width, + float height); +void _cogl_add_stencil_clip (float x, + float y, + float width, + float height, gboolean first); -void _cogl_add_path_to_stencil_buffer (CoglFixedVec2 nodes_min, - CoglFixedVec2 nodes_max, +void _cogl_add_path_to_stencil_buffer (floatVec2 nodes_min, + floatVec2 nodes_max, guint path_size, CoglPathNode *path, gboolean merge); void _cogl_enable_clip_planes (void); void _cogl_disable_clip_planes (void); void _cogl_disable_stencil_buffer (void); -void _cogl_set_matrix (const CoglFixed *matrix); +void _cogl_set_matrix (const float *matrix); typedef struct _CoglClipStack CoglClipStack; @@ -75,13 +75,13 @@ struct _CoglClipStackEntryRect CoglClipStackEntryType type; /* The rectangle for this clip */ - CoglFixed x_offset; - CoglFixed y_offset; - CoglFixed width; - CoglFixed height; + float x_offset; + float y_offset; + float width; + float height; /* The matrix that was current when the clip was set */ - CoglFixed matrix[16]; + float matrix[16]; }; struct _CoglClipStackEntryPath @@ -89,20 +89,20 @@ struct _CoglClipStackEntryPath CoglClipStackEntryType type; /* The matrix that was current when the clip was set */ - CoglFixed matrix[16]; + float matrix[16]; - CoglFixedVec2 path_nodes_min; - CoglFixedVec2 path_nodes_max; + floatVec2 path_nodes_min; + floatVec2 path_nodes_max; guint path_size; CoglPathNode path[1]; }; void -cogl_clip_set (CoglFixed x_offset, - CoglFixed y_offset, - CoglFixed width, - CoglFixed height) +cogl_clip_set (float x_offset, + float y_offset, + float width, + float height) { CoglClipStackEntryRect *entry; CoglClipStack *stack; diff --git a/clutter/cogl/common/cogl-color.c b/clutter/cogl/common/cogl-color.c index a248b95c9..dac35849d 100644 --- a/clutter/cogl/common/cogl-color.c +++ b/clutter/cogl/common/cogl-color.c @@ -59,17 +59,17 @@ cogl_color_set_from_4d (CoglColor *dest, void cogl_color_set_from_4x (CoglColor *dest, - CoglFixed red, - CoglFixed green, - CoglFixed blue, - CoglFixed alpha) + float red, + float green, + float blue, + float alpha) { g_return_if_fail (dest != NULL); - dest->red = COGL_FIXED_TO_INT (red * 255); - dest->green = COGL_FIXED_TO_INT (green * 255); - dest->blue = COGL_FIXED_TO_INT (blue * 255); - dest->alpha = COGL_FIXED_TO_INT (alpha * 255); + dest->red = (red * 255); + dest->green = (green * 255); + dest->blue = (blue * 255); + dest->alpha = (alpha * 255); } unsigned char @@ -84,10 +84,10 @@ cogl_color_get_red_float (const CoglColor *color) return (float) color->red / 255.0; } -CoglFixed +float cogl_color_get_red (const CoglColor *color) { - return COGL_FIXED_FROM_FLOAT ((float) color->red / 255.0); + return ((float) color->red / 255.0); } unsigned char @@ -102,10 +102,10 @@ cogl_color_get_green_float (const CoglColor *color) return (float) color->green / 255.0; } -CoglFixed +float cogl_color_get_green (const CoglColor *color) { - return COGL_FIXED_FROM_FLOAT ((float) color->green / 255.0); + return ((float) color->green / 255.0); } unsigned char @@ -120,10 +120,10 @@ cogl_color_get_blue_float (const CoglColor *color) return (float) color->blue / 255.0; } -CoglFixed +float cogl_color_get_blue (const CoglColor *color) { - return COGL_FIXED_FROM_FLOAT ((float) color->blue / 255.0); + return ((float) color->blue / 255.0); } unsigned char @@ -138,10 +138,10 @@ cogl_color_get_alpha_float (const CoglColor *color) return (float) color->alpha / 255.0; } -CoglFixed +float cogl_color_get_alpha (const CoglColor *color) { - return COGL_FIXED_FROM_FLOAT ((float) color->alpha / 255.0); + return ((float) color->alpha / 255.0); } void @@ -157,10 +157,10 @@ cogl_set_source_color4ub (guint8 red, } void -cogl_set_source_color4x (CoglFixed red, - CoglFixed green, - CoglFixed blue, - CoglFixed alpha) +cogl_set_source_color4x (float red, + float green, + float blue, + float alpha) { CoglColor c = { 0, }; diff --git a/clutter/cogl/common/cogl-primitives.c b/clutter/cogl/common/cogl-primitives.c index a063331f2..27e0e36a7 100644 --- a/clutter/cogl/common/cogl-primitives.c +++ b/clutter/cogl/common/cogl-primitives.c @@ -38,18 +38,18 @@ /* these are defined in the particular backend(float in gl vs fixed in gles)*/ void _cogl_path_add_node (gboolean new_sub_path, - CoglFixed x, - CoglFixed y); + float x, + float y); void _cogl_path_fill_nodes (); void _cogl_path_stroke_nodes (); void _cogl_rectangle (gint x, gint y, guint width, guint height); -void _cogl_rectanglex (CoglFixed x, - CoglFixed y, - CoglFixed width, - CoglFixed height); +void _cogl_rectanglex (float x, + float y, + float width, + float height); void cogl_rectangle (gint x, gint y, @@ -62,10 +62,10 @@ cogl_rectangle (gint x, } void -cogl_rectanglex (CoglFixed x, - CoglFixed y, - CoglFixed width, - CoglFixed height) +cogl_rectanglex (float x, + float y, + float width, + float height) { cogl_clip_ensure (); @@ -116,8 +116,8 @@ cogl_path_stroke_preserve (void) } void -cogl_path_move_to (CoglFixed x, - CoglFixed y) +cogl_path_move_to (float x, + float y) { _COGL_GET_CONTEXT (ctx, NO_RETVAL); @@ -132,8 +132,8 @@ cogl_path_move_to (CoglFixed x, } void -cogl_path_rel_move_to (CoglFixed x, - CoglFixed y) +cogl_path_rel_move_to (float x, + float y) { _COGL_GET_CONTEXT (ctx, NO_RETVAL); @@ -142,8 +142,8 @@ cogl_path_rel_move_to (CoglFixed x, } void -cogl_path_line_to (CoglFixed x, - CoglFixed y) +cogl_path_line_to (float x, + float y) { _COGL_GET_CONTEXT (ctx, NO_RETVAL); @@ -154,8 +154,8 @@ cogl_path_line_to (CoglFixed x, } void -cogl_path_rel_line_to (CoglFixed x, - CoglFixed y) +cogl_path_rel_line_to (float x, + float y) { _COGL_GET_CONTEXT (ctx, NO_RETVAL); @@ -181,17 +181,17 @@ cogl_path_new (void) } void -cogl_path_line (CoglFixed x1, - CoglFixed y1, - CoglFixed x2, - CoglFixed y2) +cogl_path_line (float x1, + float y1, + float x2, + float y2) { cogl_path_move_to (x1, y1); cogl_path_line_to (x2, y2); } void -cogl_path_polyline (CoglFixed *coords, +cogl_path_polyline (float *coords, gint num_points) { gint c = 0; @@ -203,7 +203,7 @@ cogl_path_polyline (CoglFixed *coords, } void -cogl_path_polygon (CoglFixed *coords, +cogl_path_polygon (float *coords, gint num_points) { cogl_path_polyline (coords, num_points); @@ -211,10 +211,10 @@ cogl_path_polygon (CoglFixed *coords, } void -cogl_path_rectangle (CoglFixed x, - CoglFixed y, - CoglFixed width, - CoglFixed height) +cogl_path_rectangle (float x, + float y, + float width, + float height) { cogl_path_move_to (x, y); cogl_path_line_to (x + width, y); @@ -224,20 +224,20 @@ cogl_path_rectangle (CoglFixed x, } static void -_cogl_path_arc (CoglFixed center_x, - CoglFixed center_y, - CoglFixed radius_x, - CoglFixed radius_y, - CoglAngle angle_1, - CoglAngle angle_2, - CoglAngle angle_step, +_cogl_path_arc (float center_x, + float center_y, + float radius_x, + float radius_y, + float angle_1, + float angle_2, + float angle_step, guint move_first) { - CoglAngle a = 0x0; - CoglFixed cosa = 0x0; - CoglFixed sina = 0x0; - CoglFixed px = 0x0; - CoglFixed py = 0x0; + float a = 0x0; + float cosa = 0x0; + float sina = 0x0; + float px = 0x0; + float py = 0x0; /* Fix invalid angles */ @@ -252,11 +252,11 @@ _cogl_path_arc (CoglFixed center_x, a = angle_1; while (a != angle_2) { - cosa = cogl_angle_cos (a); - sina = cogl_angle_sin (a); + cosa = cosf (a * (G_PI/180.0)); + sina = sinf (a * (G_PI/180.0)); - px = center_x + COGL_FIXED_MUL (cosa, radius_x); - py = center_y + COGL_FIXED_MUL (sina, radius_y); + px = center_x + (cosa * radius_x); + py = center_y + (sina * radius_y); if (a == angle_1 && move_first) cogl_path_move_to (px, py); @@ -279,24 +279,24 @@ _cogl_path_arc (CoglFixed center_x, /* Make sure the final point is drawn */ - cosa = cogl_angle_cos (angle_2); - sina = cogl_angle_sin (angle_2); + cosa = cosf (angle_2 * (G_PI/180.0)); + sina = sinf (angle_2 * (G_PI/180.0)); - px = center_x + COGL_FIXED_MUL (cosa, radius_x); - py = center_y + COGL_FIXED_MUL (sina, radius_y); + px = center_x + (cosa * radius_x); + py = center_y + (sina * radius_y); cogl_path_line_to (px, py); } void -cogl_path_arc (CoglFixed center_x, - CoglFixed center_y, - CoglFixed radius_x, - CoglFixed radius_y, - CoglAngle angle_1, - CoglAngle angle_2) +cogl_path_arc (float center_x, + float center_y, + float radius_x, + float radius_y, + float angle_1, + float angle_2) { - CoglAngle angle_step = 10; + float angle_step = 10; /* it is documented that a move to is needed to create a freestanding * arc */ @@ -308,13 +308,13 @@ cogl_path_arc (CoglFixed center_x, void -cogl_path_arc_rel (CoglFixed center_x, - CoglFixed center_y, - CoglFixed radius_x, - CoglFixed radius_y, - CoglAngle angle_1, - CoglAngle angle_2, - CoglAngle angle_step) +cogl_path_arc_rel (float center_x, + float center_y, + float radius_x, + float radius_y, + float angle_1, + float angle_2, + float angle_step) { _COGL_GET_CONTEXT (ctx, NO_RETVAL); @@ -326,50 +326,50 @@ cogl_path_arc_rel (CoglFixed center_x, } void -cogl_path_ellipse (CoglFixed center_x, - CoglFixed center_y, - CoglFixed radius_x, - CoglFixed radius_y) +cogl_path_ellipse (float center_x, + float center_y, + float radius_x, + float radius_y) { - CoglAngle angle_step = 10; + float angle_step = 10; /* FIXME: if shows to be slow might be optimized * by mirroring just a quarter of it */ _cogl_path_arc (center_x, center_y, radius_x, radius_y, - 0, COGL_ANGLE_FROM_DEG (360), + 0, 360, angle_step, 1 /* move first */); cogl_path_close(); } void -cogl_path_round_rectangle (CoglFixed x, - CoglFixed y, - CoglFixed width, - CoglFixed height, - CoglFixed radius, - CoglAngle arc_step) +cogl_path_round_rectangle (float x, + float y, + float width, + float height, + float radius, + float arc_step) { - CoglFixed inner_width = width - (radius << 1); - CoglFixed inner_height = height - (radius << 1); + float inner_width = width - (radius * 2); + float inner_height = height - (radius * 2); _COGL_GET_CONTEXT (ctx, NO_RETVAL); cogl_path_move_to (x, y + radius); cogl_path_arc_rel (radius, 0, radius, radius, - COGL_ANGLE_FROM_DEG (180), - COGL_ANGLE_FROM_DEG (270), + 180, + 270, arc_step); cogl_path_line_to (ctx->path_pen.x + inner_width, ctx->path_pen.y); cogl_path_arc_rel (0, radius, radius, radius, - COGL_ANGLE_FROM_DEG (-90), - COGL_ANGLE_FROM_DEG (0), + -90, + 0, arc_step); cogl_path_line_to (ctx->path_pen.x, @@ -377,16 +377,16 @@ cogl_path_round_rectangle (CoglFixed x, cogl_path_arc_rel (-radius, 0, radius, radius, - COGL_ANGLE_FROM_DEG (0), - COGL_ANGLE_FROM_DEG (90), + 0, + 90, arc_step); cogl_path_line_to (ctx->path_pen.x - inner_width, ctx->path_pen.y); cogl_path_arc_rel (0, -radius, radius, radius, - COGL_ANGLE_FROM_DEG (90), - COGL_ANGLE_FROM_DEG (180), + 90, + 180, arc_step); cogl_path_close (); @@ -400,14 +400,14 @@ _cogl_path_bezier3_sub (CoglBezCubic *cubic) CoglBezCubic *cleft; CoglBezCubic *cright; CoglBezCubic *c; - CoglFixedVec2 dif1; - CoglFixedVec2 dif2; - CoglFixedVec2 mm; - CoglFixedVec2 c1; - CoglFixedVec2 c2; - CoglFixedVec2 c3; - CoglFixedVec2 c4; - CoglFixedVec2 c5; + floatVec2 dif1; + floatVec2 dif2; + floatVec2 mm; + floatVec2 c1; + floatVec2 c2; + floatVec2 c3; + floatVec2 c4; + floatVec2 c5; gint cindex; /* Put first curve on stack */ @@ -418,16 +418,13 @@ _cogl_path_bezier3_sub (CoglBezCubic *cubic) { c = &cubics[cindex]; -#define CFX_MUL2(x) ((x) << 1) -#define CFX_MUL3(x) (((x) << 1) + (x)) -#define CFX_SQ(x) COGL_FIXED_MUL (x, x) /* Calculate distance of control points from their * counterparts on the line between end points */ - dif1.x = CFX_MUL3 (c->p2.x) - CFX_MUL2 (c->p1.x) - c->p4.x; - dif1.y = CFX_MUL3 (c->p2.y) - CFX_MUL2 (c->p1.y) - c->p4.y; - dif2.x = CFX_MUL3 (c->p3.x) - CFX_MUL2 (c->p4.x) - c->p1.x; - dif2.y = CFX_MUL3 (c->p3.y) - CFX_MUL2 (c->p4.y) - c->p1.y; + dif1.x = (c->p2.x * 3) - (c->p1.x * 2) - c->p4.x; + dif1.y = (c->p2.y * 3) - (c->p1.y * 2) - c->p4.y; + dif2.x = (c->p3.x * 3) - (c->p4.x * 2) - c->p1.x; + dif2.y = (c->p3.y * 3) - (c->p4.y * 2) - c->p1.y; if (dif1.x < 0) dif1.x = -dif1.x; @@ -438,16 +435,13 @@ _cogl_path_bezier3_sub (CoglBezCubic *cubic) if (dif2.y < 0) dif2.y = -dif2.y; -#undef CFX_MUL2 -#undef CFX_MUL3 -#undef CFX_SQ /* Pick the greatest of two distances */ if (dif1.x < dif2.x) dif1.x = dif2.x; if (dif1.y < dif2.y) dif1.y = dif2.y; /* Cancel if the curve is flat enough */ - if (dif1.x + dif1.y <= COGL_FIXED_1 || + if (dif1.x + dif1.y <= 1.0 || cindex == _COGL_MAX_BEZ_RECURSE_DEPTH-1) { /* Add subdivision point (skip last) */ @@ -465,20 +459,20 @@ _cogl_path_bezier3_sub (CoglBezCubic *cubic) cright = c; cleft = &cubics[++cindex]; /* Subdivide into 2 sub-curves */ - c1.x = ((c->p1.x + c->p2.x) >> 1); - c1.y = ((c->p1.y + c->p2.y) >> 1); - mm.x = ((c->p2.x + c->p3.x) >> 1); - mm.y = ((c->p2.y + c->p3.y) >> 1); - c5.x = ((c->p3.x + c->p4.x) >> 1); - c5.y = ((c->p3.y + c->p4.y) >> 1); + c1.x = ((c->p1.x + c->p2.x) / 2); + c1.y = ((c->p1.y + c->p2.y) / 2); + mm.x = ((c->p2.x + c->p3.x) / 2); + mm.y = ((c->p2.y + c->p3.y) / 2); + c5.x = ((c->p3.x + c->p4.x) / 2); + c5.y = ((c->p3.y + c->p4.y) / 2); - c2.x = ((c1.x + mm.x) >> 1); - c2.y = ((c1.y + mm.y) >> 1); - c4.x = ((mm.x + c5.x) >> 1); - c4.y = ((mm.y + c5.y) >> 1); + c2.x = ((c1.x + mm.x) / 2); + c2.y = ((c1.y + mm.y) / 2); + c4.x = ((mm.x + c5.x) / 2); + c4.y = ((mm.y + c5.y) / 2); - c3.x = ((c2.x + c4.x) >> 1); - c3.y = ((c2.y + c4.y) >> 1); + c3.x = ((c2.x + c4.x) / 2); + c3.y = ((c2.y + c4.y) / 2); /* Add left recursion to stack */ cleft->p1 = c->p1; @@ -495,12 +489,12 @@ _cogl_path_bezier3_sub (CoglBezCubic *cubic) } void -cogl_path_curve_to (CoglFixed x1, - CoglFixed y1, - CoglFixed x2, - CoglFixed y2, - CoglFixed x3, - CoglFixed y3) +cogl_path_curve_to (float x1, + float y1, + float x2, + float y2, + float x3, + float y3) { CoglBezCubic cubic; @@ -524,12 +518,12 @@ cogl_path_curve_to (CoglFixed x1, } void -cogl_path_rel_curve_to (CoglFixed x1, - CoglFixed y1, - CoglFixed x2, - CoglFixed y2, - CoglFixed x3, - CoglFixed y3) +cogl_path_rel_curve_to (float x1, + float y1, + float x2, + float y2, + float x3, + float y3) { _COGL_GET_CONTEXT (ctx, NO_RETVAL); @@ -554,11 +548,11 @@ _cogl_path_bezier2_sub (CoglBezQuad *quad) CoglBezQuad *qleft; CoglBezQuad *qright; CoglBezQuad *q; - CoglFixedVec2 mid; - CoglFixedVec2 dif; - CoglFixedVec2 c1; - CoglFixedVec2 c2; - CoglFixedVec2 c3; + floatVec2 mid; + floatVec2 dif; + floatVec2 c1; + floatVec2 c2; + floatVec2 c3; gint qindex; /* Put first curve on stack */ @@ -573,15 +567,15 @@ _cogl_path_bezier2_sub (CoglBezQuad *quad) /* Calculate distance of control point from its * counterpart on the line between end points */ - mid.x = ((q->p1.x + q->p3.x) >> 1); - mid.y = ((q->p1.y + q->p3.y) >> 1); + mid.x = ((q->p1.x + q->p3.x) / 2); + mid.y = ((q->p1.y + q->p3.y) / 2); dif.x = (q->p2.x - mid.x); dif.y = (q->p2.y - mid.y); if (dif.x < 0) dif.x = -dif.x; if (dif.y < 0) dif.y = -dif.y; /* Cancel if the curve is flat enough */ - if (dif.x + dif.y <= COGL_FIXED_1 || + if (dif.x + dif.y <= 1.0 || qindex == _COGL_MAX_BEZ_RECURSE_DEPTH - 1) { /* Add subdivision point (skip last) */ @@ -594,12 +588,12 @@ _cogl_path_bezier2_sub (CoglBezQuad *quad) qright = q; qleft = &quads[++qindex]; /* Subdivide into 2 sub-curves */ - c1.x = ((q->p1.x + q->p2.x) >> 1); - c1.y = ((q->p1.y + q->p2.y) >> 1); - c3.x = ((q->p2.x + q->p3.x) >> 1); - c3.y = ((q->p2.y + q->p3.y) >> 1); - c2.x = ((c1.x + c3.x) >> 1); - c2.y = ((c1.y + c3.y) >> 1); + c1.x = ((q->p1.x + q->p2.x) / 2); + c1.y = ((q->p1.y + q->p2.y) / 2); + c3.x = ((q->p2.x + q->p3.x) / 2); + c3.y = ((q->p2.y + q->p3.y) / 2); + c2.x = ((c1.x + c3.x) / 2); + c2.y = ((c1.y + c3.y) / 2); /* Add left recursion onto stack */ qleft->p1 = q->p1; @@ -614,10 +608,10 @@ _cogl_path_bezier2_sub (CoglBezQuad *quad) } void -cogl_path_curve2_to (CoglFixed x1, - CoglFixed y1, - CoglFixed x2, - CoglFixed y2) +cogl_path_curve2_to (float x1, + float y1, + float x2, + float y2) { _COGL_GET_CONTEXT (ctx, NO_RETVAL); @@ -639,10 +633,10 @@ cogl_path_curve2_to (CoglFixed x1, } void -cogl_rel_curve2_to (CoglFixed x1, - CoglFixed y1, - CoglFixed x2, - CoglFixed y2) +cogl_rel_curve2_to (float x1, + float y1, + float x2, + float y2) { _COGL_GET_CONTEXT (ctx, NO_RETVAL); diff --git a/clutter/cogl/common/cogl-primitives.h b/clutter/cogl/common/cogl-primitives.h index 01905d611..0a54ec145 100644 --- a/clutter/cogl/common/cogl-primitives.h +++ b/clutter/cogl/common/cogl-primitives.h @@ -26,15 +26,15 @@ #ifndef __COGL_PRIMITIVES_H #define __COGL_PRIMITIVES_H -typedef struct _CoglFixedVec2 CoglFixedVec2; +typedef struct _floatVec2 floatVec2; typedef struct _CoglBezQuad CoglBezQuad; typedef struct _CoglBezCubic CoglBezCubic; typedef struct _CoglPathNode CoglPathNode; -struct _CoglFixedVec2 +struct _floatVec2 { - CoglFixed x; - CoglFixed y; + float x; + float y; }; #ifdef CLUTTER_COGL_HAS_GL @@ -67,17 +67,17 @@ struct _CoglPathNode struct _CoglBezQuad { - CoglFixedVec2 p1; - CoglFixedVec2 p2; - CoglFixedVec2 p3; + floatVec2 p1; + floatVec2 p2; + floatVec2 p3; }; struct _CoglBezCubic { - CoglFixedVec2 p1; - CoglFixedVec2 p2; - CoglFixedVec2 p3; - CoglFixedVec2 p4; + floatVec2 p1; + floatVec2 p2; + floatVec2 p3; + floatVec2 p4; }; #endif /* __COGL_PRIMITIVES_H */ diff --git a/clutter/cogl/gl/cogl-context.h b/clutter/cogl/gl/cogl-context.h index d49330763..ec8d85e03 100644 --- a/clutter/cogl/gl/cogl-context.h +++ b/clutter/cogl/gl/cogl-context.h @@ -51,12 +51,12 @@ typedef struct gboolean enable_backface_culling; /* Primitives */ - CoglFixedVec2 path_start; - CoglFixedVec2 path_pen; + floatVec2 path_start; + floatVec2 path_pen; GArray *path_nodes; guint last_path; - CoglFixedVec2 path_nodes_min; - CoglFixedVec2 path_nodes_max; + floatVec2 path_nodes_min; + floatVec2 path_nodes_max; /* Cache of inverse projection matrix */ GLfloat inverse_projection[16]; diff --git a/clutter/cogl/gl/cogl-primitives.c b/clutter/cogl/gl/cogl-primitives.c index ca46d85ac..dc5c5c62a 100644 --- a/clutter/cogl/gl/cogl-primitives.c +++ b/clutter/cogl/gl/cogl-primitives.c @@ -53,33 +53,33 @@ _cogl_rectangle (gint x, void -_cogl_rectanglex (CoglFixed x, - CoglFixed y, - CoglFixed width, - CoglFixed height) +_cogl_rectanglex (float x, + float y, + float width, + float height) { _COGL_GET_CONTEXT (ctx, NO_RETVAL); cogl_enable (ctx->color_alpha < 255 ? COGL_ENABLE_BLEND : 0); - GE( glRectf (COGL_FIXED_TO_FLOAT (x), - COGL_FIXED_TO_FLOAT (y), - COGL_FIXED_TO_FLOAT (x + width), - COGL_FIXED_TO_FLOAT (y + height)) ); + GE( glRectf ( (x), + (y), + (x + width), + (y + height)) ); } void _cogl_path_add_node (gboolean new_sub_path, - CoglFixed x, - CoglFixed y) + float x, + float y) { CoglPathNode new_node; _COGL_GET_CONTEXT (ctx, NO_RETVAL); - new_node.x = COGL_FIXED_TO_FLOAT (x); - new_node.y = COGL_FIXED_TO_FLOAT (y); + new_node.x = (x); + new_node.y = (y); new_node.path_size = 0; if (new_sub_path || ctx->path_nodes->len == 0) @@ -129,24 +129,24 @@ _cogl_path_stroke_nodes () } static void -_cogl_path_get_bounds (CoglFixedVec2 nodes_min, - CoglFixedVec2 nodes_max, +_cogl_path_get_bounds (floatVec2 nodes_min, + floatVec2 nodes_max, gint *bounds_x, gint *bounds_y, guint *bounds_w, guint *bounds_h) { - *bounds_x = COGL_FIXED_FLOOR (nodes_min.x); - *bounds_y = COGL_FIXED_FLOOR (nodes_min.y); - *bounds_w = COGL_FIXED_CEIL (nodes_max.x - - COGL_FIXED_FROM_INT (*bounds_x)); - *bounds_h = COGL_FIXED_CEIL (nodes_max.y - - COGL_FIXED_FROM_INT (*bounds_y)); + *bounds_x = floorf (nodes_min.x); + *bounds_y = floorf (nodes_min.y); + *bounds_w = ceilf (nodes_max.x + - (float)(*bounds_x)); + *bounds_h = ceilf (nodes_max.y + - (float)(*bounds_y)); } void -_cogl_add_path_to_stencil_buffer (CoglFixedVec2 nodes_min, - CoglFixedVec2 nodes_max, +_cogl_add_path_to_stencil_buffer (floatVec2 nodes_min, + floatVec2 nodes_max, guint path_size, CoglPathNode *path, gboolean merge) diff --git a/clutter/cogl/gl/cogl-texture.c b/clutter/cogl/gl/cogl-texture.c index 4c30639a9..5b7326cc7 100644 --- a/clutter/cogl/gl/cogl-texture.c +++ b/clutter/cogl/gl/cogl-texture.c @@ -54,15 +54,15 @@ struct _CoglSpanIter gint index; GArray *array; CoglTexSliceSpan *span; - CoglFixed pos; - CoglFixed next_pos; - CoglFixed origin; - CoglFixed cover_start; - CoglFixed cover_end; - CoglFixed intersect_start; - CoglFixed intersect_end; - CoglFixed intersect_start_local; - CoglFixed intersect_end_local; + float pos; + float next_pos; + float origin; + float cover_start; + float cover_end; + float intersect_start; + float intersect_end; + float intersect_start_local; + float intersect_end_local; gboolean intersects; }; @@ -102,7 +102,7 @@ _cogl_span_iter_update (CoglSpanIter *iter) /* Offset next position by span size */ iter->next_pos = iter->pos + - COGL_FIXED_FROM_INT (iter->span->size - iter->span->waste); + (float)(iter->span->size - iter->span->waste); /* Check if span intersects the area to cover */ if (iter->next_pos <= iter->cover_start || @@ -131,9 +131,9 @@ _cogl_span_iter_update (CoglSpanIter *iter) static void _cogl_span_iter_begin (CoglSpanIter *iter, GArray *array, - CoglFixed origin, - CoglFixed cover_start, - CoglFixed cover_end) + float origin, + float cover_start, + float cover_end) { /* Copy info */ iter->index = 0; @@ -471,8 +471,8 @@ _cogl_texture_upload_subregion_to_gl (CoglTexture *tex, /* Iterate vertical spans */ for (source_y = src_y, _cogl_span_iter_begin (&y_iter, tex->slice_y_spans, - 0, COGL_FIXED_FROM_INT (dst_y), - COGL_FIXED_FROM_INT (dst_y + height)); + 0, (float)(dst_y), + (float)(dst_y + height)); !_cogl_span_iter_end (&y_iter); @@ -492,8 +492,8 @@ _cogl_texture_upload_subregion_to_gl (CoglTexture *tex, /* Iterate horizontal spans */ for (source_x = src_x, _cogl_span_iter_begin (&x_iter, tex->slice_x_spans, - 0, COGL_FIXED_FROM_INT (dst_x), - COGL_FIXED_FROM_INT (dst_x + width)); + 0, (float)(dst_x), + (float)(dst_x + width)); !_cogl_span_iter_end (&x_iter); @@ -511,15 +511,15 @@ _cogl_texture_upload_subregion_to_gl (CoglTexture *tex, x_iter.index); /* Pick intersection width and height */ - inter_w = COGL_FIXED_TO_INT (x_iter.intersect_end - + inter_w = (x_iter.intersect_end - x_iter.intersect_start); - inter_h = COGL_FIXED_TO_INT (y_iter.intersect_end - + inter_h = (y_iter.intersect_end - y_iter.intersect_start); /* Localize intersection top-left corner to slice*/ - local_x = COGL_FIXED_TO_INT (x_iter.intersect_start - + local_x = (x_iter.intersect_start - x_iter.pos); - local_y = COGL_FIXED_TO_INT (y_iter.intersect_start - + local_y = (y_iter.intersect_start - y_iter.pos); /* Pick slice GL handle */ @@ -555,7 +555,7 @@ _cogl_texture_upload_subregion_to_gl (CoglTexture *tex, guint wx, wy; src = source_bmp->data - + (src_y + COGL_FIXED_TO_INT (y_iter.intersect_start) + + (src_y + (y_iter.intersect_start) - dst_y) * source_bmp->rowstride + (src_x + x_span->start + x_span->size - x_span->waste @@ -600,7 +600,7 @@ _cogl_texture_upload_subregion_to_gl (CoglTexture *tex, guint copy_width; src = source_bmp->data - + (src_x + COGL_FIXED_TO_INT (x_iter.intersect_start) + + (src_x + (x_iter.intersect_start) - dst_x) * bpp + (src_y + y_span->start + y_span->size - y_span->waste @@ -2010,24 +2010,24 @@ _cogl_texture_add_quad_vertices (GLfloat x1, GLfloat y1, static void _cogl_texture_quad_sw (CoglTexture *tex, - CoglFixed x1, - CoglFixed y1, - CoglFixed x2, - CoglFixed y2, - CoglFixed tx1, - CoglFixed ty1, - CoglFixed tx2, - CoglFixed ty2) + float x1, + float y1, + float x2, + float y2, + float tx1, + float ty1, + float tx2, + float ty2) { CoglSpanIter iter_x , iter_y; - CoglFixed tw , th; - CoglFixed tqx , tqy; - CoglFixed first_tx , first_ty; - CoglFixed first_qx , first_qy; - CoglFixed slice_tx1 , slice_ty1; - CoglFixed slice_tx2 , slice_ty2; - CoglFixed slice_qx1 , slice_qy1; - CoglFixed slice_qx2 , slice_qy2; + float tw , th; + float tqx , tqy; + float first_tx , first_ty; + float first_qx , first_qy; + float slice_tx1 , slice_ty1; + float slice_tx2 , slice_ty2; + float slice_qx1 , slice_qy1; + float slice_qx2 , slice_qy2; GLuint gl_handle; _COGL_GET_CONTEXT (ctx, NO_RETVAL); @@ -2050,7 +2050,7 @@ _cogl_texture_quad_sw (CoglTexture *tex, slices */ if (tx2 < tx1) { - CoglFixed temp = x1; + float temp = x1; x1 = x2; x2 = temp; temp = tx1; @@ -2059,7 +2059,7 @@ _cogl_texture_quad_sw (CoglTexture *tex, } if (ty2 < ty1) { - CoglFixed temp = y1; + float temp = y1; y1 = y2; y2 = temp; temp = ty1; @@ -2068,27 +2068,27 @@ _cogl_texture_quad_sw (CoglTexture *tex, } /* Scale ratio from texture to quad widths */ - tw = COGL_FIXED_FROM_INT (tex->bitmap.width); - th = COGL_FIXED_FROM_INT (tex->bitmap.height); + tw = (float)(tex->bitmap.width); + th = (float)(tex->bitmap.height); - tqx = COGL_FIXED_DIV (x2 - x1, COGL_FIXED_MUL (tw, (tx2 - tx1))); - tqy = COGL_FIXED_DIV (y2 - y1, COGL_FIXED_MUL (th, (ty2 - ty1))); + tqx = (x2 - x1 / (tw * (tx2 - tx1))); + tqy = (y2 - y1 / (th * (ty2 - ty1))); /* Integral texture coordinate for first tile */ - first_tx = COGL_FIXED_FROM_INT (COGL_FIXED_FLOOR (tx1)); - first_ty = COGL_FIXED_FROM_INT (COGL_FIXED_FLOOR (ty1)); + first_tx = (float)(floorf (tx1)); + first_ty = (float)(floorf (ty1)); /* Denormalize texture coordinates */ - first_tx = COGL_FIXED_MUL (first_tx, tw); - first_ty = COGL_FIXED_MUL (first_ty, th); - tx1 = COGL_FIXED_MUL (tx1, tw); - ty1 = COGL_FIXED_MUL (ty1, th); - tx2 = COGL_FIXED_MUL (tx2, tw); - ty2 = COGL_FIXED_MUL (ty2, th); + first_tx = (first_tx * tw); + first_ty = (first_ty * th); + tx1 = (tx1 * tw); + ty1 = (ty1 * th); + tx2 = (tx2 * tw); + ty2 = (ty2 * th); /* Quad coordinate of the first tile */ - first_qx = x1 - COGL_FIXED_MUL (tx1 - first_tx, tqx); - first_qy = y1 - COGL_FIXED_MUL (ty1 - first_ty, tqy); + first_qx = x1 - (tx1 - first_tx * tqx); + first_qy = y1 - (ty1 - first_ty * tqy); /* Iterate until whole quad height covered */ @@ -2102,10 +2102,10 @@ _cogl_texture_quad_sw (CoglTexture *tex, /* Span-quad intersection in quad coordinates */ slice_qy1 = first_qy + - COGL_FIXED_MUL (iter_y.intersect_start - first_ty, tqy); + (iter_y.intersect_start - first_ty * tqy); slice_qy2 = first_qy + - COGL_FIXED_MUL (iter_y.intersect_end - first_ty, tqy); + (iter_y.intersect_end - first_ty * tqy); /* Localize slice texture coordinates */ slice_ty1 = iter_y.intersect_start - iter_y.pos; @@ -2130,10 +2130,10 @@ _cogl_texture_quad_sw (CoglTexture *tex, /* Span-quad intersection in quad coordinates */ slice_qx1 = first_qx + - COGL_FIXED_MUL (iter_x.intersect_start - first_tx, tqx); + (iter_x.intersect_start - first_tx * tqx); slice_qx2 = first_qx + - COGL_FIXED_MUL (iter_x.intersect_end - first_tx, tqx); + (iter_x.intersect_end - first_tx * tqx); /* Localize slice texture coordinates */ slice_tx1 = iter_x.intersect_start - iter_x.pos; @@ -2149,14 +2149,14 @@ _cogl_texture_quad_sw (CoglTexture *tex, #if COGL_DEBUG printf("~~~~~ slice (%d,%d)\n", iter_x.index, iter_y.index); - printf("qx1: %f\n", COGL_FIXED_TO_FLOAT (slice_qx1)); - printf("qy1: %f\n", COGL_FIXED_TO_FLOAT (slice_qy1)); - printf("qx2: %f\n", COGL_FIXED_TO_FLOAT (slice_qx2)); - printf("qy2: %f\n", COGL_FIXED_TO_FLOAT (slice_qy2)); - printf("tx1: %f\n", COGL_FIXED_TO_FLOAT (slice_tx1)); - printf("ty1: %f\n", COGL_FIXED_TO_FLOAT (slice_ty1)); - printf("tx2: %f\n", COGL_FIXED_TO_FLOAT (slice_tx2)); - printf("ty2: %f\n", COGL_FIXED_TO_FLOAT (slice_ty2)); + printf("qx1: %f\n", (slice_qx1)); + printf("qy1: %f\n", (slice_qy1)); + printf("qx2: %f\n", (slice_qx2)); + printf("qy2: %f\n", (slice_qy2)); + printf("tx1: %f\n", (slice_tx1)); + printf("ty1: %f\n", (slice_ty1)); + printf("tx2: %f\n", (slice_tx2)); + printf("ty2: %f\n", (slice_ty2)); #endif /* Pick and bind opengl texture object */ @@ -2172,28 +2172,28 @@ _cogl_texture_quad_sw (CoglTexture *tex, ctx->texture_target = tex->gl_target; ctx->texture_current = gl_handle; - _cogl_texture_add_quad_vertices (COGL_FIXED_TO_FLOAT (slice_qx1), - COGL_FIXED_TO_FLOAT (slice_qy1), - COGL_FIXED_TO_FLOAT (slice_qx2), - COGL_FIXED_TO_FLOAT (slice_qy2), - COGL_FIXED_TO_FLOAT (slice_tx1), - COGL_FIXED_TO_FLOAT (slice_ty1), - COGL_FIXED_TO_FLOAT (slice_tx2), - COGL_FIXED_TO_FLOAT (slice_ty2)); + _cogl_texture_add_quad_vertices ( (slice_qx1), + (slice_qy1), + (slice_qx2), + (slice_qy2), + (slice_tx1), + (slice_ty1), + (slice_tx2), + (slice_ty2)); } } } static void _cogl_texture_quad_hw (CoglTexture *tex, - CoglFixed x1, - CoglFixed y1, - CoglFixed x2, - CoglFixed y2, - CoglFixed tx1, - CoglFixed ty1, - CoglFixed tx2, - CoglFixed ty2) + float x1, + float y1, + float x2, + float y2, + float tx1, + float ty1, + float tx2, + float ty2) { GLuint gl_handle; CoglTexSliceSpan *x_span; @@ -2209,10 +2209,10 @@ _cogl_texture_quad_hw (CoglTexture *tex, /* If the texture coords are all in the range [0,1] then we want to clamp the coords to the edge otherwise it can pull in edge pixels from the wrong side when scaled */ - if (tx1 >= 0 && tx1 <= COGL_FIXED_1 - && tx2 >= 0 && tx2 <= COGL_FIXED_1 - && ty1 >= 0 && ty1 <= COGL_FIXED_1 - && ty2 >= 0 && ty2 <= COGL_FIXED_1) + if (tx1 >= 0 && tx1 <= 1.0 + && tx2 >= 0 && tx2 <= 1.0 + && ty1 >= 0 && ty1 <= 1.0 + && ty2 >= 0 && ty2 <= 1.0) wrap_mode = GL_CLAMP_TO_EDGE; else wrap_mode = GL_REPEAT; @@ -2251,19 +2251,19 @@ _cogl_texture_quad_hw (CoglTexture *tex, ty2 *= y_span->size; } - _cogl_texture_add_quad_vertices (COGL_FIXED_TO_FLOAT (x1), - COGL_FIXED_TO_FLOAT (y1), - COGL_FIXED_TO_FLOAT (x2), - COGL_FIXED_TO_FLOAT (y2), - COGL_FIXED_TO_FLOAT (tx1), - COGL_FIXED_TO_FLOAT (ty1), - COGL_FIXED_TO_FLOAT (tx2), - COGL_FIXED_TO_FLOAT (ty2)); + _cogl_texture_add_quad_vertices ( (x1), + (y1), + (x2), + (y2), + (tx1), + (ty1), + (tx2), + (ty2)); } void cogl_texture_multiple_rectangles (CoglHandle handle, - const CoglFixed *verts, + const float *verts, guint n_rects) { CoglTexture *tex; @@ -2314,10 +2314,10 @@ cogl_texture_multiple_rectangles (CoglHandle handle, if (tex->slice_gl_handles->len == 1 && ((cogl_features_available (COGL_FEATURE_TEXTURE_NPOT) && tex->gl_target == GL_TEXTURE_2D) - || (verts[4] >= 0 && verts[4] <= COGL_FIXED_1 - && verts[6] >= 0 && verts[6] <= COGL_FIXED_1 - && verts[5] >= 0 && verts[5] <= COGL_FIXED_1 - && verts[7] >= 0 && verts[7] <= COGL_FIXED_1))) + || (verts[4] >= 0 && verts[4] <= 1.0 + && verts[6] >= 0 && verts[6] <= 1.0 + && verts[5] >= 0 && verts[5] <= 1.0 + && verts[7] >= 0 && verts[7] <= 1.0))) _cogl_texture_quad_hw (tex, verts[0],verts[1], verts[2],verts[3], verts[4],verts[5], verts[6],verts[7]); else @@ -2333,16 +2333,16 @@ cogl_texture_multiple_rectangles (CoglHandle handle, void cogl_texture_rectangle (CoglHandle handle, - CoglFixed x1, - CoglFixed y1, - CoglFixed x2, - CoglFixed y2, - CoglFixed tx1, - CoglFixed ty1, - CoglFixed tx2, - CoglFixed ty2) + float x1, + float y1, + float x2, + float y2, + float tx1, + float ty1, + float tx2, + float ty2) { - CoglFixed verts[8]; + float verts[8]; verts[0] = x1; verts[1] = y1; @@ -2455,16 +2455,16 @@ cogl_texture_polygon (CoglHandle handle, OpenGL */ for (i = 0; i < n_vertices; i++, p++) { - CoglFixed tx, ty; + float tx, ty; -#define CFX_F COGL_FIXED_TO_FLOAT +#define CFX_F tx = ((vertices[i].tx - - (COGL_FIXED_FROM_INT (x_span->start) + - ((float)(x_span->start) / tex->bitmap.width)) * tex->bitmap.width / x_span->size); ty = ((vertices[i].ty - - (COGL_FIXED_FROM_INT (y_span->start) + - ((float)(y_span->start) / tex->bitmap.height)) * tex->bitmap.height / y_span->size); diff --git a/clutter/cogl/gl/cogl.c b/clutter/cogl/gl/cogl.c index 411cd8adc..7b61b6353 100644 --- a/clutter/cogl/gl/cogl.c +++ b/clutter/cogl/gl/cogl.c @@ -209,19 +209,19 @@ cogl_pop_matrix (void) } void -cogl_scale (CoglFixed x, CoglFixed y) +cogl_scale (float x, float y) { - glScaled (COGL_FIXED_TO_DOUBLE (x), - COGL_FIXED_TO_DOUBLE (y), + glScaled ((double)(x), + (double)(y), 1.0); } void -cogl_translatex (CoglFixed x, CoglFixed y, CoglFixed z) +cogl_translatex (float x, float y, float z) { - glTranslated (COGL_FIXED_TO_DOUBLE (x), - COGL_FIXED_TO_DOUBLE (y), - COGL_FIXED_TO_DOUBLE (z)); + glTranslated ((double)(x), + (double)(y), + (double)(z)); } void @@ -231,12 +231,12 @@ cogl_translate (gint x, gint y, gint z) } void -cogl_rotatex (CoglFixed angle, gint x, gint y, gint z) +cogl_rotatex (float angle, gint x, gint y, gint z) { - glRotated (COGL_FIXED_TO_DOUBLE (angle), - COGL_FIXED_TO_DOUBLE (x), - COGL_FIXED_TO_DOUBLE (y), - COGL_FIXED_TO_DOUBLE (z)); + glRotated ((double)(angle), + (double)(x), + (double)(y), + (double)(z)); } void @@ -466,24 +466,24 @@ set_clip_plane (GLint plane_num, } void -_cogl_set_clip_planes (CoglFixed x_offset, - CoglFixed y_offset, - CoglFixed width, - CoglFixed height) +_cogl_set_clip_planes (float x_offset, + float y_offset, + float width, + float height) { GLfloat modelview[16], projection[16]; - GLfloat vertex_tl[4] = { COGL_FIXED_TO_FLOAT (x_offset), - COGL_FIXED_TO_FLOAT (y_offset), + GLfloat vertex_tl[4] = { (x_offset), + (y_offset), 0.0f, 1.0f }; - GLfloat vertex_tr[4] = { COGL_FIXED_TO_FLOAT (x_offset + width), - COGL_FIXED_TO_FLOAT (y_offset), + GLfloat vertex_tr[4] = { (x_offset + width), + (y_offset), 0.0f, 1.0f }; - GLfloat vertex_bl[4] = { COGL_FIXED_TO_FLOAT (x_offset), - COGL_FIXED_TO_FLOAT (y_offset + height), + GLfloat vertex_bl[4] = { (x_offset), + (y_offset + height), 0.0f, 1.0f }; - GLfloat vertex_br[4] = { COGL_FIXED_TO_FLOAT (x_offset + width), - COGL_FIXED_TO_FLOAT (y_offset + height), + GLfloat vertex_br[4] = { (x_offset + width), + (y_offset + height), 0.0f, 1.0f }; GE( glGetFloatv (GL_MODELVIEW_MATRIX, modelview) ); @@ -518,10 +518,10 @@ _cogl_set_clip_planes (CoglFixed x_offset, } void -_cogl_add_stencil_clip (CoglFixed x_offset, - CoglFixed y_offset, - CoglFixed width, - CoglFixed height, +_cogl_add_stencil_clip (float x_offset, + float y_offset, + float width, + float height, gboolean first) { _COGL_GET_CONTEXT (ctx, NO_RETVAL); @@ -537,10 +537,10 @@ _cogl_add_stencil_clip (CoglFixed x_offset, /* Punch out a hole to allow the rectangle */ GE( glStencilFunc (GL_NEVER, 0x1, 0x1) ); GE( glStencilOp (GL_REPLACE, GL_REPLACE, GL_REPLACE) ); - GE( glRectf (COGL_FIXED_TO_FLOAT (x_offset), - COGL_FIXED_TO_FLOAT (y_offset), - COGL_FIXED_TO_FLOAT (x_offset + width), - COGL_FIXED_TO_FLOAT (y_offset + height)) ); + GE( glRectf ( (x_offset), + (y_offset), + (x_offset + width), + (y_offset + height)) ); } else { @@ -548,10 +548,10 @@ _cogl_add_stencil_clip (CoglFixed x_offset, rectangle */ GE( glStencilFunc (GL_NEVER, 0x1, 0x3) ); GE( glStencilOp (GL_INCR, GL_INCR, GL_INCR) ); - GE( glRectf (COGL_FIXED_TO_FLOAT (x_offset), - COGL_FIXED_TO_FLOAT (y_offset), - COGL_FIXED_TO_FLOAT (x_offset + width), - COGL_FIXED_TO_FLOAT (y_offset + height)) ); + GE( glRectf ( (x_offset), + (y_offset), + (x_offset + width), + (y_offset + height)) ); /* Subtract one from all pixels in the stencil buffer so that only pixels where both the original stencil buffer and the @@ -574,13 +574,13 @@ _cogl_add_stencil_clip (CoglFixed x_offset, } void -_cogl_set_matrix (const CoglFixed *matrix) +_cogl_set_matrix (const float *matrix) { float float_matrix[16]; int i; for (i = 0; i < 16; i++) - float_matrix[i] = COGL_FIXED_TO_FLOAT (matrix[i]); + float_matrix[i] = (matrix[i]); GE( glLoadIdentity () ); GE( glMultMatrixf (float_matrix) ); @@ -612,20 +612,20 @@ _cogl_disable_clip_planes (void) void cogl_alpha_func (COGLenum func, - CoglFixed ref) + float ref) { - GE( glAlphaFunc (func, COGL_FIXED_TO_FLOAT(ref)) ); + GE( glAlphaFunc (func, (ref)) ); } void -cogl_perspective (CoglFixed fovy, - CoglFixed aspect, - CoglFixed zNear, - CoglFixed zFar) +cogl_perspective (float fovy, + float aspect, + float zNear, + float zFar) { - CoglFixed xmax, ymax; - CoglFixed x, y, c, d; - CoglFixed fovy_rad_half = COGL_FIXED_MUL (fovy, COGL_FIXED_PI) / 360; + float xmax, ymax; + float x, y, c, d; + float fovy_rad_half = (fovy * G_PI) / 360; GLfloat m[16]; @@ -646,22 +646,22 @@ cogl_perspective (CoglFixed fovy, * precision */ ymax = - COGL_FIXED_MUL (zNear, - COGL_FIXED_FAST_DIV (cogl_fixed_sin (fovy_rad_half), - cogl_fixed_cos (fovy_rad_half))); + (zNear * + (sinf (fovy_rad_half) / + cosf (fovy_rad_half))); - xmax = COGL_FIXED_MUL (ymax, aspect); + xmax = (ymax * aspect); - x = COGL_FIXED_FAST_DIV (zNear, xmax); - y = COGL_FIXED_FAST_DIV (zNear, ymax); - c = COGL_FIXED_FAST_DIV (-(zFar + zNear), ( zFar - zNear)); + x = (zNear / xmax); + y = (zNear / ymax); + c = (-(zFar + zNear) / ( zFar - zNear)); d = cogl_fixed_mul_div (-(2 * zFar), zNear, (zFar - zNear)); #define M(row,col) m[col*4+row] - M(0,0) = COGL_FIXED_TO_FLOAT (x); - M(1,1) = COGL_FIXED_TO_FLOAT (y); - M(2,2) = COGL_FIXED_TO_FLOAT (c); - M(2,3) = COGL_FIXED_TO_FLOAT (d); + M(0,0) = (x); + M(1,1) = (y); + M(2,2) = (c); + M(2,3) = (d); M(3,2) = -1.0F; GE( glMultMatrixf (m) ); @@ -672,22 +672,22 @@ cogl_perspective (CoglFixed fovy, memset (ctx->inverse_projection, 0, sizeof (GLfloat) * 16); #define m ctx->inverse_projection - M(0, 0) = 1.0f / COGL_FIXED_TO_FLOAT (x); - M(1, 1) = 1.0f / COGL_FIXED_TO_FLOAT (y); + M(0, 0) = 1.0f / (x); + M(1, 1) = 1.0f / (y); M(2, 3) = -1.0f; - M(3, 2) = 1.0f / COGL_FIXED_TO_FLOAT (d); - M(3, 3) = COGL_FIXED_TO_FLOAT (c) / COGL_FIXED_TO_FLOAT (d); + M(3, 2) = 1.0f / (d); + M(3, 3) = (c) / (d); #undef m #undef M } void -cogl_frustum (CoglFixed left, - CoglFixed right, - CoglFixed bottom, - CoglFixed top, - CoglFixed z_near, - CoglFixed z_far) +cogl_frustum (float left, + float right, + float bottom, + float top, + float z_near, + float z_far) { GLfloat c, d; @@ -696,32 +696,32 @@ cogl_frustum (CoglFixed left, GE( glMatrixMode (GL_PROJECTION) ); GE( glLoadIdentity () ); - GE( glFrustum (COGL_FIXED_TO_DOUBLE (left), - COGL_FIXED_TO_DOUBLE (right), - COGL_FIXED_TO_DOUBLE (bottom), - COGL_FIXED_TO_DOUBLE (top), - COGL_FIXED_TO_DOUBLE (z_near), - COGL_FIXED_TO_DOUBLE (z_far)) ); + GE( glFrustum ((double)(left), + (double)(right), + (double)(bottom), + (double)(top), + (double)(z_near), + (double)(z_far)) ); GE( glMatrixMode (GL_MODELVIEW) ); /* Calculate and store the inverse of the matrix */ memset (ctx->inverse_projection, 0, sizeof (GLfloat) * 16); - c = -COGL_FIXED_TO_FLOAT (z_far + z_near) - / COGL_FIXED_TO_FLOAT (z_far - z_near); - d = -COGL_FIXED_TO_FLOAT (2 * COGL_FIXED_MUL (z_far, z_near)) - / COGL_FIXED_TO_FLOAT (z_far - z_near); + c = - (z_far + z_near) + / (z_far - z_near); + d = - (2 * (z_far * z_near)) + / (z_far - z_near); #define M(row,col) ctx->inverse_projection[col*4+row] - M(0,0) = COGL_FIXED_TO_FLOAT (right - left) - / COGL_FIXED_TO_FLOAT (2 * z_near); - M(0,3) = COGL_FIXED_TO_FLOAT (right + left) - / COGL_FIXED_TO_FLOAT (2 * z_near); - M(1,1) = COGL_FIXED_TO_FLOAT (top - bottom) - / COGL_FIXED_TO_FLOAT (2 * z_near); - M(1,3) = COGL_FIXED_TO_FLOAT (top + bottom) - / COGL_FIXED_TO_FLOAT (2 * z_near); + M(0,0) = (right - left) + / (2 * z_near); + M(0,3) = (right + left) + / (2 * z_near); + M(1,1) = (top - bottom) + / (2 * z_near); + M(1,3) = (top + bottom) + / (2 * z_near); M(2,3) = -1.0f; M(3,2) = 1.0f / d; M(3,3) = c / d; @@ -738,10 +738,10 @@ cogl_viewport (guint width, void cogl_setup_viewport (guint width, guint height, - CoglFixed fovy, - CoglFixed aspect, - CoglFixed z_near, - CoglFixed z_far) + float fovy, + float aspect, + float z_near, + float z_far) { GLfloat z_camera; @@ -769,13 +769,13 @@ cogl_setup_viewport (guint width, z_camera = DEFAULT_Z_CAMERA; - if (fovy != COGL_FIXED_60) + if (fovy != 60.0) { - CoglFixed fovy_rad = COGL_FIXED_MUL (fovy, COGL_FIXED_PI) / 180; + float fovy_rad = (fovy * G_PI) / 180; z_camera = - COGL_FIXED_TO_FLOAT (COGL_FIXED_DIV (cogl_fixed_sin (fovy_rad), - cogl_fixed_cos (fovy_rad)) >> 1); + ((sinf (fovy_rad) / + cosf (fovy_rad)) >> 1); } GE( glTranslatef (-0.5f, -0.5f, -z_camera) ); @@ -1164,75 +1164,75 @@ cogl_features_available (CoglFeatureFlags features) } void -cogl_get_modelview_matrix (CoglFixed m[16]) +cogl_get_modelview_matrix (float m[16]) { GLdouble md[16]; glGetDoublev(GL_MODELVIEW_MATRIX, &md[0]); #define M(m,row,col) m[col*4+row] - M(m,0,0) = COGL_FIXED_FROM_FLOAT (M(md,0,0)); - M(m,0,1) = COGL_FIXED_FROM_FLOAT (M(md,0,1)); - M(m,0,2) = COGL_FIXED_FROM_FLOAT (M(md,0,2)); - M(m,0,3) = COGL_FIXED_FROM_FLOAT (M(md,0,3)); + M(m,0,0) = (M(md,0,0)); + M(m,0,1) = (M(md,0,1)); + M(m,0,2) = (M(md,0,2)); + M(m,0,3) = (M(md,0,3)); - M(m,1,0) = COGL_FIXED_FROM_FLOAT (M(md,1,0)); - M(m,1,1) = COGL_FIXED_FROM_FLOAT (M(md,1,1)); - M(m,1,2) = COGL_FIXED_FROM_FLOAT (M(md,1,2)); - M(m,1,3) = COGL_FIXED_FROM_FLOAT (M(md,1,3)); + M(m,1,0) = (M(md,1,0)); + M(m,1,1) = (M(md,1,1)); + M(m,1,2) = (M(md,1,2)); + M(m,1,3) = (M(md,1,3)); - M(m,2,0) = COGL_FIXED_FROM_FLOAT (M(md,2,0)); - M(m,2,1) = COGL_FIXED_FROM_FLOAT (M(md,2,1)); - M(m,2,2) = COGL_FIXED_FROM_FLOAT (M(md,2,2)); - M(m,2,3) = COGL_FIXED_FROM_FLOAT (M(md,2,3)); + M(m,2,0) = (M(md,2,0)); + M(m,2,1) = (M(md,2,1)); + M(m,2,2) = (M(md,2,2)); + M(m,2,3) = (M(md,2,3)); - M(m,3,0) = COGL_FIXED_FROM_FLOAT (M(md,3,0)); - M(m,3,1) = COGL_FIXED_FROM_FLOAT (M(md,3,1)); - M(m,3,2) = COGL_FIXED_FROM_FLOAT (M(md,3,2)); - M(m,3,3) = COGL_FIXED_FROM_FLOAT (M(md,3,3)); + M(m,3,0) = (M(md,3,0)); + M(m,3,1) = (M(md,3,1)); + M(m,3,2) = (M(md,3,2)); + M(m,3,3) = (M(md,3,3)); #undef M } void -cogl_get_projection_matrix (CoglFixed m[16]) +cogl_get_projection_matrix (float m[16]) { GLdouble md[16]; glGetDoublev(GL_PROJECTION_MATRIX, &md[0]); #define M(m,row,col) m[col*4+row] - M(m,0,0) = COGL_FIXED_FROM_FLOAT (M(md,0,0)); - M(m,0,1) = COGL_FIXED_FROM_FLOAT (M(md,0,1)); - M(m,0,2) = COGL_FIXED_FROM_FLOAT (M(md,0,2)); - M(m,0,3) = COGL_FIXED_FROM_FLOAT (M(md,0,3)); + M(m,0,0) = (M(md,0,0)); + M(m,0,1) = (M(md,0,1)); + M(m,0,2) = (M(md,0,2)); + M(m,0,3) = (M(md,0,3)); - M(m,1,0) = COGL_FIXED_FROM_FLOAT (M(md,1,0)); - M(m,1,1) = COGL_FIXED_FROM_FLOAT (M(md,1,1)); - M(m,1,2) = COGL_FIXED_FROM_FLOAT (M(md,1,2)); - M(m,1,3) = COGL_FIXED_FROM_FLOAT (M(md,1,3)); + M(m,1,0) = (M(md,1,0)); + M(m,1,1) = (M(md,1,1)); + M(m,1,2) = (M(md,1,2)); + M(m,1,3) = (M(md,1,3)); - M(m,2,0) = COGL_FIXED_FROM_FLOAT (M(md,2,0)); - M(m,2,1) = COGL_FIXED_FROM_FLOAT (M(md,2,1)); - M(m,2,2) = COGL_FIXED_FROM_FLOAT (M(md,2,2)); - M(m,2,3) = COGL_FIXED_FROM_FLOAT (M(md,2,3)); + M(m,2,0) = (M(md,2,0)); + M(m,2,1) = (M(md,2,1)); + M(m,2,2) = (M(md,2,2)); + M(m,2,3) = (M(md,2,3)); - M(m,3,0) = COGL_FIXED_FROM_FLOAT (M(md,3,0)); - M(m,3,1) = COGL_FIXED_FROM_FLOAT (M(md,3,1)); - M(m,3,2) = COGL_FIXED_FROM_FLOAT (M(md,3,2)); - M(m,3,3) = COGL_FIXED_FROM_FLOAT (M(md,3,3)); + M(m,3,0) = (M(md,3,0)); + M(m,3,1) = (M(md,3,1)); + M(m,3,2) = (M(md,3,2)); + M(m,3,3) = (M(md,3,3)); #undef M } void -cogl_get_viewport (CoglFixed v[4]) +cogl_get_viewport (float v[4]) { GLdouble vd[4]; glGetDoublev(GL_VIEWPORT, &vd[0]); - v[0] = COGL_FIXED_FROM_FLOAT (vd[0]); - v[1] = COGL_FIXED_FROM_FLOAT (vd[1]); - v[2] = COGL_FIXED_FROM_FLOAT (vd[2]); - v[3] = COGL_FIXED_FROM_FLOAT (vd[3]); + v[0] = (vd[0]); + v[1] = (vd[1]); + v[2] = (vd[2]); + v[3] = (vd[3]); } void @@ -1263,9 +1263,9 @@ cogl_get_bitmasks (gint *red, gint *green, gint *blue, gint *alpha) void cogl_fog_set (const CoglColor *fog_color, - CoglFixed density, - CoglFixed start, - CoglFixed stop) + float density, + float start, + float stop) { GLfloat fogColor[4]; @@ -1281,8 +1281,8 @@ cogl_fog_set (const CoglColor *fog_color, glFogi (GL_FOG_MODE, GL_LINEAR); glHint (GL_FOG_HINT, GL_NICEST); - glFogf (GL_FOG_DENSITY, COGL_FIXED_TO_FLOAT (density)); - glFogf (GL_FOG_START, COGL_FIXED_TO_FLOAT (start)); - glFogf (GL_FOG_END, COGL_FIXED_TO_FLOAT (stop)); + glFogf (GL_FOG_DENSITY, (density)); + glFogf (GL_FOG_START, (start)); + glFogf (GL_FOG_END, (stop)); } diff --git a/clutter/cogl/gles/cogl-context.c b/clutter/cogl/gles/cogl-context.c index b09568de4..e5c017e80 100644 --- a/clutter/cogl/gles/cogl-context.c +++ b/clutter/cogl/gles/cogl-context.c @@ -80,7 +80,7 @@ cogl_create_context () #endif /* Init OpenGL state */ - GE( cogl_wrap_glTexEnvx (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE) ); + GE( cogl_wrap_glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE) ); GE( glColorMask (TRUE, TRUE, TRUE, FALSE) ); GE( glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) ); cogl_enable (0); diff --git a/clutter/cogl/gles/cogl-context.h b/clutter/cogl/gles/cogl-context.h index 92b8b96a2..d941aaa57 100644 --- a/clutter/cogl/gles/cogl-context.h +++ b/clutter/cogl/gles/cogl-context.h @@ -53,15 +53,15 @@ typedef struct gboolean enable_backface_culling; /* Primitives */ - CoglFixedVec2 path_start; - CoglFixedVec2 path_pen; + floatVec2 path_start; + floatVec2 path_pen; GArray *path_nodes; guint last_path; - CoglFixedVec2 path_nodes_min; - CoglFixedVec2 path_nodes_max; + floatVec2 path_nodes_min; + floatVec2 path_nodes_max; /* Cache of inverse projection matrix */ - CoglFixed inverse_projection[16]; + float inverse_projection[16]; /* Textures */ GArray *texture_handles; diff --git a/clutter/cogl/gles/cogl-fbo.c b/clutter/cogl/gles/cogl-fbo.c index d5b02818b..3b1099e26 100644 --- a/clutter/cogl/gles/cogl-fbo.c +++ b/clutter/cogl/gles/cogl-fbo.c @@ -227,12 +227,12 @@ cogl_draw_buffer (CoglBufferTarget target, CoglHandle offscreen) /* Setup new viewport and matrices */ GE( glViewport (0, 0, fbo->width, fbo->height) ); - GE( cogl_wrap_glTranslatex (-COGL_FIXED_1, -COGL_FIXED_1, 0) ); - GE( cogl_wrap_glScalex (COGL_FIXED_DIV (COGL_FIXED_FROM_INT (2), - COGL_FIXED_FROM_INT (fbo->width)), - COGL_FIXED_DIV (COGL_FIXED_FROM_INT (2), - COGL_FIXED_FROM_INT (fbo->height)), - COGL_FIXED_1) ); + GE( cogl_wrap_glTranslatef (-1.0, -1.0, 0) ); + GE( cogl_wrap_glScalef (((float)(2) / + (float)(fbo->width)), + ((float)(2) / + (float)(fbo->height)), + 1.0) ); /* Bind offscreen framebuffer object */ GE( glBindFramebuffer (GL_FRAMEBUFFER, fbo->gl_handle) ); diff --git a/clutter/cogl/gles/cogl-gles2-wrapper.c b/clutter/cogl/gles/cogl-gles2-wrapper.c index d43ad21da..4be0a55ba 100644 --- a/clutter/cogl/gles/cogl-gles2-wrapper.c +++ b/clutter/cogl/gles/cogl-gles2-wrapper.c @@ -104,7 +104,7 @@ cogl_gles2_wrapper_create_shader (GLenum type, const char *source) void cogl_gles2_wrapper_init (CoglGles2Wrapper *wrapper) { - GLfixed default_fog_color[4] = { 0, 0, 0, 0 }; + GLfloat default_fog_color[4] = { 0, 0, 0, 0 }; memset (wrapper, 0, sizeof (CoglGles2Wrapper)); @@ -118,11 +118,11 @@ cogl_gles2_wrapper_init (CoglGles2Wrapper *wrapper) /* Initialize the fogging options */ cogl_wrap_glDisable (GL_FOG); - cogl_wrap_glFogx (GL_FOG_MODE, GL_LINEAR); - cogl_wrap_glFogx (GL_FOG_DENSITY, COGL_FIXED_1); - cogl_wrap_glFogx (GL_FOG_START, 0); - cogl_wrap_glFogx (GL_FOG_END, 1); - cogl_wrap_glFogxv (GL_FOG_COLOR, default_fog_color); + cogl_wrap_glFogf (GL_FOG_MODE, GL_LINEAR); + cogl_wrap_glFogf (GL_FOG_DENSITY, 1.0); + cogl_wrap_glFogf (GL_FOG_START, 0); + cogl_wrap_glFogf (GL_FOG_END, 1); + cogl_wrap_glFogfv (GL_FOG_COLOR, default_fog_color); /* Initialize alpha testing */ cogl_wrap_glDisable (GL_ALPHA_TEST); @@ -517,10 +517,10 @@ cogl_gles2_wrapper_update_matrix (CoglGles2Wrapper *wrapper, GLenum matrix_num) void cogl_wrap_glClearColorx (GLclampx r, GLclampx g, GLclampx b, GLclampx a) { - glClearColor (COGL_FIXED_TO_FLOAT (r), - COGL_FIXED_TO_FLOAT (g), - COGL_FIXED_TO_FLOAT (b), - COGL_FIXED_TO_FLOAT (a)); + glClearColor ( (r), + (g), + (b), + (a)); } void @@ -666,58 +666,58 @@ cogl_wrap_glMultMatrix (const float *m) } void -cogl_wrap_glMultMatrixx (const GLfixed *m) +cogl_wrap_glMultMatrixf (const GLfloat *m) { float new_matrix[16]; int i; for (i = 0; i < 16; i++) - new_matrix[i] = COGL_FIXED_TO_FLOAT (m[i]); + new_matrix[i] = (m[i]); cogl_wrap_glMultMatrix (new_matrix); } void -cogl_wrap_glFrustumx (GLfixed left, GLfixed right, - GLfixed bottom, GLfixed top, - GLfixed z_near, GLfixed z_far) +cogl_wrap_glFrustumf (GLfloat left, GLfloat right, + GLfloat bottom, GLfloat top, + GLfloat z_near, GLfloat z_far) { float matrix[16]; - float two_near = COGL_FIXED_TO_FLOAT (2 * z_near); + float two_near = (2 * z_near); memset (matrix, 0, sizeof (matrix)); - matrix[0] = two_near / COGL_FIXED_TO_FLOAT (right - left); - matrix[5] = two_near / COGL_FIXED_TO_FLOAT (top - bottom); - matrix[8] = COGL_FIXED_TO_FLOAT (right + left) - / COGL_FIXED_TO_FLOAT (right - left); - matrix[9] = COGL_FIXED_TO_FLOAT (top + bottom) - / COGL_FIXED_TO_FLOAT (top - bottom); - matrix[10] = -COGL_FIXED_TO_FLOAT (z_far + z_near) - / COGL_FIXED_TO_FLOAT (z_far - z_near); + matrix[0] = two_near / (right - left); + matrix[5] = two_near / (top - bottom); + matrix[8] = (right + left) + / (right - left); + matrix[9] = (top + bottom) + / (top - bottom); + matrix[10] = - (z_far + z_near) + / (z_far - z_near); matrix[11] = -1.0f; - matrix[14] = -two_near * COGL_FIXED_TO_FLOAT (z_far) - / COGL_FIXED_TO_FLOAT (z_far - z_near); + matrix[14] = -two_near * (z_far) + / (z_far - z_near); cogl_wrap_glMultMatrix (matrix); } void -cogl_wrap_glScalex (GLfixed x, GLfixed y, GLfixed z) +cogl_wrap_glScalef (GLfloat x, GLfloat y, GLfloat z) { float matrix[16]; memset (matrix, 0, sizeof (matrix)); - matrix[0] = COGL_FIXED_TO_FLOAT (x); - matrix[5] = COGL_FIXED_TO_FLOAT (y); - matrix[10] = COGL_FIXED_TO_FLOAT (z); + matrix[0] = (x); + matrix[5] = (y); + matrix[10] = (z); matrix[15] = 1.0f; cogl_wrap_glMultMatrix (matrix); } void -cogl_wrap_glTranslatex (GLfixed x, GLfixed y, GLfixed z) +cogl_wrap_glTranslatef (GLfloat x, GLfloat y, GLfloat z) { float matrix[16]; @@ -725,22 +725,22 @@ cogl_wrap_glTranslatex (GLfixed x, GLfixed y, GLfixed z) matrix[0] = 1.0f; matrix[5] = 1.0f; matrix[10] = 1.0f; - matrix[12] = COGL_FIXED_TO_FLOAT (x); - matrix[13] = COGL_FIXED_TO_FLOAT (y); - matrix[14] = COGL_FIXED_TO_FLOAT (z); + matrix[12] = (x); + matrix[13] = (y); + matrix[14] = (z); matrix[15] = 1.0f; cogl_wrap_glMultMatrix (matrix); } void -cogl_wrap_glRotatex (GLfixed angle, GLfixed x, GLfixed y, GLfixed z) +cogl_wrap_glRotatef (GLfloat angle, GLfloat x, GLfloat y, GLfloat z) { float matrix[16]; - float xf = COGL_FIXED_TO_FLOAT (x); - float yf = COGL_FIXED_TO_FLOAT (y); - float zf = COGL_FIXED_TO_FLOAT (z); - float anglef = COGL_FIXED_TO_FLOAT (angle) * G_PI / 180.0f; + float xf = (x); + float yf = (y); + float zf = (z); + float anglef = (angle) * G_PI / 180.0f; float c = cosf (anglef); float s = sinf (anglef); @@ -768,21 +768,21 @@ cogl_wrap_glRotatex (GLfixed angle, GLfixed x, GLfixed y, GLfixed z) } void -cogl_wrap_glOrthox (GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, - GLfixed near, GLfixed far) +cogl_wrap_glOrthof (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, + GLfloat near, GLfloat far) { float matrix[16]; - float xrange = COGL_FIXED_TO_FLOAT (right - left); - float yrange = COGL_FIXED_TO_FLOAT (top - bottom); - float zrange = COGL_FIXED_TO_FLOAT (far - near); + float xrange = (right - left); + float yrange = (top - bottom); + float zrange = (far - near); memset (matrix, 0, sizeof (matrix)); matrix[0] = 2.0f / xrange; matrix[5] = 2.0f / yrange; matrix[10] = 2.0f / zrange; - matrix[12] = COGL_FIXED_TO_FLOAT (right + left) / xrange; - matrix[13] = COGL_FIXED_TO_FLOAT (top + bottom) / yrange; - matrix[14] = COGL_FIXED_TO_FLOAT (far + near) / zrange; + matrix[12] = (right + left) / xrange; + matrix[13] = (top + bottom) / yrange; + matrix[14] = (far + near) / zrange; matrix[15] = 1.0f; cogl_wrap_glMultMatrix (matrix); @@ -1033,7 +1033,7 @@ cogl_gles2_wrapper_bind_texture (GLenum target, GLuint texture, } void -cogl_wrap_glTexEnvx (GLenum target, GLenum pname, GLfixed param) +cogl_wrap_glTexEnvf (GLenum target, GLenum pname, GLfloat param) { /* This function is only used to set the texture mode once to GL_MODULATE. The shader is hard-coded to modulate the texture so @@ -1143,17 +1143,17 @@ cogl_wrap_glAlphaFunc (GLenum func, GLclampf ref) } void -cogl_wrap_glColor4x (GLclampx r, GLclampx g, GLclampx b, GLclampx a) +cogl_wrap_glColor4f (GLclampx r, GLclampx g, GLclampx b, GLclampx a) { glVertexAttrib4f (COGL_GLES2_WRAPPER_COLOR_ATTRIB, - COGL_FIXED_TO_FLOAT (r), - COGL_FIXED_TO_FLOAT (g), - COGL_FIXED_TO_FLOAT (b), - COGL_FIXED_TO_FLOAT (a)); + (r), + (g), + (b), + (a)); } void -cogl_wrap_glClipPlanex (GLenum plane, GLfixed *equation) +cogl_wrap_glClipPlanef (GLenum plane, GLfloat *equation) { /* FIXME */ } @@ -1161,10 +1161,10 @@ cogl_wrap_glClipPlanex (GLenum plane, GLfixed *equation) static void cogl_gles2_float_array_to_fixed (int size, const GLfloat *floats, - GLfixed *fixeds) + GLfloat *fixeds) { while (size-- > 0) - *(fixeds++) = COGL_FIXED_FROM_FLOAT (*(floats++)); + *(fixeds++) = (*(floats++)); } void @@ -1185,7 +1185,7 @@ cogl_wrap_glGetIntegerv (GLenum pname, GLint *params) } void -cogl_wrap_glGetFixedv (GLenum pname, GLfixed *params) +cogl_wrap_glGetFixedv (GLenum pname, GLfloat *params) { _COGL_GET_GLES2_WRAPPER (w, NO_RETVAL); @@ -1215,7 +1215,7 @@ cogl_wrap_glGetFixedv (GLenum pname, GLfixed *params) } void -cogl_wrap_glFogx (GLenum pname, GLfixed param) +cogl_wrap_glFogf (GLenum pname, GLfloat param) { _COGL_GET_GLES2_WRAPPER (w, NO_RETVAL); @@ -1227,23 +1227,23 @@ cogl_wrap_glFogx (GLenum pname, GLfixed param) case GL_FOG_DENSITY: _COGL_GLES2_CHANGE_UNIFORM (w, FOG_DENSITY, fog_density, - COGL_FIXED_TO_FLOAT (param)); + (param)); break; case GL_FOG_START: _COGL_GLES2_CHANGE_UNIFORM (w, FOG_START, fog_start, - COGL_FIXED_TO_FLOAT (param)); + (param)); break; case GL_FOG_END: _COGL_GLES2_CHANGE_UNIFORM (w, FOG_END, fog_end, - COGL_FIXED_TO_FLOAT (param)); + (param)); break; } } void -cogl_wrap_glFogxv (GLenum pname, const GLfixed *params) +cogl_wrap_glFogfv (GLenum pname, const GLfloat *params) { int i; _COGL_GET_GLES2_WRAPPER (w, NO_RETVAL); @@ -1251,7 +1251,7 @@ cogl_wrap_glFogxv (GLenum pname, const GLfixed *params) if (pname == GL_FOG_COLOR) { for (i = 0; i < 4; i++) - w->fog_color[i] = COGL_FIXED_TO_FLOAT (params[i]); + w->fog_color[i] = (params[i]); w->dirty_uniforms |= COGL_GLES2_DIRTY_FOG_COLOR; } diff --git a/clutter/cogl/gles/cogl-gles2-wrapper.h b/clutter/cogl/gles/cogl-gles2-wrapper.h index 7e7472c58..cb700cc3a 100644 --- a/clutter/cogl/gles/cogl-gles2-wrapper.h +++ b/clutter/cogl/gles/cogl-gles2-wrapper.h @@ -209,16 +209,16 @@ void cogl_wrap_glPushMatrix (); void cogl_wrap_glPopMatrix (); void cogl_wrap_glMatrixMode (GLenum mode); void cogl_wrap_glLoadIdentity (); -void cogl_wrap_glMultMatrixx (const GLfixed *m); -void cogl_wrap_glFrustumx (GLfixed left, GLfixed right, - GLfixed bottom, GLfixed top, - GLfixed z_near, GLfixed z_far); -void cogl_wrap_glScalex (GLfixed x, GLfixed y, GLfixed z); -void cogl_wrap_glTranslatex (GLfixed x, GLfixed y, GLfixed z); -void cogl_wrap_glRotatex (GLfixed angle, GLfixed x, GLfixed y, GLfixed z); -void cogl_wrap_glOrthox (GLfixed left, GLfixed right, - GLfixed bottom, GLfixed top, - GLfixed near, GLfixed far); +void cogl_wrap_glMultMatrixf (const GLfloat *m); +void cogl_wrap_glFrustumf (GLfloat left, GLfloat right, + GLfloat bottom, GLfloat top, + GLfloat z_near, GLfloat z_far); +void cogl_wrap_glScalef (GLfloat x, GLfloat y, GLfloat z); +void cogl_wrap_glTranslatef (GLfloat x, GLfloat y, GLfloat z); +void cogl_wrap_glRotatef (GLfloat angle, GLfloat x, GLfloat y, GLfloat z); +void cogl_wrap_glOrthof (GLfloat left, GLfloat right, + GLfloat bottom, GLfloat top, + GLfloat near, GLfloat far); void cogl_wrap_glEnable (GLenum cap); void cogl_wrap_glDisable (GLenum cap); @@ -232,22 +232,22 @@ void cogl_wrap_glColorPointer (GLint size, GLenum type, GLsizei stride, void cogl_wrap_glNormalPointer (GLenum type, GLsizei stride, const GLvoid *pointer); -void cogl_wrap_glTexEnvx (GLenum target, GLenum pname, GLfixed param); +void cogl_wrap_glTexEnvf (GLenum target, GLenum pname, GLfloat param); void cogl_wrap_glEnableClientState (GLenum array); void cogl_wrap_glDisableClientState (GLenum array); void cogl_wrap_glAlphaFunc (GLenum func, GLclampf ref); -void cogl_wrap_glColor4x (GLclampx r, GLclampx g, GLclampx b, GLclampx a); +void cogl_wrap_glColor4f (GLclampx r, GLclampx g, GLclampx b, GLclampx a); -void cogl_wrap_glClipPlanex (GLenum plane, GLfixed *equation); +void cogl_wrap_glClipPlanef (GLenum plane, GLfloat *equation); void cogl_wrap_glGetIntegerv (GLenum pname, GLint *params); -void cogl_wrap_glGetFixedv (GLenum pname, GLfixed *params); +void cogl_wrap_glGetFixedv (GLenum pname, GLfloat *params); -void cogl_wrap_glFogx (GLenum pname, GLfixed param); -void cogl_wrap_glFogxv (GLenum pname, const GLfixed *params); +void cogl_wrap_glFogf (GLenum pname, GLfloat param); +void cogl_wrap_glFogfv (GLenum pname, const GLfloat *params); void cogl_wrap_glDrawArrays (GLenum mode, GLint first, GLsizei count); void cogl_wrap_glDrawElements (GLenum mode, GLsizei count, GLenum type, @@ -280,28 +280,28 @@ void _cogl_gles2_clear_cache_for_program (CoglHandle program); #define cogl_wrap_glPopMatrix glPopMatrix #define cogl_wrap_glMatrixMode glMatrixMode #define cogl_wrap_glLoadIdentity glLoadIdentity -#define cogl_wrap_glMultMatrixx glMultMatrixx -#define cogl_wrap_glFrustumx glFrustumx -#define cogl_wrap_glScalex glScalex -#define cogl_wrap_glTranslatex glTranslatex -#define cogl_wrap_glRotatex glRotatex -#define cogl_wrap_glOrthox glOrthox +#define cogl_wrap_glMultMatrixf glMultMatrixx +#define cogl_wrap_glFrustumf glFrustumx +#define cogl_wrap_glScalef glScalex +#define cogl_wrap_glTranslatef glTranslatex +#define cogl_wrap_glRotatef glRotatex +#define cogl_wrap_glOrthof glOrthox #define cogl_wrap_glEnable glEnable #define cogl_wrap_glDisable glDisable #define cogl_wrap_glTexCoordPointer glTexCoordPointer #define cogl_wrap_glVertexPointer glVertexPointer #define cogl_wrap_glColorPointer glColorPointer #define cogl_wrap_glNormalPointer glNormalPointer -#define cogl_wrap_glTexEnvx glTexEnvx +#define cogl_wrap_glTexEnvf glTexEnvx #define cogl_wrap_glEnableClientState glEnableClientState #define cogl_wrap_glDisableClientState glDisableClientState #define cogl_wrap_glAlphaFunc glAlphaFunc -#define cogl_wrap_glColor4x glColor4x -#define cogl_wrap_glClipPlanex glClipPlanex +#define cogl_wrap_glColor4f glColor4x +#define cogl_wrap_glClipPlanef glClipPlanex #define cogl_wrap_glGetIntegerv glGetIntegerv #define cogl_wrap_glGetFixedv glGetFixedv -#define cogl_wrap_glFogx glFogx -#define cogl_wrap_glFogxv glFogxv +#define cogl_wrap_glFogf glFogx +#define cogl_wrap_glFogfv glFogxv #define cogl_wrap_glTexParameteri glTexParameteri /* The extra third parameter of the bind texture wrapper isn't needed diff --git a/clutter/cogl/gles/cogl-primitives.c b/clutter/cogl/gles/cogl-primitives.c index f6248ea9e..901fa5d09 100644 --- a/clutter/cogl/gles/cogl-primitives.c +++ b/clutter/cogl/gles/cogl-primitives.c @@ -64,12 +64,12 @@ _cogl_rectangle (gint x, void -_cogl_rectanglex (CoglFixed x, - CoglFixed y, - CoglFixed width, - CoglFixed height) +_cogl_rectanglex (float x, + float y, + float width, + float height) { - GLfixed rect_verts[8] = { + GLfloat rect_verts[8] = { x, y, x + width, y, x, y + height, @@ -89,8 +89,8 @@ _cogl_rectanglex (CoglFixed x, void _cogl_path_add_node (gboolean new_sub_path, - CoglFixed x, - CoglFixed y) + float x, + float y) { CoglPathNode new_node; @@ -147,19 +147,19 @@ _cogl_path_stroke_nodes () } static void -_cogl_path_get_bounds (CoglFixedVec2 nodes_min, - CoglFixedVec2 nodes_max, +_cogl_path_get_bounds (floatVec2 nodes_min, + floatVec2 nodes_max, gint *bounds_x, gint *bounds_y, guint *bounds_w, guint *bounds_h) { - *bounds_x = COGL_FIXED_FLOOR (nodes_min.x); - *bounds_y = COGL_FIXED_FLOOR (nodes_min.y); - *bounds_w = COGL_FIXED_CEIL (nodes_max.x - - COGL_FIXED_FROM_INT (*bounds_x)); - *bounds_h = COGL_FIXED_CEIL (nodes_max.y - - COGL_FIXED_FROM_INT (*bounds_y)); + *bounds_x = floorf (nodes_min.x); + *bounds_y = floorf (nodes_min.y); + *bounds_w = ceilf (nodes_max.x + - (float)(*bounds_x)); + *bounds_h = ceilf (nodes_max.y + - (float)(*bounds_y)); } static gint compare_ints (gconstpointer a, @@ -169,8 +169,8 @@ static gint compare_ints (gconstpointer a, } void -_cogl_add_path_to_stencil_buffer (CoglFixedVec2 nodes_min, - CoglFixedVec2 nodes_max, +_cogl_add_path_to_stencil_buffer (floatVec2 nodes_min, + floatVec2 nodes_max, guint path_size, CoglPathNode *path, gboolean merge) @@ -244,12 +244,12 @@ _cogl_add_path_to_stencil_buffer (CoglFixedVec2 nodes_min, GE( cogl_wrap_glMatrixMode (GL_PROJECTION) ); GE( cogl_wrap_glPushMatrix () ); GE( cogl_wrap_glLoadIdentity () ); - cogl_rectanglex (-COGL_FIXED_1, -COGL_FIXED_1, - COGL_FIXED_FROM_INT (2), - COGL_FIXED_FROM_INT (2)); - cogl_rectanglex (-COGL_FIXED_1, -COGL_FIXED_1, - COGL_FIXED_FROM_INT (2), - COGL_FIXED_FROM_INT (2)); + cogl_rectanglex (-1.0, -1.0, + (float)(2), + (float)(2)); + cogl_rectanglex (-1.0, -1.0, + (float)(2), + (float)(2)); GE( cogl_wrap_glPopMatrix () ); GE( cogl_wrap_glMatrixMode (GL_MODELVIEW) ); GE( cogl_wrap_glPopMatrix () ); @@ -292,14 +292,14 @@ _cogl_path_fill_nodes_scanlines (CoglPathNode *path, for (i=0; i < bounds_h; i++) scanlines[i]=NULL; - first_x = prev_x = COGL_FIXED_TO_INT (path->x); - first_y = prev_y = COGL_FIXED_TO_INT (path->y); + first_x = prev_x = (path->x); + first_y = prev_y = (path->y); /* create scanline intersection list */ for (i=1; i < path_size; i++) { - gint dest_x = COGL_FIXED_TO_INT (path[i].x); - gint dest_y = COGL_FIXED_TO_INT (path[i].y); + gint dest_x = (path[i].x); + gint dest_y = (path[i].y); gint ydir; gint dx; gint dy; @@ -362,7 +362,7 @@ _cogl_path_fill_nodes_scanlines (CoglPathNode *path, { gint spans = 0; gint span_no; - GLfixed *coords; + GLfloat *coords; /* count number of spans */ for (i=0; i < bounds_h; i++) @@ -380,7 +380,7 @@ _cogl_path_fill_nodes_scanlines (CoglPathNode *path, iter = next->next; } } - coords = g_malloc0 (spans * sizeof (GLfixed) * 3 * 2 * 2); + coords = g_malloc0 (spans * sizeof (GLfloat) * 3 * 2 * 2); span_no = 0; /* build list of triangles */ @@ -390,15 +390,15 @@ _cogl_path_fill_nodes_scanlines (CoglPathNode *path, while (iter) { GSList *next = iter->next; - GLfixed x0, x1; - GLfixed y0, y1; + GLfloat x0, x1; + GLfloat y0, y1; if (!next) break; - x0 = COGL_FIXED_FROM_INT (GPOINTER_TO_INT (iter->data)); - x1 = COGL_FIXED_FROM_INT (GPOINTER_TO_INT (next->data)); - y0 = COGL_FIXED_FROM_INT (bounds_y + i); - y1 = COGL_FIXED_FROM_INT (bounds_y + i + 1) + 2048; + x0 = (float)(GPOINTER_TO_INT (iter->data)); + x1 = (float)(GPOINTER_TO_INT (next->data)); + y0 = (float)(bounds_y + i); + y1 = (float)(bounds_y + i + 1) + 2048; /* render scanlines 1.0625 high to avoid gaps when transformed */ diff --git a/clutter/cogl/gles/cogl-texture.c b/clutter/cogl/gles/cogl-texture.c index 7de709507..9f99ef3b8 100644 --- a/clutter/cogl/gles/cogl-texture.c +++ b/clutter/cogl/gles/cogl-texture.c @@ -63,15 +63,15 @@ struct _CoglSpanIter gint index; GArray *array; CoglTexSliceSpan *span; - CoglFixed pos; - CoglFixed next_pos; - CoglFixed origin; - CoglFixed cover_start; - CoglFixed cover_end; - CoglFixed intersect_start; - CoglFixed intersect_end; - CoglFixed intersect_start_local; - CoglFixed intersect_end_local; + float pos; + float next_pos; + float origin; + float cover_start; + float cover_end; + float intersect_start; + float intersect_end; + float intersect_start_local; + float intersect_end_local; gboolean intersects; }; @@ -116,7 +116,7 @@ _cogl_span_iter_update (CoglSpanIter *iter) /* Offset next position by span size */ iter->next_pos = iter->pos + - COGL_FIXED_FROM_INT (iter->span->size - iter->span->waste); + (float)(iter->span->size - iter->span->waste); /* Check if span intersects the area to cover */ if (iter->next_pos <= iter->cover_start || @@ -145,9 +145,9 @@ _cogl_span_iter_update (CoglSpanIter *iter) static void _cogl_span_iter_begin (CoglSpanIter *iter, GArray *array, - CoglFixed origin, - CoglFixed cover_start, - CoglFixed cover_end) + float origin, + float cover_start, + float cover_end) { /* Copy info */ iter->index = 0; @@ -398,10 +398,10 @@ _cogl_texture_draw_and_read (CoglTexture *tex, GLint *viewport) { gint bpp; - CoglFixed rx1, ry1; - CoglFixed rx2, ry2; - CoglFixed tx1, ty1; - CoglFixed tx2, ty2; + float rx1, ry1; + float rx2, ry2; + float tx1, ty1; + float tx2, ty2; int bw, bh; CoglBitmap rect_bmp; CoglHandle handle; @@ -422,9 +422,9 @@ _cogl_texture_draw_and_read (CoglTexture *tex, /* Draw the texture image */ cogl_texture_rectangle (handle, 0, 0, - COGL_FIXED_FROM_INT (tex->bitmap.width), - COGL_FIXED_FROM_INT (tex->bitmap.height), - 0, 0, COGL_FIXED_1, COGL_FIXED_1); + (float)(tex->bitmap.width), + (float)(tex->bitmap.height), + 0, 0, 1.0, 1.0); /* Read into target bitmap */ prep_for_gl_pixels_download (tex->bitmap.rowstride); @@ -439,7 +439,7 @@ _cogl_texture_draw_and_read (CoglTexture *tex, ry1 = 0; ry2 = 0; ty1 = 0; ty2 = 0; -#define CFIX COGL_FIXED_FROM_INT +#define CFIX (float) /* Walk Y axis until whole bitmap height consumed */ for (bh = tex->bitmap.height; bh > 0; bh -= viewport[3]) @@ -450,7 +450,7 @@ _cogl_texture_draw_and_read (CoglTexture *tex, /* Normalized texture Y coords */ ty1 = ty2; - ty2 = COGL_FIXED_DIV (CFIX (ry2), CFIX (tex->bitmap.height)); + ty2 = (CFIX (ry2) / CFIX (tex->bitmap.height)); rx1 = 0; rx2 = 0; tx1 = 0; tx2 = 0; @@ -464,7 +464,7 @@ _cogl_texture_draw_and_read (CoglTexture *tex, /* Normalized texture X coords */ tx1 = tx2; - tx2 = COGL_FIXED_DIV (CFIX (rx2), CFIX (tex->bitmap.width)); + tx2 = (CFIX (rx2) / CFIX (tex->bitmap.width)); /* Clear buffer with transparent black, draw with white for direct copy to framebuffer */ @@ -544,10 +544,10 @@ _cogl_texture_download_from_gl (CoglTexture *tex, GE( cogl_wrap_glPushMatrix () ); GE( cogl_wrap_glLoadIdentity () ); - GE( cogl_wrap_glOrthox (0, COGL_FIXED_FROM_INT (viewport[2]), - 0, COGL_FIXED_FROM_INT (viewport[3]), - COGL_FIXED_FROM_INT (0), - COGL_FIXED_FROM_INT (100)) ); + GE( cogl_wrap_glOrthof (0, (float)(viewport[2]), + 0, (float)(viewport[3]), + (float)(0), + (float)(100)) ); GE( cogl_wrap_glMatrixMode (GL_MODELVIEW) ); GE( cogl_wrap_glPushMatrix () ); @@ -662,8 +662,8 @@ _cogl_texture_upload_subregion_to_gl (CoglTexture *tex, /* Iterate vertical spans */ for (source_y = src_y, _cogl_span_iter_begin (&y_iter, tex->slice_y_spans, - 0, COGL_FIXED_FROM_INT (dst_y), - COGL_FIXED_FROM_INT (dst_y + height)); + 0, (float)(dst_y), + (float)(dst_y + height)); !_cogl_span_iter_end (&y_iter); @@ -683,8 +683,8 @@ _cogl_texture_upload_subregion_to_gl (CoglTexture *tex, /* Iterate horizontal spans */ for (source_x = src_x, _cogl_span_iter_begin (&x_iter, tex->slice_x_spans, - 0, COGL_FIXED_FROM_INT (dst_x), - COGL_FIXED_FROM_INT (dst_x + width)); + 0, (float)(dst_x), + (float)(dst_x + width)); !_cogl_span_iter_end (&x_iter); @@ -702,15 +702,15 @@ _cogl_texture_upload_subregion_to_gl (CoglTexture *tex, x_iter.index); /* Pick intersection width and height */ - inter_w = COGL_FIXED_TO_INT (x_iter.intersect_end - + inter_w = (x_iter.intersect_end - x_iter.intersect_start); - inter_h = COGL_FIXED_TO_INT (y_iter.intersect_end - + inter_h = (y_iter.intersect_end - y_iter.intersect_start); /* Localize intersection top-left corner to slice*/ - local_x = COGL_FIXED_TO_INT (x_iter.intersect_start - + local_x = (x_iter.intersect_start - x_iter.pos); - local_y = COGL_FIXED_TO_INT (y_iter.intersect_start - + local_y = (y_iter.intersect_start - y_iter.pos); /* Pick slice GL handle */ @@ -768,7 +768,7 @@ _cogl_texture_upload_subregion_to_gl (CoglTexture *tex, guint wx, wy; src = source_bmp->data - + (src_y + COGL_FIXED_TO_INT (y_iter.intersect_start) + + (src_y + (y_iter.intersect_start) - dst_y) * source_bmp->rowstride + (src_x + x_span->start + x_span->size - x_span->waste @@ -813,7 +813,7 @@ _cogl_texture_upload_subregion_to_gl (CoglTexture *tex, guint copy_width; src = source_bmp->data - + (src_x + COGL_FIXED_TO_INT (x_iter.intersect_start) + + (src_x + (x_iter.intersect_start) - dst_x) * bpp + (src_y + y_span->start + y_span->size - y_span->waste @@ -2148,24 +2148,24 @@ _cogl_texture_add_quad_vertices (GLfloat x1, GLfloat y1, static void _cogl_texture_quad_sw (CoglTexture *tex, - CoglFixed x1, - CoglFixed y1, - CoglFixed x2, - CoglFixed y2, - CoglFixed tx1, - CoglFixed ty1, - CoglFixed tx2, - CoglFixed ty2) + float x1, + float y1, + float x2, + float y2, + float tx1, + float ty1, + float tx2, + float ty2) { CoglSpanIter iter_x , iter_y; - CoglFixed tw , th; - CoglFixed tqx , tqy; - CoglFixed first_tx , first_ty; - CoglFixed first_qx , first_qy; - CoglFixed slice_tx1 , slice_ty1; - CoglFixed slice_tx2 , slice_ty2; - CoglFixed slice_qx1 , slice_qy1; - CoglFixed slice_qx2 , slice_qy2; + float tw , th; + float tqx , tqy; + float first_tx , first_ty; + float first_qx , first_qy; + float slice_tx1 , slice_ty1; + float slice_tx2 , slice_ty2; + float slice_qx1 , slice_qy1; + float slice_qx2 , slice_qy2; GLuint gl_handle; _COGL_GET_CONTEXT (ctx, NO_RETVAL); @@ -2180,7 +2180,7 @@ _cogl_texture_quad_sw (CoglTexture *tex, slices */ if (tx2 < tx1) { - CoglFixed temp = x1; + float temp = x1; x1 = x2; x2 = temp; temp = tx1; @@ -2189,7 +2189,7 @@ _cogl_texture_quad_sw (CoglTexture *tex, } if (ty2 < ty1) { - CoglFixed temp = y1; + float temp = y1; y1 = y2; y2 = temp; temp = ty1; @@ -2198,27 +2198,27 @@ _cogl_texture_quad_sw (CoglTexture *tex, } /* Scale ratio from texture to quad widths */ - tw = COGL_FIXED_FROM_INT (tex->bitmap.width); - th = COGL_FIXED_FROM_INT (tex->bitmap.height); + tw = (float)(tex->bitmap.width); + th = (float)(tex->bitmap.height); - tqx = COGL_FIXED_DIV (x2 - x1, COGL_FIXED_MUL (tw, (tx2 - tx1))); - tqy = COGL_FIXED_DIV (y2 - y1, COGL_FIXED_MUL (th, (ty2 - ty1))); + tqx = (x2 - x1 / (tw * (tx2 - tx1))); + tqy = (y2 - y1 / (th * (ty2 - ty1))); /* Integral texture coordinate for first tile */ - first_tx = COGL_FIXED_FROM_INT (COGL_FIXED_FLOOR (tx1)); - first_ty = COGL_FIXED_FROM_INT (COGL_FIXED_FLOOR (ty1)); + first_tx = (float)(floorf (tx1)); + first_ty = (float)(floorf (ty1)); /* Denormalize texture coordinates */ - first_tx = COGL_FIXED_MUL (first_tx, tw); - first_ty = COGL_FIXED_MUL (first_ty, th); - tx1 = COGL_FIXED_MUL (tx1, tw); - ty1 = COGL_FIXED_MUL (ty1, th); - tx2 = COGL_FIXED_MUL (tx2, tw); - ty2 = COGL_FIXED_MUL (ty2, th); + first_tx = (first_tx * tw); + first_ty = (first_ty * th); + tx1 = (tx1 * tw); + ty1 = (ty1 * th); + tx2 = (tx2 * tw); + ty2 = (ty2 * th); /* Quad coordinate of the first tile */ - first_qx = x1 - COGL_FIXED_MUL (tx1 - first_tx, tqx); - first_qy = y1 - COGL_FIXED_MUL (ty1 - first_ty, tqy); + first_qx = x1 - (tx1 - first_tx * tqx); + first_qy = y1 - (ty1 - first_ty * tqy); /* Iterate until whole quad height covered */ @@ -2232,10 +2232,10 @@ _cogl_texture_quad_sw (CoglTexture *tex, /* Span-quad intersection in quad coordinates */ slice_qy1 = first_qy + - COGL_FIXED_MUL (iter_y.intersect_start - first_ty, tqy); + (iter_y.intersect_start - first_ty * tqy); slice_qy2 = first_qy + - COGL_FIXED_MUL (iter_y.intersect_end - first_ty, tqy); + (iter_y.intersect_end - first_ty * tqy); /* Localize slice texture coordinates */ slice_ty1 = iter_y.intersect_start - iter_y.pos; @@ -2257,10 +2257,10 @@ _cogl_texture_quad_sw (CoglTexture *tex, /* Span-quad intersection in quad coordinates */ slice_qx1 = first_qx + - COGL_FIXED_MUL (iter_x.intersect_start - first_tx, tqx); + (iter_x.intersect_start - first_tx * tqx); slice_qx2 = first_qx + - COGL_FIXED_MUL (iter_x.intersect_end - first_tx, tqx); + (iter_x.intersect_end - first_tx * tqx); /* Localize slice texture coordinates */ slice_tx1 = iter_x.intersect_start - iter_x.pos; @@ -2273,14 +2273,14 @@ _cogl_texture_quad_sw (CoglTexture *tex, #if COGL_DEBUG printf("~~~~~ slice (%d,%d)\n", iter_x.index, iter_y.index); - printf("qx1: %f\n", COGL_FIXED_TO_FLOAT (slice_qx1)); - printf("qy1: %f\n", COGL_FIXED_TO_FLOAT (slice_qy1)); - printf("qx2: %f\n", COGL_FIXED_TO_FLOAT (slice_qx2)); - printf("qy2: %f\n", COGL_FIXED_TO_FLOAT (slice_qy2)); - printf("tx1: %f\n", COGL_FIXED_TO_FLOAT (slice_tx1)); - printf("ty1: %f\n", COGL_FIXED_TO_FLOAT (slice_ty1)); - printf("tx2: %f\n", COGL_FIXED_TO_FLOAT (slice_tx2)); - printf("ty2: %f\n", COGL_FIXED_TO_FLOAT (slice_ty2)); + printf("qx1: %f\n", (slice_qx1)); + printf("qy1: %f\n", (slice_qy1)); + printf("qx2: %f\n", (slice_qx2)); + printf("qy2: %f\n", (slice_qy2)); + printf("tx1: %f\n", (slice_tx1)); + printf("ty1: %f\n", (slice_ty1)); + printf("tx2: %f\n", (slice_tx2)); + printf("ty2: %f\n", (slice_ty2)); #endif /* Pick and bind opengl texture object */ @@ -2297,28 +2297,28 @@ _cogl_texture_quad_sw (CoglTexture *tex, ctx->texture_current = gl_handle; ctx->texture_format = tex->gl_intformat; - _cogl_texture_add_quad_vertices (COGL_FIXED_TO_FLOAT (slice_qx1), - COGL_FIXED_TO_FLOAT (slice_qy1), - COGL_FIXED_TO_FLOAT (slice_qx2), - COGL_FIXED_TO_FLOAT (slice_qy2), - COGL_FIXED_TO_FLOAT (slice_tx1), - COGL_FIXED_TO_FLOAT (slice_ty1), - COGL_FIXED_TO_FLOAT (slice_tx2), - COGL_FIXED_TO_FLOAT (slice_ty2)); + _cogl_texture_add_quad_vertices ( (slice_qx1), + (slice_qy1), + (slice_qx2), + (slice_qy2), + (slice_tx1), + (slice_ty1), + (slice_tx2), + (slice_ty2)); } } } static void _cogl_texture_quad_hw (CoglTexture *tex, - CoglFixed x1, - CoglFixed y1, - CoglFixed x2, - CoglFixed y2, - CoglFixed tx1, - CoglFixed ty1, - CoglFixed tx2, - CoglFixed ty2) + float x1, + float y1, + float x2, + float y2, + float tx1, + float ty1, + float tx2, + float ty2) { GLuint gl_handle; CoglTexSliceSpan *x_span; @@ -2352,19 +2352,19 @@ _cogl_texture_quad_hw (CoglTexture *tex, ty1 = ty1 * (y_span->size - y_span->waste) / y_span->size; ty2 = ty2 * (y_span->size - y_span->waste) / y_span->size; - _cogl_texture_add_quad_vertices (COGL_FIXED_TO_FLOAT (x1), - COGL_FIXED_TO_FLOAT (y1), - COGL_FIXED_TO_FLOAT (x2), - COGL_FIXED_TO_FLOAT (y2), - COGL_FIXED_TO_FLOAT (tx1), - COGL_FIXED_TO_FLOAT (ty1), - COGL_FIXED_TO_FLOAT (tx2), - COGL_FIXED_TO_FLOAT (ty2)); + _cogl_texture_add_quad_vertices ( (x1), + (y1), + (x2), + (y2), + (tx1), + (ty1), + (tx2), + (ty2)); } void cogl_texture_multiple_rectangles (CoglHandle handle, - const CoglFixed *verts, + const float *verts, guint n_rects) { CoglTexture *tex; @@ -2411,10 +2411,10 @@ cogl_texture_multiple_rectangles (CoglHandle handle, if (tex->slice_gl_handles->len == 1 && ((cogl_features_available (COGL_FEATURE_TEXTURE_NPOT) && tex->gl_target == GL_TEXTURE_2D) - || (verts[4] >= 0 && verts[4] <= COGL_FIXED_1 - && verts[6] >= 0 && verts[6] <= COGL_FIXED_1 - && verts[5] >= 0 && verts[5] <= COGL_FIXED_1 - && verts[7] >= 0 && verts[7] <= COGL_FIXED_1))) + || (verts[4] >= 0 && verts[4] <= 1.0 + && verts[6] >= 0 && verts[6] <= 1.0 + && verts[5] >= 0 && verts[5] <= 1.0 + && verts[7] >= 0 && verts[7] <= 1.0))) _cogl_texture_quad_hw (tex, verts[0],verts[1], verts[2],verts[3], verts[4],verts[5], verts[6],verts[7]); else @@ -2430,16 +2430,16 @@ cogl_texture_multiple_rectangles (CoglHandle handle, void cogl_texture_rectangle (CoglHandle handle, - CoglFixed x1, - CoglFixed y1, - CoglFixed x2, - CoglFixed y2, - CoglFixed tx1, - CoglFixed ty1, - CoglFixed tx2, - CoglFixed ty2) + float x1, + float y1, + float x2, + float y2, + float tx1, + float ty1, + float tx2, + float ty2) { - CoglFixed verts[8]; + float verts[8]; verts[0] = x1; verts[1] = y1; @@ -2541,7 +2541,7 @@ cogl_texture_polygon (CoglHandle handle, OpenGL */ for (i = 0; i < n_vertices; i++, p++) { -#define CFX_F COGL_FIXED_TO_FLOAT +#define CFX_F p->v[0] = CFX_F(vertices[i].x); p->v[1] = CFX_F(vertices[i].y); diff --git a/clutter/cogl/gles/cogl.c b/clutter/cogl/gles/cogl.c index bb4a0ea76..226f2e432 100644 --- a/clutter/cogl/gles/cogl.c +++ b/clutter/cogl/gles/cogl.c @@ -116,41 +116,41 @@ cogl_pop_matrix (void) } void -cogl_scale (CoglFixed x, CoglFixed y) +cogl_scale (float x, float y) { - GE( cogl_wrap_glScalex (x, y, COGL_FIXED_1) ); + GE( cogl_wrap_glScalef (x, y, 1.0) ); } void -cogl_translatex (CoglFixed x, CoglFixed y, CoglFixed z) +cogl_translatex (float x, float y, float z) { - GE( cogl_wrap_glTranslatex (x, y, z) ); + GE( cogl_wrap_glTranslatef (x, y, z) ); } void cogl_translate (gint x, gint y, gint z) { - GE( cogl_wrap_glTranslatex (COGL_FIXED_FROM_INT(x), - COGL_FIXED_FROM_INT(y), - COGL_FIXED_FROM_INT(z)) ); + GE( cogl_wrap_glTranslatef ((float)(x), + (float)(y), + (float)(z)) ); } void -cogl_rotatex (CoglFixed angle, - CoglFixed x, - CoglFixed y, - CoglFixed z) +cogl_rotatex (float angle, + float x, + float y, + float z) { - GE( cogl_wrap_glRotatex (angle,x,y,z) ); + GE( cogl_wrap_glRotatef (angle,x,y,z) ); } void cogl_rotate (gint angle, gint x, gint y, gint z) { - GE( cogl_wrap_glRotatex (COGL_FIXED_FROM_INT(angle), - COGL_FIXED_FROM_INT(x), - COGL_FIXED_FROM_INT(y), - COGL_FIXED_FROM_INT(z)) ); + GE( cogl_wrap_glRotatef ((float)(angle), + (float)(x), + (float)(y), + (float)(z)) ); } static inline gboolean @@ -315,7 +315,7 @@ cogl_set_source_color (const CoglColor *color) #else /* conversion can cause issues with picking on some gles implementations */ - GE( cogl_wrap_glColor4x (cogl_color_get_red (color), + GE( cogl_wrap_glColor4f (cogl_color_get_red (color), cogl_color_get_green (color), cogl_color_get_blue (color), cogl_color_get_alpha (color)) ); @@ -326,22 +326,22 @@ cogl_set_source_color (const CoglColor *color) } static void -apply_matrix (const CoglFixed *matrix, CoglFixed *vertex) +apply_matrix (const float *matrix, float *vertex) { int x, y; - CoglFixed vertex_out[4] = { 0 }; + float vertex_out[4] = { 0 }; for (y = 0; y < 4; y++) for (x = 0; x < 4; x++) - vertex_out[y] += cogl_fixed_mul (vertex[x], matrix[y + x * 4]); + vertex_out[y] += (vertex[x] * matrix[y + x * 4]); memcpy (vertex, vertex_out, sizeof (vertex_out)); } static void -project_vertex (CoglFixed *modelview, - CoglFixed *project, - CoglFixed *vertex) +project_vertex (float *modelview, + float *project, + float *vertex) { int i; @@ -351,21 +351,21 @@ project_vertex (CoglFixed *modelview, apply_matrix (project, vertex); /* Convert from homogenized coordinates */ for (i = 0; i < 4; i++) - vertex[i] = cogl_fixed_div (vertex[i], vertex[3]); + vertex[i] = (vertex[i] / vertex[3]); } static void set_clip_plane (GLint plane_num, - const CoglFixed *vertex_a, - const CoglFixed *vertex_b) + const float *vertex_a, + const float *vertex_b) { - GLfixed plane[4]; - GLfixed angle; + GLfloat plane[4]; + GLfloat angle; _COGL_GET_CONTEXT (ctx, NO_RETVAL); /* Calculate the angle between the axes and the line crossing the two points */ - angle = cogl_fixed_mul (cogl_fixed_atan2 (vertex_b[1] - vertex_a[1], + angle = (atan2f (vertex_b[1] - vertex_a[1] * vertex_b[0] - vertex_a[0]), COGL_RADIANS_TO_DEGREES); @@ -374,36 +374,36 @@ set_clip_plane (GLint plane_num, projection matrix so we can specify the plane in screen coordinates */ GE( cogl_wrap_glLoadIdentity () ); - GE( cogl_wrap_glMultMatrixx ((GLfixed *) ctx->inverse_projection) ); + GE( cogl_wrap_glMultMatrixf ((GLfloat *) ctx->inverse_projection) ); /* Rotate about point a */ - GE( cogl_wrap_glTranslatex (vertex_a[0], vertex_a[1], vertex_a[2]) ); + GE( cogl_wrap_glTranslatef (vertex_a[0], vertex_a[1], vertex_a[2]) ); /* Rotate the plane by the calculated angle so that it will connect the two points */ - GE( cogl_wrap_glRotatex (angle, 0.0f, 0.0f, 1.0f) ); - GE( cogl_wrap_glTranslatex (-vertex_a[0], -vertex_a[1], -vertex_a[2]) ); + GE( cogl_wrap_glRotatef (angle, 0.0f, 0.0f, 1.0f) ); + GE( cogl_wrap_glTranslatef (-vertex_a[0], -vertex_a[1], -vertex_a[2]) ); plane[0] = 0; - plane[1] = -COGL_FIXED_1; + plane[1] = -1.0; plane[2] = 0; plane[3] = vertex_a[1]; - GE( cogl_wrap_glClipPlanex (plane_num, plane) ); + GE( cogl_wrap_glClipPlanef (plane_num, plane) ); GE( cogl_wrap_glPopMatrix () ); } void -_cogl_set_clip_planes (CoglFixed x_offset, - CoglFixed y_offset, - CoglFixed width, - CoglFixed height) +_cogl_set_clip_planes (float x_offset, + float y_offset, + float width, + float height) { - GLfixed modelview[16], projection[16]; + GLfloat modelview[16], projection[16]; - CoglFixed vertex_tl[4] = { x_offset, y_offset, 0, COGL_FIXED_1 }; - CoglFixed vertex_tr[4] = { x_offset + width, y_offset, 0, COGL_FIXED_1 }; - CoglFixed vertex_bl[4] = { x_offset, y_offset + height, 0, COGL_FIXED_1 }; - CoglFixed vertex_br[4] = { x_offset + width, y_offset + height, - 0, COGL_FIXED_1 }; + float vertex_tl[4] = { x_offset, y_offset, 0, 1.0 }; + float vertex_tr[4] = { x_offset + width, y_offset, 0, 1.0 }; + float vertex_bl[4] = { x_offset, y_offset + height, 0, 1.0 }; + float vertex_br[4] = { x_offset + width, y_offset + height, + 0, 1.0 }; GE( cogl_wrap_glGetFixedv (GL_MODELVIEW_MATRIX, modelview) ); GE( cogl_wrap_glGetFixedv (GL_PROJECTION_MATRIX, projection) ); @@ -421,7 +421,7 @@ _cogl_set_clip_planes (CoglFixed x_offset, if ((vertex_tl[0] < vertex_tr[0] ? 1 : 0) != (vertex_bl[1] < vertex_tl[1] ? 1 : 0)) { - CoglFixed temp[4]; + float temp[4]; memcpy (temp, vertex_tl, sizeof (temp)); memcpy (vertex_tl, vertex_tr, sizeof (temp)); memcpy (vertex_tr, temp, sizeof (temp)); @@ -437,10 +437,10 @@ _cogl_set_clip_planes (CoglFixed x_offset, } void -_cogl_add_stencil_clip (CoglFixed x_offset, - CoglFixed y_offset, - CoglFixed width, - CoglFixed height, +_cogl_add_stencil_clip (float x_offset, + float y_offset, + float width, + float height, gboolean first) { _COGL_GET_CONTEXT (ctx, NO_RETVAL); @@ -476,9 +476,9 @@ _cogl_add_stencil_clip (CoglFixed x_offset, GE( cogl_wrap_glMatrixMode (GL_PROJECTION) ); GE( cogl_wrap_glPushMatrix () ); GE( cogl_wrap_glLoadIdentity () ); - cogl_rectanglex (-COGL_FIXED_1, -COGL_FIXED_1, - COGL_FIXED_FROM_INT (2), - COGL_FIXED_FROM_INT (2)); + cogl_rectanglex (-1.0, -1.0, + (float)(2), + (float)(2)); GE( cogl_wrap_glPopMatrix () ); GE( cogl_wrap_glMatrixMode (GL_MODELVIEW) ); GE( cogl_wrap_glPopMatrix () ); @@ -490,10 +490,10 @@ _cogl_add_stencil_clip (CoglFixed x_offset, } void -_cogl_set_matrix (const CoglFixed *matrix) +_cogl_set_matrix (const float *matrix) { GE( cogl_wrap_glLoadIdentity () ); - GE( cogl_wrap_glMultMatrixx (matrix) ); + GE( cogl_wrap_glMultMatrixf (matrix) ); } void @@ -522,25 +522,25 @@ _cogl_disable_clip_planes (void) void cogl_alpha_func (COGLenum func, - CoglFixed ref) + float ref) { - GE( cogl_wrap_glAlphaFunc (func, COGL_FIXED_TO_FLOAT(ref)) ); + GE( cogl_wrap_glAlphaFunc (func, (ref)) ); } /* * Fixed point implementation of the perspective function */ void -cogl_perspective (CoglFixed fovy, - CoglFixed aspect, - CoglFixed zNear, - CoglFixed zFar) +cogl_perspective (float fovy, + float aspect, + float zNear, + float zFar) { - CoglFixed xmax, ymax; - CoglFixed x, y, c, d; - CoglFixed fovy_rad_half = cogl_fixed_mul (fovy, COGL_FIXED_PI) / 360; + float xmax, ymax; + float x, y, c, d; + float fovy_rad_half = (fovy * G_PI) / 360; - GLfixed m[16]; + GLfloat m[16]; _COGL_GET_CONTEXT (ctx, NO_RETVAL); @@ -558,76 +558,76 @@ cogl_perspective (CoglFixed fovy, * 2) When working with small numbers, we can are loosing significant * precision */ - ymax = cogl_fixed_mul (zNear, - cogl_fixed_div (cogl_fixed_sin (fovy_rad_half), - cogl_fixed_cos (fovy_rad_half))); - xmax = cogl_fixed_mul (ymax, aspect); + ymax = (zNear * + (sinf (fovy_rad_half) / + cosf (fovy_rad_half))); + xmax = (ymax * aspect); - x = cogl_fixed_div (zNear, xmax); - y = cogl_fixed_div (zNear, ymax); - c = cogl_fixed_div (-(zFar + zNear), ( zFar - zNear)); - d = cogl_fixed_div (-(cogl_fixed_mul (2 * zFar, zNear)), (zFar - zNear)); + x = (zNear / xmax); + y = (zNear / ymax); + c = (-(zFar + zNear) / ( zFar - zNear)); + d = (-((2 * zFar * zNear)) / (zFar - zNear)); #define M(row,col) m[col*4+row] M(0,0) = x; M(1,1) = y; M(2,2) = c; M(2,3) = d; - M(3,2) = -COGL_FIXED_1; + M(3,2) = -1.0; - GE( cogl_wrap_glMultMatrixx (m) ); + GE( cogl_wrap_glMultMatrixf (m) ); GE( cogl_wrap_glMatrixMode (GL_MODELVIEW) ); /* Calculate and store the inverse of the matrix */ - memset (ctx->inverse_projection, 0, sizeof (CoglFixed) * 16); + memset (ctx->inverse_projection, 0, sizeof (float) * 16); #define m ctx->inverse_projection - M(0, 0) = cogl_fixed_div (COGL_FIXED_1, x); - M(1, 1) = cogl_fixed_div (COGL_FIXED_1, y); - M(2, 3) = -COGL_FIXED_1; - M(3, 2) = cogl_fixed_div (COGL_FIXED_1, d); - M(3, 3) = cogl_fixed_div (c, d); + M(0, 0) = (1.0 / x); + M(1, 1) = (1.0 / y); + M(2, 3) = -1.0; + M(3, 2) = (1.0 / d); + M(3, 3) = (c / d); #undef m #undef M } void -cogl_frustum (CoglFixed left, - CoglFixed right, - CoglFixed bottom, - CoglFixed top, - CoglFixed z_near, - CoglFixed z_far) +cogl_frustum (float left, + float right, + float bottom, + float top, + float z_near, + float z_far) { - CoglFixed c, d; + float c, d; _COGL_GET_CONTEXT (ctx, NO_RETVAL); GE( cogl_wrap_glMatrixMode (GL_PROJECTION) ); GE( cogl_wrap_glLoadIdentity () ); - GE( cogl_wrap_glFrustumx (left, right, + GE( cogl_wrap_glFrustumf (left, right, bottom, top, z_near, z_far) ); GE( cogl_wrap_glMatrixMode (GL_MODELVIEW) ); /* Calculate and store the inverse of the matrix */ - memset (ctx->inverse_projection, 0, sizeof (CoglFixed) * 16); + memset (ctx->inverse_projection, 0, sizeof (float) * 16); - c = -cogl_fixed_div (z_far + z_near, z_far - z_near); - d = -cogl_fixed_div (2 * cogl_fixed_mul (z_far, z_near), z_far - z_near); + c = -(z_far + z_near / z_far - z_near); + d = -(2 * (z_far * z_near) / z_far - z_near); #define M(row,col) ctx->inverse_projection[col*4+row] - M(0,0) = cogl_fixed_div (right - left, 2 * z_near); - M(0,3) = cogl_fixed_div (right + left, 2 * z_near); - M(1,1) = cogl_fixed_div (top - bottom, 2 * z_near); - M(1,3) = cogl_fixed_div (top + bottom, 2 * z_near); - M(2,3) = -COGL_FIXED_1; - M(3,2) = cogl_fixed_div (COGL_FIXED_1, d); - M(3,3) = cogl_fixed_div (c, d); + M(0,0) = (right - left / 2 * z_near); + M(0,3) = (right + left / 2 * z_near); + M(1,1) = (top - bottom / 2 * z_near); + M(1,3) = (top + bottom / 2 * z_near); + M(2,3) = -1.0; + M(3,2) = (1.0 / d); + M(3,3) = (c / d); #undef M } @@ -641,19 +641,19 @@ cogl_viewport (guint width, void cogl_setup_viewport (guint w, guint h, - CoglFixed fovy, - CoglFixed aspect, - CoglFixed z_near, - CoglFixed z_far) + float fovy, + float aspect, + float z_near, + float z_far) { gint width = (gint) w; gint height = (gint) h; - CoglFixed z_camera; + float z_camera; GE( glViewport (0, 0, width, height) ); /* For Ortho projection. - * cogl_wrap_glOrthox (0, width << 16, 0, height << 16, -1 << 16, 1 << 16); + * cogl_wrap_glOrthof (0, width << 16, 0, height << 16, -1 << 16, 1 << 16); */ cogl_perspective (fovy, aspect, z_near, z_far); @@ -666,24 +666,24 @@ cogl_setup_viewport (guint w, * See comments in ../gl/cogl.c */ #define DEFAULT_Z_CAMERA 0.869f - z_camera = COGL_FIXED_FROM_FLOAT (DEFAULT_Z_CAMERA); + z_camera = (DEFAULT_Z_CAMERA); - if (fovy != COGL_FIXED_60) + if (fovy != 60.0) { - CoglFixed fovy_rad = cogl_fixed_mul (fovy, COGL_FIXED_PI) / 180; + float fovy_rad = (fovy * G_PI) / 180; - z_camera = cogl_fixed_div (cogl_fixed_sin (fovy_rad), - cogl_fixed_cos (fovy_rad)) >> 1; + z_camera = (sinf (fovy_rad) / + cosf (fovy_rad)) >> 1; } - GE( cogl_wrap_glTranslatex (-1 << 15, -1 << 15, -z_camera) ); + GE( cogl_wrap_glTranslatef (-1 << 15, -1 << 15, -z_camera) ); - GE( cogl_wrap_glScalex ( COGL_FIXED_1 / width, - -COGL_FIXED_1 / height, - COGL_FIXED_1 / width) ); + GE( cogl_wrap_glScalef ( 1.0 / width, + -1.0 / height, + 1.0 / width) ); - GE( cogl_wrap_glTranslatex (0, -COGL_FIXED_1 * height, 0) ); + GE( cogl_wrap_glTranslatef (0, -1.0 * height, 0) ); } static void @@ -735,19 +735,19 @@ cogl_features_available (CoglFeatureFlags features) } void -cogl_get_modelview_matrix (CoglFixed m[16]) +cogl_get_modelview_matrix (float m[16]) { cogl_wrap_glGetFixedv(GL_MODELVIEW_MATRIX, &m[0]); } void -cogl_get_projection_matrix (CoglFixed m[16]) +cogl_get_projection_matrix (float m[16]) { cogl_wrap_glGetFixedv(GL_PROJECTION_MATRIX, &m[0]); } void -cogl_get_viewport (CoglFixed v[4]) +cogl_get_viewport (float v[4]) { GLint viewport[4]; int i; @@ -755,7 +755,7 @@ cogl_get_viewport (CoglFixed v[4]) cogl_wrap_glGetIntegerv (GL_VIEWPORT, viewport); for (i = 0; i < 4; i++) - v[i] = COGL_FIXED_FROM_INT (viewport[i]); + v[i] = (float)(viewport[i]); } void @@ -773,11 +773,11 @@ cogl_get_bitmasks (gint *red, gint *green, gint *blue, gint *alpha) void cogl_fog_set (const CoglColor *fog_color, - CoglFixed density, - CoglFixed z_near, - CoglFixed z_far) + float density, + float z_near, + float z_far) { - GLfixed fogColor[4]; + GLfloat fogColor[4]; fogColor[0] = cogl_color_get_red (fog_color); fogColor[1] = cogl_color_get_green (fog_color); @@ -786,12 +786,12 @@ cogl_fog_set (const CoglColor *fog_color, cogl_wrap_glEnable (GL_FOG); - cogl_wrap_glFogxv (GL_FOG_COLOR, fogColor); + cogl_wrap_glFogfv (GL_FOG_COLOR, fogColor); - cogl_wrap_glFogx (GL_FOG_MODE, GL_LINEAR); + cogl_wrap_glFogf (GL_FOG_MODE, GL_LINEAR); glHint (GL_FOG_HINT, GL_NICEST); - cogl_wrap_glFogx (GL_FOG_DENSITY, (GLfixed) density); - cogl_wrap_glFogx (GL_FOG_START, (GLfixed) z_near); - cogl_wrap_glFogx (GL_FOG_END, (GLfixed) z_far); + cogl_wrap_glFogf (GL_FOG_DENSITY, (GLfloat) density); + cogl_wrap_glFogf (GL_FOG_START, (GLfloat) z_near); + cogl_wrap_glFogf (GL_FOG_END, (GLfloat) z_far); } diff --git a/clutter/pango/cogl-pango-glyph-cache.c b/clutter/pango/cogl-pango-glyph-cache.c index 7a2bf2f23..8194d7a92 100644 --- a/clutter/pango/cogl-pango-glyph-cache.c +++ b/clutter/pango/cogl-pango-glyph-cache.c @@ -342,13 +342,13 @@ cogl_pango_glyph_cache_set (CoglPangoGlyphCache *cache, value = g_slice_new (CoglPangoGlyphCacheValue); value->texture = cogl_texture_ref (band->texture); - value->tx1 = COGL_FIXED_FROM_INT (band->space_remaining) + value->tx1 = (float)(band->space_remaining) / band->texture_size; - value->tx2 = COGL_FIXED_FROM_INT (band->space_remaining + width) + value->tx2 = (float)(band->space_remaining + width) / band->texture_size; - value->ty1 = COGL_FIXED_FROM_INT (band->top) + value->ty1 = (float)(band->top) / band->texture_size; - value->ty2 = COGL_FIXED_FROM_INT (band->top + height) + value->ty2 = (float)(band->top + height) / band->texture_size; value->draw_x = draw_x; value->draw_y = draw_y; diff --git a/clutter/pango/cogl-pango-glyph-cache.h b/clutter/pango/cogl-pango-glyph-cache.h index 2f4b5798b..33364e1c7 100644 --- a/clutter/pango/cogl-pango-glyph-cache.h +++ b/clutter/pango/cogl-pango-glyph-cache.h @@ -37,10 +37,10 @@ struct _CoglPangoGlyphCacheValue { CoglHandle texture; - CoglFixed tx1; - CoglFixed ty1; - CoglFixed tx2; - CoglFixed ty2; + float tx1; + float ty1; + float tx2; + float ty2; int draw_x; int draw_y; diff --git a/clutter/pango/cogl-pango-render.c b/clutter/pango/cogl-pango-render.c index e69c412ac..d8f87fb43 100644 --- a/clutter/pango/cogl-pango-render.c +++ b/clutter/pango/cogl-pango-render.c @@ -67,7 +67,7 @@ cogl_pango_renderer_glyphs_end (CoglPangoRenderer *priv) { if (priv->glyph_rectangles->len > 0) { - CoglFixed *rectangles = (CoglFixed *) priv->glyph_rectangles->data; + float *rectangles = (float *) priv->glyph_rectangles->data; cogl_texture_multiple_rectangles (priv->glyph_texture, rectangles, priv->glyph_rectangles->len / 8); g_array_set_size (priv->glyph_rectangles, 0); @@ -77,11 +77,11 @@ cogl_pango_renderer_glyphs_end (CoglPangoRenderer *priv) static void cogl_pango_renderer_draw_glyph (CoglPangoRenderer *priv, CoglPangoGlyphCacheValue *cache_value, - CoglFixed x1, - CoglFixed y1) + float x1, + float y1) { - CoglFixed x2, y2; - CoglFixed *p; + float x2, y2; + float *p; if (priv->glyph_rectangles->len > 0 && priv->glyph_texture != cache_value->texture) @@ -93,7 +93,7 @@ cogl_pango_renderer_draw_glyph (CoglPangoRenderer *priv, y2 = y1 + CLUTTER_INT_TO_FIXED (cache_value->draw_height); g_array_set_size (priv->glyph_rectangles, priv->glyph_rectangles->len + 8); - p = &g_array_index (priv->glyph_rectangles, CoglFixed, + p = &g_array_index (priv->glyph_rectangles, float, priv->glyph_rectangles->len - 8); *(p++) = x1; *(p++) = y1; @@ -133,7 +133,7 @@ cogl_pango_renderer_init (CoglPangoRenderer *priv) priv->glyph_cache = cogl_pango_glyph_cache_new (FALSE); priv->mipmapped_glyph_cache = cogl_pango_glyph_cache_new (TRUE); priv->use_mipmapping = FALSE; - priv->glyph_rectangles = g_array_new (FALSE, FALSE, sizeof (CoglFixed)); + priv->glyph_rectangles = g_array_new (FALSE, FALSE, sizeof (float)); } static void @@ -413,10 +413,10 @@ static void cogl_pango_renderer_draw_box (int x, int y, int width, int height) { - cogl_path_rectangle (COGL_FIXED_FROM_INT (x), - COGL_FIXED_FROM_INT (y - height), - COGL_FIXED_FROM_INT (width), - COGL_FIXED_FROM_INT (height)); + cogl_path_rectangle ((float)(x), + (float)(y - height), + (float)(width), + (float)(height)); cogl_path_stroke (); } @@ -424,17 +424,17 @@ static void cogl_pango_renderer_get_device_units (PangoRenderer *renderer, int xin, int yin, - CoglFixed *xout, - CoglFixed *yout) + float *xout, + float *yout) { const PangoMatrix *matrix; if ((matrix = pango_renderer_get_matrix (renderer))) { /* Convert user-space coords to device coords */ - *xout = COGL_FIXED_FROM_FLOAT ((xin * matrix->xx + yin * matrix->xy) + *xout = ((xin * matrix->xx + yin * matrix->xy) / PANGO_SCALE + matrix->x0); - *yout = COGL_FIXED_FROM_FLOAT ((yin * matrix->yy + xin * matrix->yx) + *yout = ((yin * matrix->yy + xin * matrix->yx) / PANGO_SCALE + matrix->y0); } else @@ -452,7 +452,7 @@ cogl_pango_renderer_draw_rectangle (PangoRenderer *renderer, int width, int height) { - CoglFixed x1, x2, y1, y2; + float x1, x2, y1, y2; cogl_pango_renderer_set_color_for_part (renderer, part); @@ -476,15 +476,15 @@ cogl_pango_renderer_draw_trapezoid (PangoRenderer *renderer, double x12, double x22) { - CoglFixed points[8]; + float points[8]; - points[0] = COGL_FIXED_FROM_FLOAT (x11); - points[1] = COGL_FIXED_FROM_FLOAT (y1); - points[2] = COGL_FIXED_FROM_FLOAT (x12); - points[3] = COGL_FIXED_FROM_FLOAT (y2); - points[4] = COGL_FIXED_FROM_FLOAT (x22); + points[0] = (x11); + points[1] = (y1); + points[2] = (x12); + points[3] = (y2); + points[4] = (x22); points[5] = points[3]; - points[6] = COGL_FIXED_FROM_FLOAT (x21); + points[6] = (x21); points[7] = points[1]; cogl_pango_renderer_set_color_for_part (renderer, part); @@ -510,7 +510,7 @@ cogl_pango_renderer_draw_glyphs (PangoRenderer *renderer, for (i = 0; i < glyphs->num_glyphs; i++) { PangoGlyphInfo *gi = glyphs->glyphs + i; - CoglFixed x, y; + float x, y; cogl_pango_renderer_get_device_units (renderer, xi + gi->geometry.x_offset, @@ -526,15 +526,15 @@ cogl_pango_renderer_draw_glyphs (PangoRenderer *renderer, if (font == NULL || (metrics = pango_font_get_metrics (font, NULL)) == NULL) { - cogl_pango_renderer_draw_box (COGL_FIXED_TO_INT (x), - COGL_FIXED_TO_INT (y), + cogl_pango_renderer_draw_box ( (x), + (y), PANGO_UNKNOWN_GLYPH_WIDTH, PANGO_UNKNOWN_GLYPH_HEIGHT); } else { - cogl_pango_renderer_draw_box (COGL_FIXED_TO_INT (x), - COGL_FIXED_TO_INT (y), + cogl_pango_renderer_draw_box ( (x), + (y), metrics->approximate_char_width / PANGO_SCALE, metrics->ascent / PANGO_SCALE); @@ -555,20 +555,20 @@ cogl_pango_renderer_draw_glyphs (PangoRenderer *renderer, { cogl_pango_renderer_glyphs_end (priv); - cogl_pango_renderer_draw_box (COGL_FIXED_TO_INT (x), - COGL_FIXED_TO_INT (y), + cogl_pango_renderer_draw_box ( (x), + (y), PANGO_UNKNOWN_GLYPH_WIDTH, PANGO_UNKNOWN_GLYPH_HEIGHT); } else { - CoglFixed width, height; + float width, height; - x += COGL_FIXED_FROM_INT (cache_value->draw_x); - y += COGL_FIXED_FROM_INT (cache_value->draw_y); + x += (float)(cache_value->draw_x); + y += (float)(cache_value->draw_y); - width = x + COGL_FIXED_FROM_INT (cache_value->draw_width); - height = y + COGL_FIXED_FROM_INT (cache_value->draw_height); + width = x + (float)(cache_value->draw_width); + height = y + (float)(cache_value->draw_height); cogl_pango_renderer_draw_glyph (priv, cache_value, x, y); } diff --git a/tests/conform/test-backface-culling.c b/tests/conform/test-backface-culling.c index 3b7948e96..50c19fd08 100644 --- a/tests/conform/test-backface-culling.c +++ b/tests/conform/test-backface-culling.c @@ -114,33 +114,33 @@ on_paint (ClutterActor *actor, TestState *state) the first */ for (i = 0; i < 2; i++) { - CoglFixed x1 = 0, x2, y1 = 0, y2 = COGL_FIXED_FROM_INT (TEXTURE_SIZE); + float x1 = 0, x2, y1 = 0, y2 = (float)(TEXTURE_SIZE); CoglTextureVertex verts[4]; memset (verts, 0, sizeof (verts)); /* Set the color to white so that all the textures will be drawn at their own color */ - cogl_set_source_color4x (COGL_FIXED_1, COGL_FIXED_1, - COGL_FIXED_1, COGL_FIXED_1); + cogl_set_source_color4x (1.0, 1.0, + 1.0, 1.0); - x2 = x1 + COGL_FIXED_FROM_INT (TEXTURE_SIZE); + x2 = x1 + (float)(TEXTURE_SIZE); /* Draw a front-facing texture */ cogl_texture_rectangle (state->texture, x1, y1, x2, y2, - 0, 0, COGL_FIXED_1, COGL_FIXED_1); + 0, 0, 1.0, 1.0); x1 = x2; - x2 = x1 + COGL_FIXED_FROM_INT (TEXTURE_SIZE); + x2 = x1 + (float)(TEXTURE_SIZE); /* Draw a back-facing texture */ cogl_texture_rectangle (state->texture, x2, y1, x1, y2, - 0, 0, COGL_FIXED_1, COGL_FIXED_1); + 0, 0, 1.0, 1.0); x1 = x2; - x2 = x1 + COGL_FIXED_FROM_INT (TEXTURE_SIZE); + x2 = x1 + (float)(TEXTURE_SIZE); /* Draw a front-facing texture polygon */ verts[0].x = x1; verts[0].y = y2; @@ -148,14 +148,14 @@ on_paint (ClutterActor *actor, TestState *state) verts[2].x = x2; verts[2].y = y1; verts[3].x = x1; verts[3].y = y1; verts[0].tx = 0; verts[0].ty = 0; - verts[1].tx = COGL_FIXED_1; verts[1].ty = 0; - verts[2].tx = COGL_FIXED_1; verts[2].ty = COGL_FIXED_1; - verts[3].tx = 0; verts[3].ty = COGL_FIXED_1; + verts[1].tx = 1.0; verts[1].ty = 0; + verts[2].tx = 1.0; verts[2].ty = 1.0; + verts[3].tx = 0; verts[3].ty = 1.0; cogl_texture_polygon (state->texture, 4, verts, FALSE); x1 = x2; - x2 = x1 + COGL_FIXED_FROM_INT (TEXTURE_SIZE); + x2 = x1 + (float)(TEXTURE_SIZE); /* Draw a back-facing texture polygon */ verts[0].x = x1; verts[0].y = y1; @@ -163,19 +163,19 @@ on_paint (ClutterActor *actor, TestState *state) verts[2].x = x2; verts[2].y = y2; verts[3].x = x1; verts[3].y = y2; verts[0].tx = 0; verts[0].ty = 0; - verts[1].tx = COGL_FIXED_1; verts[1].ty = 0; - verts[2].tx = COGL_FIXED_1; verts[2].ty = COGL_FIXED_1; - verts[3].tx = 0; verts[3].ty = COGL_FIXED_1; + verts[1].tx = 1.0; verts[1].ty = 0; + verts[2].tx = 1.0; verts[2].ty = 1.0; + verts[3].tx = 0; verts[3].ty = 1.0; cogl_texture_polygon (state->texture, 4, verts, FALSE); x1 = x2; - x2 = x1 + COGL_FIXED_FROM_INT (TEXTURE_SIZE); + x2 = x1 + (float)(TEXTURE_SIZE); /* Draw a regular rectangle (this should always show) */ - cogl_set_source_color4x (COGL_FIXED_1, 0, 0, COGL_FIXED_1); - cogl_rectangle (COGL_FIXED_TO_INT (x1), COGL_FIXED_TO_INT (y1), - COGL_FIXED_TO_INT (x2 - x1), COGL_FIXED_TO_INT (y2 - y1)); + cogl_set_source_color4x (1.0, 0, 0, 1.0); + cogl_rectangle ( (x1), (y1), + (x2 - x1), (y2 - y1)); /* The second time round draw beneath the first with backface culling disabled */ diff --git a/tests/interactive/test-cogl-tex-tile.c b/tests/interactive/test-cogl-tex-tile.c index fe7138a60..5063dff19 100644 --- a/tests/interactive/test-cogl-tex-tile.c +++ b/tests/interactive/test-cogl-tex-tile.c @@ -94,9 +94,9 @@ test_coglbox_paint(ClutterActor *self) cos_frame = clutter_cosi (CLUTTER_ANGLE_FROM_DEG (priv->frame)); pingpong_frame = (priv->frame <= 180 ? priv->frame : 360 - priv->frame); - frac_frame = COGL_FIXED_DIV (CLUTTER_INT_TO_FIXED (pingpong_frame), + frac_frame = (CLUTTER_INT_TO_FIXED (pingpong_frame) / CLUTTER_INT_TO_FIXED (180)); - frac_frame += (COGL_FIXED_1 >> 1); + frac_frame += (1.0 >> 1); frac_frame <<= 1; for (t=0; t<4; t+=2) @@ -104,8 +104,8 @@ test_coglbox_paint(ClutterActor *self) texcoords[t] += cos_frame; texcoords[t+1] += sin_frame; - texcoords[t] = COGL_FIXED_MUL (texcoords[t], frac_frame); - texcoords[t+1] = COGL_FIXED_MUL (texcoords[t+1], frac_frame); + texcoords[t] = (texcoords[t] * frac_frame); + texcoords[t+1] = (texcoords[t+1] * frac_frame); } priv = TEST_COGLBOX_GET_PRIVATE (self); diff --git a/tests/interactive/test-text-field.c b/tests/interactive/test-text-field.c index ca582731d..3087a7fe4 100644 --- a/tests/interactive/test-text-field.c +++ b/tests/interactive/test-text-field.c @@ -19,7 +19,7 @@ on_entry_paint (ClutterActor *actor, cogl_path_round_rectangle (0, 0, CLUTTER_UNITS_TO_FIXED (width), CLUTTER_UNITS_TO_FIXED (height), - COGL_FIXED_FROM_INT (4), + (float)(4), COGL_ANGLE_FROM_DEG (1.0)); cogl_path_stroke (); } From a2cf7e4a19fec5edf017aef0bba972b59c62b1cf Mon Sep 17 00:00:00 2001 From: Robert Bragg Date: Tue, 20 Jan 2009 16:20:54 +0000 Subject: [PATCH 25/26] [Automatic fixed-to-float.sh change] Applies a number fixed to float patches To deal with all the corner cases that couldn't be scripted a number of patches were written for the remaining 10% of the effort. Note: again no API changes were made in Clutter, only in Cogl. --- clutter/clutter-actor.c | 53 ++++----- clutter/clutter-alpha.c | 139 +++++++++++++----------- clutter/clutter-alpha.h | 2 +- clutter/clutter-behaviour-ellipse.c | 144 +++++++++++-------------- clutter/clutter-bezier.c | 2 +- clutter/clutter-fixed.c | 4 +- clutter/clutter-path.c | 4 +- clutter/clutter-texture.c | 2 +- clutter/cogl/cogl-color.h | 10 +- clutter/cogl/cogl-fixed.h | 12 +++ clutter/cogl/cogl-path.h | 22 +--- clutter/cogl/cogl.h.in | 50 ++------- clutter/cogl/common/cogl-color.c | 6 +- clutter/cogl/common/cogl-fixed.c | 6 ++ clutter/cogl/common/cogl-primitives.c | 33 ++---- clutter/cogl/gl/cogl-primitives.c | 63 ++++------- clutter/cogl/gl/cogl-texture.c | 5 +- clutter/cogl/gl/cogl.c | 113 ++++--------------- clutter/cogl/gles/cogl-gles2-wrapper.c | 45 ++------ clutter/cogl/gles/cogl-gles2-wrapper.h | 31 +++--- clutter/cogl/gles/cogl-primitives.c | 92 +++++----------- clutter/cogl/gles/cogl-texture.c | 5 +- clutter/cogl/gles/cogl.c | 70 ++++-------- clutter/pango/cogl-pango-render.c | 8 +- doc/reference/cogl/cogl-sections.txt | 4 +- tests/conform/test-backface-culling.c | 4 +- tests/interactive/test-cogl-tex-tile.c | 10 +- 27 files changed, 355 insertions(+), 584 deletions(-) diff --git a/clutter/clutter-actor.c b/clutter/clutter-actor.c index 1e481cd2b..e0903fe38 100644 --- a/clutter/clutter-actor.c +++ b/clutter/clutter-actor.c @@ -806,7 +806,7 @@ static inline void mtx_transform (const ClutterFixed m[], fixed_vertex_t *vertex) { - ClutterFixed _x, _y, _z, _w; + float _x, _y, _z, _w; _x = vertex->x; _y = vertex->y; @@ -846,8 +846,11 @@ mtx_transform (const ClutterFixed m[], /* Help macros to scale from OpenGL <-1,1> coordinates system to our * X-window based <0,window-size> coordinates */ -#define MTX_GL_SCALE_X(x,w,v1,v2) (CLUTTER_FIXED_MUL (((CLUTTER_FIXED_DIV ((x), (w)) + 1.0) >> 1), (v1)) + (v2)) -#define MTX_GL_SCALE_Y(y,w,v1,v2) ((v1) - CLUTTER_FIXED_MUL (((CLUTTER_FIXED_DIV ((y), (w)) + 1.0) >> 1), (v1)) + (v2)) +#define MTX_GL_SCALE_X(x,w,v1,v2) \ + (CLUTTER_FIXED_MUL (((CLUTTER_FIXED_DIV ((x), (w)) + 1.0) / 2), (v1)) + (v2)) +#define MTX_GL_SCALE_Y(y,w,v1,v2) \ + ((v1) - CLUTTER_FIXED_MUL (((CLUTTER_FIXED_DIV ((y), (w)) + 1.0) / 2), \ + (v1)) + (v2)) #define MTX_GL_SCALE_Z(z,w,v1,v2) (MTX_GL_SCALE_X ((z), (w), (v1), (v2))) /* transforms a 4-tuple of coordinates using @matrix and @@ -1345,8 +1348,8 @@ _clutter_actor_apply_modelview_transform (ClutterActor *self) gboolean is_stage = CLUTTER_IS_STAGE (self); if (!is_stage) - cogl_translatex (CLUTTER_UNITS_TO_FIXED (priv->allocation.x1), - CLUTTER_UNITS_TO_FIXED (priv->allocation.y1), + cogl_translate (CLUTTER_UNITS_TO_FLOAT (priv->allocation.x1), + CLUTTER_UNITS_TO_FLOAT (priv->allocation.y1), 0); /* @@ -1360,50 +1363,50 @@ _clutter_actor_apply_modelview_transform (ClutterActor *self) if (priv->rzang) { - cogl_translatex (CLUTTER_UNITS_TO_FIXED (priv->rzx), - CLUTTER_UNITS_TO_FIXED (priv->rzy), + cogl_translate (CLUTTER_UNITS_TO_FLOAT (priv->rzx), + CLUTTER_UNITS_TO_FLOAT (priv->rzy), 0); - cogl_rotatex (priv->rzang, 0, 0, 1.0); + cogl_rotate (priv->rzang, 0, 0, 1.0); - cogl_translatex (CLUTTER_UNITS_TO_FIXED (-priv->rzx), - CLUTTER_UNITS_TO_FIXED (-priv->rzy), + cogl_translate (CLUTTER_UNITS_TO_FLOAT (-priv->rzx), + CLUTTER_UNITS_TO_FLOAT (-priv->rzy), 0); } if (priv->ryang) { - cogl_translatex (CLUTTER_UNITS_TO_FIXED (priv->ryx), + cogl_translate (CLUTTER_UNITS_TO_FLOAT (priv->ryx), 0, - CLUTTER_UNITS_TO_FIXED (priv->z + priv->ryz)); + CLUTTER_UNITS_TO_FLOAT (priv->z + priv->ryz)); - cogl_rotatex (priv->ryang, 0, 1.0, 0); + cogl_rotate (priv->ryang, 0, 1.0, 0); - cogl_translatex (CLUTTER_UNITS_TO_FIXED (-priv->ryx), + cogl_translate (CLUTTER_UNITS_TO_FLOAT (-priv->ryx), 0, - CLUTTER_UNITS_TO_FIXED (-(priv->z + priv->ryz))); + CLUTTER_UNITS_TO_FLOAT (-(priv->z + priv->ryz))); } if (priv->rxang) { - cogl_translatex (0, - CLUTTER_UNITS_TO_FIXED (priv->rxy), - CLUTTER_UNITS_TO_FIXED (priv->z + priv->rxz)); + cogl_translate (0, + CLUTTER_UNITS_TO_FLOAT (priv->rxy), + CLUTTER_UNITS_TO_FLOAT (priv->z + priv->rxz)); - cogl_rotatex (priv->rxang, 1.0, 0, 0); + cogl_rotate (priv->rxang, 1.0, 0, 0); - cogl_translatex (0, - CLUTTER_UNITS_TO_FIXED (-priv->rxy), - CLUTTER_UNITS_TO_FIXED (-(priv->z + priv->rxz))); + cogl_translate (0, + CLUTTER_UNITS_TO_FLOAT (-priv->rxy), + CLUTTER_UNITS_TO_FLOAT (-(priv->z + priv->rxz))); } if (!is_stage && (priv->anchor_x || priv->anchor_y)) - cogl_translatex (CLUTTER_UNITS_TO_FIXED (-priv->anchor_x), - CLUTTER_UNITS_TO_FIXED (-priv->anchor_y), + cogl_translate (CLUTTER_UNITS_TO_FLOAT (-priv->anchor_x), + CLUTTER_UNITS_TO_FLOAT (-priv->anchor_y), 0); if (priv->z) - cogl_translatex (0, 0, priv->z); + cogl_translate (0, 0, priv->z); } /* Recursively applies the transforms associated with this actor and diff --git a/clutter/clutter-alpha.c b/clutter/clutter-alpha.c index 60ef0d396..dda0f6c81 100644 --- a/clutter/clutter-alpha.c +++ b/clutter/clutter-alpha.c @@ -697,6 +697,11 @@ clutter_ramp_func (ClutterAlpha *alpha, } } +#if 0 +/* + * The following three functions are left in place for reference + * purposes. + */ static guint32 sincx1024_func (ClutterAlpha *alpha, float angle, @@ -716,7 +721,7 @@ sincx1024_func (ClutterAlpha *alpha, x -= (512 * 512 / angle); - sine = ((sinf (x * (G_PI/180.0)) + offset) / 2) + sine = ((cogl_angle_sin (x) + offset) / 2) * CLUTTER_ALPHA_MAX_ALPHA; sine = sine >> COGL_FIXED_Q; @@ -724,11 +729,6 @@ sincx1024_func (ClutterAlpha *alpha, return sine; } -#if 0 -/* - * The following two functions are left in place for reference - * purposes. - */ static guint32 sincx_func (ClutterAlpha *alpha, ClutterFixed angle, @@ -747,7 +747,7 @@ sincx_func (ClutterAlpha *alpha, x = CLUTTER_FIXED_MUL (x, CFX_PI) - CLUTTER_FIXED_DIV (CFX_PI, angle); - sine = (sinf (x) + offset) / 2; + sine = (cogl_angle_sin (x) + offset) / 2; CLUTTER_NOTE (ALPHA, "sine: %2f\n", CLUTTER_FIXED_TO_DOUBLE (sine)); @@ -806,9 +806,28 @@ guint32 clutter_sine_func (ClutterAlpha *alpha, gpointer dummy) { -#if 0 +#if 1 + ClutterTimeline *timeline; + gint current_frame_num, n_frames; + float radians, sine; + + timeline = clutter_alpha_get_timeline (alpha); + + current_frame_num = clutter_timeline_get_current_frame (timeline); + n_frames = clutter_timeline_get_n_frames (timeline); + + radians = ((float)current_frame_num / n_frames) * (2.0 * G_PI); + sine = sinf (radians); + + /* shift from range [-1, 1] -> [0, 1] */ + sine = (sine + 1.0) / 2.0; + + CLUTTER_NOTE (ALPHA, "sine: %2f\n", sine); + + return sine * CLUTTER_ALPHA_MAX_ALPHA; +#elif 0 return sinc_func (alpha, 2.0, 1.0); -#else +#elif 0 /* 2.0 above represents full circle */ return sincx1024_func (alpha, 1024, 1.0); #endif @@ -842,18 +861,17 @@ clutter_sine_inc_func (ClutterAlpha *alpha, ClutterTimeline * timeline; gint frame; gint n_frames; - float x; - ClutterFixed sine; + float radians; + float sine; timeline = clutter_alpha_get_timeline (alpha); frame = clutter_timeline_get_current_frame (timeline); n_frames = clutter_timeline_get_n_frames (timeline); - x = 256 * frame / n_frames; + radians = ((float)frame / n_frames) * (G_PI / 2); + sine = sinf (radians); - sine = sinf (x * (G_PI/180.0)) * CLUTTER_ALPHA_MAX_ALPHA; - - return ((guint32) sine) >> COGL_FIXED_Q; + return (guint32) (sine * CLUTTER_ALPHA_MAX_ALPHA); } /** @@ -884,18 +902,17 @@ clutter_sine_dec_func (ClutterAlpha *alpha, ClutterTimeline * timeline; gint frame; gint n_frames; - float x; - ClutterFixed sine; + float radians; + float sine; timeline = clutter_alpha_get_timeline (alpha); frame = clutter_timeline_get_current_frame (timeline); n_frames = clutter_timeline_get_n_frames (timeline); - x = 256 * frame / n_frames + 256; + radians = ((float)frame / n_frames) * (G_PI / 2); + sine = sinf (radians + (G_PI / 2)); - sine = sinf (x * (G_PI/180.0)) * CLUTTER_ALPHA_MAX_ALPHA; - - return ((guint32) sine) >> COGL_FIXED_Q; + return (guint32) (sine * CLUTTER_ALPHA_MAX_ALPHA); } /** @@ -926,18 +943,17 @@ clutter_sine_half_func (ClutterAlpha *alpha, ClutterTimeline *timeline; gint frame; gint n_frames; - float x; - ClutterFixed sine; + float radians; + float sine; timeline = clutter_alpha_get_timeline (alpha); frame = clutter_timeline_get_current_frame (timeline); n_frames = clutter_timeline_get_n_frames (timeline); - x = 512 * frame / n_frames; + radians = ((float)frame / n_frames) * G_PI; + sine = sinf (radians); - sine = sinf (x * (G_PI/180.0)) * CLUTTER_ALPHA_MAX_ALPHA; - - return ((guint32) sine) >> COGL_FIXED_Q; + return (guint32) (sine * CLUTTER_ALPHA_MAX_ALPHA); } /** @@ -962,19 +978,20 @@ clutter_sine_in_func (ClutterAlpha *alpha, ClutterTimeline *timeline; gint frame; gint n_frames; - float x; - ClutterFixed sine; + float radians; + float sine; timeline = clutter_alpha_get_timeline (alpha); frame = clutter_timeline_get_current_frame (timeline); n_frames = clutter_timeline_get_n_frames (timeline); - /* XXX- if we use 768 we overflow */ - x = 256 * frame / n_frames + 767; + radians = ((float)frame / n_frames) * (G_PI / 2); + sine = sinf (radians - (G_PI / 2)); - sine = (sinf (x * (G_PI/180.0)) + 1) * CLUTTER_ALPHA_MAX_ALPHA; + /* shift from range [-1, 0] -> [0, 1] */ + sine = sine + 1.0; - return ((guint32) sine) >> COGL_FIXED_Q; + return (guint32) (sine * CLUTTER_ALPHA_MAX_ALPHA); } /** @@ -998,18 +1015,17 @@ clutter_sine_out_func (ClutterAlpha *alpha, ClutterTimeline *timeline; gint frame; gint n_frames; - float x; - ClutterFixed sine; + float radians; + float sine; timeline = clutter_alpha_get_timeline (alpha); frame = clutter_timeline_get_current_frame (timeline); n_frames = clutter_timeline_get_n_frames (timeline); - x = 256 * frame / n_frames; + radians = ((float)frame / n_frames) * (G_PI / 2); + sine = sinf (radians); - sine = sinf (x * (G_PI/180.0)) * CLUTTER_ALPHA_MAX_ALPHA; - - return ((guint32) sine) >> COGL_FIXED_Q; + return (guint32) (sine * CLUTTER_ALPHA_MAX_ALPHA); } /** @@ -1034,18 +1050,20 @@ clutter_sine_in_out_func (ClutterAlpha *alpha, ClutterTimeline *timeline; gint frame; gint n_frames; - float x; - ClutterFixed sine; + float radians; + float sine; timeline = clutter_alpha_get_timeline (alpha); frame = clutter_timeline_get_current_frame (timeline); n_frames = clutter_timeline_get_n_frames (timeline); - x = -256 * frame / n_frames + 256; + radians = ((float)frame / n_frames) * G_PI; + sine = sinf (radians - (G_PI / 2)); - sine = (sinf (x * (G_PI/180.0)) + 1) / 2 * CLUTTER_ALPHA_MAX_ALPHA; + /* shift from range [-1, 1] -> [0, 1] */ + sine = (sine + 1.0) / 2.0; - return ((guint32) sine) >> COGL_FIXED_Q; + return (guint32) (sine * CLUTTER_ALPHA_MAX_ALPHA); } /** @@ -1113,30 +1131,23 @@ clutter_smoothstep_inc_func (ClutterAlpha *alpha, ClutterTimeline *timeline; gint frame; gint n_frames; - guint32 r; - guint32 x; + float r; + float x; /* * The smoothstep function uses f(x) = -2x^3 + 3x^2 where x is from <0,1>, - * and precission is critical -- we use 8.24 fixed format for this operation. - * The earlier operations involve division, which we cannot do in 8.24 for - * numbers in <0,1> we use ClutterFixed. + * and precission is critical. */ timeline = clutter_alpha_get_timeline (alpha); frame = clutter_timeline_get_current_frame (timeline); n_frames = clutter_timeline_get_n_frames (timeline); - /* - * Convert x to 8.24 for next step. - */ - x = CLUTTER_FIXED_DIV (frame, n_frames) << 8; + x = (float)frame / n_frames; /* * f(x) = -2x^3 + 3x^2 - * - * Convert result to ClutterFixed to avoid overflow in next step. */ - r = ((x >> 12) * (x >> 12) * 3 - (x >> 15) * (x >> 16) * (x >> 16)) >> 8; + r = -2 * x * x * x + 3 * x * x; return (r * CLUTTER_ALPHA_MAX_ALPHA); } @@ -1204,9 +1215,9 @@ clutter_exp_inc_func (ClutterAlpha *alpha, * * (2^x_alpha_max) - 1 == CLUTTER_ALPHA_MAX_ALPHA */ -#if CLUTTER_ALPHA_MAX_ALPHA != 0xffff -#error Adjust x_alpha_max to match CLUTTER_ALPHA_MAX_ALPHA -#endif + /* XXX: If this fails: + * Adjust x_alpha_max to match CLUTTER_ALPHA_MAX_ALPHA */ + g_assert (CLUTTER_ALPHA_MAX_ALPHA == 65535.0); timeline = clutter_alpha_get_timeline (alpha); frame = clutter_timeline_get_current_frame (timeline); @@ -1214,7 +1225,7 @@ clutter_exp_inc_func (ClutterAlpha *alpha, x = x_alpha_max * frame / n_frames; - result = CLAMP (pow2f (x) - 1, 0, CLUTTER_ALPHA_MAX_ALPHA); + result = CLAMP (powf (2, x) - 1, 0, CLUTTER_ALPHA_MAX_ALPHA); return result; } @@ -1255,9 +1266,9 @@ clutter_exp_dec_func (ClutterAlpha *alpha, * * (2^x_alpha_max) - 1 == CLUTTER_ALPHA_MAX_ALPHA */ -#if CLUTTER_ALPHA_MAX_ALPHA != 0xffff -#error Adjust x_alpha_max to match CLUTTER_ALPHA_MAX_ALPHA -#endif + /* XXX: If this fails: + * Adjust x_alpha_max to match CLUTTER_ALPHA_MAX_ALPHA */ + g_assert (CLUTTER_ALPHA_MAX_ALPHA == 65535.0); timeline = clutter_alpha_get_timeline (alpha); frame = clutter_timeline_get_current_frame (timeline); @@ -1265,7 +1276,7 @@ clutter_exp_dec_func (ClutterAlpha *alpha, x = (x_alpha_max * (n_frames - frame)) / n_frames; - result = CLAMP (pow2f (x) - 1, 0, CLUTTER_ALPHA_MAX_ALPHA); + result = CLAMP (powf (2, x) - 1, 0, CLUTTER_ALPHA_MAX_ALPHA); return result; } diff --git a/clutter/clutter-alpha.h b/clutter/clutter-alpha.h index eba9e3fb8..e409d7762 100644 --- a/clutter/clutter-alpha.h +++ b/clutter/clutter-alpha.h @@ -106,7 +106,7 @@ struct _ClutterAlphaClass * * Since: 0.2 */ -#define CLUTTER_ALPHA_MAX_ALPHA (0xffff) +#define CLUTTER_ALPHA_MAX_ALPHA (65535.0f) GType clutter_alpha_get_type (void) G_GNUC_CONST; diff --git a/clutter/clutter-behaviour-ellipse.c b/clutter/clutter-behaviour-ellipse.c index 162a9492d..4212b957d 100644 --- a/clutter/clutter-behaviour-ellipse.c +++ b/clutter/clutter-behaviour-ellipse.c @@ -190,17 +190,13 @@ actor_apply_knot_foreach (ClutterBehaviour *behave, static inline float clamp_angle (float a) { - float a1, a2; gint rounds; - /* Need to add the 256 offset here, since the user space 0 maps to our - * -256 - */ - rounds = (a + 256) / 1024; - a1 = rounds * 1024; - a2 = a - a1; + rounds = a / 360; + if (a < 0) + rounds--; - return a2; + return a - 360 * rounds; } static void @@ -218,11 +214,11 @@ clutter_behaviour_ellipse_alpha_notify (ClutterBehaviour *behave, if (priv->direction == CLUTTER_ROTATE_CW && start >= end) { - end += 1024; + end += 360; } else if (priv->direction == CLUTTER_ROTATE_CCW && start <= end) { - end -= 1024; + end -= 360; } angle = (end - start) * alpha / CLUTTER_ALPHA_MAX_ALPHA + start; @@ -247,30 +243,25 @@ clutter_behaviour_ellipse_set_property (GObject *gobject, switch (prop_id) { case PROP_ANGLE_START: - priv->angle_start = - COGL_ANGLE_FROM_DEG (g_value_get_double (value)) - 256; + priv->angle_start = g_value_get_double (value); break; case PROP_ANGLE_END: - priv->angle_end = - COGL_ANGLE_FROM_DEG (g_value_get_double (value)) - 256; + priv->angle_end = g_value_get_double (value); break; case PROP_ANGLE_TILT_X: - priv->angle_tilt_x = - COGL_ANGLE_FROM_DEG (g_value_get_double (value)); + priv->angle_tilt_x = g_value_get_double (value); break; case PROP_ANGLE_TILT_Y: - priv->angle_tilt_y = - COGL_ANGLE_FROM_DEG (g_value_get_double (value)); + priv->angle_tilt_y = g_value_get_double (value); break; case PROP_ANGLE_TILT_Z: - priv->angle_tilt_z = - COGL_ANGLE_FROM_DEG (g_value_get_double (value)); + priv->angle_tilt_z = g_value_get_double (value); break; case PROP_WIDTH: - priv->a = g_value_get_int (value) >> 1; + priv->a = g_value_get_int (value) / 2; break; case PROP_HEIGHT: - priv->b = g_value_get_int (value) >> 1; + priv->b = g_value_get_int (value) / 2; break; case PROP_CENTER: { @@ -301,30 +292,25 @@ clutter_behaviour_ellipse_get_property (GObject *gobject, switch (prop_id) { case PROP_ANGLE_START: - g_value_set_double (value, - COGL_ANGLE_TO_DEG (priv->angle_start + 256)); + g_value_set_double (value, priv->angle_start); break; case PROP_ANGLE_END: - g_value_set_double (value, - COGL_ANGLE_TO_DEG (priv->angle_end + 256)); + g_value_set_double (value, priv->angle_end); break; case PROP_ANGLE_TILT_X: - g_value_set_double (value, - COGL_ANGLE_TO_DEG (priv->angle_tilt_x)); + g_value_set_double (value, priv->angle_tilt_x); break; case PROP_ANGLE_TILT_Y: - g_value_set_double (value, - COGL_ANGLE_TO_DEG (priv->angle_tilt_y)); + g_value_set_double (value, priv->angle_tilt_y); break; case PROP_ANGLE_TILT_Z: - g_value_set_double (value, - COGL_ANGLE_TO_DEG (priv->angle_tilt_z)); + g_value_set_double (value, priv->angle_tilt_z); break; case PROP_WIDTH: - g_value_set_int (value, (priv->a << 1)); + g_value_set_int (value, (priv->a * 2)); break; case PROP_HEIGHT: - g_value_set_int (value, (priv->b << 1)); + g_value_set_int (value, (priv->b * 2)); break; case PROP_CENTER: g_value_set_boxed (value, &priv->center); @@ -513,12 +499,8 @@ clutter_behaviour_ellipse_init (ClutterBehaviourEllipse * self) priv->direction = CLUTTER_ROTATE_CW; - /* The inital values have to reflect the 90 degree offset between the normal - * mathematical space and the clutter clock-based space; the default end - * value of 360 is clamped to 0. - */ - priv->angle_start = -256; - priv->angle_end = -256; + priv->angle_start = 0; + priv->angle_end = 0; } /** @@ -611,8 +593,8 @@ clutter_behaviour_ellipse_newx (ClutterAlpha * alpha, "width", width, "height", height, "direction", direction, - "angle-start", COGL_ANGLE_FROM_DEGX (start), - "angle-end", COGL_ANGLE_FROM_DEGX (end), + "angle-start", (double)CLUTTER_FIXED_TO_FLOAT (start), + "angle-end", (double)CLUTTER_FIXED_TO_FLOAT (end), NULL); } @@ -695,9 +677,9 @@ clutter_behaviour_ellipse_set_width (ClutterBehaviourEllipse * self, priv = self->priv; - if (priv->a != width >> 1) + if (priv->a != width / 2) { - priv->a = width >> 1; + priv->a = width / 2; g_object_notify (G_OBJECT (self), "width"); } @@ -718,7 +700,7 @@ clutter_behaviour_ellipse_get_width (ClutterBehaviourEllipse *self) { g_return_val_if_fail (CLUTTER_IS_BEHAVIOUR_ELLIPSE (self), 0); - return self->priv->a << 1; + return self->priv->a * 2; } /** @@ -740,9 +722,9 @@ clutter_behaviour_ellipse_set_height (ClutterBehaviourEllipse *self, priv = self->priv; - if (priv->b != height >> 1) + if (priv->b != height / 2) { - priv->b = height >> 1; + priv->b = height / 2; g_object_notify (G_OBJECT (self), "height"); } @@ -763,7 +745,7 @@ clutter_behaviour_ellipse_get_height (ClutterBehaviourEllipse *self) { g_return_val_if_fail (CLUTTER_IS_BEHAVIOUR_ELLIPSE (self), 0); - return self->priv->b << 1; + return self->priv->b * 2; } /** @@ -780,10 +762,11 @@ void clutter_behaviour_ellipse_set_angle_start (ClutterBehaviourEllipse *self, gdouble angle_start) { + ClutterFixed new_angle = CLUTTER_FLOAT_TO_FIXED (angle_start); + g_return_if_fail (CLUTTER_IS_BEHAVIOUR_ELLIPSE (self)); - clutter_behaviour_ellipse_set_angle_startx (self, - CLUTTER_FLOAT_TO_FIXED (angle_start)); + clutter_behaviour_ellipse_set_angle_startx (self, new_angle); } /** @@ -805,7 +788,7 @@ clutter_behaviour_ellipse_set_angle_startx (ClutterBehaviourEllipse *self, float new_angle; g_return_if_fail (CLUTTER_IS_BEHAVIOUR_ELLIPSE (self)); - new_angle = clamp_angle (COGL_ANGLE_FROM_DEGX (angle_start) - 256); + new_angle = clamp_angle (CLUTTER_FIXED_TO_FLOAT (angle_start)); priv = self->priv; if (priv->angle_start != new_angle) @@ -830,7 +813,7 @@ clutter_behaviour_ellipse_get_angle_start (ClutterBehaviourEllipse *self) { g_return_val_if_fail (CLUTTER_IS_BEHAVIOUR_ELLIPSE (self), 0.0); - return COGL_ANGLE_TO_DEG (self->priv->angle_start + 256); + return (double)self->priv->angle_start; } /** @@ -848,7 +831,7 @@ clutter_behaviour_ellipse_get_angle_startx (ClutterBehaviourEllipse *self) { g_return_val_if_fail (CLUTTER_IS_BEHAVIOUR_ELLIPSE (self), 0); - return COGL_ANGLE_TO_DEGX (self->priv->angle_start); + return CLUTTER_FLOAT_TO_FIXED (self->priv->angle_start); } /** @@ -865,10 +848,11 @@ void clutter_behaviour_ellipse_set_angle_end (ClutterBehaviourEllipse *self, gdouble angle_end) { + ClutterFixed new_angle = CLUTTER_FLOAT_TO_FIXED (angle_end); + g_return_if_fail (CLUTTER_IS_BEHAVIOUR_ELLIPSE (self)); - clutter_behaviour_ellipse_set_angle_endx (self, - CLUTTER_FLOAT_TO_FIXED (angle_end)); + clutter_behaviour_ellipse_set_angle_endx (self, new_angle); } /** @@ -891,7 +875,7 @@ clutter_behaviour_ellipse_set_angle_endx (ClutterBehaviourEllipse *self, g_return_if_fail (CLUTTER_IS_BEHAVIOUR_ELLIPSE (self)); - new_angle = clamp_angle (COGL_ANGLE_FROM_DEGX (angle_end) - 256); + new_angle = clamp_angle (CLUTTER_FIXED_TO_FLOAT (angle_end)); priv = self->priv; @@ -918,7 +902,7 @@ clutter_behaviour_ellipse_get_angle_end (ClutterBehaviourEllipse *self) { g_return_val_if_fail (CLUTTER_IS_BEHAVIOUR_ELLIPSE (self), 0.0); - return COGL_ANGLE_TO_DEG (self->priv->angle_end + 256); + return self->priv->angle_end; } /** @@ -936,7 +920,7 @@ clutter_behaviour_ellipse_get_angle_endx (ClutterBehaviourEllipse *self) { g_return_val_if_fail (CLUTTER_IS_BEHAVIOUR_ELLIPSE (self), 0); - return COGL_ANGLE_TO_DEGX (self->priv->angle_end); + return CLUTTER_FLOAT_TO_FIXED (self->priv->angle_end); } /** @@ -955,11 +939,11 @@ clutter_behaviour_ellipse_set_angle_tilt (ClutterBehaviourEllipse *self, ClutterRotateAxis axis, gdouble angle_tilt) { + ClutterFixed new_angle = CLUTTER_FLOAT_TO_FIXED (angle_tilt); + g_return_if_fail (CLUTTER_IS_BEHAVIOUR_ELLIPSE (self)); - clutter_behaviour_ellipse_set_angle_tiltx (self, - axis, - CLUTTER_FLOAT_TO_FIXED (angle_tilt)); + clutter_behaviour_ellipse_set_angle_tiltx (self, axis, new_angle); } /** @@ -983,7 +967,7 @@ clutter_behaviour_ellipse_set_angle_tiltx (ClutterBehaviourEllipse *self, g_return_if_fail (CLUTTER_IS_BEHAVIOUR_ELLIPSE (self)); - new_angle = COGL_ANGLE_FROM_DEGX (angle_tilt); + new_angle = CLUTTER_FIXED_TO_FLOAT (angle_tilt); priv = self->priv; @@ -1038,11 +1022,11 @@ clutter_behaviour_ellipse_get_angle_tilt (ClutterBehaviourEllipse *self, switch (axis) { case CLUTTER_X_AXIS: - return COGL_ANGLE_TO_DEG (self->priv->angle_tilt_x); + return self->priv->angle_tilt_x; case CLUTTER_Y_AXIS: - return COGL_ANGLE_TO_DEG (self->priv->angle_tilt_y); + return self->priv->angle_tilt_y; case CLUTTER_Z_AXIS: - return COGL_ANGLE_TO_DEG (self->priv->angle_tilt_z); + return self->priv->angle_tilt_z; } return 0; @@ -1068,11 +1052,11 @@ clutter_behaviour_ellipse_get_angle_tiltx (ClutterBehaviourEllipse *self, switch (axis) { case CLUTTER_X_AXIS: - return COGL_ANGLE_TO_DEGX (self->priv->angle_tilt_x); + return CLUTTER_FLOAT_TO_FIXED (self->priv->angle_tilt_x); case CLUTTER_Y_AXIS: - return COGL_ANGLE_TO_DEGX (self->priv->angle_tilt_y); + return CLUTTER_FLOAT_TO_FIXED (self->priv->angle_tilt_y); case CLUTTER_Z_AXIS: - return COGL_ANGLE_TO_DEGX (self->priv->angle_tilt_z); + return CLUTTER_FLOAT_TO_FIXED (self->priv->angle_tilt_z); } return 0; @@ -1100,9 +1084,9 @@ clutter_behaviour_ellipse_set_tilt (ClutterBehaviourEllipse *self, g_return_if_fail (CLUTTER_IS_BEHAVIOUR_ELLIPSE (self)); - new_angle_x = COGL_ANGLE_FROM_DEG (angle_tilt_x); - new_angle_y = COGL_ANGLE_FROM_DEG (angle_tilt_y); - new_angle_z = COGL_ANGLE_FROM_DEG (angle_tilt_z); + new_angle_x = (float)angle_tilt_x; + new_angle_y = (float)angle_tilt_y; + new_angle_z = (float)angle_tilt_z; priv = self->priv; @@ -1154,9 +1138,9 @@ clutter_behaviour_ellipse_set_tiltx (ClutterBehaviourEllipse *self, g_return_if_fail (CLUTTER_IS_BEHAVIOUR_ELLIPSE (self)); - new_angle_x = COGL_ANGLE_FROM_DEGX (angle_tilt_x); - new_angle_y = COGL_ANGLE_FROM_DEGX (angle_tilt_y); - new_angle_z = COGL_ANGLE_FROM_DEGX (angle_tilt_z); + new_angle_x = CLUTTER_FIXED_TO_FLOAT (angle_tilt_x); + new_angle_y = CLUTTER_FIXED_TO_FLOAT (angle_tilt_y); + new_angle_z = CLUTTER_FIXED_TO_FLOAT (angle_tilt_z); priv = self->priv; @@ -1210,13 +1194,13 @@ clutter_behaviour_ellipse_get_tilt (ClutterBehaviourEllipse *self, priv = self->priv; if (angle_tilt_x) - *angle_tilt_x = COGL_ANGLE_TO_DEG (priv->angle_tilt_x); + *angle_tilt_x = priv->angle_tilt_x; if (angle_tilt_y) - *angle_tilt_y = COGL_ANGLE_TO_DEG (priv->angle_tilt_y); + *angle_tilt_y = priv->angle_tilt_y; if (angle_tilt_z) - *angle_tilt_z = COGL_ANGLE_TO_DEG (priv->angle_tilt_z); + *angle_tilt_z = priv->angle_tilt_z; } /** @@ -1246,13 +1230,13 @@ clutter_behaviour_ellipse_get_tiltx (ClutterBehaviourEllipse *self, priv = self->priv; if (angle_tilt_x) - *angle_tilt_x = COGL_ANGLE_TO_DEGX (priv->angle_tilt_x); + *angle_tilt_x = priv->angle_tilt_x; if (angle_tilt_y) - *angle_tilt_y = COGL_ANGLE_TO_DEGX (priv->angle_tilt_y); + *angle_tilt_y = priv->angle_tilt_y; if (angle_tilt_z) - *angle_tilt_z = COGL_ANGLE_TO_DEGX (priv->angle_tilt_z); + *angle_tilt_z = priv->angle_tilt_z; } /** diff --git a/clutter/clutter-bezier.c b/clutter/clutter-bezier.c index 6a476268f..66c4ddfd1 100644 --- a/clutter/clutter-bezier.c +++ b/clutter/clutter-bezier.c @@ -252,7 +252,7 @@ _clutter_bezier_init (ClutterBezier *b, int x = _clutter_bezier_t2x (b, t); int y = _clutter_bezier_t2y (b, t); - guint l = clutter_sqrti ((y - yp)*(y - yp) + (x - xp)*(x - xp)); + guint l = cogl_sqrti ((y - yp)*(y - yp) + (x - xp)*(x - xp)); l += length[i-1]; diff --git a/clutter/clutter-fixed.c b/clutter/clutter-fixed.c index 3027a7591..315fe32e2 100644 --- a/clutter/clutter-fixed.c +++ b/clutter/clutter-fixed.c @@ -251,8 +251,8 @@ param_fixed_init (GParamSpec *pspec) { ClutterParamSpecFixed *fspec = CLUTTER_PARAM_SPEC_FIXED (pspec); - fspec->minimum = COGL_FIXED_MIN; - fspec->maximum = COGL_FIXED_MAX; + fspec->minimum = CLUTTER_MAXFIXED; + fspec->maximum = CLUTTER_MINFIXED; fspec->default_value = 0; } diff --git a/clutter/clutter-path.c b/clutter/clutter-path.c index 6f9340249..c459cdf9f 100644 --- a/clutter/clutter-path.c +++ b/clutter/clutter-path.c @@ -1217,11 +1217,11 @@ clutter_path_node_distance (const ClutterKnot *start, * If we are using limited precision sqrti implementation, fallback on * clib sqrt if the precission would be less than 10% */ -#if INT_MAX > CLUTTER_SQRTI_ARG_10_PERCENT +#if INT_MAX > COGL_SQRTI_ARG_10_PERCENT if (t <= COGL_SQRTI_ARG_10_PERCENT) return cogl_sqrti (t); else - return COGL_FLOAT_TO_INT (sqrt(t)); + return COGL_FLOAT_TO_INT (sqrtf(t)); #else return cogl_sqrti (t); #endif diff --git a/clutter/clutter-texture.c b/clutter/clutter-texture.c index b0b46e430..8a306e9f7 100644 --- a/clutter/clutter-texture.c +++ b/clutter/clutter-texture.c @@ -474,7 +474,7 @@ clutter_texture_set_fbo_projection (ClutterActor *self) /* Set up a projection matrix so that the actor will be projected as if it was drawn at its original location */ - tan_angle = tanf (COGL_ANGLE_FROM_DEGX (perspective.fovy / 2 * (G_PI/180.0))); + tan_angle = tanf ((perspective.fovy / 2) * (G_PI/180.0)); near_size = CLUTTER_FIXED_MUL (perspective.z_near, tan_angle); cogl_frustum (CLUTTER_FIXED_MUL (tx_min, near_size), diff --git a/clutter/cogl/cogl-color.h b/clutter/cogl/cogl-color.h index 6cdf52bd9..05650d34a 100644 --- a/clutter/cogl/cogl-color.h +++ b/clutter/cogl/cogl-color.h @@ -68,7 +68,7 @@ void cogl_color_set_from_4d (CoglColor *dest, gdouble alpha); /** - * cogl_color_set_from_4x: + * cogl_color_set_from_4f: * @dest: return location for a #CoglColor * @red: value of the red channel, between 0 and %1.0 * @green: value of the green channel, between 0 and %1.0 @@ -79,7 +79,7 @@ void cogl_color_set_from_4d (CoglColor *dest, * * Since: 1.0 */ -void cogl_color_set_from_4x (CoglColor *dest, +void cogl_color_set_from_4f (CoglColor *dest, float red, float green, float blue, @@ -248,7 +248,7 @@ float cogl_color_get_alpha (const CoglColor *color); * Sets the source color using normalized values for each component. * This color will be used for any subsequent drawing operation. * - * See also cogl_set_source_color4ub() and cogl_set_source_color4x() + * See also cogl_set_source_color4ub() and cogl_set_source_color4f() * if you already have the color components. * * Since: 1.0 @@ -276,7 +276,7 @@ void cogl_set_source_color4ub (guint8 red, guint8 alpha); /** - * cogl_set_source_color4x: + * cogl_set_source_color4f: * @red: value of the red channel, between 0 and %1.0 * @green: value of the green channel, between 0 and %1.0 * @blue: value of the blue channel, between 0 and %1.0 @@ -291,7 +291,7 @@ void cogl_set_source_color4ub (guint8 red, * * Since: 1.0 */ -void cogl_set_source_color4x (float red, +void cogl_set_source_color4f (float red, float green, float blue, float alpha); diff --git a/clutter/cogl/cogl-fixed.h b/clutter/cogl/cogl-fixed.h index a52107421..8d7c9e96a 100644 --- a/clutter/cogl/cogl-fixed.h +++ b/clutter/cogl/cogl-fixed.h @@ -455,6 +455,18 @@ G_BEGIN_DECLS */ CoglFixed cogl_fixed_sin (CoglFixed angle); +/** + * cogl_fixed_tan: + * @angle: a #CoglFixed number + * + * Computes the tangent of @angle. + * + * Return value: the tangent of the passed angle, in fixed point notation + * + * Since: 1.0 + */ +CoglFixed cogl_fixed_tan (CoglFixed angle); + /** * cogl_fixed_cos: * @angle: a #CoglFixed number diff --git a/clutter/cogl/cogl-path.h b/clutter/cogl/cogl-path.h index 0d2982923..aa378647a 100644 --- a/clutter/cogl/cogl-path.h +++ b/clutter/cogl/cogl-path.h @@ -60,24 +60,10 @@ G_BEGIN_DECLS * Fills a rectangle at the given coordinates with the current * drawing color in a highly optimizied fashion. **/ -void cogl_rectangle (gint x, - gint y, - guint width, - guint height); - -/** - * cogl_rectanglex: - * @x: X coordinate of the top-left corner - * @y: Y coordinate of the top-left corner - * @width: Width of the rectangle - * @height: Height of the rectangle - * - * A fixed-point version of cogl_fast_fill_rectangle. - **/ -void cogl_rectanglex (float x, - float y, - float width, - float height); +void cogl_rectangle (float x, + float y, + float width, + float height); /** * cogl_path_fill: diff --git a/clutter/cogl/cogl.h.in b/clutter/cogl/cogl.h.in index cc26f882f..f8d574524 100644 --- a/clutter/cogl/cogl.h.in +++ b/clutter/cogl/cogl.h.in @@ -231,7 +231,7 @@ void cogl_scale (float x, float y); /** - * cogl_translatex: + * cogl_translate: * @x: Distance to translate along the x-axis * @y: Distance to translate along the y-axis * @z: Distance to translate along the z-axis @@ -239,26 +239,12 @@ void cogl_scale (float x, * Multiplies the current model-view matrix by one that translates the * model along all three axes according to the given values. */ -void cogl_translatex (float x, - float y, - float z); +void cogl_translate (float x, + float y, + float z); /** - * cogl_translate: - * @x: Distance to translate along the x-axis - * @y: Distance to translate along the y-axis - * @z: Distance to translate along the z-axis - * - * Integer version of cogl_translatex(). Multiplies the current - * model-view matrix by one that translates the model along all three - * axes according to the given values. - */ -void cogl_translate (gint x, - gint y, - gint z); - -/** - * cogl_rotatex: + * cogl_rotate: * @angle: Angle in degrees to rotate. * @x: X-component of vertex to rotate around. * @y: Y-component of vertex to rotate around. @@ -270,26 +256,10 @@ void cogl_translate (gint x, * degrees about the vertex (0, 0, 1) causes a small counter-clockwise * rotation. */ -void cogl_rotatex (float angle, - gint x, - gint y, - gint z); - -/** - * cogl_rotate: - * @angle: Angle in degrees to rotate. - * @x: X-component of vertex to rotate around. - * @y: Y-component of vertex to rotate around. - * @z: Z-component of vertex to rotate around. - * - * Integer version of cogl_rotatex(). Multiplies the current - * model-view matrix by one that rotates the model around the vertex - * specified by @x, @y and @z. - */ -void cogl_rotate (gint angle, - gint x, - gint y, - gint z); +void cogl_rotate (float angle, + float x, + float y, + float z); /** * cogl_get_modelview_matrix: @@ -442,7 +412,7 @@ void cogl_enable_backface_culling (gboolean setting); * comparing with the value in @ref. The default function is CGL_ALWAYS the * initial reference value is 1.0. */ -void cogl_alpha_func (COGLenum func, +void cogl_alpha_func (COGLenum func, float ref); /** diff --git a/clutter/cogl/common/cogl-color.c b/clutter/cogl/common/cogl-color.c index dac35849d..e4b74c6b0 100644 --- a/clutter/cogl/common/cogl-color.c +++ b/clutter/cogl/common/cogl-color.c @@ -58,7 +58,7 @@ cogl_color_set_from_4d (CoglColor *dest, } void -cogl_color_set_from_4x (CoglColor *dest, +cogl_color_set_from_4f (CoglColor *dest, float red, float green, float blue, @@ -157,13 +157,13 @@ cogl_set_source_color4ub (guint8 red, } void -cogl_set_source_color4x (float red, +cogl_set_source_color4f (float red, float green, float blue, float alpha) { CoglColor c = { 0, }; - cogl_color_set_from_4x (&c, red, green, blue, alpha); + cogl_color_set_from_4f (&c, red, green, blue, alpha); cogl_set_source_color (&c); } diff --git a/clutter/cogl/common/cogl-fixed.c b/clutter/cogl/common/cogl-fixed.c index 348d2ce28..2e27da1ba 100644 --- a/clutter/cogl/common/cogl-fixed.c +++ b/clutter/cogl/common/cogl-fixed.c @@ -481,6 +481,12 @@ cogl_angle_sin (CoglAngle angle) return result; } +CoglFixed +cogl_fixed_tan (CoglFixed angle) +{ + return cogl_angle_tan (COGL_ANGLE_FROM_DEGX (angle)); +} + CoglFixed cogl_angle_tan (CoglAngle angle) { diff --git a/clutter/cogl/common/cogl-primitives.c b/clutter/cogl/common/cogl-primitives.c index 27e0e36a7..7e9b1b94e 100644 --- a/clutter/cogl/common/cogl-primitives.c +++ b/clutter/cogl/common/cogl-primitives.c @@ -33,6 +33,7 @@ #include #include +#include #define _COGL_MAX_BEZ_RECURSE_DEPTH 16 @@ -42,37 +43,21 @@ void _cogl_path_add_node (gboolean new_sub_path, float y); void _cogl_path_fill_nodes (); void _cogl_path_stroke_nodes (); -void _cogl_rectangle (gint x, - gint y, - guint width, - guint height); -void _cogl_rectanglex (float x, - float y, - float width, - float height); +void _cogl_rectangle (float x, + float y, + float width, + float height); void -cogl_rectangle (gint x, - gint y, - guint width, - guint height) +cogl_rectangle (float x, + float y, + float width, + float height) { cogl_clip_ensure (); _cogl_rectangle (x, y, width, height); } -void -cogl_rectanglex (float x, - float y, - float width, - float height) -{ - cogl_clip_ensure (); - - _cogl_rectanglex (x, y, width, height); -} - - void cogl_path_fill (void) { diff --git a/clutter/cogl/gl/cogl-primitives.c b/clutter/cogl/gl/cogl-primitives.c index dc5c5c62a..e44565780 100644 --- a/clutter/cogl/gl/cogl-primitives.c +++ b/clutter/cogl/gl/cogl-primitives.c @@ -34,39 +34,22 @@ #include #include +#include #define _COGL_MAX_BEZ_RECURSE_DEPTH 16 void -_cogl_rectangle (gint x, - gint y, - guint width, - guint height) +_cogl_rectangle (float x, + float y, + float width, + float height) { _COGL_GET_CONTEXT (ctx, NO_RETVAL); cogl_enable (ctx->color_alpha < 255 ? COGL_ENABLE_BLEND : 0); - GE( glRecti (x, y, x + width, y + height) ); -} - - -void -_cogl_rectanglex (float x, - float y, - float width, - float height) -{ - _COGL_GET_CONTEXT (ctx, NO_RETVAL); - - cogl_enable (ctx->color_alpha < 255 - ? COGL_ENABLE_BLEND : 0); - - GE( glRectf ( (x), - (y), - (x + width), - (y + height)) ); + GE( glRectf (x, y, x + width, y + height) ); } void @@ -131,17 +114,15 @@ _cogl_path_stroke_nodes () static void _cogl_path_get_bounds (floatVec2 nodes_min, floatVec2 nodes_max, - gint *bounds_x, - gint *bounds_y, - guint *bounds_w, - guint *bounds_h) + float *bounds_x, + float *bounds_y, + float *bounds_w, + float *bounds_h) { - *bounds_x = floorf (nodes_min.x); - *bounds_y = floorf (nodes_min.y); - *bounds_w = ceilf (nodes_max.x - - (float)(*bounds_x)); - *bounds_h = ceilf (nodes_max.y - - (float)(*bounds_y)); + *bounds_x = nodes_min.x; + *bounds_y = nodes_min.y; + *bounds_w = nodes_max.x - *bounds_x; + *bounds_h = nodes_max.y - *bounds_y; } void @@ -153,10 +134,10 @@ _cogl_add_path_to_stencil_buffer (floatVec2 nodes_min, { guint path_start = 0; guint sub_path_num = 0; - gint bounds_x; - gint bounds_y; - guint bounds_w; - guint bounds_h; + float bounds_x; + float bounds_y; + float bounds_w; + float bounds_h; _cogl_path_get_bounds (nodes_min, nodes_max, &bounds_x, &bounds_y, &bounds_w, &bounds_h); @@ -238,10 +219,10 @@ _cogl_add_path_to_stencil_buffer (floatVec2 nodes_min, void _cogl_path_fill_nodes () { - gint bounds_x; - gint bounds_y; - guint bounds_w; - guint bounds_h; + float bounds_x; + float bounds_y; + float bounds_w; + float bounds_h; _COGL_GET_CONTEXT (ctx, NO_RETVAL); diff --git a/clutter/cogl/gl/cogl-texture.c b/clutter/cogl/gl/cogl-texture.c index 5b7326cc7..1dac0731c 100644 --- a/clutter/cogl/gl/cogl-texture.c +++ b/clutter/cogl/gl/cogl-texture.c @@ -37,6 +37,7 @@ #include #include +#include /* #define COGL_DEBUG 1 @@ -555,7 +556,7 @@ _cogl_texture_upload_subregion_to_gl (CoglTexture *tex, guint wx, wy; src = source_bmp->data - + (src_y + (y_iter.intersect_start) + + (src_y + ((int)y_iter.intersect_start) - dst_y) * source_bmp->rowstride + (src_x + x_span->start + x_span->size - x_span->waste @@ -600,7 +601,7 @@ _cogl_texture_upload_subregion_to_gl (CoglTexture *tex, guint copy_width; src = source_bmp->data - + (src_x + (x_iter.intersect_start) + + (src_x + ((int)x_iter.intersect_start) - dst_x) * bpp + (src_y + y_span->start + y_span->size - y_span->waste diff --git a/clutter/cogl/gl/cogl.c b/clutter/cogl/gl/cogl.c index 7b61b6353..aa0ec78aa 100644 --- a/clutter/cogl/gl/cogl.c +++ b/clutter/cogl/gl/cogl.c @@ -211,38 +211,21 @@ cogl_pop_matrix (void) void cogl_scale (float x, float y) { - glScaled ((double)(x), - (double)(y), + glScalef ((float)(x), + (float)(y), 1.0); } void -cogl_translatex (float x, float y, float z) +cogl_translate (float x, float y, float z) { - glTranslated ((double)(x), - (double)(y), - (double)(z)); + glTranslatef (x, y, z); } void -cogl_translate (gint x, gint y, gint z) +cogl_rotate (float angle, float x, float y, float z) { - glTranslatef ((float)x, (float)y, (float)z); -} - -void -cogl_rotatex (float angle, gint x, gint y, gint z) -{ - glRotated ((double)(angle), - (double)(x), - (double)(y), - (double)(z)); -} - -void -cogl_rotate (gint angle, gint x, gint y, gint z) -{ - glRotatef ((float)angle, (float)x, (float)y, (float)z); + glRotatef (angle, x, y, z); } static inline gboolean @@ -645,17 +628,13 @@ cogl_perspective (float fovy, * 2) When working with small numbers, we are loosing significant * precision */ - ymax = - (zNear * - (sinf (fovy_rad_half) / - cosf (fovy_rad_half))); - + ymax = (zNear * (sinf (fovy_rad_half) / cosf (fovy_rad_half))); xmax = (ymax * aspect); x = (zNear / xmax); y = (zNear / ymax); c = (-(zFar + zNear) / ( zFar - zNear)); - d = cogl_fixed_mul_div (-(2 * zFar), zNear, (zFar - zNear)); + d = (-(2 * zFar) * zNear) / (zFar - zNear); #define M(row,col) m[col*4+row] M(0,0) = (x); @@ -696,12 +675,12 @@ cogl_frustum (float left, GE( glMatrixMode (GL_PROJECTION) ); GE( glLoadIdentity () ); - GE( glFrustum ((double)(left), - (double)(right), - (double)(bottom), - (double)(top), - (double)(z_near), - (double)(z_far)) ); + GE( glFrustum ((GLdouble)(left), + (GLdouble)(right), + (GLdouble)(bottom), + (GLdouble)(top), + (GLdouble)(z_near), + (GLdouble)(z_far)) ); GE( glMatrixMode (GL_MODELVIEW) ); @@ -773,9 +752,7 @@ cogl_setup_viewport (guint width, { float fovy_rad = (fovy * G_PI) / 180; - z_camera = - ((sinf (fovy_rad) / - cosf (fovy_rad)) >> 1); + z_camera = ((sinf (fovy_rad) / cosf (fovy_rad)) / 2); } GE( glTranslatef (-0.5f, -0.5f, -z_camera) ); @@ -1166,73 +1143,19 @@ cogl_features_available (CoglFeatureFlags features) void cogl_get_modelview_matrix (float m[16]) { - GLdouble md[16]; - - glGetDoublev(GL_MODELVIEW_MATRIX, &md[0]); - -#define M(m,row,col) m[col*4+row] - M(m,0,0) = (M(md,0,0)); - M(m,0,1) = (M(md,0,1)); - M(m,0,2) = (M(md,0,2)); - M(m,0,3) = (M(md,0,3)); - - M(m,1,0) = (M(md,1,0)); - M(m,1,1) = (M(md,1,1)); - M(m,1,2) = (M(md,1,2)); - M(m,1,3) = (M(md,1,3)); - - M(m,2,0) = (M(md,2,0)); - M(m,2,1) = (M(md,2,1)); - M(m,2,2) = (M(md,2,2)); - M(m,2,3) = (M(md,2,3)); - - M(m,3,0) = (M(md,3,0)); - M(m,3,1) = (M(md,3,1)); - M(m,3,2) = (M(md,3,2)); - M(m,3,3) = (M(md,3,3)); -#undef M + glGetFloatv (GL_MODELVIEW_MATRIX, m); } void cogl_get_projection_matrix (float m[16]) { - GLdouble md[16]; - - glGetDoublev(GL_PROJECTION_MATRIX, &md[0]); - -#define M(m,row,col) m[col*4+row] - M(m,0,0) = (M(md,0,0)); - M(m,0,1) = (M(md,0,1)); - M(m,0,2) = (M(md,0,2)); - M(m,0,3) = (M(md,0,3)); - - M(m,1,0) = (M(md,1,0)); - M(m,1,1) = (M(md,1,1)); - M(m,1,2) = (M(md,1,2)); - M(m,1,3) = (M(md,1,3)); - - M(m,2,0) = (M(md,2,0)); - M(m,2,1) = (M(md,2,1)); - M(m,2,2) = (M(md,2,2)); - M(m,2,3) = (M(md,2,3)); - - M(m,3,0) = (M(md,3,0)); - M(m,3,1) = (M(md,3,1)); - M(m,3,2) = (M(md,3,2)); - M(m,3,3) = (M(md,3,3)); -#undef M + glGetFloatv (GL_PROJECTION_MATRIX, m); } void cogl_get_viewport (float v[4]) { - GLdouble vd[4]; - glGetDoublev(GL_VIEWPORT, &vd[0]); - - v[0] = (vd[0]); - v[1] = (vd[1]); - v[2] = (vd[2]); - v[3] = (vd[3]); + glGetFloatv (GL_VIEWPORT, v); } void diff --git a/clutter/cogl/gles/cogl-gles2-wrapper.c b/clutter/cogl/gles/cogl-gles2-wrapper.c index 4be0a55ba..b65f9e217 100644 --- a/clutter/cogl/gles/cogl-gles2-wrapper.c +++ b/clutter/cogl/gles/cogl-gles2-wrapper.c @@ -514,15 +514,6 @@ cogl_gles2_wrapper_update_matrix (CoglGles2Wrapper *wrapper, GLenum matrix_num) } } -void -cogl_wrap_glClearColorx (GLclampx r, GLclampx g, GLclampx b, GLclampx a) -{ - glClearColor ( (r), - (g), - (b), - (a)); -} - void cogl_wrap_glPushMatrix () { @@ -1143,13 +1134,9 @@ cogl_wrap_glAlphaFunc (GLenum func, GLclampf ref) } void -cogl_wrap_glColor4f (GLclampx r, GLclampx g, GLclampx b, GLclampx a) +cogl_wrap_glColor4f (GLclampf r, GLclampf g, GLclampf b, GLclampf a) { - glVertexAttrib4f (COGL_GLES2_WRAPPER_COLOR_ATTRIB, - (r), - (g), - (b), - (a)); + glVertexAttrib4f (COGL_GLES2_WRAPPER_COLOR_ATTRIB, r, g, b, a); } void @@ -1158,15 +1145,6 @@ cogl_wrap_glClipPlanef (GLenum plane, GLfloat *equation) /* FIXME */ } -static void -cogl_gles2_float_array_to_fixed (int size, - const GLfloat *floats, - GLfloat *fixeds) -{ - while (size-- > 0) - *(fixeds++) = (*(floats++)); -} - void cogl_wrap_glGetIntegerv (GLenum pname, GLint *params) { @@ -1185,31 +1163,24 @@ cogl_wrap_glGetIntegerv (GLenum pname, GLint *params) } void -cogl_wrap_glGetFixedv (GLenum pname, GLfloat *params) +cogl_wrap_glGetFloatv (GLenum pname, GLfloat *params) { _COGL_GET_GLES2_WRAPPER (w, NO_RETVAL); switch (pname) { case GL_MODELVIEW_MATRIX: - cogl_gles2_float_array_to_fixed (16, w->modelview_stack - + w->modelview_stack_pos * 16, - params); + memcpy (params, w->modelview_stack + w->modelview_stack_pos * 16, + sizeof (GLfloat) * 16); break; case GL_PROJECTION_MATRIX: - cogl_gles2_float_array_to_fixed (16, w->projection_stack - + w->projection_stack_pos * 16, - params); + memcpy (params, w->projection_stack + w->projection_stack_pos * 16, + sizeof (GLfloat) * 16); break; case GL_VIEWPORT: - { - GLfloat v[4]; - - glGetFloatv (GL_VIEWPORT, v); - cogl_gles2_float_array_to_fixed (4, v, params); - } + glGetFloatv (GL_VIEWPORT, params); break; } } diff --git a/clutter/cogl/gles/cogl-gles2-wrapper.h b/clutter/cogl/gles/cogl-gles2-wrapper.h index cb700cc3a..f126993ef 100644 --- a/clutter/cogl/gles/cogl-gles2-wrapper.h +++ b/clutter/cogl/gles/cogl-gles2-wrapper.h @@ -203,8 +203,6 @@ struct _CoglGles2WrapperShader void cogl_gles2_wrapper_init (CoglGles2Wrapper *wrapper); void cogl_gles2_wrapper_deinit (CoglGles2Wrapper *wrapper); -void cogl_wrap_glClearColorx (GLclampx r, GLclampx g, GLclampx b, GLclampx a); - void cogl_wrap_glPushMatrix (); void cogl_wrap_glPopMatrix (); void cogl_wrap_glMatrixMode (GLenum mode); @@ -239,12 +237,12 @@ void cogl_wrap_glDisableClientState (GLenum array); void cogl_wrap_glAlphaFunc (GLenum func, GLclampf ref); -void cogl_wrap_glColor4f (GLclampx r, GLclampx g, GLclampx b, GLclampx a); +void cogl_wrap_glColor4f (GLclampf r, GLclampf g, GLclampf b, GLclampf a); void cogl_wrap_glClipPlanef (GLenum plane, GLfloat *equation); void cogl_wrap_glGetIntegerv (GLenum pname, GLint *params); -void cogl_wrap_glGetFixedv (GLenum pname, GLfloat *params); +void cogl_wrap_glGetFloatv (GLenum pname, GLfloat *params); void cogl_wrap_glFogf (GLenum pname, GLfloat param); void cogl_wrap_glFogfv (GLenum pname, const GLfloat *params); @@ -273,35 +271,34 @@ void _cogl_gles2_clear_cache_for_program (CoglHandle program); /* If we're not using GL ES 2 then just use the GL functions directly */ -#define cogl_wrap_glClearColorx glClearColorx #define cogl_wrap_glDrawArrays glDrawArrays #define cogl_wrap_glDrawElements glDrawElements #define cogl_wrap_glPushMatrix glPushMatrix #define cogl_wrap_glPopMatrix glPopMatrix #define cogl_wrap_glMatrixMode glMatrixMode #define cogl_wrap_glLoadIdentity glLoadIdentity -#define cogl_wrap_glMultMatrixf glMultMatrixx -#define cogl_wrap_glFrustumf glFrustumx -#define cogl_wrap_glScalef glScalex -#define cogl_wrap_glTranslatef glTranslatex -#define cogl_wrap_glRotatef glRotatex -#define cogl_wrap_glOrthof glOrthox +#define cogl_wrap_glMultMatrixf glMultMatrixf +#define cogl_wrap_glFrustumf glFrustumf +#define cogl_wrap_glScalef glScalef +#define cogl_wrap_glTranslatef glTranslatef +#define cogl_wrap_glRotatef glRotatef +#define cogl_wrap_glOrthof glOrthof #define cogl_wrap_glEnable glEnable #define cogl_wrap_glDisable glDisable #define cogl_wrap_glTexCoordPointer glTexCoordPointer #define cogl_wrap_glVertexPointer glVertexPointer #define cogl_wrap_glColorPointer glColorPointer #define cogl_wrap_glNormalPointer glNormalPointer -#define cogl_wrap_glTexEnvf glTexEnvx +#define cogl_wrap_glTexEnvf glTexEnvf #define cogl_wrap_glEnableClientState glEnableClientState #define cogl_wrap_glDisableClientState glDisableClientState #define cogl_wrap_glAlphaFunc glAlphaFunc -#define cogl_wrap_glColor4f glColor4x -#define cogl_wrap_glClipPlanef glClipPlanex +#define cogl_wrap_glColor4f glColor4f +#define cogl_wrap_glClipPlanef glClipPlanef #define cogl_wrap_glGetIntegerv glGetIntegerv -#define cogl_wrap_glGetFixedv glGetFixedv -#define cogl_wrap_glFogf glFogx -#define cogl_wrap_glFogfv glFogxv +#define cogl_wrap_glGetFloatv glGetFloatv +#define cogl_wrap_glFogf glFogf +#define cogl_wrap_glFogfv glFogfv #define cogl_wrap_glTexParameteri glTexParameteri /* The extra third parameter of the bind texture wrapper isn't needed diff --git a/clutter/cogl/gles/cogl-primitives.c b/clutter/cogl/gles/cogl-primitives.c index 901fa5d09..1a588056d 100644 --- a/clutter/cogl/gles/cogl-primitives.c +++ b/clutter/cogl/gles/cogl-primitives.c @@ -34,59 +34,31 @@ #include #include +#include #define _COGL_MAX_BEZ_RECURSE_DEPTH 16 void -_cogl_rectangle (gint x, - gint y, - guint width, - guint height) +_cogl_rectangle (float x, + float y, + float width, + float height) { - /* 32-bit integers are not supported as coord types - in GLES . Fixed type has got 16 bits left of the - point which is equal to short anyway. */ - - GLshort rect_verts[8] = { - (GLshort) x, (GLshort) y, - (GLshort) (x + width), (GLshort) y, - (GLshort) x, (GLshort) (y + height), - (GLshort) (x + width), (GLshort) (y + height) + GLfloat rect_verts[8] = { + (GLfloat) x, (GLfloat) y, + (GLfloat) (x + width), (GLfloat) y, + (GLfloat) x, (GLfloat) (y + height), + (GLfloat) (x + width), (GLfloat) (y + height) }; _COGL_GET_CONTEXT (ctx, NO_RETVAL); cogl_enable (COGL_ENABLE_VERTEX_ARRAY | (ctx->color_alpha < 255 ? COGL_ENABLE_BLEND : 0)); - GE ( cogl_wrap_glVertexPointer (2, GL_SHORT, 0, rect_verts ) ); + GE ( cogl_wrap_glVertexPointer (2, GL_FLOAT, 0, rect_verts ) ); GE ( cogl_wrap_glDrawArrays (GL_TRIANGLE_STRIP, 0, 4) ); } - -void -_cogl_rectanglex (float x, - float y, - float width, - float height) -{ - GLfloat rect_verts[8] = { - x, y, - x + width, y, - x, y + height, - x + width, y + height - }; - - _COGL_GET_CONTEXT (ctx, NO_RETVAL); - - cogl_enable (COGL_ENABLE_VERTEX_ARRAY - | (ctx->color_alpha < 255 - ? COGL_ENABLE_BLEND : 0)); - - GE( cogl_wrap_glVertexPointer (2, GL_FIXED, 0, rect_verts) ); - GE( cogl_wrap_glDrawArrays (GL_TRIANGLE_STRIP, 0, 4) ); - -} - void _cogl_path_add_node (gboolean new_sub_path, float x, @@ -149,17 +121,15 @@ _cogl_path_stroke_nodes () static void _cogl_path_get_bounds (floatVec2 nodes_min, floatVec2 nodes_max, - gint *bounds_x, - gint *bounds_y, - guint *bounds_w, - guint *bounds_h) + float *bounds_x, + float *bounds_y, + float *bounds_w, + float *bounds_h) { - *bounds_x = floorf (nodes_min.x); - *bounds_y = floorf (nodes_min.y); - *bounds_w = ceilf (nodes_max.x - - (float)(*bounds_x)); - *bounds_h = ceilf (nodes_max.y - - (float)(*bounds_y)); + *bounds_x = nodes_min.x; + *bounds_y = nodes_min.y; + *bounds_w = nodes_max.x - *bounds_x; + *bounds_h = nodes_max.y - *bounds_y; } static gint compare_ints (gconstpointer a, @@ -177,10 +147,10 @@ _cogl_add_path_to_stencil_buffer (floatVec2 nodes_min, { guint path_start = 0; guint sub_path_num = 0; - gint bounds_x; - gint bounds_y; - guint bounds_w; - guint bounds_h; + float bounds_x; + float bounds_y; + float bounds_w; + float bounds_h; _cogl_path_get_bounds (nodes_min, nodes_max, &bounds_x, &bounds_y, &bounds_w, &bounds_h); @@ -244,12 +214,8 @@ _cogl_add_path_to_stencil_buffer (floatVec2 nodes_min, GE( cogl_wrap_glMatrixMode (GL_PROJECTION) ); GE( cogl_wrap_glPushMatrix () ); GE( cogl_wrap_glLoadIdentity () ); - cogl_rectanglex (-1.0, -1.0, - (float)(2), - (float)(2)); - cogl_rectanglex (-1.0, -1.0, - (float)(2), - (float)(2)); + cogl_rectangle (-1.0, -1.0, 2, 2); + cogl_rectangle (-1.0, -1.0, 2, 2); GE( cogl_wrap_glPopMatrix () ); GE( cogl_wrap_glMatrixMode (GL_MODELVIEW) ); GE( cogl_wrap_glPopMatrix () ); @@ -435,10 +401,10 @@ _cogl_path_fill_nodes_scanlines (CoglPathNode *path, void _cogl_path_fill_nodes () { - gint bounds_x; - gint bounds_y; - guint bounds_w; - guint bounds_h; + float bounds_x; + float bounds_y; + float bounds_w; + float bounds_h; _COGL_GET_CONTEXT (ctx, NO_RETVAL); diff --git a/clutter/cogl/gles/cogl-texture.c b/clutter/cogl/gles/cogl-texture.c index 9f99ef3b8..deb7224bd 100644 --- a/clutter/cogl/gles/cogl-texture.c +++ b/clutter/cogl/gles/cogl-texture.c @@ -39,6 +39,7 @@ #include #include +#include #define glVertexPointer cogl_wrap_glVertexPointer #define glTexCoordPointer cogl_wrap_glTexCoordPointer @@ -768,7 +769,7 @@ _cogl_texture_upload_subregion_to_gl (CoglTexture *tex, guint wx, wy; src = source_bmp->data - + (src_y + (y_iter.intersect_start) + + (src_y + ((int)y_iter.intersect_start) - dst_y) * source_bmp->rowstride + (src_x + x_span->start + x_span->size - x_span->waste @@ -813,7 +814,7 @@ _cogl_texture_upload_subregion_to_gl (CoglTexture *tex, guint copy_width; src = source_bmp->data - + (src_x + (x_iter.intersect_start) + + (src_x + ((int)x_iter.intersect_start) - dst_x) * bpp + (src_y + y_span->start + y_span->size - y_span->waste diff --git a/clutter/cogl/gles/cogl.c b/clutter/cogl/gles/cogl.c index 226f2e432..997f24aa8 100644 --- a/clutter/cogl/gles/cogl.c +++ b/clutter/cogl/gles/cogl.c @@ -37,6 +37,7 @@ #include "cogl-context.h" #include "cogl-gles2-wrapper.h" +#include /* GL error to string conversion */ #if COGL_DEBUG @@ -92,10 +93,10 @@ cogl_paint_init (const CoglColor *color) fprintf(stderr, "\n ============== Paint Start ================ \n"); #endif - cogl_wrap_glClearColorx (cogl_color_get_red (color), - cogl_color_get_green (color), - cogl_color_get_blue (color), - 0); + glClearColor (cogl_color_get_red (color), + cogl_color_get_green (color), + cogl_color_get_blue (color), + 0); glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); cogl_wrap_glDisable (GL_LIGHTING); @@ -122,35 +123,15 @@ cogl_scale (float x, float y) } void -cogl_translatex (float x, float y, float z) +cogl_translate (float x, float y, float z) { GE( cogl_wrap_glTranslatef (x, y, z) ); } void -cogl_translate (gint x, gint y, gint z) +cogl_rotate (float angle, float x, float y, float z) { - GE( cogl_wrap_glTranslatef ((float)(x), - (float)(y), - (float)(z)) ); -} - -void -cogl_rotatex (float angle, - float x, - float y, - float z) -{ - GE( cogl_wrap_glRotatef (angle,x,y,z) ); -} - -void -cogl_rotate (gint angle, gint x, gint y, gint z) -{ - GE( cogl_wrap_glRotatef ((float)(angle), - (float)(x), - (float)(y), - (float)(z)) ); + GE( cogl_wrap_glRotatef (angle, x, y, z) ); } static inline gboolean @@ -365,9 +346,8 @@ set_clip_plane (GLint plane_num, /* Calculate the angle between the axes and the line crossing the two points */ - angle = (atan2f (vertex_b[1] - vertex_a[1] * - vertex_b[0] - vertex_a[0]), - COGL_RADIANS_TO_DEGREES); + angle = atan2f (vertex_b[1] - vertex_a[1], + vertex_b[0] - vertex_a[0]) * (180.0/G_PI); GE( cogl_wrap_glPushMatrix () ); /* Load the identity matrix and multiply by the reverse of the @@ -405,8 +385,8 @@ _cogl_set_clip_planes (float x_offset, float vertex_br[4] = { x_offset + width, y_offset + height, 0, 1.0 }; - GE( cogl_wrap_glGetFixedv (GL_MODELVIEW_MATRIX, modelview) ); - GE( cogl_wrap_glGetFixedv (GL_PROJECTION_MATRIX, projection) ); + GE( cogl_wrap_glGetFloatv (GL_MODELVIEW_MATRIX, modelview) ); + GE( cogl_wrap_glGetFloatv (GL_PROJECTION_MATRIX, projection) ); project_vertex (modelview, projection, vertex_tl); project_vertex (modelview, projection, vertex_tr); @@ -457,7 +437,7 @@ _cogl_add_stencil_clip (float x_offset, GE( glStencilFunc (GL_NEVER, 0x1, 0x1) ); GE( glStencilOp (GL_REPLACE, GL_REPLACE, GL_REPLACE) ); - cogl_rectanglex (x_offset, y_offset, width, height); + cogl_rectangle (x_offset, y_offset, width, height); } else { @@ -465,7 +445,7 @@ _cogl_add_stencil_clip (float x_offset, rectangle */ GE( glStencilFunc (GL_NEVER, 0x1, 0x3) ); GE( glStencilOp (GL_INCR, GL_INCR, GL_INCR) ); - cogl_rectanglex (x_offset, y_offset, width, height); + cogl_rectangle (x_offset, y_offset, width, height); /* Subtract one from all pixels in the stencil buffer so that only pixels where both the original stencil buffer and the @@ -476,9 +456,7 @@ _cogl_add_stencil_clip (float x_offset, GE( cogl_wrap_glMatrixMode (GL_PROJECTION) ); GE( cogl_wrap_glPushMatrix () ); GE( cogl_wrap_glLoadIdentity () ); - cogl_rectanglex (-1.0, -1.0, - (float)(2), - (float)(2)); + cogl_rectangle (-1.0, -1.0, 2, 2); GE( cogl_wrap_glPopMatrix () ); GE( cogl_wrap_glMatrixMode (GL_MODELVIEW) ); GE( cogl_wrap_glPopMatrix () ); @@ -558,15 +536,13 @@ cogl_perspective (float fovy, * 2) When working with small numbers, we can are loosing significant * precision */ - ymax = (zNear * - (sinf (fovy_rad_half) / - cosf (fovy_rad_half))); + ymax = (zNear * (sinf (fovy_rad_half) / cosf (fovy_rad_half))); xmax = (ymax * aspect); x = (zNear / xmax); y = (zNear / ymax); c = (-(zFar + zNear) / ( zFar - zNear)); - d = (-((2 * zFar * zNear)) / (zFar - zNear)); + d = (-(2 * zFar) * zNear) / (zFar - zNear); #define M(row,col) m[col*4+row] M(0,0) = x; @@ -671,13 +647,13 @@ cogl_setup_viewport (guint w, if (fovy != 60.0) { float fovy_rad = (fovy * G_PI) / 180; - - z_camera = (sinf (fovy_rad) / - cosf (fovy_rad)) >> 1; + + z_camera = (sinf (fovy_rad) / cosf (fovy_rad)) / 2; } - GE( cogl_wrap_glTranslatef (-1 << 15, -1 << 15, -z_camera) ); + + GE( cogl_wrap_glTranslatef (-0.5f, -0.5f, -z_camera) ); GE( cogl_wrap_glScalef ( 1.0 / width, -1.0 / height, @@ -737,13 +713,13 @@ cogl_features_available (CoglFeatureFlags features) void cogl_get_modelview_matrix (float m[16]) { - cogl_wrap_glGetFixedv(GL_MODELVIEW_MATRIX, &m[0]); + cogl_wrap_glGetFloatv (GL_MODELVIEW_MATRIX, m); } void cogl_get_projection_matrix (float m[16]) { - cogl_wrap_glGetFixedv(GL_PROJECTION_MATRIX, &m[0]); + cogl_wrap_glGetFloatv (GL_PROJECTION_MATRIX, m); } void diff --git a/clutter/pango/cogl-pango-render.c b/clutter/pango/cogl-pango-render.c index d8f87fb43..3cafc81e2 100644 --- a/clutter/pango/cogl-pango-render.c +++ b/clutter/pango/cogl-pango-render.c @@ -102,8 +102,6 @@ cogl_pango_renderer_draw_glyph (CoglPangoRenderer *priv, *(p++) = cache_value->tx2; *(p++) = cache_value->ty2; } -#define COGL_PANGO_UNIT_TO_FIXED(x) ((x) << (COGL_FIXED_Q - 10)) - static void cogl_pango_renderer_finalize (GObject *object); static void cogl_pango_renderer_draw_glyphs (PangoRenderer *renderer, PangoFont *font, @@ -439,8 +437,8 @@ cogl_pango_renderer_get_device_units (PangoRenderer *renderer, } else { - *xout = COGL_PANGO_UNIT_TO_FIXED (xin); - *yout = COGL_PANGO_UNIT_TO_FIXED (yin); + *xout = PANGO_PIXELS (xin); + *yout = PANGO_PIXELS (yin); } } @@ -463,7 +461,7 @@ cogl_pango_renderer_draw_rectangle (PangoRenderer *renderer, x + width, y + height, &x2, &y2); - cogl_rectanglex (x1, y1, x2 - x1, y2 - y1); + cogl_rectangle (x1, y1, x2 - x1, y2 - y1); } static void diff --git a/doc/reference/cogl/cogl-sections.txt b/doc/reference/cogl/cogl-sections.txt index dcd7c933f..db4e16af6 100644 --- a/doc/reference/cogl/cogl-sections.txt +++ b/doc/reference/cogl/cogl-sections.txt @@ -89,7 +89,7 @@ cogl_path_stroke cogl_path_stroke_preserve cogl_set_source_color cogl_set_source_color4ub -cogl_set_source_color4x +cogl_set_source_color4f cogl_rectangle @@ -257,7 +257,7 @@ cogl_color_copy cogl_color_free cogl_color_set_from_4ub cogl_color_set_from_4d -cogl_color_set_from_4x +cogl_color_set_from_4f cogl_color_get_red diff --git a/tests/conform/test-backface-culling.c b/tests/conform/test-backface-culling.c index 50c19fd08..630394906 100644 --- a/tests/conform/test-backface-culling.c +++ b/tests/conform/test-backface-culling.c @@ -121,7 +121,7 @@ on_paint (ClutterActor *actor, TestState *state) /* Set the color to white so that all the textures will be drawn at their own color */ - cogl_set_source_color4x (1.0, 1.0, + cogl_set_source_color4f (1.0, 1.0, 1.0, 1.0); x2 = x1 + (float)(TEXTURE_SIZE); @@ -173,7 +173,7 @@ on_paint (ClutterActor *actor, TestState *state) x2 = x1 + (float)(TEXTURE_SIZE); /* Draw a regular rectangle (this should always show) */ - cogl_set_source_color4x (1.0, 0, 0, 1.0); + cogl_set_source_color4f (1.0, 0, 0, 1.0); cogl_rectangle ( (x1), (y1), (x2 - x1), (y2 - y1)); diff --git a/tests/interactive/test-cogl-tex-tile.c b/tests/interactive/test-cogl-tex-tile.c index 5063dff19..177d60e65 100644 --- a/tests/interactive/test-cogl-tex-tile.c +++ b/tests/interactive/test-cogl-tex-tile.c @@ -90,14 +90,14 @@ test_coglbox_paint(ClutterActor *self) ClutterFixed sin_frame, cos_frame; ClutterFixed frac_frame; gint t; - sin_frame = clutter_sini (CLUTTER_ANGLE_FROM_DEG (priv->frame)); - cos_frame = clutter_cosi (CLUTTER_ANGLE_FROM_DEG (priv->frame)); + sin_frame = clutter_sinx (priv->frame); + cos_frame = clutter_cosx (priv->frame); pingpong_frame = (priv->frame <= 180 ? priv->frame : 360 - priv->frame); frac_frame = (CLUTTER_INT_TO_FIXED (pingpong_frame) / - CLUTTER_INT_TO_FIXED (180)); - frac_frame += (1.0 >> 1); - frac_frame <<= 1; + CLUTTER_INT_TO_FIXED (180)); + frac_frame += 0.5; + frac_frame *= 2; for (t=0; t<4; t+=2) { From c29a3b4deefaf9e4a71cf4cd9b582489de9d67c4 Mon Sep 17 00:00:00 2001 From: Robert Bragg Date: Tue, 20 Jan 2009 16:20:55 +0000 Subject: [PATCH 26/26] [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: