2007-11-06 Tomas Frydrych <tf@o-hand.com>

* clutter/clutter-fixed.h:
	Added CLUTTER_SQRTI_ARG_MAX, CLUTTER_SQRTI_5_PERCENT,
	CLUTTER_SQRTI_10_PERCENT expressing clutter_sqrti limits.
	Stripped trailing whitespace.

        * clutter/clutter-fixed.c:
	(clutter_sqrti):
	Updated documentation, stripped trailing whitespace.

        * clutter/clutter-behaviour-path.c:
	(node_distance):
	Use clib sqrt if clutter_sqrti() precission would be worse than
	10%.
	Stripped trailing whitespace.
This commit is contained in:
Tomas Frydrych 2007-11-06 15:46:23 +00:00
parent 9461dd216b
commit 3b07be19ba
4 changed files with 141 additions and 71 deletions

View File

@ -1,3 +1,20 @@
2007-11-06 Tomas Frydrych <tf@o-hand.com>
* clutter/clutter-fixed.h:
Added CLUTTER_SQRTI_ARG_MAX, CLUTTER_SQRTI_5_PERCENT,
CLUTTER_SQRTI_10_PERCENT expressing clutter_sqrti limits.
Stripped trailing whitespace.
* clutter/clutter-fixed.c:
(clutter_sqrti):
Updated documentation, stripped trailing whitespace.
* clutter/clutter-behaviour-path.c:
(node_distance):
Use clib sqrt if clutter_sqrti() precission would be worse than
10%.
Stripped trailing whitespace.
2007-11-06 Emmanuele Bassi <ebassi@openedhand.com> 2007-11-06 Emmanuele Bassi <ebassi@openedhand.com>
* clutter/clutter-layout.h: Add commodity macros to test for * clutter/clutter-layout.h: Add commodity macros to test for
@ -19,7 +36,7 @@
* clutter/clutter-container.[ch]: removed find_child_by_id method * clutter/clutter-container.[ch]: removed find_child_by_id method
from interface (and all implementations of it) since this from interface (and all implementations of it) since this
functionality is now implemented using a global hash. functionality is now implemented using a global hash.
* clutter/clutter-box.c: * clutter/clutter-box.c:
* clutter/clutter-group.c: * clutter/clutter-group.c:
2007-11-01 Emmanuele Bassi <ebassi@openedhand.com> 2007-11-01 Emmanuele Bassi <ebassi@openedhand.com>
@ -124,7 +141,7 @@
* clutter/cogl/gles/cogl-defines.h: * clutter/cogl/gles/cogl-defines.h:
* clutter/cogl/gl/cogl.c: * clutter/cogl/gl/cogl.c:
* clutter/cogl/gles/cogl.c: * clutter/cogl/gles/cogl.c:
Switch from use of guint to COGLuint. Avoids problems when Switch from use of guint to COGLuint. Avoids problems when
guint != GLuint on some platforms, i.e OSX. guint != GLuint on some platforms, i.e OSX.
(Tommi Komulainen, #525, #523) (Tommi Komulainen, #525, #523)
@ -368,18 +385,18 @@
* clutter/clutter-color.c: Copy the alpha when shading. * clutter/clutter-color.c: Copy the alpha when shading.
2007-10-16 Tomas Frydrych <tf@o-hand.com> 2007-10-16 Tomas Frydrych <tf@o-hand.com>
* clutter.symbols: * clutter.symbols:
Added a bunch of missing symbols. Added a bunch of missing symbols.
* clutter/clutter-script.c: * clutter/clutter-script.c:
* json/json-node.c: * json/json-node.c:
Use g_slice_new0 instead of g_slice_new to avoid passing Use g_slice_new0 instead of g_slice_new to avoid passing
garbage to functions. garbage to functions.
* tests/test-threads.c: * tests/test-threads.c:
Replaced non-portable sleep() with g_usleep(). Replaced non-portable sleep() with g_usleep().
2007-10-15 Tomas Frydrych <tf@o-hand.com> 2007-10-15 Tomas Frydrych <tf@o-hand.com>
* clutter/cogl/gl/cogl-defines.h: * clutter/cogl/gl/cogl-defines.h:
@ -393,7 +410,7 @@
* clutter/clutter-event.c: * clutter/clutter-event.c:
* clutter/clutter-event.h: * clutter/clutter-event.h:
Add synthetic flag and make put_event use it Add synthetic flag and make put_event use it
(via modded patch from pippin) (via modded patch from pippin)
* clutter/clutter-main.c: (clutter_do_event): * clutter/clutter-main.c: (clutter_do_event):
@ -412,9 +429,9 @@
* clutter.symbols: * clutter.symbols:
A list of public symbols, one per line; semi-autogenerated, so A list of public symbols, one per line; semi-autogenerated, so
might not be complete -- PLEASE when adding new public APIs, add might not be complete -- PLEASE when adding new public APIs, add
the function name to this file. the function name to this file.
2007-10-12 Emmanuele Bassi <ebassi@openedhand.com> 2007-10-12 Emmanuele Bassi <ebassi@openedhand.com>
* clutter/clutter-actor.c: Add a :depth property, so we can * clutter/clutter-actor.c: Add a :depth property, so we can

View File

@ -59,7 +59,7 @@
static void clutter_scriptable_iface_init (ClutterScriptableIface *iface); static void clutter_scriptable_iface_init (ClutterScriptableIface *iface);
G_DEFINE_TYPE_WITH_CODE (ClutterBehaviourPath, G_DEFINE_TYPE_WITH_CODE (ClutterBehaviourPath,
clutter_behaviour_path, clutter_behaviour_path,
CLUTTER_TYPE_BEHAVIOUR, CLUTTER_TYPE_BEHAVIOUR,
G_IMPLEMENT_INTERFACE (CLUTTER_TYPE_SCRIPTABLE, G_IMPLEMENT_INTERFACE (CLUTTER_TYPE_SCRIPTABLE,
@ -92,7 +92,7 @@ enum
PROP_KNOT PROP_KNOT
}; };
static void static void
clutter_behaviour_path_finalize (GObject *object) clutter_behaviour_path_finalize (GObject *object)
{ {
ClutterBehaviourPath *self = CLUTTER_BEHAVIOUR_PATH(object); ClutterBehaviourPath *self = CLUTTER_BEHAVIOUR_PATH(object);
@ -104,8 +104,8 @@ clutter_behaviour_path_finalize (GObject *object)
} }
static inline void static inline void
interpolate (const ClutterKnot *begin, interpolate (const ClutterKnot *begin,
const ClutterKnot *end, const ClutterKnot *end,
ClutterKnot *out, ClutterKnot *out,
ClutterFixed t) ClutterFixed t)
{ {
@ -117,18 +117,28 @@ static gint
node_distance (const ClutterKnot *begin, node_distance (const ClutterKnot *begin,
const ClutterKnot *end) const ClutterKnot *end)
{ {
gint t;
g_return_val_if_fail (begin != NULL, 0); g_return_val_if_fail (begin != NULL, 0);
g_return_val_if_fail (end != NULL, 0); g_return_val_if_fail (end != NULL, 0);
if (clutter_knot_equal (begin, end)) if (clutter_knot_equal (begin, end))
return 0; return 0;
#if 1 t = (end->x - begin->x) * (end->x - begin->x) +
return clutter_sqrti ((end->x - begin->x) * (end->x - begin->x) + (end->y - begin->y) * (end->y - begin->y);
(end->y - begin->y) * (end->y - begin->y));
/*
* 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 (t <= CLUTTER_SQRTI_ARG_10_PERCENT)
return clutter_sqrti (t);
else
return CLUTTER_FLOAT_TO_INT(sqrt(t));
#else #else
return CLUTTER_FLOAT_TO_INT(sqrt((end->x - begin->x) * (end->x - begin->x) + return clutter_sqrti (t);
(end->y - begin->y) * (end->y - begin->y)));
#endif #endif
} }
@ -166,7 +176,7 @@ path_alpha_to_position (ClutterBehaviourPath *behave,
GSList *l; GSList *l;
gint total_len, offset, dist = 0; gint total_len, offset, dist = 0;
/* FIXME: Optimise. Much of the data used here can be pre-generated /* FIXME: Optimise. Much of the data used here can be pre-generated
* ( total_len, dist between knots ) when knots are added/removed. * ( total_len, dist between knots ) when knots are added/removed.
*/ */
@ -181,29 +191,29 @@ path_alpha_to_position (ClutterBehaviourPath *behave,
total_len = path_total_length (behave); total_len = path_total_length (behave);
offset = (alpha * total_len) / CLUTTER_ALPHA_MAX_ALPHA; offset = (alpha * total_len) / CLUTTER_ALPHA_MAX_ALPHA;
CLUTTER_NOTE (BEHAVIOUR, "alpha %i vs %i, len: %i vs %i", CLUTTER_NOTE (BEHAVIOUR, "alpha %i vs %i, len: %i vs %i",
alpha, CLUTTER_ALPHA_MAX_ALPHA, alpha, CLUTTER_ALPHA_MAX_ALPHA,
offset, total_len); offset, total_len);
if (offset == 0) if (offset == 0)
{ {
/* first knot */ /* first knot */
clutter_behaviour_actors_foreach (behaviour, clutter_behaviour_actors_foreach (behaviour,
actor_apply_knot_foreach, actor_apply_knot_foreach,
priv->knots->data); priv->knots->data);
priv->last_knot_passed = (ClutterKnot*)priv->knots->data; priv->last_knot_passed = (ClutterKnot*)priv->knots->data;
g_signal_emit (behave, path_signals[KNOT_REACHED], 0, g_signal_emit (behave, path_signals[KNOT_REACHED], 0,
priv->knots->data); priv->knots->data);
return; return;
} }
if (offset == total_len) if (offset == total_len)
{ {
/* Special case for last knot */ /* Special case for last knot */
ClutterKnot *last_knot = (g_slist_last (priv->knots))->data; ClutterKnot *last_knot = (g_slist_last (priv->knots))->data;
clutter_behaviour_actors_foreach (behaviour, clutter_behaviour_actors_foreach (behaviour,
actor_apply_knot_foreach, actor_apply_knot_foreach,
last_knot); last_knot);
@ -217,7 +227,7 @@ path_alpha_to_position (ClutterBehaviourPath *behave,
{ {
gint dist_to_next = 0; gint dist_to_next = 0;
ClutterKnot *knot = l->data; ClutterKnot *knot = l->data;
if (l->next) if (l->next)
{ {
ClutterKnot *next = l->next->data; ClutterKnot *next = l->next->data;
@ -228,12 +238,12 @@ path_alpha_to_position (ClutterBehaviourPath *behave,
{ {
ClutterKnot new; ClutterKnot new;
ClutterFixed t; ClutterFixed t;
t = CLUTTER_INT_TO_FIXED (offset - dist) / dist_to_next; t = CLUTTER_INT_TO_FIXED (offset - dist) / dist_to_next;
interpolate (knot, next, &new, t); interpolate (knot, next, &new, t);
clutter_behaviour_actors_foreach (behaviour, clutter_behaviour_actors_foreach (behaviour,
actor_apply_knot_foreach, actor_apply_knot_foreach,
&new); &new);
@ -323,7 +333,7 @@ clutter_behaviour_path_class_init (ClutterBehaviourPathClass *klass)
CLUTTER_TYPE_KNOT); CLUTTER_TYPE_KNOT);
behave_class->alpha_notify = clutter_behaviour_path_alpha_notify; behave_class->alpha_notify = clutter_behaviour_path_alpha_notify;
g_type_class_add_private (klass, sizeof (ClutterBehaviourPathPrivate)); g_type_class_add_private (klass, sizeof (ClutterBehaviourPathPrivate));
} }
@ -379,7 +389,7 @@ clutter_behaviour_path_parse_custom_node (ClutterScriptable *scriptable,
array = json_node_get_array (node); array = json_node_get_array (node);
knots_len = json_array_get_length (array); knots_len = json_array_get_length (array);
for (i = 0; i < knots_len; i++) for (i = 0; i < knots_len; i++)
{ {
JsonNode *val = json_array_get_element (array, i); JsonNode *val = json_array_get_element (array, i);
@ -430,8 +440,8 @@ clutter_behaviour_path_new (ClutterAlpha *alpha,
{ {
ClutterBehaviourPath *behave; ClutterBehaviourPath *behave;
gint i; gint i;
behave = g_object_new (CLUTTER_TYPE_BEHAVIOUR_PATH, behave = g_object_new (CLUTTER_TYPE_BEHAVIOUR_PATH,
"alpha", alpha, "alpha", alpha,
NULL); NULL);
@ -449,7 +459,7 @@ clutter_behaviour_path_new (ClutterAlpha *alpha,
* clutter_behaviour_path_get_knots: * clutter_behaviour_path_get_knots:
* @pathb: a #ClutterBehvaiourPath * @pathb: a #ClutterBehvaiourPath
* *
* Returns a copy of the list of knots contained by @pathb * Returns a copy of the list of knots contained by @pathb
* *
* Return value: a #GSList of the paths knots. * Return value: a #GSList of the paths knots.
* *
@ -465,7 +475,7 @@ clutter_behaviour_path_get_knots (ClutterBehaviourPath *pathb)
retval = NULL; retval = NULL;
for (l = pathb->priv->knots; l != NULL; l = l->next) for (l = pathb->priv->knots; l != NULL; l = l->next)
retval = g_slist_prepend (retval, l->data); retval = g_slist_prepend (retval, l->data);
return g_slist_reverse (retval); return g_slist_reverse (retval);
} }
@ -473,7 +483,7 @@ clutter_behaviour_path_get_knots (ClutterBehaviourPath *pathb)
* clutter_behaviour_path_append_knot: * clutter_behaviour_path_append_knot:
* @pathb: a #ClutterBehvaiourPath * @pathb: a #ClutterBehvaiourPath
* @knot: a #ClutterKnot to append. * @knot: a #ClutterKnot to append.
* *
* Appends a #ClutterKnot to the path * Appends a #ClutterKnot to the path
* *
* Since: 0.2 * Since: 0.2
@ -494,9 +504,9 @@ clutter_behaviour_path_append_knot (ClutterBehaviourPath *pathb,
/** /**
* clutter_behaviour_path_insert_knot: * clutter_behaviour_path_insert_knot:
* @pathb: a #ClutterBehvaiourPath * @pathb: a #ClutterBehvaiourPath
* @offset: position in path to insert knot. * @offset: position in path to insert knot.
* @knot: a #ClutterKnot to append. * @knot: a #ClutterKnot to append.
* *
* Inserts a #ClutterKnot in the path at specified position. Values greater * Inserts a #ClutterKnot in the path at specified position. Values greater
* than total number of knots will append the knot at the end of path. * than total number of knots will append the knot at the end of path.
* *
@ -520,7 +530,7 @@ clutter_behaviour_path_insert_knot (ClutterBehaviourPath *pathb,
* clutter_behaviour_path_remove_knot: * clutter_behaviour_path_remove_knot:
* @pathb: a #ClutterBehvaiourPath * @pathb: a #ClutterBehvaiourPath
* @offset: position in path to remove knot. * @offset: position in path to remove knot.
* *
* Removes a #ClutterKnot in the path at specified offset. * Removes a #ClutterKnot in the path at specified offset.
* *
* Since: 0.2 * Since: 0.2
@ -567,7 +577,7 @@ clutter_behaviour_path_append_knots_valist (ClutterBehaviourPath *pathb,
* @Varargs: additional knots to add to the path * @Varargs: additional knots to add to the path
* *
* Adds a NULL-terminated list of knots to a path. This function is * Adds a NULL-terminated list of knots to a path. This function is
* equivalent to calling clutter_behaviour_path_append_knot() for each * equivalent to calling clutter_behaviour_path_append_knot() for each
* member of the list. * member of the list.
* *
* Since: 0.2 * Since: 0.2
@ -590,7 +600,7 @@ clutter_behaviour_path_append_knots (ClutterBehaviourPath *pathb,
/** /**
* clutter_behaviour_path_clear: * clutter_behaviour_path_clear:
* @pathb: a #ClutterBehvaiourPath * @pathb: a #ClutterBehvaiourPath
* *
* Removes all knots from a path * Removes all knots from a path
* *
* Since: 0.2 * Since: 0.2

View File

@ -608,7 +608,9 @@ clutter_sqrtx (ClutterFixed x)
* *
* This function is about 10x faster than clib sqrt() on x86, and (this is * This function is about 10x faster than clib sqrt() on x86, and (this is
* not a typo!) more than 800x faster on ARM without FPU. It's error is < 5% * not a typo!) more than 800x faster on ARM without FPU. It's error is < 5%
* for arguments < 132 and < 10% for arguments < 5591. * for arguments < #CLUTTER_SQRTI_ARG_5_PERCENT and < 10% for arguments <
* #CLUTTER_SQRTI_ARG_10_PERCENT. The maximum argument that can be passed to
* this function is CLUTTER_SQRTI_ARG_MAX.
* *
* Return value: integer square root. * Return value: integer square root.
* *

View File

@ -33,14 +33,14 @@ G_BEGIN_DECLS
/** /**
* ClutterFixed: * ClutterFixed:
* *
* Fixed point number (16.16) * Fixed point number (16.16)
*/ */
typedef gint32 ClutterFixed; typedef gint32 ClutterFixed;
/** /**
* ClutterAngle: * ClutterAngle:
* *
* Integer representation of an angle such that 1024 corresponds to * Integer representation of an angle such that 1024 corresponds to
* full circle (i.e., 2*Pi). * full circle (i.e., 2*Pi).
*/ */
@ -59,96 +59,96 @@ typedef gint32 ClutterAngle; /* angle such that 1024 == 2*PI */
/** /**
* CFX_Q: * CFX_Q:
* *
* Size in bits of decimal part of floating point value. * Size in bits of decimal part of floating point value.
*/ */
#define CFX_Q 16 /* Decimal part size in bits */ #define CFX_Q 16 /* Decimal part size in bits */
/** /**
* CFX_ONE: * CFX_ONE:
* *
* 1.0 represented as a fixed point value. * 1.0 represented as a fixed point value.
*/ */
#define CFX_ONE (1 << CFX_Q) /* 1 */ #define CFX_ONE (1 << CFX_Q) /* 1 */
/** /**
* CFX_HALF: * CFX_HALF:
* *
* 0.5 represented as a fixed point value. * 0.5 represented as a fixed point value.
*/ */
#define CFX_HALF 32768 #define CFX_HALF 32768
/** /**
* CFX_MAX: * CFX_MAX:
* *
* Maximum fixed point value. * Maximum fixed point value.
*/ */
#define CFX_MAX 0x7fffffff #define CFX_MAX 0x7fffffff
/** /**
* CFX_MIN: * CFX_MIN:
* *
* Minimum fixed point value. * Minimum fixed point value.
*/ */
#define CFX_MIN 0x80000000 #define CFX_MIN 0x80000000
/** /**
* CFX_PI: * CFX_PI:
* *
* Fixed point representation of Pi * Fixed point representation of Pi
*/ */
#define CFX_PI 0x0003243f #define CFX_PI 0x0003243f
/** /**
* CFX_2PI: * CFX_2PI:
* *
* Fixed point representation of Pi*2 * Fixed point representation of Pi*2
*/ */
#define CFX_2PI 0x0006487f #define CFX_2PI 0x0006487f
/** /**
* CFX_PI_2: * CFX_PI_2:
* *
* Fixed point representation of Pi/2 * Fixed point representation of Pi/2
*/ */
#define CFX_PI_2 0x00019220 /* pi/2 */ #define CFX_PI_2 0x00019220 /* pi/2 */
/** /**
* CFX_PI_4: * CFX_PI_4:
* *
* Fixed point representation of Pi/4 * Fixed point representation of Pi/4
*/ */
#define CFX_PI_4 0x0000c910 /* pi/4 */ #define CFX_PI_4 0x0000c910 /* pi/4 */
/** /**
* CFX_360: * CFX_360:
* *
* Fixed point representation of the number 360 * Fixed point representation of the number 360
*/ */
#define CFX_360 CLUTTER_INT_TO_FIXED (360) #define CFX_360 CLUTTER_INT_TO_FIXED (360)
/** /**
* CFX_240: * CFX_240:
* *
* Fixed point representation of the number 240 * Fixed point representation of the number 240
*/ */
#define CFX_240 CLUTTER_INT_TO_FIXED (240) #define CFX_240 CLUTTER_INT_TO_FIXED (240)
/** /**
* CFX_180: * CFX_180:
* *
* Fixed point representation of the number 180 * Fixed point representation of the number 180
*/ */
#define CFX_180 CLUTTER_INT_TO_FIXED (180) #define CFX_180 CLUTTER_INT_TO_FIXED (180)
/** /**
* CFX_120: * CFX_120:
* *
* Fixed point representation of the number 120 * Fixed point representation of the number 120
*/ */
#define CFX_120 CLUTTER_INT_TO_FIXED (120) #define CFX_120 CLUTTER_INT_TO_FIXED (120)
/** /**
* CFX_60: * CFX_60:
* *
* Fixed point representation of the number 60 * Fixed point representation of the number 60
*/ */
#define CFX_60 CLUTTER_INT_TO_FIXED (60) #define CFX_60 CLUTTER_INT_TO_FIXED (60)
/** /**
* CFX_255: * CFX_255:
* *
* Fixed point representation of the number 255 * Fixed point representation of the number 255
*/ */
#define CFX_255 CLUTTER_INT_TO_FIXED (255) #define CFX_255 CLUTTER_INT_TO_FIXED (255)
@ -156,7 +156,7 @@ typedef gint32 ClutterAngle; /* angle such that 1024 == 2*PI */
/** /**
* CLUTTER_FIXED_TO_FLOAT: * CLUTTER_FIXED_TO_FLOAT:
* @x: a fixed point value * @x: a fixed point value
* *
* Convert a fixed point value to float. * Convert a fixed point value to float.
*/ */
#define CLUTTER_FIXED_TO_FLOAT(x) ((float) ((int)(x) / 65536.0)) #define CLUTTER_FIXED_TO_FLOAT(x) ((float) ((int)(x) / 65536.0))
@ -164,7 +164,7 @@ typedef gint32 ClutterAngle; /* angle such that 1024 == 2*PI */
/** /**
* CLUTTER_FIXED_TO_DOUBLE: * CLUTTER_FIXED_TO_DOUBLE:
* @x: a fixed point value * @x: a fixed point value
* *
* Convert a fixed point value to double. * Convert a fixed point value to double.
*/ */
#define CLUTTER_FIXED_TO_DOUBLE(x) ((double) ((int)(x) / 65536.0)) #define CLUTTER_FIXED_TO_DOUBLE(x) ((double) ((int)(x) / 65536.0))
@ -172,7 +172,7 @@ typedef gint32 ClutterAngle; /* angle such that 1024 == 2*PI */
/** /**
* CLUTTER_FLOAT_TO_FIXED: * CLUTTER_FLOAT_TO_FIXED:
* @x: a floating point value * @x: a floating point value
* *
* Convert a float value to fixed. * Convert a float value to fixed.
*/ */
#define CLUTTER_FLOAT_TO_FIXED(x) (_clutter_double_to_fixed ((x))) #define CLUTTER_FLOAT_TO_FIXED(x) (_clutter_double_to_fixed ((x)))
@ -180,7 +180,7 @@ typedef gint32 ClutterAngle; /* angle such that 1024 == 2*PI */
/** /**
* CLUTTER_FLOAT_TO_INT: * CLUTTER_FLOAT_TO_INT:
* @x: a floating point value * @x: a floating point value
* *
* Convert a float value to int. * Convert a float value to int.
*/ */
#define CLUTTER_FLOAT_TO_INT(x) (_clutter_double_to_int ((x))) #define CLUTTER_FLOAT_TO_INT(x) (_clutter_double_to_int ((x)))
@ -188,7 +188,7 @@ typedef gint32 ClutterAngle; /* angle such that 1024 == 2*PI */
/** /**
* CLUTTER_FLOAT_TO_UINT: * CLUTTER_FLOAT_TO_UINT:
* @x: a floating point value * @x: a floating point value
* *
* Convert a float value to unsigned int. * Convert a float value to unsigned int.
*/ */
#define CLUTTER_FLOAT_TO_UINT(x) (_clutter_double_to_uint ((x))) #define CLUTTER_FLOAT_TO_UINT(x) (_clutter_double_to_uint ((x)))
@ -196,7 +196,7 @@ typedef gint32 ClutterAngle; /* angle such that 1024 == 2*PI */
/** /**
* CLUTTER_INT_TO_FIXED: * CLUTTER_INT_TO_FIXED:
* @x: an integer value * @x: an integer value
* *
* Convert an integer value to fixed point. * Convert an integer value to fixed point.
*/ */
#define CLUTTER_INT_TO_FIXED(x) ((x) << CFX_Q) #define CLUTTER_INT_TO_FIXED(x) ((x) << CFX_Q)
@ -216,7 +216,7 @@ typedef gint32 ClutterAngle; /* angle such that 1024 == 2*PI */
/** /**
* CLUTTER_FIXED_INT: * CLUTTER_FIXED_INT:
* @x: a fixed point value * @x: a fixed point value
* *
* Convert a fixed point value to integer (removing decimal part). * Convert a fixed point value to integer (removing decimal part).
* *
* Deprecated:0.6: Use %CLUTTER_FIXED_TO_INT instead * Deprecated:0.6: Use %CLUTTER_FIXED_TO_INT instead
@ -228,7 +228,7 @@ typedef gint32 ClutterAngle; /* angle such that 1024 == 2*PI */
/** /**
* CLUTTER_FIXED_FRACTION: * CLUTTER_FIXED_FRACTION:
* @x: a fixed point value * @x: a fixed point value
* *
* Retrieves the fractionary part of a fixed point value * Retrieves the fractionary part of a fixed point value
*/ */
#define CLUTTER_FIXED_FRACTION(x) ((x) & ((1 << CFX_Q) - 1)) #define CLUTTER_FIXED_FRACTION(x) ((x) & ((1 << CFX_Q) - 1))
@ -236,7 +236,7 @@ typedef gint32 ClutterAngle; /* angle such that 1024 == 2*PI */
/** /**
* CLUTTER_FIXED_FLOOR: * CLUTTER_FIXED_FLOOR:
* @x: a fixed point value * @x: a fixed point value
* *
* Round down a fixed point value to an integer. * Round down a fixed point value to an integer.
*/ */
#define CLUTTER_FIXED_FLOOR(x) (((x) >= 0) ? ((x) >> CFX_Q) \ #define CLUTTER_FIXED_FLOOR(x) (((x) >= 0) ? ((x) >> CFX_Q) \
@ -244,7 +244,7 @@ typedef gint32 ClutterAngle; /* angle such that 1024 == 2*PI */
/** /**
* CLUTTER_FIXED_CEIL: * CLUTTER_FIXED_CEIL:
* @x: a fixed point value * @x: a fixed point value
* *
* Round up a fixed point value to an integer. * Round up a fixed point value to an integer.
*/ */
#define CLUTTER_FIXED_CEIL(x) (CLUTTER_FIXED_FLOOR (x + 0xffff)) #define CLUTTER_FIXED_CEIL(x) (CLUTTER_FIXED_FLOOR (x + 0xffff))
@ -253,7 +253,7 @@ typedef gint32 ClutterAngle; /* angle such that 1024 == 2*PI */
* CLUTTER_FIXED_MUL: * CLUTTER_FIXED_MUL:
* @x: a fixed point value * @x: a fixed point value
* @y: a fixed point value * @y: a fixed point value
* *
* Multiply two fixed point values * Multiply two fixed point values
*/ */
#define CLUTTER_FIXED_MUL(x,y) ((x) >> 8) * ((y) >> 8) #define CLUTTER_FIXED_MUL(x,y) ((x) >> 8) * ((y) >> 8)
@ -262,7 +262,7 @@ typedef gint32 ClutterAngle; /* angle such that 1024 == 2*PI */
* CLUTTER_FIXED_DIV: * CLUTTER_FIXED_DIV:
* @x: a fixed point value * @x: a fixed point value
* @y: a fixed point value * @y: a fixed point value
* *
* Divide two fixed point values * Divide two fixed point values
*/ */
#define CLUTTER_FIXED_DIV(x,y) ((((x) << 8)/(y)) << 8) #define CLUTTER_FIXED_DIV(x,y) ((((x) << 8)/(y)) << 8)
@ -290,7 +290,7 @@ ClutterFixed clutter_tani (ClutterAngle angle);
* @angle: a #ClutterFixed angle in radians * @angle: a #ClutterFixed angle in radians
* *
* Fixed point cosine function * Fixed point cosine function
* *
* Return value: #ClutterFixed cosine value. * Return value: #ClutterFixed cosine value.
* *
* Note: Implemneted as a macro. * Note: Implemneted as a macro.
@ -307,7 +307,7 @@ ClutterFixed clutter_tani (ClutterAngle angle);
* *
* ClutterAngle is an integer such that 1024 represents * ClutterAngle is an integer such that 1024 represents
* full circle. * full circle.
* *
* Return value: #ClutterFixed cosine value. * Return value: #ClutterFixed cosine value.
* *
* Note: Implemneted as a macro. * Note: Implemneted as a macro.
@ -316,6 +316,47 @@ ClutterFixed clutter_tani (ClutterAngle angle);
*/ */
#define clutter_cosi(angle) (clutter_sini ((angle) + 256)) #define clutter_cosi(angle) (clutter_sini ((angle) + 256))
/**
* CLUTTER_SQRTI_ARG_MAX
*
* Maximum argument that can be passed to #clutter_sqrti function.
*
* Since: 0.6
*/
#ifndef __SSE2__
#define CLUTTER_SQRTI_ARG_MAX 0x3fffff
#else
#define CLUTTER_SQRTI_ARG_MAX INT_MAX
#endif
/**
* CLUTTER_SQRTI_ARG_5_PERCENT
*
* Maximum argument that can be passed to #clutter_sqrti for which the
* resulting error is < 5%
*
* Since: 0.6
*/
#ifndef __SSE2__
#define CLUTTER_SQRTI_ARG_5_PERCENT 131
#else
#define CLUTTER_SQRTI_ARG_5_PERCENT INT_MAX
#endif
/**
* CLUTTER_SQRTI_ARG_10_PERCENT
*
* Maximum argument that can be passed to #clutter_sqrti for which the
* resulting error is < 10%
*
* Since: 0.6
*/
#ifndef __SSE2__
#define CLUTTER_SQRTI_ARG_10_PERCENT 5590
#else
#define CLUTTER_SQRTI_ARG_10_PERCENT INT_MAX
#endif
ClutterFixed clutter_sqrtx (ClutterFixed x); ClutterFixed clutter_sqrtx (ClutterFixed x);
gint clutter_sqrti (gint x); gint clutter_sqrti (gint x);