mutter/fixed-to-float-patches/clutter-behaviour-ellipse.c.0.patch

381 lines
12 KiB
Diff
Raw Normal View History

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. "
2008-12-19 21:55:35 +00:00
diff --git a/clutter/clutter-behaviour-ellipse.c b/clutter/clutter-behaviour-ellipse.c
index 162a949..4212b95 100644
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. "
2008-12-19 21:55:35 +00:00
--- 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)
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. "
2008-12-19 21:55:35 +00:00
{
- float a1, a2;
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. "
2008-12-19 21:55:35 +00:00
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--;
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. "
2008-12-19 21:55:35 +00:00
- 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;
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. "
2008-12-19 21:55:35 +00:00
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,
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. "
2008-12-19 21:55:35 +00:00
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,
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. "
2008-12-19 21:55:35 +00:00
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,
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. "
2008-12-19 21:55:35 +00:00
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;
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. "
2008-12-19 21:55:35 +00:00
priv = self->priv;
@@ -1154,9 +1138,9 @@ clutter_behaviour_ellipse_set_tiltx (ClutterBehaviourEllipse *self,
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. "
2008-12-19 21:55:35 +00:00
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);
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. "
2008-12-19 21:55:35 +00:00
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;
}
/**