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:
parent
9461dd216b
commit
3b07be19ba
17
ChangeLog
17
ChangeLog
@ -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>
|
||||
|
||||
* clutter/clutter-layout.h: Add commodity macros to test for
|
||||
|
@ -117,18 +117,28 @@ static gint
|
||||
node_distance (const ClutterKnot *begin,
|
||||
const ClutterKnot *end)
|
||||
{
|
||||
gint t;
|
||||
|
||||
g_return_val_if_fail (begin != NULL, 0);
|
||||
g_return_val_if_fail (end != NULL, 0);
|
||||
|
||||
if (clutter_knot_equal (begin, end))
|
||||
return 0;
|
||||
|
||||
#if 1
|
||||
return clutter_sqrti ((end->x - begin->x) * (end->x - begin->x) +
|
||||
(end->y - begin->y) * (end->y - begin->y));
|
||||
t = (end->x - begin->x) * (end->x - begin->x) +
|
||||
(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
|
||||
return CLUTTER_FLOAT_TO_INT(sqrt((end->x - begin->x) * (end->x - begin->x) +
|
||||
(end->y - begin->y) * (end->y - begin->y)));
|
||||
return clutter_sqrti (t);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -608,7 +608,9 @@ clutter_sqrtx (ClutterFixed x)
|
||||
*
|
||||
* 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%
|
||||
* 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.
|
||||
*
|
||||
|
@ -316,6 +316,47 @@ ClutterFixed clutter_tani (ClutterAngle angle);
|
||||
*/
|
||||
#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);
|
||||
gint clutter_sqrti (gint x);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user