documentation for fixed point API
This commit is contained in:
parent
9bd77e25b2
commit
7078dc5254
3
AUTHORS
3
AUTHORS
@ -1,4 +1,5 @@
|
||||
Matthew Allum <mallum@o-hand.com> - primary authour
|
||||
Emmanuele Bassi <ebassi@o-hand.com> - python bindings, gobject/glib mastery
|
||||
Iain Holmes <iain@o-hand.com> - GTK Clutter widget
|
||||
Jorn Baayen <jorn@o-hand.com> - Gstreamer bits
|
||||
Jorn Baayen <jorn@o-hand.com> - Gstreamer bits
|
||||
Tomas Frydrych <tf@o-hand.com> - Fixed point magic
|
||||
|
12
ChangeLog
12
ChangeLog
@ -1,3 +1,15 @@
|
||||
2007-01-17 Tomas Frydrych <tf@openedhand.com>
|
||||
* configure.ac:
|
||||
* clutter/clutter-behavior-path.c:
|
||||
Added --without-fpu option.
|
||||
|
||||
* doc/refrence/tmpl/clutter-fixed.sgml:
|
||||
* clutter/clutter-fixed.c:
|
||||
* clutter/clutter-fixed.h:
|
||||
Documentation for fixed point API.
|
||||
|
||||
* AUTHORS: added self.
|
||||
|
||||
2007-01-17 Emmanuele Bassi <ebassi@openedhand.com>
|
||||
|
||||
* clutter/clutter-feature.h:
|
||||
|
@ -196,8 +196,13 @@ node_distance (const ClutterKnot *begin,
|
||||
if (clutter_knot_equal (begin, end))
|
||||
return 0;
|
||||
|
||||
#ifdef CFX_NO_FPU
|
||||
return clutter_sqrti ((end->x - begin->x) * (end->x - begin->x) +
|
||||
(end->y - begin->y) * (end->y - begin->y));
|
||||
#else
|
||||
return (gint) sqrt ((end->x - begin->x) * (end->x - begin->x) +
|
||||
(end->y - begin->y) * (end->y - begin->y));
|
||||
#endif
|
||||
}
|
||||
|
||||
static gint
|
||||
|
@ -115,7 +115,7 @@ static ClutterFixed sin_tbl [] =
|
||||
*
|
||||
* Fixed point implementation of sine function
|
||||
*
|
||||
* Return value: sine value (as fixed point).
|
||||
* Return value: #ClutterFixed sine value.
|
||||
*
|
||||
* Since: 0.2
|
||||
*/
|
||||
@ -204,7 +204,7 @@ clutter_sinx (ClutterFixed angle)
|
||||
* ClutterAngle is an integer such that 1024 represents
|
||||
* full circle.
|
||||
*
|
||||
* Return value: sine value (as fixed point).
|
||||
* Return value: #ClutterFixed sine value.
|
||||
*
|
||||
* Since: 0.2
|
||||
*/
|
||||
@ -331,7 +331,7 @@ ClutterFixed sqrt_tbl [] =
|
||||
*
|
||||
* A fixed point implementation of squre root
|
||||
*
|
||||
* Return value: square root (as fixed point).
|
||||
* Return value: #ClutterFixed square root.
|
||||
*
|
||||
* Since: 0.2
|
||||
*/
|
||||
@ -450,7 +450,7 @@ clutter_sqrtx (ClutterFixed x)
|
||||
*
|
||||
* A fixed point implementation of square root for integers
|
||||
*
|
||||
* Return value: square root (as truncated integer).
|
||||
* Return value: integer square root (truncated).
|
||||
*
|
||||
*
|
||||
* Since: 0.2
|
||||
|
@ -30,7 +30,19 @@
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/**
|
||||
* ClutterFixed:
|
||||
*
|
||||
* Fixed point number (16.16)
|
||||
*/
|
||||
typedef gint32 ClutterFixed;
|
||||
|
||||
/**
|
||||
* ClutterAngle:
|
||||
*
|
||||
* Integer representation of an agnle such that 1024 corresponds to
|
||||
* fool circle (i.e., 2*Pi).
|
||||
*/
|
||||
typedef gint32 ClutterAngle; /* angle such that 1024 == 2*PI */
|
||||
|
||||
#define CFX_Q 16 /* Decimal part size in bits */
|
||||
@ -41,47 +53,156 @@ typedef gint32 ClutterAngle; /* angle such that 1024 == 2*PI */
|
||||
/*
|
||||
* some commonly used constants
|
||||
*/
|
||||
|
||||
/**
|
||||
* CFX_PI:
|
||||
*
|
||||
* Fixed point representation of Pi
|
||||
*/
|
||||
#define CFX_PI 0x0003243f
|
||||
/**
|
||||
* CFX_2PI:
|
||||
*
|
||||
* Fixed point representation of Pi*2
|
||||
*/
|
||||
#define CFX_2PI 0x0006487f
|
||||
/**
|
||||
* CFX_PI2:
|
||||
*
|
||||
* Fixed point representation of Pi/2
|
||||
*/
|
||||
#define CFX_PI_2 0x00019220 /* pi/2 */
|
||||
/**
|
||||
* CFX_PI4:
|
||||
*
|
||||
* Fixed point representation of Pi/4
|
||||
*/
|
||||
#define CFX_PI_4 0x0000c910 /* pi/4 */
|
||||
#define CFX_PI8192 0x6487ed51 /* pi * 0x2000, to improve precision */
|
||||
|
||||
/**
|
||||
* CFX_360:
|
||||
*
|
||||
* Fixed point representation of the number 360
|
||||
*/
|
||||
#define CFX_360 CLUTTER_INT_TO_FIXED (360)
|
||||
/**
|
||||
* CFX_240:
|
||||
*
|
||||
* Fixed point representation of the number 240
|
||||
*/
|
||||
#define CFX_240 CLUTTER_INT_TO_FIXED (240)
|
||||
/**
|
||||
* CFX_180:
|
||||
*
|
||||
* Fixed point representation of the number 180
|
||||
*/
|
||||
#define CFX_180 CLUTTER_INT_TO_FIXED (180)
|
||||
/**
|
||||
* CFX_120:
|
||||
*
|
||||
* Fixed point representation of the number 120
|
||||
*/
|
||||
#define CFX_120 CLUTTER_INT_TO_FIXED (120)
|
||||
/**
|
||||
* CFX_60:
|
||||
*
|
||||
* Fixed point representation of the number 60
|
||||
*/
|
||||
#define CFX_60 CLUTTER_INT_TO_FIXED (60)
|
||||
/**
|
||||
* CFX_255:
|
||||
*
|
||||
* Fixed point representation of the number 255
|
||||
*/
|
||||
#define CFX_255 CLUTTER_INT_TO_FIXED (255)
|
||||
|
||||
/**
|
||||
* CLUTTER_FIXED_TO_FLOAT:
|
||||
*
|
||||
* Macro to convert from fixed to floating point.
|
||||
*/
|
||||
#define CLUTTER_FIXED_TO_FLOAT(x) ((float)((int)(x)/65536.0))
|
||||
|
||||
/**
|
||||
* CLUTTER_FIXED_TO_DOUBLE:
|
||||
*
|
||||
* Macro to convert from fixed to doulbe precission floating point.
|
||||
*/
|
||||
#define CLUTTER_FIXED_TO_DOUBLE(x) ((double)((int)(x)/65536.0))
|
||||
|
||||
/**
|
||||
* CLUTTER_FLOAT_TO_FIXED:
|
||||
*
|
||||
* Macro to convert from floating to fixed point.
|
||||
*/
|
||||
#define CLUTTER_FLOAT_TO_FIXED(x) \
|
||||
( (ABS(x) > 32767.0) ? \
|
||||
(((x)/(x))*0x7fffffff) \
|
||||
: ((long)((x) * 65536.0 + ((x) < 0 ? -0.5 : 0.5))) )
|
||||
|
||||
|
||||
/**
|
||||
* CLUTTER_INT_TO_FIXED:
|
||||
*
|
||||
* Macro to convert from int to fixed point representation.
|
||||
*/
|
||||
#define CLUTTER_INT_TO_FIXED(x) ((x) << CFX_Q)
|
||||
|
||||
/**
|
||||
* CLUTTER_FIXED_INT:
|
||||
*
|
||||
* Macro to convert from fixed point to integer.
|
||||
*/
|
||||
#define CLUTTER_FIXED_INT(x) ((x) >> CFX_Q)
|
||||
|
||||
/**
|
||||
* CLUTTER_FIXED_FRACTION:
|
||||
*
|
||||
* Macro to retrive the fraction of a fixed point number.
|
||||
*/
|
||||
#define CLUTTER_FIXED_FRACTION(x) ((x) & ((1 << CFX_Q) - 1))
|
||||
|
||||
/**
|
||||
* CLUTTER_FIXED_FLOOR:
|
||||
*
|
||||
* Macro to obtain greatest integer lesser than given fixed point value.
|
||||
*/
|
||||
#define CLUTTER_FIXED_FLOOR(x) \
|
||||
(((x) >= 0) ? ((x) >> CFX_Q) : ~((~(x)) >> CFX_Q))
|
||||
|
||||
/**
|
||||
* CLUTTER_FIXED_CEIL:
|
||||
*
|
||||
* Macro to obtain smallest integer greater than given fixed point value.
|
||||
*/
|
||||
#define CLUTTER_FIXED_CEIL(x) CLUTTER_FIXED_FLOOR(x + 0xffff)
|
||||
|
||||
/**
|
||||
* CLUTTER_FIXED_MUL:
|
||||
*
|
||||
* Macro to multiply two fixed point numbers.
|
||||
*/
|
||||
#define CLUTTER_FIXED_MUL(x,y) ((x) >> 8) * ((y) >> 8)
|
||||
|
||||
/**
|
||||
* CLUTTER_FIXED_DIV:
|
||||
*
|
||||
* Macro to divide two fixed point numbers.
|
||||
*/
|
||||
#define CLUTTER_FIXED_DIV(x,y) ((((x) << 8)/(y)) << 8)
|
||||
|
||||
/* some handy short aliases to avoid exessively long lines */
|
||||
|
||||
/**
|
||||
* CFX_INT:
|
||||
*
|
||||
* Alias for CLUTTER_FIXED_INT:
|
||||
*/
|
||||
#define CFX_INT CLUTTER_FIXED_INT
|
||||
/**
|
||||
* CFX_MUL:
|
||||
*
|
||||
* Alias for CLUTTER_FIXED_MUL:
|
||||
*/
|
||||
#define CFX_MUL CLUTTER_FIXED_MUL
|
||||
|
||||
/**
|
||||
* CFX_DIV:
|
||||
*
|
||||
* Alias for CLUTTER_FIXED_DIV:
|
||||
*/
|
||||
#define CFX_DIV CLUTTER_FIXED_DIV
|
||||
|
||||
/* Fixed point math routines */
|
||||
@ -89,7 +210,36 @@ ClutterFixed clutter_sinx (ClutterFixed angle);
|
||||
ClutterFixed clutter_sini (ClutterAngle angle);
|
||||
|
||||
/* convenience macros for the cos functions */
|
||||
|
||||
/**
|
||||
* clutter_cosx:
|
||||
* @angle: a #ClutterFixed angle in radians
|
||||
*
|
||||
* Fixed point cosine function
|
||||
*
|
||||
* Return value: #ClutterFixed cosine value.
|
||||
*
|
||||
* Note: Implemneted as a macro.
|
||||
*
|
||||
* Since: 0.2
|
||||
*/
|
||||
#define clutter_cosx(x) clutter_fixed_sin((x) - CFX_PI_2)
|
||||
|
||||
/**
|
||||
* clutter_cosi:
|
||||
* @angle: a #ClutterAngle angle
|
||||
*
|
||||
* Very fast fixed point implementation of cosine function.
|
||||
*
|
||||
* ClutterAngle is an integer such that 1024 represents
|
||||
* full circle.
|
||||
*
|
||||
* Return value: #ClutterFixed cosine value.
|
||||
*
|
||||
* Note: Implemneted as a macro.
|
||||
*
|
||||
* Since: 0.2
|
||||
*/
|
||||
#define clutter_cosi(x) clutter_sini((x) - 256)
|
||||
|
||||
ClutterFixed clutter_sqrtx (ClutterFixed x);
|
||||
|
11
configure.ac
11
configure.ac
@ -132,6 +132,14 @@ fi
|
||||
|
||||
AC_SUBST(CLUTTER_DEBUG_CFLAGS)
|
||||
|
||||
AC_ARG_WITH(fpu, AS_HELP_STRING([--without-fpu],
|
||||
[Assume no fpu is present]),
|
||||
[with_fpu=$withval], [with_fpu=yes])
|
||||
|
||||
if test "x$with_fpu" != "xyes" ; then
|
||||
CLUTTER_FIXED_CFLAGS="-DCFX_NO_FPU"
|
||||
fi
|
||||
|
||||
dnl = GTK Doc check ========================================================
|
||||
|
||||
GTK_DOC_CHECK([1.4])
|
||||
@ -140,7 +148,7 @@ dnl ========================================================================
|
||||
|
||||
AC_SUBST(GCC_FLAGS)
|
||||
|
||||
CLUTTER_CFLAGS="$GLX_CLAGS $CLUTTER_DEPS_CFLAGS"
|
||||
CLUTTER_CFLAGS="$GLX_CLAGS $CLUTTER_DEPS_CFLAGS $CLUTTER_FIXED_CFLAGS"
|
||||
CLUTTER_LIBS="$GLX_LIBS $CLUTTER_DEPS_LIBS"
|
||||
|
||||
AC_SUBST(CLUTTER_CFLAGS)
|
||||
@ -170,4 +178,5 @@ echo " prefix: ${prefix}"
|
||||
echo ""
|
||||
echo " Debug level: ${enable_debug}"
|
||||
echo " Documentation: ${enable_gtk_doc}"
|
||||
echo " FPU: ${with_fpu}"
|
||||
echo ""
|
||||
|
@ -29,28 +29,28 @@ floating-to-fixed conversion.
|
||||
|
||||
<!-- ##### MACRO CFX_Q ##### -->
|
||||
<para>
|
||||
|
||||
Number of bits used to store fractional part of #ClutterFixed.
|
||||
</para>
|
||||
|
||||
|
||||
|
||||
<!-- ##### MACRO CFX_ONE ##### -->
|
||||
<para>
|
||||
|
||||
#ClutterFixed representation of 1.
|
||||
</para>
|
||||
|
||||
|
||||
|
||||
<!-- ##### MACRO CFX_MAX ##### -->
|
||||
<para>
|
||||
|
||||
Maximum number representable by #ClutterFixed.
|
||||
</para>
|
||||
|
||||
|
||||
|
||||
<!-- ##### MACRO CFX_MIN ##### -->
|
||||
<para>
|
||||
|
||||
Minumum number representable by #ClutterFixed.
|
||||
</para>
|
||||
|
||||
|
||||
@ -63,198 +63,191 @@ floating-to-fixed conversion.
|
||||
|
||||
<!-- ##### MACRO CFX_PI ##### -->
|
||||
<para>
|
||||
|
||||
#ClutterFixed representation of Pi.
|
||||
</para>
|
||||
|
||||
|
||||
|
||||
<!-- ##### MACRO CFX_2PI ##### -->
|
||||
<para>
|
||||
|
||||
#ClutterFixed representation of 2 * Pi.
|
||||
</para>
|
||||
|
||||
|
||||
|
||||
<!-- ##### MACRO CFX_PI_2 ##### -->
|
||||
<para>
|
||||
|
||||
#ClutterFixed representation of Pi/2.
|
||||
</para>
|
||||
|
||||
|
||||
|
||||
<!-- ##### MACRO CFX_PI_4 ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
|
||||
|
||||
<!-- ##### MACRO CFX_PI8192 ##### -->
|
||||
<para>
|
||||
|
||||
#ClutterFixed representation of Pi/4.
|
||||
</para>
|
||||
|
||||
|
||||
|
||||
<!-- ##### MACRO CFX_120 ##### -->
|
||||
<para>
|
||||
|
||||
#ClutterFixed representation of 120.
|
||||
</para>
|
||||
|
||||
|
||||
|
||||
<!-- ##### MACRO CFX_180 ##### -->
|
||||
<para>
|
||||
|
||||
#ClutterFixed representation of 180.
|
||||
</para>
|
||||
|
||||
|
||||
|
||||
<!-- ##### MACRO CFX_240 ##### -->
|
||||
<para>
|
||||
|
||||
#ClutterFixed representation of 240.
|
||||
</para>
|
||||
|
||||
|
||||
|
||||
<!-- ##### MACRO CFX_360 ##### -->
|
||||
<para>
|
||||
|
||||
#ClutterFixed representation of 360.
|
||||
</para>
|
||||
|
||||
|
||||
|
||||
<!-- ##### MACRO CFX_60 ##### -->
|
||||
<para>
|
||||
|
||||
#ClutterFixed representation of 60.
|
||||
</para>
|
||||
|
||||
|
||||
|
||||
<!-- ##### MACRO CFX_255 ##### -->
|
||||
<para>
|
||||
|
||||
#ClutterFixed representation of 255.
|
||||
</para>
|
||||
|
||||
|
||||
|
||||
<!-- ##### MACRO CFX_DIV ##### -->
|
||||
<para>
|
||||
|
||||
Alias for #CLUTTER_FIXED_DIV.
|
||||
</para>
|
||||
|
||||
|
||||
|
||||
<!-- ##### MACRO CFX_INT ##### -->
|
||||
<para>
|
||||
|
||||
Alias for #CLUTTER_FIXED_INT.
|
||||
</para>
|
||||
|
||||
|
||||
|
||||
<!-- ##### MACRO CFX_MUL ##### -->
|
||||
<para>
|
||||
|
||||
Alias for #CLUTTER_FIXED_MUL.
|
||||
</para>
|
||||
|
||||
|
||||
|
||||
<!-- ##### MACRO CLUTTER_FIXED_TO_FLOAT ##### -->
|
||||
<para>
|
||||
|
||||
Macro for converting #ClutterFixed to single precission floating point.
|
||||
</para>
|
||||
|
||||
@x:
|
||||
@x: #ClutterFixed
|
||||
|
||||
|
||||
<!-- ##### MACRO CLUTTER_FIXED_TO_DOUBLE ##### -->
|
||||
<para>
|
||||
|
||||
Macro for converting #ClutterFixed to double precission floating point.
|
||||
</para>
|
||||
|
||||
@x:
|
||||
@x: #ClutterFixed
|
||||
|
||||
|
||||
<!-- ##### MACRO CLUTTER_FLOAT_TO_FIXED ##### -->
|
||||
<para>
|
||||
|
||||
Macro for converting floating point numbers to #ClutterFixed.
|
||||
</para>
|
||||
|
||||
@x:
|
||||
@x: double or float
|
||||
|
||||
|
||||
<!-- ##### MACRO CLUTTER_INT_TO_FIXED ##### -->
|
||||
<para>
|
||||
|
||||
Macro for converting integers to #ClutterFixed.
|
||||
</para>
|
||||
|
||||
@x:
|
||||
@x: int
|
||||
|
||||
|
||||
<!-- ##### MACRO CLUTTER_FIXED_INT ##### -->
|
||||
<para>
|
||||
|
||||
Macro to obtain integer part of #ClutterFixed.
|
||||
</para>
|
||||
|
||||
@x:
|
||||
@x: #ClutterFixed
|
||||
|
||||
|
||||
<!-- ##### MACRO CLUTTER_FIXED_FRACTION ##### -->
|
||||
<para>
|
||||
|
||||
Macro to obtain the fraction of #ClutterFixed.
|
||||
</para>
|
||||
|
||||
@x:
|
||||
@x: #ClutterFixed
|
||||
|
||||
|
||||
<!-- ##### MACRO CLUTTER_FIXED_FLOOR ##### -->
|
||||
<para>
|
||||
|
||||
Macro to obtain greatest integer smaller than given #ClutterFixed.
|
||||
</para>
|
||||
|
||||
@x:
|
||||
@x: #ClutterFixed
|
||||
|
||||
|
||||
<!-- ##### MACRO CLUTTER_FIXED_CEIL ##### -->
|
||||
<para>
|
||||
|
||||
Macro to obtain smallest integer greater than given #ClutterFixed.
|
||||
</para>
|
||||
|
||||
@x:
|
||||
@x: #ClutterFixed
|
||||
|
||||
|
||||
<!-- ##### MACRO CLUTTER_FIXED_MUL ##### -->
|
||||
<para>
|
||||
|
||||
Macro for multiplication of two #ClutterFixed numbers.
|
||||
</para>
|
||||
|
||||
@x:
|
||||
@y:
|
||||
@x: #ClutterFixed
|
||||
@y: #ClutterFixed
|
||||
|
||||
|
||||
<!-- ##### MACRO CLUTTER_FIXED_DIV ##### -->
|
||||
<para>
|
||||
|
||||
Macro for difvision of two #ClutterFixed numbers.
|
||||
</para>
|
||||
|
||||
@x:
|
||||
@y:
|
||||
@x: #ClutterFixed
|
||||
@y: #ClutterFixed
|
||||
|
||||
|
||||
<!-- ##### MACRO clutter_cosi ##### -->
|
||||
<para>
|
||||
|
||||
Very fast fixed point cosine function.
|
||||
</para>
|
||||
|
||||
@x:
|
||||
@x: #ClutterAngle
|
||||
|
||||
|
||||
<!-- ##### MACRO clutter_cosx ##### -->
|
||||
<para>
|
||||
|
||||
Fast fixed point cosine function.
|
||||
</para>
|
||||
|
||||
@x:
|
||||
@x: #ClutterFixed
|
||||
|
||||
|
||||
<!-- ##### FUNCTION clutter_sini ##### -->
|
||||
|
Loading…
Reference in New Issue
Block a user