mirror of
https://github.com/brl/mutter.git
synced 2024-11-26 10:00:45 -05:00
2008-10-30 Emmanuele Bassi <ebassi@linux.intel.com>
Bug 1209 - Move fixed point API in COGL * clutter/cogl/cogl-fixed.h: * clutter/cogl/cogl.h.in: * clutter/cogl/common/Makefile.am: * clutter/cogl/common/cogl-fixed.c: Add fixed point API, modelled after the ClutterFixed. The CoglFixed API supercedes the ClutterFixed one and avoids the dependency of COGL on Clutter's own API. * clutter/cogl/common/cogl-clip-stack.c: * clutter/cogl/common/cogl-primitives.c: * clutter/cogl/common/cogl-primitives.h: Update internal usage of ClutterFixed to CoglFixed. * clutter/cogl/gl/Makefile.am: * clutter/cogl/gl/cogl-primitives.c: * clutter/cogl/gl/cogl-texture.c: * clutter/cogl/gl/cogl.c: Ditto, in the GL implementation of the COGL API. * clutter/cogl/gles/Makefile.am: * clutter/cogl/gles/cogl-fbo.c: * clutter/cogl/gles/cogl-gles2-wrapper.c: * clutter/cogl/gles/cogl-primitives.c: * clutter/cogl/gles/cogl-texture.c: * clutter/cogl/gles/cogl.c: Ditto, in the GLES implementation of the COGL API. * clutter/pango/pangoclutter-glyph-cache.c: * clutter/pango/pangoclutter-glyph-cache.h: Ditto, in the Pango renderer glyphs cache. * clutter/clutter-fixed.c: * clutter/clutter-fixed.h: ClutterFixed and related API becomes a simple transition API for bindings and public Clutter API. * clutter/clutter-actor.c: * clutter/clutter-alpha.c: * clutter/clutter-backend.c: * clutter/clutter-behaviour-depth.c: * clutter/clutter-behaviour-ellipse.c: * clutter/clutter-behaviour-path.c: * clutter/clutter-behaviour-rotate.c: * clutter/clutter-behaviour-scale.c: * clutter/clutter-clone-texture.c: * clutter/clutter-color.c: * clutter/clutter-entry.c: * clutter/clutter-stage.c: * clutter/clutter-texture.c: * clutter/clutter-timeline.c: * clutter/clutter-units.h: Move from the internal usage of ClutterFixed to CoglFixed. * doc/reference/clutter/clutter-sections.txt: * doc/reference/cogl/cogl-docs.sgml: * doc/reference/cogl/cogl-sections.txt: Update the documentation. * tests/test-cogl-tex-tile.c: * tests/test-project.c: Fix tests after the API change * README: Add release notes.
This commit is contained in:
parent
1b619c3843
commit
71a0be6fff
753
cogl-fixed.h
Normal file
753
cogl-fixed.h
Normal file
@ -0,0 +1,753 @@
|
||||
#ifndef __COGL_FIXED_H__
|
||||
#define __COGL_FIXED_H__
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
/**
|
||||
* SECTION:cogl-fixed
|
||||
* @short_description: Fixed Point API
|
||||
*
|
||||
* COGL has a fixed point API targeted at platforms without a floating
|
||||
* point unit, such as embedded devices. On such platforms this API should
|
||||
* be preferred to the floating point one as it does not trigger the slow
|
||||
* path of software emulation, relying on integer math for fixed-to-floating
|
||||
* and floating-to-fixed notations conversion.
|
||||
*
|
||||
* It is not recommened for use on platforms with a floating point unit
|
||||
* (e.g. desktop systems), nor for use in language bindings.
|
||||
*
|
||||
* Basic rules of Fixed Point arithmethic:
|
||||
* <itemizedlist>
|
||||
* <listitem>
|
||||
* <para>Two fixed point numbers can be directly added, subtracted and
|
||||
* have their modulus taken.</para>
|
||||
* </listitem>
|
||||
* <listitem>
|
||||
* <para>To add other numerical type to a fixed point number it has to
|
||||
* be first converted to fixed point.</para>
|
||||
* </listitem>
|
||||
* <listitem>
|
||||
* <para>A fixed point number can be directly multiplied or divided by
|
||||
* an integer.</para>
|
||||
* </listitem>
|
||||
* <listitem>
|
||||
* <para>Two fixed point numbers can only be multiplied and divided by
|
||||
* the provided %COGL_FIXED_MUL and %COGL_FIXED_DIV macros.</para>
|
||||
* </listitem>
|
||||
* </itemizedlist>
|
||||
*
|
||||
* The fixed point API is available since COGL 1.0.
|
||||
*/
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/**
|
||||
* CoglFixed:
|
||||
*
|
||||
* Fixed point number using a (16.16) notation.
|
||||
*/
|
||||
typedef gint32 CoglFixed;
|
||||
|
||||
/*
|
||||
* some commonly used constants
|
||||
*/
|
||||
|
||||
/**
|
||||
* COGL_FIXED_BITS:
|
||||
*
|
||||
* Evaluates to the number of bits used by the #CoglFixed type.
|
||||
*
|
||||
* Since: 1.0
|
||||
*/
|
||||
#define COGL_FIXED_BITS (32)
|
||||
|
||||
/**
|
||||
* COGL_FIXED_Q:
|
||||
*
|
||||
* Evaluates to the number of bits used for the non-integer part
|
||||
* of the #CoglFixed type.
|
||||
*
|
||||
* Since: 1.0
|
||||
*/
|
||||
#define COGL_FIXED_Q (COGL_FIXED_BITS - 16)
|
||||
|
||||
/**
|
||||
* COGL_FIXED_1:
|
||||
*
|
||||
* The number 1 expressed as a #CoglFixed number.
|
||||
*
|
||||
* Since: 1.0
|
||||
*/
|
||||
#define COGL_FIXED_1 (1 << COGL_FIXED_Q)
|
||||
|
||||
/**
|
||||
* COGL_FIXED_0_5:
|
||||
*
|
||||
* The number 0.5 expressed as a #CoglFixed number.
|
||||
*
|
||||
* Since: 1.0
|
||||
*/
|
||||
#define COGL_FIXED_0_5 (32768)
|
||||
|
||||
/**
|
||||
* COGL_FIXED_EPSILON:
|
||||
*
|
||||
* A very small number expressed as a #CoglFixed number.
|
||||
*
|
||||
* Since: 1.0
|
||||
*/
|
||||
#define COGL_FIXED_EPSILON (1)
|
||||
|
||||
/**
|
||||
* COGL_FIXED_MAX:
|
||||
*
|
||||
* The biggest number representable using #CoglFixed
|
||||
*
|
||||
* Since: 1.0
|
||||
*/
|
||||
#define COGL_FIXED_MAX (0x7fffffff)
|
||||
|
||||
/**
|
||||
* COGL_FIXED_MIN:
|
||||
*
|
||||
* The smallest number representable using #CoglFixed
|
||||
*
|
||||
* Since: 1.0
|
||||
*/
|
||||
#define COGL_FIXED_MIN (0x80000000)
|
||||
|
||||
/**
|
||||
* COGL_FIXED_PI:
|
||||
*
|
||||
* The number pi, expressed as a #CoglFixed number.
|
||||
*
|
||||
* Since: 1.0
|
||||
*/
|
||||
#define COGL_FIXED_PI (0x0003243f)
|
||||
|
||||
/**
|
||||
* COGL_FIXED_2_PI:
|
||||
*
|
||||
* Two times pi, expressed as a #CoglFixed number.
|
||||
*
|
||||
* Since: 1.0
|
||||
*/
|
||||
#define COGL_FIXED_2_PI (0x0006487f)
|
||||
|
||||
/**
|
||||
* COGL_FIXED_PI_2:
|
||||
*
|
||||
* Half pi, expressed as a #CoglFixed number.
|
||||
*
|
||||
* Since: 1.0
|
||||
*/
|
||||
#define COGL_FIXED_PI_2 (0x00019220)
|
||||
|
||||
/**
|
||||
* COGL_FIXED_PI_4:
|
||||
*
|
||||
* pi / 4, expressed as #CoglFixed number.
|
||||
*
|
||||
* Since: 1.0
|
||||
*/
|
||||
#define COGL_FIXED_PI_4 (0x0000c910)
|
||||
|
||||
/**
|
||||
* COGL_FIXED_360:
|
||||
*
|
||||
* Evaluates to the number 360 in fixed point notation.
|
||||
*
|
||||
* Since: 1.0
|
||||
*/
|
||||
#define COGL_FIXED_360 (COGL_FIXED_FROM_INT (360))
|
||||
|
||||
/**
|
||||
* COGL_FIXED_270:
|
||||
*
|
||||
* Evaluates to the number 270 in fixed point notation.
|
||||
*
|
||||
* Since: 1.0
|
||||
*/
|
||||
#define COGL_FIXED_270 (COGL_FIXED_FROM_INT (270))
|
||||
|
||||
/**
|
||||
* COGL_FIXED_255:
|
||||
*
|
||||
* Evaluates to the number 255 in fixed point notation.
|
||||
*
|
||||
* Since: 1.0
|
||||
*/
|
||||
#define COGL_FIXED_255 (COGL_FIXED_FROM_INT (255))
|
||||
|
||||
/**
|
||||
* COGL_FIXED_240:
|
||||
*
|
||||
* Evaluates to the number 240 in fixed point notation.
|
||||
*
|
||||
* Since: 1.0
|
||||
*/
|
||||
#define COGL_FIXED_240 (COGL_FIXED_FROM_INT (240))
|
||||
|
||||
/**
|
||||
* COGL_FIXED_180:
|
||||
*
|
||||
* Evaluates to the number 180 in fixed point notation.
|
||||
*
|
||||
* Since: 1.0
|
||||
*/
|
||||
#define COGL_FIXED_180 (COGL_FIXED_FROM_INT (180))
|
||||
|
||||
/**
|
||||
* COGL_FIXED_120:
|
||||
*
|
||||
* Evaluates to the number 120 in fixed point notation.
|
||||
*
|
||||
* Since: 1.0
|
||||
*/
|
||||
#define COGL_FIXED_120 (COGL_FIXED_FROM_INT (120))
|
||||
|
||||
/**
|
||||
* COGL_FIXED_90:
|
||||
*
|
||||
* Evaluates to the number 90 in fixed point notation.
|
||||
*
|
||||
* Since: 1.0
|
||||
*/
|
||||
#define COGL_FIXED_90 (COGL_FIXED_FROM_INT (90))
|
||||
|
||||
/**
|
||||
* COGL_FIXED_60:
|
||||
*
|
||||
* Evaluates to the number 60 in fixed point notation.
|
||||
*
|
||||
* Since: 1.0
|
||||
*/
|
||||
#define COGL_FIXED_60 (COGL_FIXED_FROM_INT (60))
|
||||
|
||||
/**
|
||||
* COGL_FIXED_45:
|
||||
*
|
||||
* Evaluates to the number 45 in fixed point notation.
|
||||
*
|
||||
* Since: 1.0
|
||||
*/
|
||||
#define COGL_FIXED_45 (COGL_FIXED_FROM_INT (45))
|
||||
|
||||
/**
|
||||
* COGL_FIXED_30:
|
||||
*
|
||||
* Evaluates to the number 30 in fixed point notation.
|
||||
*
|
||||
* Since: 1.0
|
||||
*/
|
||||
#define COGL_FIXED_30 (COGL_FIXED_FROM_INT (30))
|
||||
|
||||
/**
|
||||
* COGL_RADIANS_TO_DEGREES:
|
||||
*
|
||||
* Evaluates to 180 / pi in fixed point notation.
|
||||
*
|
||||
* Since: 1.0
|
||||
*/
|
||||
#define COGL_RADIANS_TO_DEGREES (0x394bb8)
|
||||
|
||||
/*
|
||||
* conversion macros
|
||||
*/
|
||||
|
||||
/**
|
||||
* COGL_FIXED_FROM_FLOAT:
|
||||
* @x: a floating point number
|
||||
*
|
||||
* Converts @x from a floating point to a fixed point notation.
|
||||
*
|
||||
* Since: 1.0
|
||||
*/
|
||||
#define COGL_FIXED_FROM_FLOAT(x) (cogl_double_to_fixed (x))
|
||||
|
||||
/**
|
||||
* COGL_FIXED_TO_FLOAT:
|
||||
* @x: a #CoglFixed number
|
||||
*
|
||||
* Converts @x from a fixed point to a floating point notation, in
|
||||
* single precision.
|
||||
*
|
||||
* Since: 1.0
|
||||
*/
|
||||
#define COGL_FIXED_TO_FLOAT(x) ((float) ((int)(x) / 65536.0))
|
||||
|
||||
/**
|
||||
* COGL_FIXED_TO_FLOAT:
|
||||
* @x: a #CoglFixed number
|
||||
*
|
||||
* Converts @x from a fixed point to a floatint point notation, in
|
||||
* double precision.
|
||||
*
|
||||
* Since: 1.0
|
||||
*/
|
||||
#define COGL_FIXED_TO_DOUBLE(x) ((double) ((int)(x) / 65536.0))
|
||||
|
||||
/**
|
||||
* COGL_FIXED_FROM_INT:
|
||||
* @x: an integer number
|
||||
*
|
||||
* Converts @x from an integer to a fixed point notation.
|
||||
*
|
||||
* Since: 1.0
|
||||
*/
|
||||
#define COGL_FIXED_FROM_INT(x) ((x) << COGL_FIXED_Q)
|
||||
|
||||
/**
|
||||
* COGL_FIXED_TO_INT:
|
||||
* @x: a #CoglFixed number
|
||||
*
|
||||
* Converts @x from a fixed point notation to an integer, dropping
|
||||
* the fractional part without rounding.
|
||||
*
|
||||
* Since: 1.0
|
||||
*/
|
||||
#define COGL_FIXED_TO_INT(x) ((x) >> COGL_FIXED_Q)
|
||||
|
||||
/**
|
||||
* COGL_FLOAT_TO_INT:
|
||||
* @x: a floatint point number
|
||||
*
|
||||
* Converts @x from a floating point notation to a signed integer.
|
||||
*
|
||||
* Since: 1.0
|
||||
*/
|
||||
#define COGL_FLOAT_TO_INT(x) (cogl_double_to_int ((x)))
|
||||
|
||||
/**
|
||||
* COGL_FLOAT_TO_UINT:
|
||||
* @x: a floatint point number
|
||||
*
|
||||
* Converts @x from a floating point notation to an unsigned integer.
|
||||
*
|
||||
* Since: 1.0
|
||||
*/
|
||||
#define COGL_FLOAT_TO_UINT(x) (cogl_double_to_uint ((x)))
|
||||
|
||||
/*
|
||||
* fixed point math functions
|
||||
*/
|
||||
|
||||
/**
|
||||
* COGL_FIXED_FRACTION:
|
||||
* @x: a #CoglFixed number
|
||||
*
|
||||
* Retrieves the fractionary part of @x.
|
||||
*
|
||||
* Since: 1.0
|
||||
*/
|
||||
#define COGL_FIXED_FRACTION(x) ((x) & ((1 << COGL_FIXED_Q) - 1))
|
||||
|
||||
/**
|
||||
* COGL_FIXED_FLOOR:
|
||||
* @x: a #CoglFixed number
|
||||
*
|
||||
* Rounds down a fixed point number to the previous integer.
|
||||
*
|
||||
* Since: 1.0
|
||||
*/
|
||||
#define COGL_FIXED_FLOOR(x) (((x) >= 0) ? ((x) >> COGL_FIXED_Q) \
|
||||
: ~((~(x)) >> COGL_FIXED_Q))
|
||||
|
||||
/**
|
||||
* COGL_FIXED_CEIL:
|
||||
* @x: a #CoglFixed number
|
||||
*
|
||||
* Rounds up a fixed point number to the next integer.
|
||||
*
|
||||
* Since: 1.0
|
||||
*/
|
||||
#define COGL_FIXED_CEIL(x) (COGL_FIXED_FLOOR ((x) + 0xffff))
|
||||
|
||||
/**
|
||||
* COGL_FIXED_MUL:
|
||||
* @a: a #CoglFixed number
|
||||
* @b: a #CoglFixed number
|
||||
*
|
||||
* Computes (a * b).
|
||||
*
|
||||
* Since: 1.0
|
||||
*/
|
||||
#define COGL_FIXED_MUL(a,b) (cogl_fixed_mul ((a), (b)))
|
||||
|
||||
/**
|
||||
* COGL_FIXED_DIV:
|
||||
* @a: a #CoglFixed number
|
||||
* @b: a #CoglFixed number
|
||||
*
|
||||
* Computes (a / b).
|
||||
*
|
||||
* Since: 1.0
|
||||
*/
|
||||
#define COGL_FIXED_DIV(a,b) (cogl_fixed_div ((a), (b)))
|
||||
|
||||
/**
|
||||
* COGL_FIXED_MUL_DIV:
|
||||
* @a: a #CoglFixed number
|
||||
* @b: a #CoglFixed number
|
||||
* @c: a #CoglFixed number
|
||||
*
|
||||
* Computes ((a * b) / c). It is logically equivalent to:
|
||||
*
|
||||
* |[
|
||||
* res = COGL_FIXED_DIV (COGL_FIXED_MUL (a, b), c);
|
||||
* ]|
|
||||
*
|
||||
* But it is shorter to type.
|
||||
*
|
||||
* Since: 1.0
|
||||
*/
|
||||
#define COGL_FIXED_MUL_DIV(a,b,c) (cogl_fixed_mul_div ((a), (b), (c)))
|
||||
|
||||
/**
|
||||
* COGL_FIXED_FAST_MUL:
|
||||
* @a: a #CoglFixed number
|
||||
* @b: a #CoglFixed number
|
||||
*
|
||||
* Fast version of %COGL_FIXED_MUL, implemented as a macro.
|
||||
*
|
||||
* <note>This macro might lose precision. If the precision of the result
|
||||
* is important use %COGL_FIXED_MUL instead.</note>
|
||||
*
|
||||
* Since: 1.0
|
||||
*/
|
||||
#define COGL_FIXED_FAST_MUL(a,b) ((a) >> 8) * ((b) >> 8)
|
||||
|
||||
/**
|
||||
* COGL_FIXED_FAST_DIV:
|
||||
* @a: a #CoglFixed number
|
||||
* @b: a #CoglFixed number
|
||||
*
|
||||
* Fast version of %COGL_FIXED_DIV, implemented as a macro.
|
||||
*
|
||||
* <note>This macro might lose precision. If the precision of the result
|
||||
* is important use %COGL_FIXED_DIV instead.</note>
|
||||
*
|
||||
* Since: 1.0
|
||||
*/
|
||||
#define COGL_FIXED_FAST_DIV(a,b) ((((a) << 8) / (b)) << 8)
|
||||
|
||||
/**
|
||||
* cogl_fixed_sin:
|
||||
* @angle: a #CoglFixed number
|
||||
*
|
||||
* Computes the sine of @angle.
|
||||
*
|
||||
* Return value: the sine of the passed angle, in fixed point notation
|
||||
*
|
||||
* Since: 1.0
|
||||
*/
|
||||
CoglFixed cogl_fixed_sin (CoglFixed angle);
|
||||
|
||||
/**
|
||||
* cogl_fixed_cos:
|
||||
* @angle: a #CoglFixed number
|
||||
*
|
||||
* Computes the cosine of @angle.
|
||||
*
|
||||
* Return value: the cosine of the passed angle, in fixed point notation
|
||||
*
|
||||
* Since: 1.0
|
||||
*/
|
||||
CoglFixed cogl_fixed_cos (CoglFixed angle);
|
||||
|
||||
/**
|
||||
* cogl_fixed_atani:
|
||||
* @a: a #CoglFixed number
|
||||
*
|
||||
* Computes the arc tangent of @a.
|
||||
*
|
||||
* Return value: the arc tangent of the passed value, in fixed point notation
|
||||
*
|
||||
* Since: 1.0
|
||||
*/
|
||||
CoglFixed cogl_fixed_atani (CoglFixed a);
|
||||
|
||||
/**
|
||||
* cogl_fixed_atan2:
|
||||
* @a: the numerator as a #CoglFixed number
|
||||
* @b: the denominator as a #CoglFixed number
|
||||
*
|
||||
* Computes the arc tangent of @a / @b but uses the sign of both
|
||||
* arguments to return the angle in right quadrant.
|
||||
*
|
||||
* Return value: the arc tangent of the passed fraction, in fixed point
|
||||
* notation
|
||||
*
|
||||
* Since: 1.0
|
||||
*/
|
||||
CoglFixed cogl_fixed_atan2 (CoglFixed a,
|
||||
CoglFixed b);
|
||||
|
||||
/*< public >*/
|
||||
|
||||
/* Fixed point math routines */
|
||||
G_INLINE_FUNC CoglFixed cogl_fixed_mul (CoglFixed a,
|
||||
CoglFixed b);
|
||||
G_INLINE_FUNC CoglFixed cogl_fixed_div (CoglFixed a,
|
||||
CoglFixed b);
|
||||
G_INLINE_FUNC CoglFixed cogl_fixed_mul_div (CoglFixed a,
|
||||
CoglFixed b,
|
||||
CoglFixed c);
|
||||
|
||||
/**
|
||||
* COGL_SQRTI_ARG_MAX:
|
||||
*
|
||||
* Maximum argument that can be passed to cogl_sqrti() function.
|
||||
*
|
||||
* Since: 1.0
|
||||
*/
|
||||
#ifndef __SSE2__
|
||||
#define COGL_SQRTI_ARG_MAX 0x3fffff
|
||||
#else
|
||||
#define COGL_SQRTI_ARG_MAX INT_MAX
|
||||
#endif
|
||||
|
||||
/**
|
||||
* COGL_SQRTI_ARG_5_PERCENT:
|
||||
*
|
||||
* Maximum argument that can be passed to cogl_sqrti() for which the
|
||||
* resulting error is < 5%
|
||||
*
|
||||
* Since: 1.0
|
||||
*/
|
||||
#ifndef __SSE2__
|
||||
#define COGL_SQRTI_ARG_5_PERCENT 210
|
||||
#else
|
||||
#define COGL_SQRTI_ARG_5_PERCENT INT_MAX
|
||||
#endif
|
||||
|
||||
/**
|
||||
* COGL_SQRTI_ARG_10_PERCENT:
|
||||
*
|
||||
* Maximum argument that can be passed to cogl_sqrti() for which the
|
||||
* resulting error is < 10%
|
||||
*
|
||||
* Since: 1.0
|
||||
*/
|
||||
#ifndef __SSE2__
|
||||
#define COGL_SQRTI_ARG_10_PERCENT 5590
|
||||
#else
|
||||
#define COGL_SQRTI_ARG_10_PERCENT INT_MAX
|
||||
#endif
|
||||
|
||||
/**
|
||||
* cogl_fixed_sqrt:
|
||||
* @x: a #CoglFixed number
|
||||
*
|
||||
* Computes the square root of @x.
|
||||
*
|
||||
* Return value: the square root of the passed value, in floating point
|
||||
* notation
|
||||
*
|
||||
* Since: 1.0
|
||||
*/
|
||||
CoglFixed cogl_fixed_sqrt (CoglFixed x);
|
||||
|
||||
/**
|
||||
* cogl_fixed_log2:
|
||||
* @x: value to calculate base 2 logarithm from
|
||||
*
|
||||
* Calculates base 2 logarithm.
|
||||
*
|
||||
* This function is some 2.5 times faster on x86, and over 12 times faster on
|
||||
* fpu-less arm, than using libc log().
|
||||
*
|
||||
* Return value: base 2 logarithm.
|
||||
*
|
||||
* Since: 1.0
|
||||
*/
|
||||
CoglFixed cogl_fixed_log2 (guint x);
|
||||
|
||||
/**
|
||||
* cogl_fixed_pow2:
|
||||
* @x: a #CoglFixed number
|
||||
*
|
||||
* Calculates 2 to the @x power.
|
||||
*
|
||||
* This function is around 11 times faster on x86, and around 22 times faster
|
||||
* on fpu-less arm than libc pow(2, x).
|
||||
*
|
||||
* Return value: the power of 2 to the passed value
|
||||
*
|
||||
* Since: 1.0
|
||||
*/
|
||||
guint cogl_fixed_pow2 (CoglFixed x);
|
||||
|
||||
/**
|
||||
* cogl_fixed_pow:
|
||||
* @x: base
|
||||
* @y: #CoglFixed exponent
|
||||
*
|
||||
* Calculates @x to the @y power.
|
||||
*
|
||||
* Return value: the power of @x to the @y
|
||||
*
|
||||
* Since: 1.0
|
||||
*/
|
||||
guint cogl_fixed_pow (guint x,
|
||||
CoglFixed y);
|
||||
|
||||
/**
|
||||
* cogl_sqrti:
|
||||
* @x: integer value
|
||||
*
|
||||
* Very fast fixed point implementation of square root for integers.
|
||||
*
|
||||
* This function is at least 6x faster than clib sqrt() on x86, and (this is
|
||||
* not a typo!) about 500x faster on ARM without FPU. It's error is less than
|
||||
* 5% for arguments smaller than %COGL_SQRTI_ARG_5_PERCENT and less than 10%
|
||||
* for narguments smaller than %COGL_SQRTI_ARG_10_PERCENT. The maximum
|
||||
* argument that can be passed to this function is %COGL_SQRTI_ARG_MAX.
|
||||
*
|
||||
* Return value: integer square root.
|
||||
*
|
||||
* Since: 1.0
|
||||
*/
|
||||
gint cogl_sqrti (gint x);
|
||||
|
||||
/**
|
||||
* CoglAngle:
|
||||
*
|
||||
* Integer representation of an angle such that 1024 corresponds to
|
||||
* full circle (i.e., 2 * pi).
|
||||
*
|
||||
* Since: 1.0
|
||||
*/
|
||||
typedef gint32 CoglAngle;
|
||||
|
||||
/**
|
||||
* COGL_ANGLE_FROM_DEG:
|
||||
* @x: an angle in degrees in floating point notation
|
||||
*
|
||||
* Converts an angle in degrees into a #CoglAngle.
|
||||
*
|
||||
* Since: 1.0
|
||||
*/
|
||||
#define COGL_ANGLE_FROM_DEG(x) (COGL_FLOAT_TO_INT (((float)(x) * 1024.0f) / 360.0f))
|
||||
|
||||
/**
|
||||
* COGL_ANGLE_TO_DEG:
|
||||
* @x: a #CoglAngle
|
||||
*
|
||||
* Converts a #CoglAngle into an angle in degrees, using floatint point
|
||||
* notation.
|
||||
*
|
||||
* Since: 1.0
|
||||
*/
|
||||
#define COGL_ANGLE_TO_DEG(x) (((float)(x) * 360.0) / 1024.0)
|
||||
|
||||
/**
|
||||
* COGL_ANGLE_FROM_DEGX:
|
||||
* @x: an angle in degrees in fixed point notation
|
||||
*
|
||||
* Converts an angle in degrees into a #CoglAngle.
|
||||
*
|
||||
* Since: 1.0
|
||||
*/
|
||||
#define COGL_ANGLE_FROM_DEGX(x) (COGL_FIXED_TO_INT ((((x) / 360) * 1024) + COGL_FIXED_0_5))
|
||||
|
||||
/**
|
||||
* COGL_ANGLE_TO_DEGX:
|
||||
* @x: a #CoglAngle
|
||||
*
|
||||
* Converts a #CoglAngle into an angle in degrees, using fixed point notation
|
||||
*
|
||||
* Since: 1.0
|
||||
*/
|
||||
#define COGL_ANGLE_TO_DEGX(x) (COGL_FIXED_FROM_INT ((x) * 45) / 128)
|
||||
|
||||
/**
|
||||
* cogl_angle_sin:
|
||||
* @angle: an angle expressed using #CoglAngle
|
||||
*
|
||||
* Computes the sine of @angle
|
||||
*
|
||||
* Return value: the sine of the passed angle
|
||||
*
|
||||
* Since: 1.0
|
||||
*/
|
||||
CoglFixed cogl_angle_sin (CoglAngle angle);
|
||||
|
||||
/**
|
||||
* cogl_angle_tan:
|
||||
* @angle: an angle expressed using #CoglAngle
|
||||
*
|
||||
* Computes the tangent of @angle
|
||||
*
|
||||
* Return value: the tangent of the passed angle
|
||||
*
|
||||
* Since: 1.0
|
||||
*/
|
||||
CoglFixed cogl_angle_tan (CoglAngle angle);
|
||||
|
||||
/**
|
||||
* cogl_angle_cos:
|
||||
* @angle: an angle expressed using #CoglAngle
|
||||
*
|
||||
* Computes the cosine of @angle
|
||||
*
|
||||
* Return value: the cosine of the passed angle
|
||||
*
|
||||
* Since: 1.0
|
||||
*/
|
||||
CoglFixed cogl_angle_cos (CoglAngle angle);
|
||||
|
||||
/*< private >*/
|
||||
|
||||
#if defined (G_CAN_INLINE)
|
||||
G_INLINE_FUNC CoglFixed
|
||||
cogl_fixed_mul (CoglFixed a,
|
||||
CoglFixed b)
|
||||
{
|
||||
# ifdef __arm__
|
||||
int res_low, res_hi;
|
||||
|
||||
__asm__ ("smull %0, %1, %2, %3 \n"
|
||||
"mov %0, %0, lsr %4 \n"
|
||||
"add %1, %0, %1, lsl %5 \n"
|
||||
: "=r"(res_hi), "=r"(res_low)\
|
||||
: "r"(a), "r"(b), "i"(COGL_FIXED_Q), "i"(32 - COGL_FIXED_Q));
|
||||
|
||||
return (CoglFixed) res_low;
|
||||
# else
|
||||
long long r = (long long) a * (long long) b;
|
||||
|
||||
return (unsigned int)(r >> COGL_FIXED_Q);
|
||||
# endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined (G_CAN_INLINE)
|
||||
G_INLINE_FUNC CoglFixed
|
||||
cogl_fixed_div (CoglFixed a,
|
||||
CoglFixed b)
|
||||
{
|
||||
return (CoglFixed) ((((gint64) a) << COGL_FIXED_Q) / b);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(G_CAN_INLINE)
|
||||
G_INLINE_FUNC CoglFixed
|
||||
cogl_fixed_mul_div (CoglFixed a,
|
||||
CoglFixed b,
|
||||
CoglFixed c)
|
||||
{
|
||||
CoglFixed ab = cogl_fixed_mul (a, b);
|
||||
CoglFixed quo = cogl_fixed_div (ab, c);
|
||||
|
||||
return quo;
|
||||
}
|
||||
#endif
|
||||
|
||||
extern CoglFixed cogl_double_to_fixed (double value);
|
||||
extern gint cogl_double_to_int (double value);
|
||||
extern guint cogl_double_to_unit (double value);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __COGL_FIXED_H__ */
|
194
cogl.h.in
194
cogl.h.in
@ -45,10 +45,10 @@
|
||||
#include <glib.h>
|
||||
#include <clutter/clutter-color.h>
|
||||
#include <clutter/clutter-feature.h>
|
||||
#include <clutter/clutter-fixed.h>
|
||||
#include <clutter/clutter-types.h>
|
||||
|
||||
#include <cogl/cogl-defines-@CLUTTER_COGL@.h>
|
||||
#include <cogl/cogl-fixed.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
@ -210,8 +210,8 @@ typedef enum
|
||||
*/
|
||||
struct _CoglTextureVertex
|
||||
{
|
||||
ClutterFixed x, y, z;
|
||||
ClutterFixed tx, ty;
|
||||
CoglFixed x, y, z;
|
||||
CoglFixed tx, ty;
|
||||
ClutterColor color;
|
||||
};
|
||||
|
||||
@ -341,10 +341,10 @@ void cogl_get_bitmasks (gint *red,
|
||||
* Replaces the current projection matrix with a perspective matrix
|
||||
* based on the provided values.
|
||||
*/
|
||||
void cogl_perspective (ClutterFixed fovy,
|
||||
ClutterFixed aspect,
|
||||
ClutterFixed z_near,
|
||||
ClutterFixed z_far);
|
||||
void cogl_perspective (CoglFixed fovy,
|
||||
CoglFixed aspect,
|
||||
CoglFixed z_near,
|
||||
CoglFixed z_far);
|
||||
|
||||
/**
|
||||
* cogl_frustum:
|
||||
@ -360,12 +360,12 @@ void cogl_perspective (ClutterFixed fovy,
|
||||
*
|
||||
* Since: 0.8.2
|
||||
*/
|
||||
void cogl_frustum (ClutterFixed left,
|
||||
ClutterFixed right,
|
||||
ClutterFixed bottom,
|
||||
ClutterFixed top,
|
||||
ClutterFixed z_near,
|
||||
ClutterFixed z_far);
|
||||
void cogl_frustum (CoglFixed left,
|
||||
CoglFixed right,
|
||||
CoglFixed bottom,
|
||||
CoglFixed top,
|
||||
CoglFixed z_near,
|
||||
CoglFixed z_far);
|
||||
|
||||
/**
|
||||
* cogl_setup_viewport:
|
||||
@ -385,10 +385,10 @@ void cogl_frustum (ClutterFixed left,
|
||||
*/
|
||||
void cogl_setup_viewport (guint width,
|
||||
guint height,
|
||||
ClutterFixed fovy,
|
||||
ClutterFixed aspect,
|
||||
ClutterFixed z_near,
|
||||
ClutterFixed z_far);
|
||||
CoglFixed fovy,
|
||||
CoglFixed aspect,
|
||||
CoglFixed z_near,
|
||||
CoglFixed z_far);
|
||||
|
||||
/**
|
||||
* cogl_viewport:
|
||||
@ -425,8 +425,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 (ClutterFixed x,
|
||||
ClutterFixed y);
|
||||
void cogl_scale (CoglFixed x,
|
||||
CoglFixed y);
|
||||
|
||||
/**
|
||||
* cogl_translatex:
|
||||
@ -437,9 +437,9 @@ void cogl_scale (ClutterFixed 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 (ClutterFixed x,
|
||||
ClutterFixed y,
|
||||
ClutterFixed z);
|
||||
void cogl_translatex (CoglFixed x,
|
||||
CoglFixed y,
|
||||
CoglFixed z);
|
||||
|
||||
/**
|
||||
* cogl_translate:
|
||||
@ -468,7 +468,7 @@ void cogl_translate (gint x,
|
||||
* degrees about the vertex (0, 0, 1) causes a small counter-clockwise
|
||||
* rotation.
|
||||
*/
|
||||
void cogl_rotatex (ClutterFixed angle,
|
||||
void cogl_rotatex (CoglFixed angle,
|
||||
gint x,
|
||||
gint y,
|
||||
gint z);
|
||||
@ -491,32 +491,32 @@ void cogl_rotate (gint angle,
|
||||
|
||||
/**
|
||||
* cogl_get_modelview_matrix:
|
||||
* @m: pointer to a 4x4 array of #ClutterFixed<!-- -->s to receive the matrix
|
||||
* @m: pointer to a 4x4 array of #CoglFixed<!-- -->s to receive the matrix
|
||||
*
|
||||
* Stores the current model-view matrix in @m. The matrix is in
|
||||
* column-major order.
|
||||
*/
|
||||
void cogl_get_modelview_matrix (ClutterFixed m[16]);
|
||||
void cogl_get_modelview_matrix (CoglFixed m[16]);
|
||||
|
||||
/**
|
||||
* cogl_get_projection_matrix:
|
||||
* @m: pointer to a 4x4 array of #ClutterFixed<!-- -->s to receive the matrix
|
||||
* @m: pointer to a 4x4 array of #CoglFixed<!-- -->s to receive the matrix
|
||||
*
|
||||
* Stores the current projection matrix in @m. The matrix is in
|
||||
* column-major order.
|
||||
*/
|
||||
void cogl_get_projection_matrix (ClutterFixed m[16]);
|
||||
void cogl_get_projection_matrix (CoglFixed m[16]);
|
||||
|
||||
/**
|
||||
* cogl_get_viewport:
|
||||
* @v: pointer to a 4 element array of #ClutterFixed<!-- -->s to
|
||||
* @v: pointer to a 4 element array of #CoglFixed<!-- -->s 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 (ClutterFixed v[4]);
|
||||
void cogl_get_viewport (CoglFixed v[4]);
|
||||
|
||||
/**
|
||||
* cogl_clip_set:
|
||||
@ -531,10 +531,10 @@ void cogl_get_viewport (ClutterFixed v[4]);
|
||||
* be displayed. The rectangle dimensions are transformed by the
|
||||
* current model-view matrix.
|
||||
*/
|
||||
void cogl_clip_set (ClutterFixed x_offset,
|
||||
ClutterFixed y_offset,
|
||||
ClutterFixed width,
|
||||
ClutterFixed height);
|
||||
void cogl_clip_set (CoglFixed x_offset,
|
||||
CoglFixed y_offset,
|
||||
CoglFixed width,
|
||||
CoglFixed height);
|
||||
|
||||
/**
|
||||
* cogl_clip_unset:
|
||||
@ -602,7 +602,7 @@ void cogl_enable_backface_culling (gboolean setting);
|
||||
* initial reference value is 1.0.
|
||||
*/
|
||||
void cogl_alpha_func (COGLenum func,
|
||||
ClutterFixed ref);
|
||||
CoglFixed ref);
|
||||
|
||||
/**
|
||||
* cogl_fog_set:
|
||||
@ -619,9 +619,9 @@ void cogl_alpha_func (COGLenum func,
|
||||
* cogl_paint_init().
|
||||
*/
|
||||
void cogl_fog_set (const ClutterColor *fog_color,
|
||||
ClutterFixed density,
|
||||
ClutterFixed z_near,
|
||||
ClutterFixed z_far);
|
||||
CoglFixed density,
|
||||
CoglFixed z_near,
|
||||
CoglFixed z_far);
|
||||
|
||||
/**
|
||||
* cogl_paint_init:
|
||||
@ -954,14 +954,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,
|
||||
ClutterFixed x1,
|
||||
ClutterFixed y1,
|
||||
ClutterFixed x2,
|
||||
ClutterFixed y2,
|
||||
ClutterFixed tx1,
|
||||
ClutterFixed ty1,
|
||||
ClutterFixed tx2,
|
||||
ClutterFixed ty2);
|
||||
CoglFixed x1,
|
||||
CoglFixed y1,
|
||||
CoglFixed x2,
|
||||
CoglFixed y2,
|
||||
CoglFixed tx1,
|
||||
CoglFixed ty1,
|
||||
CoglFixed tx2,
|
||||
CoglFixed ty2);
|
||||
|
||||
/**
|
||||
* cogl_texture_polygon:
|
||||
@ -1051,10 +1051,10 @@ void cogl_rectangle (gint x,
|
||||
*
|
||||
* A fixed-point version of cogl_fast_fill_rectangle.
|
||||
**/
|
||||
void cogl_rectanglex (ClutterFixed x,
|
||||
ClutterFixed y,
|
||||
ClutterFixed width,
|
||||
ClutterFixed height);
|
||||
void cogl_rectanglex (CoglFixed x,
|
||||
CoglFixed y,
|
||||
CoglFixed width,
|
||||
CoglFixed height);
|
||||
|
||||
/**
|
||||
* cogl_path_fill:
|
||||
@ -1081,8 +1081,8 @@ void cogl_path_stroke (void);
|
||||
* Clears the previously constructed shape and begins a new path
|
||||
* contour by moving the pen to the given coordinates.
|
||||
**/
|
||||
void cogl_path_move_to (ClutterFixed x,
|
||||
ClutterFixed y);
|
||||
void cogl_path_move_to (CoglFixed x,
|
||||
CoglFixed y);
|
||||
|
||||
|
||||
/**
|
||||
@ -1094,8 +1094,8 @@ void cogl_path_move_to (ClutterFixed x,
|
||||
* contour by moving the pen to the given coordinates relative
|
||||
* to the current pen location.
|
||||
**/
|
||||
void cogl_path_rel_move_to (ClutterFixed x,
|
||||
ClutterFixed y);
|
||||
void cogl_path_rel_move_to (CoglFixed x,
|
||||
CoglFixed y);
|
||||
|
||||
/**
|
||||
* cogl_path_line_to:
|
||||
@ -1105,8 +1105,8 @@ void cogl_path_rel_move_to (ClutterFixed x,
|
||||
* Adds a straight line segment to the current path that ends at the
|
||||
* given coordinates.
|
||||
**/
|
||||
void cogl_path_line_to (ClutterFixed x,
|
||||
ClutterFixed y);
|
||||
void cogl_path_line_to (CoglFixed x,
|
||||
CoglFixed y);
|
||||
|
||||
/**
|
||||
* cogl_path_rel_line_to:
|
||||
@ -1116,8 +1116,8 @@ void cogl_path_line_to (ClutterFixed 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 (ClutterFixed x,
|
||||
ClutterFixed y);
|
||||
void cogl_path_rel_line_to (CoglFixed x,
|
||||
CoglFixed y);
|
||||
|
||||
|
||||
/**
|
||||
@ -1134,12 +1134,12 @@ void cogl_path_rel_line_to (ClutterFixed 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 (ClutterFixed center_x,
|
||||
ClutterFixed center_y,
|
||||
ClutterFixed radius_x,
|
||||
ClutterFixed radius_y,
|
||||
ClutterAngle angle_1,
|
||||
ClutterAngle angle_2);
|
||||
void cogl_path_arc (CoglFixed center_x,
|
||||
CoglFixed center_y,
|
||||
CoglFixed radius_x,
|
||||
CoglFixed radius_y,
|
||||
CoglAngle angle_1,
|
||||
CoglAngle angle_2);
|
||||
|
||||
|
||||
|
||||
@ -1156,12 +1156,12 @@ void cogl_path_arc (ClutterFixed center_x,
|
||||
* second, third and fourth control points and using current pen location
|
||||
* as the first control point.
|
||||
**/
|
||||
void cogl_path_curve_to (ClutterFixed x1,
|
||||
ClutterFixed y1,
|
||||
ClutterFixed x2,
|
||||
ClutterFixed y2,
|
||||
ClutterFixed x3,
|
||||
ClutterFixed y3);
|
||||
void cogl_path_curve_to (CoglFixed x1,
|
||||
CoglFixed y1,
|
||||
CoglFixed x2,
|
||||
CoglFixed y2,
|
||||
CoglFixed x3,
|
||||
CoglFixed y3);
|
||||
|
||||
/**
|
||||
* cogl_path_rel_curve_to:
|
||||
@ -1177,12 +1177,12 @@ void cogl_path_curve_to (ClutterFixed x1,
|
||||
* as the first control point. The given coordinates are relative to the
|
||||
* current pen location.
|
||||
*/
|
||||
void cogl_path_rel_curve_to (ClutterFixed x1,
|
||||
ClutterFixed y1,
|
||||
ClutterFixed x2,
|
||||
ClutterFixed y2,
|
||||
ClutterFixed x3,
|
||||
ClutterFixed y3);
|
||||
void cogl_path_rel_curve_to (CoglFixed x1,
|
||||
CoglFixed y1,
|
||||
CoglFixed x2,
|
||||
CoglFixed y2,
|
||||
CoglFixed x3,
|
||||
CoglFixed y3);
|
||||
|
||||
/**
|
||||
* cogl_path_close:
|
||||
@ -1202,10 +1202,10 @@ void cogl_path_close (void);
|
||||
* Clears the previously constructed shape and constructs a straight
|
||||
* line shape start and ending at the given coordinates.
|
||||
**/
|
||||
void cogl_path_line (ClutterFixed x1,
|
||||
ClutterFixed y1,
|
||||
ClutterFixed x2,
|
||||
ClutterFixed y2);
|
||||
void cogl_path_line (CoglFixed x1,
|
||||
CoglFixed y1,
|
||||
CoglFixed x2,
|
||||
CoglFixed y2);
|
||||
|
||||
/**
|
||||
* cogl_path_polyline:
|
||||
@ -1224,8 +1224,8 @@ void cogl_path_line (ClutterFixed x1,
|
||||
* fashion for the rest of the vertices. (num_points - 1) segments will
|
||||
* be constructed.
|
||||
**/
|
||||
void cogl_path_polyline (ClutterFixed *coords,
|
||||
gint num_points);
|
||||
void cogl_path_polyline (CoglFixed *coords,
|
||||
gint num_points);
|
||||
|
||||
|
||||
/**
|
||||
@ -1242,8 +1242,8 @@ void cogl_path_polyline (ClutterFixed *coords,
|
||||
* represents the Y coordinate of the first vertex, continuing in the same
|
||||
* fashion for the rest of the vertices.
|
||||
**/
|
||||
void cogl_path_polygon (ClutterFixed *coords,
|
||||
gint num_points);
|
||||
void cogl_path_polygon (CoglFixed *coords,
|
||||
gint num_points);
|
||||
|
||||
|
||||
/**
|
||||
@ -1256,10 +1256,10 @@ void cogl_path_polygon (ClutterFixed *coords,
|
||||
* Clears the previously constructed shape and constructs a rectangular
|
||||
* shape at the given coordinates.
|
||||
**/
|
||||
void cogl_path_rectangle (ClutterFixed x,
|
||||
ClutterFixed y,
|
||||
ClutterFixed width,
|
||||
ClutterFixed height);
|
||||
void cogl_path_rectangle (CoglFixed x,
|
||||
CoglFixed y,
|
||||
CoglFixed width,
|
||||
CoglFixed height);
|
||||
|
||||
/**
|
||||
* cogl_path_ellipse:
|
||||
@ -1271,10 +1271,10 @@ void cogl_path_rectangle (ClutterFixed x,
|
||||
* Clears the previously constructed shape and constructs an ellipse
|
||||
* shape.
|
||||
**/
|
||||
void cogl_path_ellipse (ClutterFixed center_x,
|
||||
ClutterFixed center_y,
|
||||
ClutterFixed radius_x,
|
||||
ClutterFixed radius_y);
|
||||
void cogl_path_ellipse (CoglFixed center_x,
|
||||
CoglFixed center_y,
|
||||
CoglFixed radius_x,
|
||||
CoglFixed radius_y);
|
||||
|
||||
/**
|
||||
* cogl_path_round_rectangle:
|
||||
@ -1289,12 +1289,12 @@ void cogl_path_ellipse (ClutterFixed center_x,
|
||||
* Clears the previously constructed shape and constructs a rectangular
|
||||
* shape with rounded corners.
|
||||
**/
|
||||
void cogl_path_round_rectangle (ClutterFixed x,
|
||||
ClutterFixed y,
|
||||
ClutterFixed width,
|
||||
ClutterFixed height,
|
||||
ClutterFixed radius,
|
||||
ClutterAngle arc_step);
|
||||
void cogl_path_round_rectangle (CoglFixed x,
|
||||
CoglFixed y,
|
||||
CoglFixed width,
|
||||
CoglFixed height,
|
||||
CoglFixed radius,
|
||||
CoglAngle arc_step);
|
||||
|
||||
/**
|
||||
* SECTION:cogl-shaders
|
||||
|
@ -25,4 +25,5 @@ libclutter_cogl_common_la_SOURCES = \
|
||||
cogl-primitives.c \
|
||||
cogl-bitmap-pixbuf.c \
|
||||
cogl-clip-stack.h \
|
||||
cogl-clip-stack.c
|
||||
cogl-clip-stack.c \
|
||||
cogl-fixed.c
|
||||
|
@ -32,19 +32,19 @@
|
||||
|
||||
/* These are defined in the particular backend (float in GL vs fixed
|
||||
in GL ES) */
|
||||
void _cogl_set_clip_planes (ClutterFixed x,
|
||||
ClutterFixed y,
|
||||
ClutterFixed width,
|
||||
ClutterFixed height);
|
||||
void _cogl_set_clip_planes (CoglFixed x,
|
||||
CoglFixed y,
|
||||
CoglFixed width,
|
||||
CoglFixed height);
|
||||
void _cogl_init_stencil_buffer (void);
|
||||
void _cogl_add_stencil_clip (ClutterFixed x,
|
||||
ClutterFixed y,
|
||||
ClutterFixed width,
|
||||
ClutterFixed height,
|
||||
void _cogl_add_stencil_clip (CoglFixed x,
|
||||
CoglFixed y,
|
||||
CoglFixed width,
|
||||
CoglFixed height,
|
||||
gboolean first);
|
||||
void _cogl_disable_clip_planes (void);
|
||||
void _cogl_disable_stencil_buffer (void);
|
||||
void _cogl_set_matrix (const ClutterFixed *matrix);
|
||||
void _cogl_set_matrix (const CoglFixed *matrix);
|
||||
|
||||
typedef struct _CoglClipStackEntry CoglClipStackEntry;
|
||||
|
||||
@ -57,13 +57,13 @@ struct _CoglClipStackEntry
|
||||
gboolean clear;
|
||||
|
||||
/* The rectangle for this clip */
|
||||
ClutterFixed x_offset;
|
||||
ClutterFixed y_offset;
|
||||
ClutterFixed width;
|
||||
ClutterFixed height;
|
||||
CoglFixed x_offset;
|
||||
CoglFixed y_offset;
|
||||
CoglFixed width;
|
||||
CoglFixed height;
|
||||
|
||||
/* The matrix that was current when the clip was set */
|
||||
ClutterFixed matrix[16];
|
||||
CoglFixed matrix[16];
|
||||
};
|
||||
|
||||
static GList *cogl_clip_stack_top = NULL;
|
||||
@ -90,10 +90,10 @@ _cogl_clip_stack_add (const CoglClipStackEntry *entry, int depth)
|
||||
}
|
||||
|
||||
void
|
||||
cogl_clip_set (ClutterFixed x_offset,
|
||||
ClutterFixed y_offset,
|
||||
ClutterFixed width,
|
||||
ClutterFixed height)
|
||||
cogl_clip_set (CoglFixed x_offset,
|
||||
CoglFixed y_offset,
|
||||
CoglFixed width,
|
||||
CoglFixed height)
|
||||
{
|
||||
CoglClipStackEntry *entry = g_slice_new (CoglClipStackEntry);
|
||||
|
||||
|
911
common/cogl-fixed.c
Normal file
911
common/cogl-fixed.c
Normal file
@ -0,0 +1,911 @@
|
||||
#define G_IMPLEMENT_INLINES
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "cogl-fixed.h"
|
||||
|
||||
/* pre-computed sin table for 1st quadrant
|
||||
*
|
||||
* Currently contains 257 entries.
|
||||
*
|
||||
* The current error (compared to system sin) is about
|
||||
* 0.5% for values near the start of the table where the
|
||||
* curve is steep, but improving rapidly. If this precision
|
||||
* is not enough, we can increase the size of the table
|
||||
*/
|
||||
static const CoglFixed sin_tbl[] =
|
||||
{
|
||||
0x00000000L, 0x00000192L, 0x00000324L, 0x000004B6L,
|
||||
0x00000648L, 0x000007DAL, 0x0000096CL, 0x00000AFEL,
|
||||
0x00000C90L, 0x00000E21L, 0x00000FB3L, 0x00001144L,
|
||||
0x000012D5L, 0x00001466L, 0x000015F7L, 0x00001787L,
|
||||
0x00001918L, 0x00001AA8L, 0x00001C38L, 0x00001DC7L,
|
||||
0x00001F56L, 0x000020E5L, 0x00002274L, 0x00002402L,
|
||||
0x00002590L, 0x0000271EL, 0x000028ABL, 0x00002A38L,
|
||||
0x00002BC4L, 0x00002D50L, 0x00002EDCL, 0x00003067L,
|
||||
0x000031F1L, 0x0000337CL, 0x00003505L, 0x0000368EL,
|
||||
0x00003817L, 0x0000399FL, 0x00003B27L, 0x00003CAEL,
|
||||
0x00003E34L, 0x00003FBAL, 0x0000413FL, 0x000042C3L,
|
||||
0x00004447L, 0x000045CBL, 0x0000474DL, 0x000048CFL,
|
||||
0x00004A50L, 0x00004BD1L, 0x00004D50L, 0x00004ECFL,
|
||||
0x0000504DL, 0x000051CBL, 0x00005348L, 0x000054C3L,
|
||||
0x0000563EL, 0x000057B9L, 0x00005932L, 0x00005AAAL,
|
||||
0x00005C22L, 0x00005D99L, 0x00005F0FL, 0x00006084L,
|
||||
0x000061F8L, 0x0000636BL, 0x000064DDL, 0x0000664EL,
|
||||
0x000067BEL, 0x0000692DL, 0x00006A9BL, 0x00006C08L,
|
||||
0x00006D74L, 0x00006EDFL, 0x00007049L, 0x000071B2L,
|
||||
0x0000731AL, 0x00007480L, 0x000075E6L, 0x0000774AL,
|
||||
0x000078ADL, 0x00007A10L, 0x00007B70L, 0x00007CD0L,
|
||||
0x00007E2FL, 0x00007F8CL, 0x000080E8L, 0x00008243L,
|
||||
0x0000839CL, 0x000084F5L, 0x0000864CL, 0x000087A1L,
|
||||
0x000088F6L, 0x00008A49L, 0x00008B9AL, 0x00008CEBL,
|
||||
0x00008E3AL, 0x00008F88L, 0x000090D4L, 0x0000921FL,
|
||||
0x00009368L, 0x000094B0L, 0x000095F7L, 0x0000973CL,
|
||||
0x00009880L, 0x000099C2L, 0x00009B03L, 0x00009C42L,
|
||||
0x00009D80L, 0x00009EBCL, 0x00009FF7L, 0x0000A130L,
|
||||
0x0000A268L, 0x0000A39EL, 0x0000A4D2L, 0x0000A605L,
|
||||
0x0000A736L, 0x0000A866L, 0x0000A994L, 0x0000AAC1L,
|
||||
0x0000ABEBL, 0x0000AD14L, 0x0000AE3CL, 0x0000AF62L,
|
||||
0x0000B086L, 0x0000B1A8L, 0x0000B2C9L, 0x0000B3E8L,
|
||||
0x0000B505L, 0x0000B620L, 0x0000B73AL, 0x0000B852L,
|
||||
0x0000B968L, 0x0000BA7DL, 0x0000BB8FL, 0x0000BCA0L,
|
||||
0x0000BDAFL, 0x0000BEBCL, 0x0000BFC7L, 0x0000C0D1L,
|
||||
0x0000C1D8L, 0x0000C2DEL, 0x0000C3E2L, 0x0000C4E4L,
|
||||
0x0000C5E4L, 0x0000C6E2L, 0x0000C7DEL, 0x0000C8D9L,
|
||||
0x0000C9D1L, 0x0000CAC7L, 0x0000CBBCL, 0x0000CCAEL,
|
||||
0x0000CD9FL, 0x0000CE8EL, 0x0000CF7AL, 0x0000D065L,
|
||||
0x0000D14DL, 0x0000D234L, 0x0000D318L, 0x0000D3FBL,
|
||||
0x0000D4DBL, 0x0000D5BAL, 0x0000D696L, 0x0000D770L,
|
||||
0x0000D848L, 0x0000D91EL, 0x0000D9F2L, 0x0000DAC4L,
|
||||
0x0000DB94L, 0x0000DC62L, 0x0000DD2DL, 0x0000DDF7L,
|
||||
0x0000DEBEL, 0x0000DF83L, 0x0000E046L, 0x0000E107L,
|
||||
0x0000E1C6L, 0x0000E282L, 0x0000E33CL, 0x0000E3F4L,
|
||||
0x0000E4AAL, 0x0000E55EL, 0x0000E610L, 0x0000E6BFL,
|
||||
0x0000E76CL, 0x0000E817L, 0x0000E8BFL, 0x0000E966L,
|
||||
0x0000EA0AL, 0x0000EAABL, 0x0000EB4BL, 0x0000EBE8L,
|
||||
0x0000EC83L, 0x0000ED1CL, 0x0000EDB3L, 0x0000EE47L,
|
||||
0x0000EED9L, 0x0000EF68L, 0x0000EFF5L, 0x0000F080L,
|
||||
0x0000F109L, 0x0000F18FL, 0x0000F213L, 0x0000F295L,
|
||||
0x0000F314L, 0x0000F391L, 0x0000F40CL, 0x0000F484L,
|
||||
0x0000F4FAL, 0x0000F56EL, 0x0000F5DFL, 0x0000F64EL,
|
||||
0x0000F6BAL, 0x0000F724L, 0x0000F78CL, 0x0000F7F1L,
|
||||
0x0000F854L, 0x0000F8B4L, 0x0000F913L, 0x0000F96EL,
|
||||
0x0000F9C8L, 0x0000FA1FL, 0x0000FA73L, 0x0000FAC5L,
|
||||
0x0000FB15L, 0x0000FB62L, 0x0000FBADL, 0x0000FBF5L,
|
||||
0x0000FC3BL, 0x0000FC7FL, 0x0000FCC0L, 0x0000FCFEL,
|
||||
0x0000FD3BL, 0x0000FD74L, 0x0000FDACL, 0x0000FDE1L,
|
||||
0x0000FE13L, 0x0000FE43L, 0x0000FE71L, 0x0000FE9CL,
|
||||
0x0000FEC4L, 0x0000FEEBL, 0x0000FF0EL, 0x0000FF30L,
|
||||
0x0000FF4EL, 0x0000FF6BL, 0x0000FF85L, 0x0000FF9CL,
|
||||
0x0000FFB1L, 0x0000FFC4L, 0x0000FFD4L, 0x0000FFE1L,
|
||||
0x0000FFECL, 0x0000FFF5L, 0x0000FFFBL, 0x0000FFFFL,
|
||||
0x00010000L,
|
||||
};
|
||||
|
||||
/* pre-computed tan table for 1st quadrant */
|
||||
static const CoglFixed tan_tbl[] =
|
||||
{
|
||||
0x00000000L, 0x00000192L, 0x00000324L, 0x000004b7L,
|
||||
0x00000649L, 0x000007dbL, 0x0000096eL, 0x00000b01L,
|
||||
0x00000c94L, 0x00000e27L, 0x00000fbaL, 0x0000114eL,
|
||||
0x000012e2L, 0x00001477L, 0x0000160cL, 0x000017a1L,
|
||||
0x00001937L, 0x00001acdL, 0x00001c64L, 0x00001dfbL,
|
||||
0x00001f93L, 0x0000212cL, 0x000022c5L, 0x0000245fL,
|
||||
0x000025f9L, 0x00002795L, 0x00002931L, 0x00002aceL,
|
||||
0x00002c6cL, 0x00002e0aL, 0x00002faaL, 0x0000314aL,
|
||||
0x000032ecL, 0x0000348eL, 0x00003632L, 0x000037d7L,
|
||||
0x0000397dL, 0x00003b24L, 0x00003cccL, 0x00003e75L,
|
||||
0x00004020L, 0x000041ccL, 0x00004379L, 0x00004528L,
|
||||
0x000046d8L, 0x0000488aL, 0x00004a3dL, 0x00004bf2L,
|
||||
0x00004da8L, 0x00004f60L, 0x0000511aL, 0x000052d5L,
|
||||
0x00005492L, 0x00005651L, 0x00005812L, 0x000059d5L,
|
||||
0x00005b99L, 0x00005d60L, 0x00005f28L, 0x000060f3L,
|
||||
0x000062c0L, 0x0000648fL, 0x00006660L, 0x00006834L,
|
||||
0x00006a0aL, 0x00006be2L, 0x00006dbdL, 0x00006f9aL,
|
||||
0x0000717aL, 0x0000735dL, 0x00007542L, 0x0000772aL,
|
||||
0x00007914L, 0x00007b02L, 0x00007cf2L, 0x00007ee6L,
|
||||
0x000080dcL, 0x000082d6L, 0x000084d2L, 0x000086d2L,
|
||||
0x000088d6L, 0x00008adcL, 0x00008ce7L, 0x00008ef4L,
|
||||
0x00009106L, 0x0000931bL, 0x00009534L, 0x00009750L,
|
||||
0x00009971L, 0x00009b95L, 0x00009dbeL, 0x00009febL,
|
||||
0x0000a21cL, 0x0000a452L, 0x0000a68cL, 0x0000a8caL,
|
||||
0x0000ab0eL, 0x0000ad56L, 0x0000afa3L, 0x0000b1f5L,
|
||||
0x0000b44cL, 0x0000b6a8L, 0x0000b909L, 0x0000bb70L,
|
||||
0x0000bdddL, 0x0000c04fL, 0x0000c2c7L, 0x0000c545L,
|
||||
0x0000c7c9L, 0x0000ca53L, 0x0000cce3L, 0x0000cf7aL,
|
||||
0x0000d218L, 0x0000d4bcL, 0x0000d768L, 0x0000da1aL,
|
||||
0x0000dcd4L, 0x0000df95L, 0x0000e25eL, 0x0000e52eL,
|
||||
0x0000e806L, 0x0000eae7L, 0x0000edd0L, 0x0000f0c1L,
|
||||
0x0000f3bbL, 0x0000f6bfL, 0x0000f9cbL, 0x0000fce1L,
|
||||
0x00010000L, 0x00010329L, 0x0001065dL, 0x0001099aL,
|
||||
0x00010ce3L, 0x00011036L, 0x00011394L, 0x000116feL,
|
||||
0x00011a74L, 0x00011df6L, 0x00012184L, 0x0001251fL,
|
||||
0x000128c6L, 0x00012c7cL, 0x0001303fL, 0x00013410L,
|
||||
0x000137f0L, 0x00013bdfL, 0x00013fddL, 0x000143ebL,
|
||||
0x00014809L, 0x00014c37L, 0x00015077L, 0x000154c9L,
|
||||
0x0001592dL, 0x00015da4L, 0x0001622eL, 0x000166ccL,
|
||||
0x00016b7eL, 0x00017045L, 0x00017523L, 0x00017a17L,
|
||||
0x00017f22L, 0x00018444L, 0x00018980L, 0x00018ed5L,
|
||||
0x00019445L, 0x000199cfL, 0x00019f76L, 0x0001a53aL,
|
||||
0x0001ab1cL, 0x0001b11dL, 0x0001b73fL, 0x0001bd82L,
|
||||
0x0001c3e7L, 0x0001ca71L, 0x0001d11fL, 0x0001d7f4L,
|
||||
0x0001def1L, 0x0001e618L, 0x0001ed6aL, 0x0001f4e8L,
|
||||
0x0001fc96L, 0x00020473L, 0x00020c84L, 0x000214c9L,
|
||||
0x00021d44L, 0x000225f9L, 0x00022ee9L, 0x00023818L,
|
||||
0x00024187L, 0x00024b3aL, 0x00025534L, 0x00025f78L,
|
||||
0x00026a0aL, 0x000274edL, 0x00028026L, 0x00028bb8L,
|
||||
0x000297a8L, 0x0002a3fbL, 0x0002b0b5L, 0x0002bdddL,
|
||||
0x0002cb79L, 0x0002d98eL, 0x0002e823L, 0x0002f740L,
|
||||
0x000306ecL, 0x00031730L, 0x00032816L, 0x000339a6L,
|
||||
0x00034bebL, 0x00035ef2L, 0x000372c6L, 0x00038776L,
|
||||
0x00039d11L, 0x0003b3a6L, 0x0003cb48L, 0x0003e40aL,
|
||||
0x0003fe02L, 0x00041949L, 0x000435f7L, 0x0004542bL,
|
||||
0x00047405L, 0x000495a9L, 0x0004b940L, 0x0004def6L,
|
||||
0x00050700L, 0x00053196L, 0x00055ef9L, 0x00058f75L,
|
||||
0x0005c35dL, 0x0005fb14L, 0x00063709L, 0x000677c0L,
|
||||
0x0006bdd0L, 0x000709ecL, 0x00075ce6L, 0x0007b7bbL,
|
||||
0x00081b98L, 0x000889e9L, 0x0009046eL, 0x00098d4dL,
|
||||
0x000a2736L, 0x000ad593L, 0x000b9cc6L, 0x000c828aL,
|
||||
0x000d8e82L, 0x000ecb1bL, 0x001046eaL, 0x00121703L,
|
||||
0x00145b00L, 0x0017448dL, 0x001b2672L, 0x002095afL,
|
||||
0x0028bc49L, 0x0036519aL, 0x00517bb6L, 0x00a2f8fdL,
|
||||
0x46d3eab2L,
|
||||
};
|
||||
|
||||
/* 257-value table of atan.
|
||||
*
|
||||
* atan_tbl[0] is atan(0.0) and atan_tbl[256] is atan(1).
|
||||
* The angles are radians in CoglFixed truncated to 16-bit (they're
|
||||
* all less than one)
|
||||
*/
|
||||
static const guint16 atan_tbl[] =
|
||||
{
|
||||
0x0000, 0x00FF, 0x01FF, 0x02FF, 0x03FF, 0x04FF, 0x05FF, 0x06FF,
|
||||
0x07FF, 0x08FF, 0x09FE, 0x0AFE, 0x0BFD, 0x0CFD, 0x0DFC, 0x0EFB,
|
||||
0x0FFA, 0x10F9, 0x11F8, 0x12F7, 0x13F5, 0x14F3, 0x15F2, 0x16F0,
|
||||
0x17EE, 0x18EB, 0x19E9, 0x1AE6, 0x1BE3, 0x1CE0, 0x1DDD, 0x1ED9,
|
||||
0x1FD5, 0x20D1, 0x21CD, 0x22C8, 0x23C3, 0x24BE, 0x25B9, 0x26B3,
|
||||
0x27AD, 0x28A7, 0x29A1, 0x2A9A, 0x2B93, 0x2C8B, 0x2D83, 0x2E7B,
|
||||
0x2F72, 0x306A, 0x3160, 0x3257, 0x334D, 0x3442, 0x3538, 0x362D,
|
||||
0x3721, 0x3815, 0x3909, 0x39FC, 0x3AEF, 0x3BE2, 0x3CD4, 0x3DC5,
|
||||
0x3EB6, 0x3FA7, 0x4097, 0x4187, 0x4277, 0x4365, 0x4454, 0x4542,
|
||||
0x462F, 0x471C, 0x4809, 0x48F5, 0x49E0, 0x4ACB, 0x4BB6, 0x4CA0,
|
||||
0x4D89, 0x4E72, 0x4F5B, 0x5043, 0x512A, 0x5211, 0x52F7, 0x53DD,
|
||||
0x54C2, 0x55A7, 0x568B, 0x576F, 0x5852, 0x5934, 0x5A16, 0x5AF7,
|
||||
0x5BD8, 0x5CB8, 0x5D98, 0x5E77, 0x5F55, 0x6033, 0x6110, 0x61ED,
|
||||
0x62C9, 0x63A4, 0x647F, 0x6559, 0x6633, 0x670C, 0x67E4, 0x68BC,
|
||||
0x6993, 0x6A6A, 0x6B40, 0x6C15, 0x6CEA, 0x6DBE, 0x6E91, 0x6F64,
|
||||
0x7036, 0x7108, 0x71D9, 0x72A9, 0x7379, 0x7448, 0x7516, 0x75E4,
|
||||
0x76B1, 0x777E, 0x7849, 0x7915, 0x79DF, 0x7AA9, 0x7B72, 0x7C3B,
|
||||
0x7D03, 0x7DCA, 0x7E91, 0x7F57, 0x801C, 0x80E1, 0x81A5, 0x8269,
|
||||
0x832B, 0x83EE, 0x84AF, 0x8570, 0x8630, 0x86F0, 0x87AF, 0x886D,
|
||||
0x892A, 0x89E7, 0x8AA4, 0x8B5F, 0x8C1A, 0x8CD5, 0x8D8E, 0x8E47,
|
||||
0x8F00, 0x8FB8, 0x906F, 0x9125, 0x91DB, 0x9290, 0x9345, 0x93F9,
|
||||
0x94AC, 0x955F, 0x9611, 0x96C2, 0x9773, 0x9823, 0x98D2, 0x9981,
|
||||
0x9A2F, 0x9ADD, 0x9B89, 0x9C36, 0x9CE1, 0x9D8C, 0x9E37, 0x9EE0,
|
||||
0x9F89, 0xA032, 0xA0DA, 0xA181, 0xA228, 0xA2CE, 0xA373, 0xA418,
|
||||
0xA4BC, 0xA560, 0xA602, 0xA6A5, 0xA746, 0xA7E8, 0xA888, 0xA928,
|
||||
0xA9C7, 0xAA66, 0xAB04, 0xABA1, 0xAC3E, 0xACDB, 0xAD76, 0xAE11,
|
||||
0xAEAC, 0xAF46, 0xAFDF, 0xB078, 0xB110, 0xB1A7, 0xB23E, 0xB2D5,
|
||||
0xB36B, 0xB400, 0xB495, 0xB529, 0xB5BC, 0xB64F, 0xB6E2, 0xB773,
|
||||
0xB805, 0xB895, 0xB926, 0xB9B5, 0xBA44, 0xBAD3, 0xBB61, 0xBBEE,
|
||||
0xBC7B, 0xBD07, 0xBD93, 0xBE1E, 0xBEA9, 0xBF33, 0xBFBC, 0xC046,
|
||||
0xC0CE, 0xC156, 0xC1DD, 0xC264, 0xC2EB, 0xC371, 0xC3F6, 0xC47B,
|
||||
0xC4FF, 0xC583, 0xC606, 0xC689, 0xC70B, 0xC78D, 0xC80E, 0xC88F,
|
||||
0xC90F
|
||||
};
|
||||
|
||||
/* look up table for square root */
|
||||
static const CoglFixed sqrt_tbl[] =
|
||||
{
|
||||
0x00000000L, 0x00010000L, 0x00016A0AL, 0x0001BB68L,
|
||||
0x00020000L, 0x00023C6FL, 0x00027312L, 0x0002A550L,
|
||||
0x0002D414L, 0x00030000L, 0x0003298BL, 0x0003510EL,
|
||||
0x000376CFL, 0x00039B05L, 0x0003BDDDL, 0x0003DF7CL,
|
||||
0x00040000L, 0x00041F84L, 0x00043E1EL, 0x00045BE1L,
|
||||
0x000478DEL, 0x00049524L, 0x0004B0BFL, 0x0004CBBCL,
|
||||
0x0004E624L, 0x00050000L, 0x00051959L, 0x00053237L,
|
||||
0x00054AA0L, 0x0005629AL, 0x00057A2BL, 0x00059159L,
|
||||
0x0005A828L, 0x0005BE9CL, 0x0005D4B9L, 0x0005EA84L,
|
||||
0x00060000L, 0x00061530L, 0x00062A17L, 0x00063EB8L,
|
||||
0x00065316L, 0x00066733L, 0x00067B12L, 0x00068EB4L,
|
||||
0x0006A21DL, 0x0006B54DL, 0x0006C847L, 0x0006DB0CL,
|
||||
0x0006ED9FL, 0x00070000L, 0x00071232L, 0x00072435L,
|
||||
0x0007360BL, 0x000747B5L, 0x00075935L, 0x00076A8CL,
|
||||
0x00077BBBL, 0x00078CC2L, 0x00079DA3L, 0x0007AE60L,
|
||||
0x0007BEF8L, 0x0007CF6DL, 0x0007DFBFL, 0x0007EFF0L,
|
||||
0x00080000L, 0x00080FF0L, 0x00081FC1L, 0x00082F73L,
|
||||
0x00083F08L, 0x00084E7FL, 0x00085DDAL, 0x00086D18L,
|
||||
0x00087C3BL, 0x00088B44L, 0x00089A32L, 0x0008A906L,
|
||||
0x0008B7C2L, 0x0008C664L, 0x0008D4EEL, 0x0008E361L,
|
||||
0x0008F1BCL, 0x00090000L, 0x00090E2EL, 0x00091C45L,
|
||||
0x00092A47L, 0x00093834L, 0x0009460CL, 0x000953CFL,
|
||||
0x0009617EL, 0x00096F19L, 0x00097CA1L, 0x00098A16L,
|
||||
0x00099777L, 0x0009A4C6L, 0x0009B203L, 0x0009BF2EL,
|
||||
0x0009CC47L, 0x0009D94FL, 0x0009E645L, 0x0009F32BL,
|
||||
0x000A0000L, 0x000A0CC5L, 0x000A1979L, 0x000A261EL,
|
||||
0x000A32B3L, 0x000A3F38L, 0x000A4BAEL, 0x000A5816L,
|
||||
0x000A646EL, 0x000A70B8L, 0x000A7CF3L, 0x000A8921L,
|
||||
0x000A9540L, 0x000AA151L, 0x000AAD55L, 0x000AB94BL,
|
||||
0x000AC534L, 0x000AD110L, 0x000ADCDFL, 0x000AE8A1L,
|
||||
0x000AF457L, 0x000B0000L, 0x000B0B9DL, 0x000B172DL,
|
||||
0x000B22B2L, 0x000B2E2BL, 0x000B3998L, 0x000B44F9L,
|
||||
0x000B504FL, 0x000B5B9AL, 0x000B66D9L, 0x000B720EL,
|
||||
0x000B7D37L, 0x000B8856L, 0x000B936AL, 0x000B9E74L,
|
||||
0x000BA973L, 0x000BB467L, 0x000BBF52L, 0x000BCA32L,
|
||||
0x000BD508L, 0x000BDFD5L, 0x000BEA98L, 0x000BF551L,
|
||||
0x000C0000L, 0x000C0AA6L, 0x000C1543L, 0x000C1FD6L,
|
||||
0x000C2A60L, 0x000C34E1L, 0x000C3F59L, 0x000C49C8L,
|
||||
0x000C542EL, 0x000C5E8CL, 0x000C68E0L, 0x000C732DL,
|
||||
0x000C7D70L, 0x000C87ACL, 0x000C91DFL, 0x000C9C0AL,
|
||||
0x000CA62CL, 0x000CB047L, 0x000CBA59L, 0x000CC464L,
|
||||
0x000CCE66L, 0x000CD861L, 0x000CE254L, 0x000CEC40L,
|
||||
0x000CF624L, 0x000D0000L, 0x000D09D5L, 0x000D13A2L,
|
||||
0x000D1D69L, 0x000D2727L, 0x000D30DFL, 0x000D3A90L,
|
||||
0x000D4439L, 0x000D4DDCL, 0x000D5777L, 0x000D610CL,
|
||||
0x000D6A9AL, 0x000D7421L, 0x000D7DA1L, 0x000D871BL,
|
||||
0x000D908EL, 0x000D99FAL, 0x000DA360L, 0x000DACBFL,
|
||||
0x000DB618L, 0x000DBF6BL, 0x000DC8B7L, 0x000DD1FEL,
|
||||
0x000DDB3DL, 0x000DE477L, 0x000DEDABL, 0x000DF6D8L,
|
||||
0x000E0000L, 0x000E0922L, 0x000E123DL, 0x000E1B53L,
|
||||
0x000E2463L, 0x000E2D6DL, 0x000E3672L, 0x000E3F70L,
|
||||
0x000E4869L, 0x000E515DL, 0x000E5A4BL, 0x000E6333L,
|
||||
0x000E6C16L, 0x000E74F3L, 0x000E7DCBL, 0x000E869DL,
|
||||
0x000E8F6BL, 0x000E9832L, 0x000EA0F5L, 0x000EA9B2L,
|
||||
0x000EB26BL, 0x000EBB1EL, 0x000EC3CBL, 0x000ECC74L,
|
||||
0x000ED518L, 0x000EDDB7L, 0x000EE650L, 0x000EEEE5L,
|
||||
0x000EF775L, 0x000F0000L, 0x000F0886L, 0x000F1107L,
|
||||
0x000F1984L, 0x000F21FCL, 0x000F2A6FL, 0x000F32DDL,
|
||||
0x000F3B47L, 0x000F43ACL, 0x000F4C0CL, 0x000F5468L,
|
||||
0x000F5CBFL, 0x000F6512L, 0x000F6D60L, 0x000F75AAL,
|
||||
0x000F7DEFL, 0x000F8630L, 0x000F8E6DL, 0x000F96A5L,
|
||||
0x000F9ED9L, 0x000FA709L, 0x000FAF34L, 0x000FB75BL,
|
||||
0x000FBF7EL, 0x000FC79DL, 0x000FCFB7L, 0x000FD7CEL,
|
||||
0x000FDFE0L, 0x000FE7EEL, 0x000FEFF8L, 0x000FF7FEL,
|
||||
0x00100000L,
|
||||
};
|
||||
|
||||
/* the difference of the angle for two adjacent values in the
|
||||
* sin_tbl table, expressed as CoglFixed number
|
||||
*/
|
||||
#define COGL_SIN_STEP 0x00000192
|
||||
|
||||
static const double _magic = 68719476736.0 * 1.5;
|
||||
|
||||
/* Where in the 64 bits of double is the mantissa.
|
||||
*
|
||||
* FIXME - this should go inside the configure.ac
|
||||
*/
|
||||
#if (__FLOAT_WORD_ORDER == 1234)
|
||||
#define _COGL_MAN 0
|
||||
#elif (__FLOAT_WORD_ORDER == 4321)
|
||||
#define _COGL_MAN 1
|
||||
#else
|
||||
#define COGL_NO_FAST_CONVERSIONS
|
||||
#endif
|
||||
|
||||
/*
|
||||
* cogl_double_to_fixed :
|
||||
* @value: value to be converted
|
||||
*
|
||||
* A fast conversion from double precision floating to fixed point
|
||||
*
|
||||
* Return value: Fixed point representation of the value
|
||||
*/
|
||||
CoglFixed
|
||||
cogl_double_to_fixed (double val)
|
||||
{
|
||||
#ifdef COGL_NO_FAST_CONVERSIONS
|
||||
return (CoglFixed) (val * (double) COGL_FIXED_1);
|
||||
#else
|
||||
union {
|
||||
double d;
|
||||
unsigned int i[2];
|
||||
} dbl;
|
||||
|
||||
dbl.d = val;
|
||||
dbl.d = dbl.d + _magic;
|
||||
|
||||
return dbl.i[_COGL_MAN];
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* cogl_double_to_int :
|
||||
* @value: value to be converted
|
||||
*
|
||||
* A fast conversion from doulbe precision floatint point to int;
|
||||
* used this instead of casting double/float to int.
|
||||
*
|
||||
* Return value: Integer part of the double
|
||||
*/
|
||||
gint
|
||||
cogl_double_to_int (double val)
|
||||
{
|
||||
#ifdef COGL_NO_FAST_CONVERSIONS
|
||||
return (gint) (val);
|
||||
#else
|
||||
union {
|
||||
double d;
|
||||
unsigned int i[2];
|
||||
} dbl;
|
||||
|
||||
dbl.d = val;
|
||||
dbl.d = dbl.d + _magic;
|
||||
|
||||
return ((int) dbl.i[_COGL_MAN]) >> 16;
|
||||
#endif
|
||||
}
|
||||
|
||||
guint
|
||||
cogl_double_to_uint (double val)
|
||||
{
|
||||
#ifdef COGL_NO_FAST_CONVERSIONS
|
||||
return (guint)(val);
|
||||
#else
|
||||
union {
|
||||
double d;
|
||||
unsigned int i[2];
|
||||
} dbl;
|
||||
|
||||
dbl.d = val;
|
||||
dbl.d = dbl.d + _magic;
|
||||
|
||||
return (dbl.i[_COGL_MAN]) >> 16;
|
||||
#endif
|
||||
}
|
||||
|
||||
#undef _COGL_MAN
|
||||
|
||||
CoglFixed
|
||||
cogl_fixed_sin (CoglFixed angle)
|
||||
{
|
||||
int sign = 1, indx1, indx2;
|
||||
CoglFixed low, high, d1, d2;
|
||||
|
||||
/* convert negative angle to positive + sign */
|
||||
if ((int) angle < 0)
|
||||
{
|
||||
sign = 1 + ~sign;
|
||||
angle = 1 + ~angle;
|
||||
}
|
||||
|
||||
/* reduce to <0, 2*pi) */
|
||||
angle = angle % COGL_FIXED_2_PI;
|
||||
|
||||
/* reduce to first quadrant and sign */
|
||||
if (angle > COGL_FIXED_PI)
|
||||
{
|
||||
sign = 1 + ~sign;
|
||||
|
||||
if (angle > COGL_FIXED_PI + COGL_FIXED_PI_2)
|
||||
{
|
||||
/* fourth qudrant */
|
||||
angle = COGL_FIXED_2_PI - angle;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* third quadrant */
|
||||
angle -= COGL_FIXED_PI;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (angle > COGL_FIXED_PI_2)
|
||||
{
|
||||
/* second quadrant */
|
||||
angle = COGL_FIXED_PI - angle;
|
||||
}
|
||||
}
|
||||
|
||||
/* Calculate indices of the two nearest values in our table
|
||||
* and return weighted average
|
||||
*
|
||||
* Handle the end of the table gracefully
|
||||
*/
|
||||
indx1 = COGL_FIXED_DIV (angle, COGL_SIN_STEP);
|
||||
indx1 = COGL_FIXED_TO_INT (indx1);
|
||||
|
||||
if (indx1 == (G_N_ELEMENTS (sin_tbl) - 1))
|
||||
{
|
||||
indx2 = indx1;
|
||||
indx1 = indx2 - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
indx2 = indx1 + 1;
|
||||
}
|
||||
|
||||
low = sin_tbl[indx1];
|
||||
high = sin_tbl[indx2];
|
||||
|
||||
d1 = angle - indx1 * COGL_SIN_STEP;
|
||||
d2 = indx2 * COGL_SIN_STEP - angle;
|
||||
|
||||
angle = ((low * d2 + high * d1) / (COGL_SIN_STEP));
|
||||
|
||||
if (sign < 0)
|
||||
angle = (1 + ~angle);
|
||||
|
||||
return angle;
|
||||
}
|
||||
|
||||
CoglFixed
|
||||
cogl_angle_sin (CoglAngle angle)
|
||||
{
|
||||
int sign = 1;
|
||||
CoglFixed result;
|
||||
|
||||
/* reduce negative angle to positive + sign */
|
||||
if (angle < 0)
|
||||
{
|
||||
sign = 1 + ~sign;
|
||||
angle = 1 + ~angle;
|
||||
}
|
||||
|
||||
/* reduce to <0, 2*pi) */
|
||||
angle &= 0x3ff;
|
||||
|
||||
/* reduce to first quadrant and sign */
|
||||
if (angle > 512)
|
||||
{
|
||||
sign = 1 + ~sign;
|
||||
|
||||
if (angle > 768)
|
||||
{
|
||||
/* fourth qudrant */
|
||||
angle = 1024 - angle;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* third quadrant */
|
||||
angle -= 512;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (angle > 256)
|
||||
{
|
||||
/* second quadrant */
|
||||
angle = 512 - angle;
|
||||
}
|
||||
}
|
||||
|
||||
result = sin_tbl[angle];
|
||||
|
||||
if (sign < 0)
|
||||
result = (1 + ~result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
CoglFixed
|
||||
cogl_angle_tan (CoglAngle angle)
|
||||
{
|
||||
int sign = 1;
|
||||
CoglFixed result;
|
||||
|
||||
/* reduce negative angle to positive + sign */
|
||||
if (angle < 0)
|
||||
{
|
||||
sign = 1 + ~sign;
|
||||
angle = 1 + ~angle;
|
||||
}
|
||||
|
||||
/* reduce to <0, pi) */
|
||||
angle &= 0x1ff;
|
||||
|
||||
/* reduce to first quadrant and sign */
|
||||
if (angle > 256)
|
||||
{
|
||||
sign = 1 + ~sign;
|
||||
angle = 512 - angle;
|
||||
}
|
||||
|
||||
result = tan_tbl[angle];
|
||||
|
||||
if (sign < 0)
|
||||
result = (1 + ~result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
CoglFixed
|
||||
cogl_fixed_atan (CoglFixed x)
|
||||
{
|
||||
gboolean negative = FALSE;
|
||||
CoglFixed angle;
|
||||
|
||||
if (x < 0)
|
||||
{
|
||||
negative = TRUE;
|
||||
x = -x;
|
||||
}
|
||||
|
||||
if (x > COGL_FIXED_1)
|
||||
{
|
||||
/* if x > 1 then atan(x) = pi/2 - atan(1/x) */
|
||||
angle = COGL_FIXED_PI / 2
|
||||
- atan_tbl[COGL_FIXED_DIV (COGL_FIXED_1, x) >> 8];
|
||||
}
|
||||
else
|
||||
angle = atan_tbl[x >> 8];
|
||||
|
||||
return negative ? -angle : angle;
|
||||
}
|
||||
|
||||
CoglFixed
|
||||
cogl_fixed_atan2 (CoglFixed y, CoglFixed x)
|
||||
{
|
||||
CoglFixed angle;
|
||||
|
||||
if (x == 0)
|
||||
angle = y >= 0 ? COGL_FIXED_PI_2 : -COGL_FIXED_PI_2;
|
||||
else
|
||||
{
|
||||
angle = cogl_fixed_atan (COGL_FIXED_DIV (y, x));
|
||||
|
||||
if (x < 0)
|
||||
angle += y >= 0 ? COGL_FIXED_PI : -COGL_FIXED_PI;
|
||||
}
|
||||
|
||||
return angle;
|
||||
}
|
||||
|
||||
CoglFixed
|
||||
cogl_fixed_sqrt (CoglFixed x)
|
||||
{
|
||||
/* The idea for this comes from the Alegro library, exploiting the
|
||||
* fact that,
|
||||
* sqrt (x) = sqrt (x/d) * sqrt (d);
|
||||
*
|
||||
* For d == 2^(n):
|
||||
*
|
||||
* sqrt (x) = sqrt (x/2^(2n)) * 2^n
|
||||
*
|
||||
* By locating suitable n for given x such that x >> 2n is in <0,255>
|
||||
* we can use a LUT of precomputed values.
|
||||
*
|
||||
* This algorithm provides both good performance and precision;
|
||||
* on ARM this function is about 5 times faster than c-lib sqrt,
|
||||
* whilst producing errors < 1%.
|
||||
*/
|
||||
int t = 0;
|
||||
int sh = 0;
|
||||
unsigned int mask = 0x40000000;
|
||||
unsigned fract = x & 0x0000ffff;
|
||||
unsigned int d1, d2;
|
||||
CoglFixed v1, v2;
|
||||
|
||||
if (x <= 0)
|
||||
return 0;
|
||||
|
||||
if (x > COGL_FIXED_255 || x < COGL_FIXED_1)
|
||||
{
|
||||
/*
|
||||
* Find the highest bit set
|
||||
*/
|
||||
#if __arm__
|
||||
/* This actually requires at least arm v5, but gcc does not seem
|
||||
* to set the architecture defines correctly, and it is I think
|
||||
* very unlikely that anyone will want to use clutter on anything
|
||||
* less than v5.
|
||||
*/
|
||||
int bit;
|
||||
__asm__ ("clz %0, %1\n"
|
||||
"rsb %0, %0, #31\n"
|
||||
:"=r"(bit)
|
||||
:"r" (x));
|
||||
|
||||
/* make even (2n) */
|
||||
bit &= 0xfffffffe;
|
||||
#else
|
||||
/* TODO -- add i386 branch using bshr
|
||||
*
|
||||
* NB: it's been said that the bshr instruction is poorly implemented
|
||||
* and that it is possible to write a faster code in C using binary
|
||||
* search -- at some point we should explore this
|
||||
*/
|
||||
int bit = 30;
|
||||
while (bit >= 0)
|
||||
{
|
||||
if (x & mask)
|
||||
break;
|
||||
|
||||
mask = (mask >> 1 | mask >> 2);
|
||||
bit -= 2;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* now bit indicates the highest bit set; there are two scenarios
|
||||
*
|
||||
* 1) bit < 23: Our number is smaller so we shift it left to maximase
|
||||
* precision (< 16 really, since <16,23> never goes
|
||||
* through here.
|
||||
*
|
||||
* 2) bit > 23: our number is above the table, so we shift right
|
||||
*/
|
||||
|
||||
sh = ((bit - 22) >> 1);
|
||||
if (bit >= 8)
|
||||
t = (x >> (16 - 22 + bit));
|
||||
else
|
||||
t = (x << (22 - 16 - bit));
|
||||
}
|
||||
else
|
||||
{
|
||||
t = COGL_FIXED_TO_INT (x);
|
||||
}
|
||||
|
||||
/* Do a weighted average of the two nearest values */
|
||||
v1 = sqrt_tbl[t];
|
||||
v2 = sqrt_tbl[t+1];
|
||||
|
||||
/*
|
||||
* 12 is fairly arbitrary -- we want integer that is not too big to cost
|
||||
* us precision
|
||||
*/
|
||||
d1 = (unsigned)(fract) >> 12;
|
||||
d2 = ((unsigned)COGL_FIXED_1 >> 12) - d1;
|
||||
|
||||
x = ((v1*d2) + (v2*d1))/(COGL_FIXED_1 >> 12);
|
||||
|
||||
if (sh > 0)
|
||||
x = x << sh;
|
||||
else if (sh < 0)
|
||||
x = (x >> (1 + ~sh));
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
/**
|
||||
* cogl_sqrti:
|
||||
* @x: integer value
|
||||
*
|
||||
* Very fast fixed point implementation of square root for integers.
|
||||
*
|
||||
* This function is at least 6x faster than clib sqrt() on x86, and (this is
|
||||
* not a typo!) about 500x faster on ARM without FPU. It's error is < 5%
|
||||
* for arguments < #COGL_SQRTI_ARG_5_PERCENT and < 10% for arguments <
|
||||
* #COGL_SQRTI_ARG_10_PERCENT. The maximum argument that can be passed to
|
||||
* this function is COGL_SQRTI_ARG_MAX.
|
||||
*
|
||||
* Return value: integer square root.
|
||||
*
|
||||
*
|
||||
* Since: 0.2
|
||||
*/
|
||||
gint
|
||||
cogl_sqrti (gint number)
|
||||
{
|
||||
#if defined __SSE2__
|
||||
/* The GCC built-in with SSE2 (sqrtsd) is up to twice as fast as
|
||||
* the pure integer code below. It is also more accurate.
|
||||
*/
|
||||
return __builtin_sqrt (number);
|
||||
#else
|
||||
/* This is a fixed point implementation of the Quake III sqrt algorithm,
|
||||
* described, for example, at
|
||||
* http://www.codemaestro.com/reviews/review00000105.html
|
||||
*
|
||||
* While the original QIII is extremely fast, the use of floating division
|
||||
* and multiplication makes it perform very on arm processors without FPU.
|
||||
*
|
||||
* The key to successfully replacing the floating point operations with
|
||||
* fixed point is in the choice of the fixed point format. The QIII
|
||||
* algorithm does not calculate the square root, but its reciprocal ('y'
|
||||
* below), which is only at the end turned to the inverse value. In order
|
||||
* for the algorithm to produce satisfactory results, the reciprocal value
|
||||
* must be represented with sufficient precission; the 16.16 we use
|
||||
* elsewhere in clutter is not good enough, and 10.22 is used instead.
|
||||
*/
|
||||
CoglFixed x;
|
||||
guint32 y_1; /* 10.22 fixed point */
|
||||
guint32 f = 0x600000; /* '1.5' as 10.22 fixed */
|
||||
|
||||
union
|
||||
{
|
||||
float f;
|
||||
guint32 i;
|
||||
} flt, flt2;
|
||||
|
||||
flt.f = number;
|
||||
|
||||
x = COGL_FIXED_FROM_INT (number) / 2;
|
||||
|
||||
/* The QIII initial estimate */
|
||||
flt.i = 0x5f3759df - ( flt.i >> 1 );
|
||||
|
||||
/* Now, we convert the float to 10.22 fixed. We exploit the mechanism
|
||||
* described at http://www.d6.com/users/checker/pdfs/gdmfp.pdf.
|
||||
*
|
||||
* We want 22 bit fraction; a single precission float uses 23 bit
|
||||
* mantisa, so we only need to add 2^(23-22) (no need for the 1.5
|
||||
* multiplier as we are only dealing with positive numbers).
|
||||
*
|
||||
* Note: we have to use two separate variables here -- for some reason,
|
||||
* if we try to use just the flt variable, gcc on ARM optimises the whole
|
||||
* addition out, and it all goes pear shape, since without it, the bits
|
||||
* in the float will not be correctly aligned.
|
||||
*/
|
||||
flt2.f = flt.f + 2.0;
|
||||
flt2.i &= 0x7FFFFF;
|
||||
|
||||
/* Now we correct the estimate */
|
||||
y_1 = (flt2.i >> 11) * (flt2.i >> 11);
|
||||
y_1 = (y_1 >> 8) * (x >> 8);
|
||||
|
||||
y_1 = f - y_1;
|
||||
flt2.i = (flt2.i >> 11) * (y_1 >> 11);
|
||||
|
||||
/* If the original argument is less than 342, we do another
|
||||
* iteration to improve precission (for arguments >= 342, the single
|
||||
* iteration produces generally better results).
|
||||
*/
|
||||
if (x < 171)
|
||||
{
|
||||
y_1 = (flt2.i >> 11) * (flt2.i >> 11);
|
||||
y_1 = (y_1 >> 8) * (x >> 8);
|
||||
|
||||
y_1 = f - y_1;
|
||||
flt2.i = (flt2.i >> 11) * (y_1 >> 11);
|
||||
}
|
||||
|
||||
/* Invert, round and convert from 10.22 to an integer
|
||||
* 0x1e3c68 is a magical rounding constant that produces slightly
|
||||
* better results than 0x200000.
|
||||
*/
|
||||
return (number * flt2.i + 0x1e3c68) >> 22;
|
||||
#endif
|
||||
}
|
||||
|
||||
CoglFixed
|
||||
cogl_fixed_mul (CoglFixed a,
|
||||
CoglFixed b)
|
||||
{
|
||||
#ifdef __arm__
|
||||
/* This provides about 12% speedeup on the gcc -O2 optimised
|
||||
* C version
|
||||
*
|
||||
* Based on code found in the following thread:
|
||||
* http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/2006-August/014405.html
|
||||
*/
|
||||
int res_low, res_hi;
|
||||
|
||||
__asm__ ("smull %0, %1, %2, %3 \n"
|
||||
"mov %0, %0, lsr %4 \n"
|
||||
"add %1, %0, %1, lsl %5 \n"
|
||||
: "=r"(res_hi), "=r"(res_low) \
|
||||
: "r"(a), "r"(b), "i"(COGL_FIXED_Q), "i"(32 - COGL_FIXED_Q));
|
||||
|
||||
return (CoglFixed) res_low;
|
||||
#else
|
||||
gint64 r = (gint64) a * (gint64) b;
|
||||
|
||||
return (CoglFixed) (r >> COGL_FIXED_Q);
|
||||
#endif
|
||||
}
|
||||
|
||||
CoglFixed
|
||||
cogl_fixed_div (CoglFixed a,
|
||||
CoglFixed b)
|
||||
{
|
||||
return (CoglFixed) ((((gint64) a) << COGL_FIXED_Q) / b);
|
||||
}
|
||||
|
||||
CoglFixed
|
||||
cogl_fixed_mul_div (CoglFixed a,
|
||||
CoglFixed b,
|
||||
CoglFixed c)
|
||||
{
|
||||
CoglFixed ab = cogl_fixed_mul (a, b);
|
||||
CoglFixed quo = cogl_fixed_div (ab, c);
|
||||
|
||||
return quo;
|
||||
}
|
||||
|
||||
/*
|
||||
* The log2x() and pow2x() functions
|
||||
*
|
||||
* The implementation of the log2x() and pow2x() exploits the
|
||||
* well-documented fact that the exponent part of IEEE floating
|
||||
* number provides a good estimate of log2 of that number, while
|
||||
* the mantissa serves as a good error-correction.
|
||||
*
|
||||
* The implementation here uses a quadratic error correction as
|
||||
* described by Ian Stephenson at:
|
||||
* http://www.dctsystems.co.uk/Software/power.html.
|
||||
*/
|
||||
|
||||
CoglFixed
|
||||
cogl_fixed_log2 (guint x)
|
||||
{
|
||||
/* Note: we could easily have a version for CoglFixed x, but the int
|
||||
* precision is enough for the current purposes.
|
||||
*/
|
||||
union
|
||||
{
|
||||
float f;
|
||||
CoglFixed i;
|
||||
} flt;
|
||||
|
||||
CoglFixed magic = 0x58bb;
|
||||
CoglFixed y;
|
||||
|
||||
/*
|
||||
* Convert x to float, then extract exponent.
|
||||
*
|
||||
* We want the result to be 16.16 fixed, so we shift (23-16) bits only
|
||||
*/
|
||||
flt.f = x;
|
||||
flt.i >>= 7;
|
||||
flt.i -= COGL_FIXED_FROM_INT (127);
|
||||
|
||||
y = COGL_FIXED_FRACTION (flt.i);
|
||||
|
||||
y = COGL_FIXED_MUL ((y - COGL_FIXED_MUL (y, y)), magic);
|
||||
|
||||
return flt.i + y;
|
||||
}
|
||||
|
||||
guint
|
||||
cogl_fixed_pow2 (CoglFixed x)
|
||||
{
|
||||
/* Note: we could easily have a version that produces CoglFixed result,
|
||||
* but the the range would be limited to x < 15, and the int precision
|
||||
* is enough for the current purposes.
|
||||
*/
|
||||
|
||||
union
|
||||
{
|
||||
float f;
|
||||
guint32 i;
|
||||
} flt;
|
||||
|
||||
CoglFixed magic = 0x56f7;
|
||||
CoglFixed y;
|
||||
|
||||
flt.i = x;
|
||||
|
||||
/*
|
||||
* Reverse of the log2x function -- convert the fixed value to a suitable
|
||||
* floating point exponent, and mantisa adjusted with quadratic error
|
||||
* correction y.
|
||||
*/
|
||||
y = COGL_FIXED_FRACTION (x);
|
||||
y = COGL_FIXED_MUL ((y - COGL_FIXED_MUL (y, y)), magic);
|
||||
|
||||
/* Shift the exponent into it's position in the floating point
|
||||
* representation; as our number is not int but 16.16 fixed, shift only
|
||||
* by (23 - 16)
|
||||
*/
|
||||
flt.i += (COGL_FIXED_FROM_INT (127) - y);
|
||||
flt.i <<= 7;
|
||||
|
||||
return COGL_FLOAT_TO_UINT (flt.f);
|
||||
}
|
||||
|
||||
guint
|
||||
cogl_fixed_pow (guint x,
|
||||
CoglFixed y)
|
||||
{
|
||||
return cogl_fixed_pow2 (COGL_FIXED_MUL (y, cogl_fixed_log2 (x)));
|
||||
}
|
||||
|
||||
CoglFixed
|
||||
cogl_angle_cos (CoglAngle angle)
|
||||
{
|
||||
CoglAngle a = angle + 256;
|
||||
|
||||
return cogl_angle_sin (a);
|
||||
}
|
||||
|
||||
CoglFixed
|
||||
cogl_fixed_cos (CoglFixed angle)
|
||||
{
|
||||
CoglFixed a = angle + COGL_FIXED_PI_2;
|
||||
|
||||
return cogl_fixed_sin (a);
|
||||
}
|
@ -38,18 +38,18 @@
|
||||
|
||||
/* these are defined in the particular backend(float in gl vs fixed in gles)*/
|
||||
void _cogl_path_clear_nodes ();
|
||||
void _cogl_path_add_node (ClutterFixed x,
|
||||
ClutterFixed y);
|
||||
void _cogl_path_add_node (CoglFixed x,
|
||||
CoglFixed 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 (ClutterFixed x,
|
||||
ClutterFixed y,
|
||||
ClutterFixed width,
|
||||
ClutterFixed height);
|
||||
void _cogl_rectanglex (CoglFixed x,
|
||||
CoglFixed y,
|
||||
CoglFixed width,
|
||||
CoglFixed height);
|
||||
void
|
||||
cogl_rectangle (gint x,
|
||||
gint y,
|
||||
@ -60,10 +60,10 @@ cogl_rectangle (gint x,
|
||||
}
|
||||
|
||||
void
|
||||
cogl_rectanglex (ClutterFixed x,
|
||||
ClutterFixed y,
|
||||
ClutterFixed width,
|
||||
ClutterFixed height)
|
||||
cogl_rectanglex (CoglFixed x,
|
||||
CoglFixed y,
|
||||
CoglFixed width,
|
||||
CoglFixed height)
|
||||
{
|
||||
_cogl_rectanglex (x, y, width, height);
|
||||
}
|
||||
@ -92,8 +92,8 @@ cogl_path_stroke (void)
|
||||
}
|
||||
|
||||
void
|
||||
cogl_path_move_to (ClutterFixed x,
|
||||
ClutterFixed y)
|
||||
cogl_path_move_to (CoglFixed x,
|
||||
CoglFixed y)
|
||||
{
|
||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||
|
||||
@ -112,8 +112,8 @@ cogl_path_move_to (ClutterFixed x,
|
||||
}
|
||||
|
||||
void
|
||||
cogl_path_rel_move_to (ClutterFixed x,
|
||||
ClutterFixed y)
|
||||
cogl_path_rel_move_to (CoglFixed x,
|
||||
CoglFixed y)
|
||||
{
|
||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||
|
||||
@ -122,8 +122,8 @@ cogl_path_rel_move_to (ClutterFixed x,
|
||||
}
|
||||
|
||||
void
|
||||
cogl_path_line_to (ClutterFixed x,
|
||||
ClutterFixed y)
|
||||
cogl_path_line_to (CoglFixed x,
|
||||
CoglFixed y)
|
||||
{
|
||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||
|
||||
@ -134,8 +134,8 @@ cogl_path_line_to (ClutterFixed x,
|
||||
}
|
||||
|
||||
void
|
||||
cogl_path_rel_line_to (ClutterFixed x,
|
||||
ClutterFixed y)
|
||||
cogl_path_rel_line_to (CoglFixed x,
|
||||
CoglFixed y)
|
||||
{
|
||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||
|
||||
@ -154,17 +154,17 @@ cogl_path_close (void)
|
||||
|
||||
|
||||
void
|
||||
cogl_path_line (ClutterFixed x1,
|
||||
ClutterFixed y1,
|
||||
ClutterFixed x2,
|
||||
ClutterFixed y2)
|
||||
cogl_path_line (CoglFixed x1,
|
||||
CoglFixed y1,
|
||||
CoglFixed x2,
|
||||
CoglFixed y2)
|
||||
{
|
||||
cogl_path_move_to (x1, y1);
|
||||
cogl_path_line_to (x2, y2);
|
||||
}
|
||||
|
||||
void
|
||||
cogl_path_polyline (ClutterFixed *coords,
|
||||
cogl_path_polyline (CoglFixed *coords,
|
||||
gint num_points)
|
||||
{
|
||||
gint c = 0;
|
||||
@ -176,7 +176,7 @@ cogl_path_polyline (ClutterFixed *coords,
|
||||
}
|
||||
|
||||
void
|
||||
cogl_path_polygon (ClutterFixed *coords,
|
||||
cogl_path_polygon (CoglFixed *coords,
|
||||
gint num_points)
|
||||
{
|
||||
cogl_path_polyline (coords, num_points);
|
||||
@ -184,10 +184,10 @@ cogl_path_polygon (ClutterFixed *coords,
|
||||
}
|
||||
|
||||
void
|
||||
cogl_path_rectangle (ClutterFixed x,
|
||||
ClutterFixed y,
|
||||
ClutterFixed width,
|
||||
ClutterFixed height)
|
||||
cogl_path_rectangle (CoglFixed x,
|
||||
CoglFixed y,
|
||||
CoglFixed width,
|
||||
CoglFixed height)
|
||||
{
|
||||
cogl_path_move_to (x, y);
|
||||
cogl_path_line_to (x + width, y);
|
||||
@ -197,20 +197,20 @@ cogl_path_rectangle (ClutterFixed x,
|
||||
}
|
||||
|
||||
static void
|
||||
_cogl_path_arc (ClutterFixed center_x,
|
||||
ClutterFixed center_y,
|
||||
ClutterFixed radius_x,
|
||||
ClutterFixed radius_y,
|
||||
ClutterAngle angle_1,
|
||||
ClutterAngle angle_2,
|
||||
ClutterAngle angle_step,
|
||||
_cogl_path_arc (CoglFixed center_x,
|
||||
CoglFixed center_y,
|
||||
CoglFixed radius_x,
|
||||
CoglFixed radius_y,
|
||||
CoglAngle angle_1,
|
||||
CoglAngle angle_2,
|
||||
CoglAngle angle_step,
|
||||
guint move_first)
|
||||
{
|
||||
ClutterAngle a = 0x0;
|
||||
ClutterFixed cosa = 0x0;
|
||||
ClutterFixed sina = 0x0;
|
||||
ClutterFixed px = 0x0;
|
||||
ClutterFixed py = 0x0;
|
||||
CoglAngle a = 0x0;
|
||||
CoglFixed cosa = 0x0;
|
||||
CoglFixed sina = 0x0;
|
||||
CoglFixed px = 0x0;
|
||||
CoglFixed py = 0x0;
|
||||
|
||||
/* Fix invalid angles */
|
||||
|
||||
@ -225,11 +225,11 @@ _cogl_path_arc (ClutterFixed center_x,
|
||||
a = angle_1;
|
||||
while (a != angle_2)
|
||||
{
|
||||
cosa = clutter_cosi (a);
|
||||
sina = clutter_sini (a);
|
||||
cosa = cogl_angle_cos (a);
|
||||
sina = cogl_angle_sin (a);
|
||||
|
||||
px = center_x + CFX_MUL (cosa, radius_x);
|
||||
py = center_y + CFX_MUL (sina, radius_y);
|
||||
px = center_x + COGL_FIXED_MUL (cosa, radius_x);
|
||||
py = center_y + COGL_FIXED_MUL (sina, radius_y);
|
||||
|
||||
if (a == angle_1 && move_first)
|
||||
cogl_path_move_to (px, py);
|
||||
@ -252,24 +252,24 @@ _cogl_path_arc (ClutterFixed center_x,
|
||||
|
||||
/* Make sure the final point is drawn */
|
||||
|
||||
cosa = clutter_cosi (angle_2);
|
||||
sina = clutter_sini (angle_2);
|
||||
cosa = cogl_angle_cos (angle_2);
|
||||
sina = cogl_angle_sin (angle_2);
|
||||
|
||||
px = center_x + CFX_MUL (cosa, radius_x);
|
||||
py = center_y + CFX_MUL (sina, radius_y);
|
||||
px = center_x + COGL_FIXED_MUL (cosa, radius_x);
|
||||
py = center_y + COGL_FIXED_MUL (sina, radius_y);
|
||||
|
||||
cogl_path_line_to (px, py);
|
||||
}
|
||||
|
||||
void
|
||||
cogl_path_arc (ClutterFixed center_x,
|
||||
ClutterFixed center_y,
|
||||
ClutterFixed radius_x,
|
||||
ClutterFixed radius_y,
|
||||
ClutterAngle angle_1,
|
||||
ClutterAngle angle_2)
|
||||
cogl_path_arc (CoglFixed center_x,
|
||||
CoglFixed center_y,
|
||||
CoglFixed radius_x,
|
||||
CoglFixed radius_y,
|
||||
CoglAngle angle_1,
|
||||
CoglAngle angle_2)
|
||||
{
|
||||
ClutterAngle angle_step = 10;
|
||||
CoglAngle angle_step = 10;
|
||||
/* it is documented that a move to is needed to create a freestanding
|
||||
* arc
|
||||
*/
|
||||
@ -281,13 +281,13 @@ cogl_path_arc (ClutterFixed center_x,
|
||||
|
||||
|
||||
void
|
||||
cogl_path_arc_rel (ClutterFixed center_x,
|
||||
ClutterFixed center_y,
|
||||
ClutterFixed radius_x,
|
||||
ClutterFixed radius_y,
|
||||
ClutterAngle angle_1,
|
||||
ClutterAngle angle_2,
|
||||
ClutterAngle angle_step)
|
||||
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_GET_CONTEXT (ctx, NO_RETVAL);
|
||||
|
||||
@ -299,50 +299,50 @@ cogl_path_arc_rel (ClutterFixed center_x,
|
||||
}
|
||||
|
||||
void
|
||||
cogl_path_ellipse (ClutterFixed center_x,
|
||||
ClutterFixed center_y,
|
||||
ClutterFixed radius_x,
|
||||
ClutterFixed radius_y)
|
||||
cogl_path_ellipse (CoglFixed center_x,
|
||||
CoglFixed center_y,
|
||||
CoglFixed radius_x,
|
||||
CoglFixed radius_y)
|
||||
{
|
||||
ClutterAngle angle_step = 10;
|
||||
CoglAngle 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, CLUTTER_ANGLE_FROM_DEG(360),
|
||||
0, COGL_ANGLE_FROM_DEG (360),
|
||||
angle_step, 1 /* move first */);
|
||||
|
||||
cogl_path_close();
|
||||
}
|
||||
|
||||
void
|
||||
cogl_path_round_rectangle (ClutterFixed x,
|
||||
ClutterFixed y,
|
||||
ClutterFixed width,
|
||||
ClutterFixed height,
|
||||
ClutterFixed radius,
|
||||
ClutterAngle arc_step)
|
||||
cogl_path_round_rectangle (CoglFixed x,
|
||||
CoglFixed y,
|
||||
CoglFixed width,
|
||||
CoglFixed height,
|
||||
CoglFixed radius,
|
||||
CoglAngle arc_step)
|
||||
{
|
||||
ClutterFixed inner_width = width - (radius << 1);
|
||||
ClutterFixed inner_height = height - (radius << 1);
|
||||
CoglFixed inner_width = width - (radius << 1);
|
||||
CoglFixed inner_height = height - (radius << 1);
|
||||
|
||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||
|
||||
cogl_path_move_to (x, y + radius);
|
||||
cogl_path_arc_rel (radius, 0,
|
||||
radius, radius,
|
||||
CLUTTER_ANGLE_FROM_DEG (180),
|
||||
CLUTTER_ANGLE_FROM_DEG (270),
|
||||
COGL_ANGLE_FROM_DEG (180),
|
||||
COGL_ANGLE_FROM_DEG (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,
|
||||
CLUTTER_ANGLE_FROM_DEG (-90),
|
||||
CLUTTER_ANGLE_FROM_DEG (0),
|
||||
COGL_ANGLE_FROM_DEG (-90),
|
||||
COGL_ANGLE_FROM_DEG (0),
|
||||
arc_step);
|
||||
|
||||
cogl_path_line_to (ctx->path_pen.x,
|
||||
@ -350,16 +350,16 @@ cogl_path_round_rectangle (ClutterFixed x,
|
||||
|
||||
cogl_path_arc_rel (-radius, 0,
|
||||
radius, radius,
|
||||
CLUTTER_ANGLE_FROM_DEG (0),
|
||||
CLUTTER_ANGLE_FROM_DEG (90),
|
||||
COGL_ANGLE_FROM_DEG (0),
|
||||
COGL_ANGLE_FROM_DEG (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,
|
||||
CLUTTER_ANGLE_FROM_DEG (90),
|
||||
CLUTTER_ANGLE_FROM_DEG (180),
|
||||
COGL_ANGLE_FROM_DEG (90),
|
||||
COGL_ANGLE_FROM_DEG (180),
|
||||
arc_step);
|
||||
|
||||
cogl_path_close ();
|
||||
@ -393,7 +393,7 @@ _cogl_path_bezier3_sub (CoglBezCubic *cubic)
|
||||
|
||||
#define CFX_MUL2(x) ((x) << 1)
|
||||
#define CFX_MUL3(x) (((x) << 1) + (x))
|
||||
#define CFX_SQ(x) CFX_MUL (x, x)
|
||||
#define CFX_SQ(x) COGL_FIXED_MUL (x, x)
|
||||
|
||||
/* Calculate distance of control points from their
|
||||
* counterparts on the line between end points */
|
||||
@ -401,10 +401,15 @@ _cogl_path_bezier3_sub (CoglBezCubic *cubic)
|
||||
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;
|
||||
if (dif1.x < 0) dif1.x = -dif1.x;
|
||||
if (dif1.y < 0) dif1.y = -dif1.y;
|
||||
if (dif2.x < 0) dif2.x = -dif2.x;
|
||||
if (dif2.y < 0) dif2.y = -dif2.y;
|
||||
|
||||
if (dif1.x < 0)
|
||||
dif1.x = -dif1.x;
|
||||
if (dif1.y < 0)
|
||||
dif1.y = -dif1.y;
|
||||
if (dif2.x < 0)
|
||||
dif2.x = -dif2.x;
|
||||
if (dif2.y < 0)
|
||||
dif2.y = -dif2.y;
|
||||
|
||||
#undef CFX_MUL2
|
||||
#undef CFX_MUL3
|
||||
@ -415,13 +420,18 @@ _cogl_path_bezier3_sub (CoglBezCubic *cubic)
|
||||
if (dif1.y < dif2.y) dif1.y = dif2.y;
|
||||
|
||||
/* Cancel if the curve is flat enough */
|
||||
if (dif1.x + dif1.y <= CFX_ONE
|
||||
|| cindex == _COGL_MAX_BEZ_RECURSE_DEPTH-1)
|
||||
if (dif1.x + dif1.y <= COGL_FIXED_1 ||
|
||||
cindex == _COGL_MAX_BEZ_RECURSE_DEPTH-1)
|
||||
{
|
||||
/* Add subdivision point (skip last) */
|
||||
if (cindex == 0) return;
|
||||
if (cindex == 0)
|
||||
return;
|
||||
|
||||
_cogl_path_add_node (c->p4.x, c->p4.y);
|
||||
--cindex; continue;
|
||||
|
||||
--cindex;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Left recursion goes on top of stack! */
|
||||
@ -458,12 +468,12 @@ _cogl_path_bezier3_sub (CoglBezCubic *cubic)
|
||||
}
|
||||
|
||||
void
|
||||
cogl_path_curve_to (ClutterFixed x1,
|
||||
ClutterFixed y1,
|
||||
ClutterFixed x2,
|
||||
ClutterFixed y2,
|
||||
ClutterFixed x3,
|
||||
ClutterFixed y3)
|
||||
cogl_path_curve_to (CoglFixed x1,
|
||||
CoglFixed y1,
|
||||
CoglFixed x2,
|
||||
CoglFixed y2,
|
||||
CoglFixed x3,
|
||||
CoglFixed y3)
|
||||
{
|
||||
CoglBezCubic cubic;
|
||||
|
||||
@ -487,12 +497,12 @@ cogl_path_curve_to (ClutterFixed x1,
|
||||
}
|
||||
|
||||
void
|
||||
cogl_path_rel_curve_to (ClutterFixed x1,
|
||||
ClutterFixed y1,
|
||||
ClutterFixed x2,
|
||||
ClutterFixed y2,
|
||||
ClutterFixed x3,
|
||||
ClutterFixed y3)
|
||||
cogl_path_rel_curve_to (CoglFixed x1,
|
||||
CoglFixed y1,
|
||||
CoglFixed x2,
|
||||
CoglFixed y2,
|
||||
CoglFixed x3,
|
||||
CoglFixed y3)
|
||||
{
|
||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||
|
||||
@ -544,8 +554,8 @@ _cogl_path_bezier2_sub (CoglBezQuad *quad)
|
||||
if (dif.y < 0) dif.y = -dif.y;
|
||||
|
||||
/* Cancel if the curve is flat enough */
|
||||
if (dif.x + dif.y <= CFX_ONE
|
||||
|| qindex == _COGL_MAX_BEZ_RECURSE_DEPTH - 1)
|
||||
if (dif.x + dif.y <= COGL_FIXED_1 ||
|
||||
qindex == _COGL_MAX_BEZ_RECURSE_DEPTH - 1)
|
||||
{
|
||||
/* Add subdivision point (skip last) */
|
||||
if (qindex == 0) return;
|
||||
@ -577,10 +587,10 @@ _cogl_path_bezier2_sub (CoglBezQuad *quad)
|
||||
}
|
||||
|
||||
void
|
||||
cogl_path_curve2_to (ClutterFixed x1,
|
||||
ClutterFixed y1,
|
||||
ClutterFixed x2,
|
||||
ClutterFixed y2)
|
||||
cogl_path_curve2_to (CoglFixed x1,
|
||||
CoglFixed y1,
|
||||
CoglFixed x2,
|
||||
CoglFixed y2)
|
||||
{
|
||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||
|
||||
@ -602,10 +612,10 @@ cogl_path_curve2_to (ClutterFixed x1,
|
||||
}
|
||||
|
||||
void
|
||||
cogl_rel_curve2_to (ClutterFixed x1,
|
||||
ClutterFixed y1,
|
||||
ClutterFixed x2,
|
||||
ClutterFixed y2)
|
||||
cogl_rel_curve2_to (CoglFixed x1,
|
||||
CoglFixed y1,
|
||||
CoglFixed x2,
|
||||
CoglFixed y2)
|
||||
{
|
||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||
|
||||
|
@ -32,8 +32,8 @@ typedef struct _CoglBezCubic CoglBezCubic;
|
||||
|
||||
struct _CoglFixedVec2
|
||||
{
|
||||
ClutterFixed x;
|
||||
ClutterFixed y;
|
||||
CoglFixed x;
|
||||
CoglFixed y;
|
||||
};
|
||||
|
||||
#ifdef CLUTTER_COGL_HAS_GL
|
||||
|
@ -58,6 +58,7 @@
|
||||
<xi:include href="xml/cogl-texture.xml"/>
|
||||
<xi:include href="xml/cogl-shaders.xml"/>
|
||||
<xi:include href="xml/cogl-offscreen.xml"/>
|
||||
<xi:include href="xml/cogl-fixed.xml"/>
|
||||
|
||||
</chapter>
|
||||
|
||||
|
@ -146,3 +146,88 @@ cogl_offscreen_blit
|
||||
cogl_offscreen_blit_region
|
||||
cogl_draw_buffer
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>cogl-fixed</FILE>
|
||||
<TITLE>Fixed Point API</TITLE>
|
||||
CoglFixed
|
||||
COGL_FIXED_BITS
|
||||
COGL_FIXED_Q
|
||||
COGL_FIXED_MAX
|
||||
COGL_FIXED_MIN
|
||||
|
||||
<SUBSECTION>
|
||||
COGL_FIXED_FROM_FLOAT
|
||||
COGL_FIXED_TO_FLOAT
|
||||
COGL_FIXED_FROM_INT
|
||||
COGL_FIXED_TO_INT
|
||||
COGL_FIXED_TO_DOUBLE
|
||||
COGL_FLOAT_TO_INT
|
||||
COGL_FLOAT_TO_UINT
|
||||
|
||||
<SUBSECTION>
|
||||
COGL_FIXED_EPSILON
|
||||
COGL_FIXED_1
|
||||
COGL_FIXED_0_5
|
||||
COGL_FIXED_30
|
||||
COGL_FIXED_45
|
||||
COGL_FIXED_60
|
||||
COGL_FIXED_90
|
||||
COGL_FIXED_120
|
||||
COGL_FIXED_180
|
||||
COGL_FIXED_240
|
||||
COGL_FIXED_255
|
||||
COGL_FIXED_270
|
||||
COGL_FIXED_360
|
||||
|
||||
<SUBSECTION>
|
||||
COGL_FIXED_MUL
|
||||
COGL_FIXED_DIV
|
||||
COGL_FIXED_MUL_DIV
|
||||
COGL_FIXED_FAST_DIV
|
||||
COGL_FIXED_FAST_MUL
|
||||
COGL_FIXED_FRACTION
|
||||
COGL_FIXED_FLOOR
|
||||
COGL_FIXED_CEIL
|
||||
|
||||
<SUBSECTION>
|
||||
COGL_FIXED_2_PI
|
||||
COGL_FIXED_PI
|
||||
COGL_FIXED_PI_2
|
||||
COGL_FIXED_PI_4
|
||||
COGL_RADIANS_TO_DEGREES
|
||||
|
||||
<SUBSECTION>
|
||||
COGL_SQRTI_ARG_10_PERCENT
|
||||
COGL_SQRTI_ARG_5_PERCENT
|
||||
COGL_SQRTI_ARG_MAX
|
||||
cogl_sqrti
|
||||
|
||||
<SUBSECTION>
|
||||
cogl_fixed_atan2
|
||||
cogl_fixed_atani
|
||||
cogl_fixed_cos
|
||||
cogl_fixed_log2
|
||||
cogl_fixed_pow
|
||||
cogl_fixed_pow2
|
||||
cogl_fixed_sin
|
||||
cogl_fixed_sqrt
|
||||
|
||||
<SUBSECTION>
|
||||
CoglAngle
|
||||
COGL_ANGLE_FROM_DEG
|
||||
COGL_ANGLE_FROM_DEGX
|
||||
COGL_ANGLE_TO_DEG
|
||||
COGL_ANGLE_TO_DEGX
|
||||
cogl_angle_cos
|
||||
cogl_angle_sin
|
||||
cogl_angle_tan
|
||||
|
||||
<SUBSECTION Private>
|
||||
cogl_fixed_mul
|
||||
cogl_fixed_div
|
||||
cogl_fixed_mul_div
|
||||
cogl_double_to_fixed
|
||||
cogl_double_to_int
|
||||
cogl_double_to_unit
|
||||
</SECTION>
|
||||
|
@ -1,6 +1,8 @@
|
||||
libclutterincludedir = $(includedir)/clutter-@CLUTTER_API_VERSION@/cogl
|
||||
libclutterinclude_HEADERS = $(top_builddir)/clutter/cogl/cogl.h \
|
||||
$(top_builddir)/clutter/cogl/cogl-defines-gl.h
|
||||
libclutterinclude_HEADERS = \
|
||||
$(top_builddir)/clutter/cogl/cogl.h \
|
||||
$(top_builddir)/clutter/cogl/cogl-defines-gl.h \
|
||||
$(top_builddir)/clutter/cogl/cogl-fixed.h
|
||||
|
||||
INCLUDES = \
|
||||
-I$(top_srcdir) \
|
||||
@ -21,6 +23,7 @@ noinst_LTLIBRARIES = libclutter-cogl.la
|
||||
libclutter_cogl_la_SOURCES = \
|
||||
$(top_builddir)/clutter/cogl/cogl.h \
|
||||
$(top_builddir)/clutter/cogl/cogl-defines-gl.h \
|
||||
$(top_builddir)/clutter/cogl/cogl-fixed.h \
|
||||
cogl-internal.h \
|
||||
cogl-texture.h \
|
||||
cogl-fbo.h \
|
||||
@ -37,4 +40,4 @@ libclutter_cogl_la_SOURCES = \
|
||||
|
||||
EXTRA_DIST = cogl-defines.h.in
|
||||
|
||||
libclutter_cogl_la_LIBADD = $(top_builddir)/clutter/cogl/common/libclutter-cogl-common.la
|
||||
libclutter_cogl_la_LIBADD = $(top_builddir)/clutter/cogl/common/libclutter-cogl-common.la
|
||||
|
@ -53,20 +53,20 @@ _cogl_rectangle (gint x,
|
||||
|
||||
|
||||
void
|
||||
_cogl_rectanglex (ClutterFixed x,
|
||||
ClutterFixed y,
|
||||
ClutterFixed width,
|
||||
ClutterFixed height)
|
||||
_cogl_rectanglex (CoglFixed x,
|
||||
CoglFixed y,
|
||||
CoglFixed width,
|
||||
CoglFixed height)
|
||||
{
|
||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||
|
||||
cogl_enable (ctx->color_alpha < 255
|
||||
? COGL_ENABLE_BLEND : 0);
|
||||
|
||||
GE( glRectf (CLUTTER_FIXED_TO_FLOAT (x),
|
||||
CLUTTER_FIXED_TO_FLOAT (y),
|
||||
CLUTTER_FIXED_TO_FLOAT (x + width),
|
||||
CLUTTER_FIXED_TO_FLOAT (y + height)) );
|
||||
GE( glRectf (COGL_FIXED_TO_FLOAT (x),
|
||||
COGL_FIXED_TO_FLOAT (y),
|
||||
COGL_FIXED_TO_FLOAT (x + width),
|
||||
COGL_FIXED_TO_FLOAT (y + height)) );
|
||||
}
|
||||
|
||||
void
|
||||
@ -83,8 +83,8 @@ _cogl_path_clear_nodes ()
|
||||
}
|
||||
|
||||
void
|
||||
_cogl_path_add_node (ClutterFixed x,
|
||||
ClutterFixed y)
|
||||
_cogl_path_add_node (CoglFixed x,
|
||||
CoglFixed y)
|
||||
{
|
||||
CoglFloatVec2 *new_nodes = NULL;
|
||||
|
||||
@ -102,8 +102,8 @@ _cogl_path_add_node (ClutterFixed x,
|
||||
ctx->path_nodes_cap *= 2;
|
||||
}
|
||||
|
||||
ctx->path_nodes [ctx->path_nodes_size] .x = CLUTTER_FIXED_TO_FLOAT (x);
|
||||
ctx->path_nodes [ctx->path_nodes_size] .y = CLUTTER_FIXED_TO_FLOAT (y);
|
||||
ctx->path_nodes [ctx->path_nodes_size] .x = COGL_FIXED_TO_FLOAT (x);
|
||||
ctx->path_nodes [ctx->path_nodes_size] .y = COGL_FIXED_TO_FLOAT (y);
|
||||
ctx->path_nodes_size++;
|
||||
|
||||
if (ctx->path_nodes_size == 1)
|
||||
@ -165,10 +165,10 @@ _cogl_path_fill_nodes ()
|
||||
GE( glStencilFunc (GL_EQUAL, 0x1, 0x1) );
|
||||
GE( glStencilOp (GL_KEEP, GL_KEEP, GL_KEEP) );
|
||||
|
||||
bounds_x = CLUTTER_FIXED_FLOOR (ctx->path_nodes_min.x);
|
||||
bounds_y = CLUTTER_FIXED_FLOOR (ctx->path_nodes_min.y);
|
||||
bounds_w = CLUTTER_FIXED_CEIL (ctx->path_nodes_max.x - ctx->path_nodes_min.x);
|
||||
bounds_h = CLUTTER_FIXED_CEIL (ctx->path_nodes_max.y - ctx->path_nodes_min.y);
|
||||
bounds_x = COGL_FIXED_FLOOR (ctx->path_nodes_min.x);
|
||||
bounds_y = COGL_FIXED_FLOOR (ctx->path_nodes_min.y);
|
||||
bounds_w = COGL_FIXED_CEIL (ctx->path_nodes_max.x - ctx->path_nodes_min.x);
|
||||
bounds_h = COGL_FIXED_CEIL (ctx->path_nodes_max.y - ctx->path_nodes_min.y);
|
||||
|
||||
cogl_rectangle (bounds_x, bounds_y, bounds_w, bounds_h);
|
||||
|
||||
|
@ -58,15 +58,15 @@ struct _CoglSpanIter
|
||||
gint index;
|
||||
GArray *array;
|
||||
CoglTexSliceSpan *span;
|
||||
ClutterFixed pos;
|
||||
ClutterFixed next_pos;
|
||||
ClutterFixed origin;
|
||||
ClutterFixed cover_start;
|
||||
ClutterFixed cover_end;
|
||||
ClutterFixed intersect_start;
|
||||
ClutterFixed intersect_end;
|
||||
ClutterFixed intersect_start_local;
|
||||
ClutterFixed intersect_end_local;
|
||||
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;
|
||||
gboolean intersects;
|
||||
};
|
||||
|
||||
@ -100,8 +100,8 @@ _cogl_span_iter_update (CoglSpanIter *iter)
|
||||
iter->index);
|
||||
|
||||
/* Offset next position by span size */
|
||||
iter->next_pos = iter->pos +
|
||||
CLUTTER_INT_TO_FIXED (iter->span->size - iter->span->waste);
|
||||
iter->next_pos = iter->pos
|
||||
+ COGL_FIXED_FROM_INT (iter->span->size - iter->span->waste);
|
||||
|
||||
/* Check if span intersects the area to cover */
|
||||
if (iter->next_pos <= iter->cover_start ||
|
||||
@ -130,9 +130,9 @@ _cogl_span_iter_update (CoglSpanIter *iter)
|
||||
static void
|
||||
_cogl_span_iter_begin (CoglSpanIter *iter,
|
||||
GArray *array,
|
||||
ClutterFixed origin,
|
||||
ClutterFixed cover_start,
|
||||
ClutterFixed cover_end)
|
||||
CoglFixed origin,
|
||||
CoglFixed cover_start,
|
||||
CoglFixed cover_end)
|
||||
{
|
||||
/* Copy info */
|
||||
iter->index = 0;
|
||||
@ -493,8 +493,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, CLUTTER_INT_TO_FIXED (dst_y),
|
||||
CLUTTER_INT_TO_FIXED (dst_y + height));
|
||||
0, COGL_FIXED_FROM_INT (dst_y),
|
||||
COGL_FIXED_FROM_INT (dst_y + height));
|
||||
|
||||
!_cogl_span_iter_end (&y_iter);
|
||||
|
||||
@ -514,8 +514,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, CLUTTER_INT_TO_FIXED (dst_x),
|
||||
CLUTTER_INT_TO_FIXED (dst_x + width));
|
||||
0, COGL_FIXED_FROM_INT (dst_x),
|
||||
COGL_FIXED_FROM_INT (dst_x + width));
|
||||
|
||||
!_cogl_span_iter_end (&x_iter);
|
||||
|
||||
@ -533,16 +533,16 @@ _cogl_texture_upload_subregion_to_gl (CoglTexture *tex,
|
||||
x_iter.index);
|
||||
|
||||
/* Pick intersection width and height */
|
||||
inter_w = CLUTTER_FIXED_TO_INT (x_iter.intersect_end -
|
||||
x_iter.intersect_start);
|
||||
inter_h = CLUTTER_FIXED_TO_INT (y_iter.intersect_end -
|
||||
y_iter.intersect_start);
|
||||
inter_w = COGL_FIXED_TO_INT (x_iter.intersect_end -
|
||||
x_iter.intersect_start);
|
||||
inter_h = COGL_FIXED_TO_INT (y_iter.intersect_end -
|
||||
y_iter.intersect_start);
|
||||
|
||||
/* Localize intersection top-left corner to slice*/
|
||||
local_x = CLUTTER_FIXED_TO_INT (x_iter.intersect_start -
|
||||
x_iter.pos);
|
||||
local_y = CLUTTER_FIXED_TO_INT (y_iter.intersect_start -
|
||||
y_iter.pos);
|
||||
local_x = COGL_FIXED_TO_INT (x_iter.intersect_start -
|
||||
x_iter.pos);
|
||||
local_y = COGL_FIXED_TO_INT (y_iter.intersect_start -
|
||||
y_iter.pos);
|
||||
|
||||
/* Pick slice GL handle */
|
||||
gl_handle = g_array_index (tex->slice_gl_handles, GLuint,
|
||||
@ -575,14 +575,20 @@ _cogl_texture_upload_subregion_to_gl (CoglTexture *tex,
|
||||
&& local_x < x_span->size - x_span->waste
|
||||
&& local_x + inter_w >= x_span->size - x_span->waste)
|
||||
{
|
||||
const guchar *src = source_bmp->data
|
||||
+ (src_y + CLUTTER_FIXED_TO_INT (y_iter.intersect_start)
|
||||
- dst_y) * source_bmp->rowstride
|
||||
+ (src_x + x_span->start + x_span->size - x_span->waste
|
||||
- dst_x - 1) * bpp;
|
||||
guchar *dst = waste_buf;
|
||||
const guchar *src;
|
||||
guchar *dst;
|
||||
guint wx, wy;
|
||||
|
||||
src = source_bmp->data
|
||||
+ (src_y + COGL_FIXED_TO_INT (y_iter.intersect_start)
|
||||
- dst_y)
|
||||
* source_bmp->rowstride
|
||||
+ (src_x + x_span->start + x_span->size - x_span->waste
|
||||
- dst_x - 1)
|
||||
* bpp;
|
||||
|
||||
dst = waste_buf;
|
||||
|
||||
for (wy = 0; wy < inter_h; wy++)
|
||||
{
|
||||
for (wx = 0; wx < x_span->waste; wx++)
|
||||
@ -612,15 +618,21 @@ _cogl_texture_upload_subregion_to_gl (CoglTexture *tex,
|
||||
&& local_y < y_span->size - y_span->waste
|
||||
&& local_y + inter_h >= y_span->size - y_span->waste)
|
||||
{
|
||||
const guchar *src = source_bmp->data
|
||||
+ (src_x + CLUTTER_FIXED_TO_INT (x_iter.intersect_start)
|
||||
- dst_x) * bpp
|
||||
+ (src_y + y_span->start + y_span->size - y_span->waste
|
||||
- dst_y - 1) * source_bmp->rowstride;
|
||||
guchar *dst = waste_buf;
|
||||
const guchar *src;
|
||||
guchar *dst;
|
||||
guint wy, wx;
|
||||
guint copy_width;
|
||||
|
||||
src = source_bmp->data
|
||||
+ (src_x + COGL_FIXED_TO_INT (x_iter.intersect_start)
|
||||
- dst_x)
|
||||
* bpp
|
||||
+ (src_y + y_span->start + y_span->size - y_span->waste
|
||||
- dst_y - 1)
|
||||
* source_bmp->rowstride;
|
||||
|
||||
dst = waste_buf;
|
||||
|
||||
if (local_x + inter_w >= x_span->size - x_span->waste)
|
||||
copy_width = x_span->size - local_x;
|
||||
else
|
||||
@ -1914,24 +1926,24 @@ cogl_texture_get_data (CoglHandle handle,
|
||||
|
||||
static void
|
||||
_cogl_texture_quad_sw (CoglTexture *tex,
|
||||
ClutterFixed x1,
|
||||
ClutterFixed y1,
|
||||
ClutterFixed x2,
|
||||
ClutterFixed y2,
|
||||
ClutterFixed tx1,
|
||||
ClutterFixed ty1,
|
||||
ClutterFixed tx2,
|
||||
ClutterFixed ty2)
|
||||
CoglFixed x1,
|
||||
CoglFixed y1,
|
||||
CoglFixed x2,
|
||||
CoglFixed y2,
|
||||
CoglFixed tx1,
|
||||
CoglFixed ty1,
|
||||
CoglFixed tx2,
|
||||
CoglFixed ty2)
|
||||
{
|
||||
CoglSpanIter iter_x , iter_y;
|
||||
ClutterFixed tw , th;
|
||||
ClutterFixed tqx , tqy;
|
||||
ClutterFixed first_tx , first_ty;
|
||||
ClutterFixed first_qx , first_qy;
|
||||
ClutterFixed slice_tx1 , slice_ty1;
|
||||
ClutterFixed slice_tx2 , slice_ty2;
|
||||
ClutterFixed slice_qx1 , slice_qy1;
|
||||
ClutterFixed slice_qx2 , slice_qy2;
|
||||
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;
|
||||
GLuint gl_handle;
|
||||
gulong enable_flags = 0;
|
||||
|
||||
@ -1956,27 +1968,27 @@ _cogl_texture_quad_sw (CoglTexture *tex,
|
||||
cogl_enable (enable_flags);
|
||||
|
||||
/* Scale ratio from texture to quad widths */
|
||||
tw = CLUTTER_INT_TO_FIXED (tex->bitmap.width);
|
||||
th = CLUTTER_INT_TO_FIXED (tex->bitmap.height);
|
||||
tw = COGL_FIXED_FROM_INT (tex->bitmap.width);
|
||||
th = COGL_FIXED_FROM_INT (tex->bitmap.height);
|
||||
|
||||
tqx = CFX_QDIV (x2-x1, CFX_QMUL (tw, (tx2 - tx1)));
|
||||
tqy = CFX_QDIV (y2-y1, CFX_QMUL (th, (ty2 - ty1)));
|
||||
tqx = COGL_FIXED_DIV (x2 - x1, COGL_FIXED_MUL (tw, (tx2 - tx1)));
|
||||
tqy = COGL_FIXED_DIV (y2 - y1, COGL_FIXED_MUL (th, (ty2 - ty1)));
|
||||
|
||||
/* Integral texture coordinate for first tile */
|
||||
first_tx = CLUTTER_INT_TO_FIXED (CLUTTER_FIXED_FLOOR (tx1));
|
||||
first_ty = CLUTTER_INT_TO_FIXED (CLUTTER_FIXED_FLOOR (ty1));
|
||||
first_tx = COGL_FIXED_FROM_INT (COGL_FIXED_FLOOR (tx1));
|
||||
first_ty = COGL_FIXED_FROM_INT (COGL_FIXED_FLOOR (ty1));
|
||||
|
||||
/* Denormalize texture coordinates */
|
||||
first_tx = CFX_QMUL (first_tx, tw);
|
||||
first_ty = CFX_QMUL (first_ty, th);
|
||||
tx1 = CFX_QMUL (tx1, tw);
|
||||
ty1 = CFX_QMUL (ty1, th);
|
||||
tx2 = CFX_QMUL (tx2, tw);
|
||||
ty2 = CFX_QMUL (ty2, th);
|
||||
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);
|
||||
|
||||
/* Quad coordinate of the first tile */
|
||||
first_qx = x1 - CFX_QMUL (tx1 - first_tx, tqx);
|
||||
first_qy = y1 - CFX_QMUL (ty1 - first_ty, tqy);
|
||||
first_qx = x1 - COGL_FIXED_MUL (tx1 - first_tx, tqx);
|
||||
first_qy = y1 - COGL_FIXED_MUL (ty1 - first_ty, tqy);
|
||||
|
||||
|
||||
/* Iterate until whole quad height covered */
|
||||
@ -1990,10 +2002,10 @@ _cogl_texture_quad_sw (CoglTexture *tex,
|
||||
|
||||
/* Span-quad intersection in quad coordinates */
|
||||
slice_qy1 = first_qy +
|
||||
CFX_QMUL (iter_y.intersect_start - first_ty, tqy);
|
||||
COGL_FIXED_MUL (iter_y.intersect_start - first_ty, tqy);
|
||||
|
||||
slice_qy2 = first_qy +
|
||||
CFX_QMUL (iter_y.intersect_end - first_ty, tqy);
|
||||
COGL_FIXED_MUL (iter_y.intersect_end - first_ty, tqy);
|
||||
|
||||
/* Localize slice texture coordinates */
|
||||
slice_ty1 = iter_y.intersect_start - iter_y.pos;
|
||||
@ -2016,10 +2028,10 @@ _cogl_texture_quad_sw (CoglTexture *tex,
|
||||
|
||||
/* Span-quad intersection in quad coordinates */
|
||||
slice_qx1 = first_qx +
|
||||
CFX_QMUL (iter_x.intersect_start - first_tx, tqx);
|
||||
COGL_FIXED_MUL (iter_x.intersect_start - first_tx, tqx);
|
||||
|
||||
slice_qx2 = first_qx +
|
||||
CFX_QMUL (iter_x.intersect_end - first_tx, tqx);
|
||||
COGL_FIXED_MUL (iter_x.intersect_end - first_tx, tqx);
|
||||
|
||||
/* Localize slice texture coordinates */
|
||||
slice_tx1 = iter_x.intersect_start - iter_x.pos;
|
||||
@ -2032,14 +2044,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", CLUTTER_FIXED_TO_FLOAT (slice_qx1));
|
||||
printf("qy1: %f\n", CLUTTER_FIXED_TO_FLOAT (slice_qy1));
|
||||
printf("qx2: %f\n", CLUTTER_FIXED_TO_FLOAT (slice_qx2));
|
||||
printf("qy2: %f\n", CLUTTER_FIXED_TO_FLOAT (slice_qy2));
|
||||
printf("tx1: %f\n", CLUTTER_FIXED_TO_FLOAT (slice_tx1));
|
||||
printf("ty1: %f\n", CLUTTER_FIXED_TO_FLOAT (slice_ty1));
|
||||
printf("tx2: %f\n", CLUTTER_FIXED_TO_FLOAT (slice_tx2));
|
||||
printf("ty2: %f\n", CLUTTER_FIXED_TO_FLOAT (slice_ty2));
|
||||
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));
|
||||
#endif
|
||||
|
||||
/* Pick and bind opengl texture object */
|
||||
@ -2049,7 +2061,7 @@ _cogl_texture_quad_sw (CoglTexture *tex,
|
||||
|
||||
GE( glBindTexture (tex->gl_target, gl_handle) );
|
||||
|
||||
#define CFX_F CLUTTER_FIXED_TO_FLOAT
|
||||
#define CFX_F COGL_FIXED_TO_FLOAT
|
||||
|
||||
/* Draw textured quad */
|
||||
glBegin (GL_QUADS);
|
||||
@ -2075,14 +2087,14 @@ _cogl_texture_quad_sw (CoglTexture *tex,
|
||||
|
||||
static void
|
||||
_cogl_texture_quad_hw (CoglTexture *tex,
|
||||
ClutterFixed x1,
|
||||
ClutterFixed y1,
|
||||
ClutterFixed x2,
|
||||
ClutterFixed y2,
|
||||
ClutterFixed tx1,
|
||||
ClutterFixed ty1,
|
||||
ClutterFixed tx2,
|
||||
ClutterFixed ty2)
|
||||
CoglFixed x1,
|
||||
CoglFixed y1,
|
||||
CoglFixed x2,
|
||||
CoglFixed y2,
|
||||
CoglFixed tx1,
|
||||
CoglFixed ty1,
|
||||
CoglFixed tx2,
|
||||
CoglFixed ty2)
|
||||
{
|
||||
CoglTexSliceSpan *x_span;
|
||||
CoglTexSliceSpan *y_span;
|
||||
@ -2122,7 +2134,7 @@ _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;
|
||||
|
||||
#define CFX_F(x) CLUTTER_FIXED_TO_FLOAT(x)
|
||||
#define CFX_F(x) COGL_FIXED_TO_FLOAT(x)
|
||||
|
||||
/* Draw textured quad */
|
||||
glBegin (GL_QUADS);
|
||||
@ -2146,17 +2158,17 @@ _cogl_texture_quad_hw (CoglTexture *tex,
|
||||
|
||||
void
|
||||
cogl_texture_rectangle (CoglHandle handle,
|
||||
ClutterFixed x1,
|
||||
ClutterFixed y1,
|
||||
ClutterFixed x2,
|
||||
ClutterFixed y2,
|
||||
ClutterFixed tx1,
|
||||
ClutterFixed ty1,
|
||||
ClutterFixed tx2,
|
||||
ClutterFixed ty2)
|
||||
CoglFixed x1,
|
||||
CoglFixed y1,
|
||||
CoglFixed x2,
|
||||
CoglFixed y2,
|
||||
CoglFixed tx1,
|
||||
CoglFixed ty1,
|
||||
CoglFixed tx2,
|
||||
CoglFixed ty2)
|
||||
{
|
||||
CoglTexture *tex;
|
||||
ClutterFixed tempx;
|
||||
CoglFixed tempx;
|
||||
|
||||
/* Check if valid texture */
|
||||
if (!cogl_is_texture (handle))
|
||||
@ -2214,9 +2226,11 @@ cogl_texture_rectangle (CoglHandle handle,
|
||||
}
|
||||
else
|
||||
{
|
||||
if (tex->slice_gl_handles->len == 1
|
||||
&& tx1 >= -CFX_ONE && tx2 <= CFX_ONE
|
||||
&& ty1 >= -CFX_ONE && ty2 <= CFX_ONE)
|
||||
if (tex->slice_gl_handles->len == 1 &&
|
||||
tx1 >= -COGL_FIXED_1 &&
|
||||
tx2 <= COGL_FIXED_1 &&
|
||||
ty1 >= -COGL_FIXED_1 &&
|
||||
ty2 <= COGL_FIXED_1)
|
||||
{
|
||||
_cogl_texture_quad_hw (tex, x1,y1, x2,y2, tx1,ty1, tx2,ty2);
|
||||
}
|
||||
@ -2317,18 +2331,18 @@ cogl_texture_polygon (CoglHandle handle,
|
||||
|
||||
/* Transform the texture co-ordinates so they are
|
||||
relative to the slice */
|
||||
tx = (CLUTTER_FIXED_TO_FLOAT (vertices[vnum].tx)
|
||||
tx = (COGL_FIXED_TO_FLOAT (vertices[vnum].tx)
|
||||
- x_span->start / (GLfloat) tex->bitmap.width)
|
||||
* tex->bitmap.width / x_span->size;
|
||||
ty = (CLUTTER_FIXED_TO_FLOAT (vertices[vnum].ty)
|
||||
ty = (COGL_FIXED_TO_FLOAT (vertices[vnum].ty)
|
||||
- y_span->start / (GLfloat) tex->bitmap.height)
|
||||
* tex->bitmap.height / y_span->size;
|
||||
|
||||
glTexCoord2f (tx, ty);
|
||||
|
||||
glVertex3f (CLUTTER_FIXED_TO_FLOAT (vertices[vnum].x),
|
||||
CLUTTER_FIXED_TO_FLOAT (vertices[vnum].y),
|
||||
CLUTTER_FIXED_TO_FLOAT (vertices[vnum].z));
|
||||
glVertex3f (COGL_FIXED_TO_FLOAT (vertices[vnum].x),
|
||||
COGL_FIXED_TO_FLOAT (vertices[vnum].y),
|
||||
COGL_FIXED_TO_FLOAT (vertices[vnum].z));
|
||||
}
|
||||
|
||||
GE( glEnd () );
|
||||
|
299
gl/cogl.c
299
gl/cogl.c
@ -209,19 +209,19 @@ cogl_pop_matrix (void)
|
||||
}
|
||||
|
||||
void
|
||||
cogl_scale (ClutterFixed x, ClutterFixed y)
|
||||
cogl_scale (CoglFixed x, CoglFixed y)
|
||||
{
|
||||
glScaled (CLUTTER_FIXED_TO_DOUBLE (x),
|
||||
CLUTTER_FIXED_TO_DOUBLE (y),
|
||||
glScaled (COGL_FIXED_TO_DOUBLE (x),
|
||||
COGL_FIXED_TO_DOUBLE (y),
|
||||
1.0);
|
||||
}
|
||||
|
||||
void
|
||||
cogl_translatex (ClutterFixed x, ClutterFixed y, ClutterFixed z)
|
||||
cogl_translatex (CoglFixed x, CoglFixed y, CoglFixed z)
|
||||
{
|
||||
glTranslated (CLUTTER_FIXED_TO_DOUBLE (x),
|
||||
CLUTTER_FIXED_TO_DOUBLE (y),
|
||||
CLUTTER_FIXED_TO_DOUBLE (z));
|
||||
glTranslated (COGL_FIXED_TO_DOUBLE (x),
|
||||
COGL_FIXED_TO_DOUBLE (y),
|
||||
COGL_FIXED_TO_DOUBLE (z));
|
||||
}
|
||||
|
||||
void
|
||||
@ -231,12 +231,12 @@ cogl_translate (gint x, gint y, gint z)
|
||||
}
|
||||
|
||||
void
|
||||
cogl_rotatex (ClutterFixed angle, gint x, gint y, gint z)
|
||||
cogl_rotatex (CoglFixed angle, gint x, gint y, gint z)
|
||||
{
|
||||
glRotated (CLUTTER_FIXED_TO_DOUBLE (angle),
|
||||
CLUTTER_FIXED_TO_DOUBLE (x),
|
||||
CLUTTER_FIXED_TO_DOUBLE (y),
|
||||
CLUTTER_FIXED_TO_DOUBLE (z));
|
||||
glRotated (COGL_FIXED_TO_DOUBLE (angle),
|
||||
COGL_FIXED_TO_DOUBLE (x),
|
||||
COGL_FIXED_TO_DOUBLE (y),
|
||||
COGL_FIXED_TO_DOUBLE (z));
|
||||
}
|
||||
|
||||
void
|
||||
@ -459,24 +459,24 @@ set_clip_plane (GLint plane_num,
|
||||
}
|
||||
|
||||
void
|
||||
_cogl_set_clip_planes (ClutterFixed x_offset,
|
||||
ClutterFixed y_offset,
|
||||
ClutterFixed width,
|
||||
ClutterFixed height)
|
||||
_cogl_set_clip_planes (CoglFixed x_offset,
|
||||
CoglFixed y_offset,
|
||||
CoglFixed width,
|
||||
CoglFixed height)
|
||||
{
|
||||
GLfloat modelview[16], projection[16];
|
||||
|
||||
GLfloat vertex_tl[4] = { CLUTTER_FIXED_TO_FLOAT (x_offset),
|
||||
CLUTTER_FIXED_TO_FLOAT (y_offset),
|
||||
GLfloat vertex_tl[4] = { COGL_FIXED_TO_FLOAT (x_offset),
|
||||
COGL_FIXED_TO_FLOAT (y_offset),
|
||||
0.0f, 1.0f };
|
||||
GLfloat vertex_tr[4] = { CLUTTER_FIXED_TO_FLOAT (x_offset + width),
|
||||
CLUTTER_FIXED_TO_FLOAT (y_offset),
|
||||
GLfloat vertex_tr[4] = { COGL_FIXED_TO_FLOAT (x_offset + width),
|
||||
COGL_FIXED_TO_FLOAT (y_offset),
|
||||
0.0f, 1.0f };
|
||||
GLfloat vertex_bl[4] = { CLUTTER_FIXED_TO_FLOAT (x_offset),
|
||||
CLUTTER_FIXED_TO_FLOAT (y_offset + height),
|
||||
GLfloat vertex_bl[4] = { COGL_FIXED_TO_FLOAT (x_offset),
|
||||
COGL_FIXED_TO_FLOAT (y_offset + height),
|
||||
0.0f, 1.0f };
|
||||
GLfloat vertex_br[4] = { CLUTTER_FIXED_TO_FLOAT (x_offset + width),
|
||||
CLUTTER_FIXED_TO_FLOAT (y_offset + height),
|
||||
GLfloat vertex_br[4] = { COGL_FIXED_TO_FLOAT (x_offset + width),
|
||||
COGL_FIXED_TO_FLOAT (y_offset + height),
|
||||
0.0f, 1.0f };
|
||||
|
||||
GE( glGetFloatv (GL_MODELVIEW_MATRIX, modelview) );
|
||||
@ -520,10 +520,10 @@ compare_y_coordinate (const void *a, const void *b)
|
||||
}
|
||||
|
||||
void
|
||||
_cogl_add_stencil_clip (ClutterFixed x_offset,
|
||||
ClutterFixed y_offset,
|
||||
ClutterFixed width,
|
||||
ClutterFixed height,
|
||||
_cogl_add_stencil_clip (CoglFixed x_offset,
|
||||
CoglFixed y_offset,
|
||||
CoglFixed width,
|
||||
CoglFixed height,
|
||||
gboolean first)
|
||||
{
|
||||
gboolean has_clip_planes
|
||||
@ -550,10 +550,10 @@ _cogl_add_stencil_clip (ClutterFixed 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 (CLUTTER_FIXED_TO_FLOAT (x_offset),
|
||||
CLUTTER_FIXED_TO_FLOAT (y_offset),
|
||||
CLUTTER_FIXED_TO_FLOAT (x_offset + width),
|
||||
CLUTTER_FIXED_TO_FLOAT (y_offset + height)) );
|
||||
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)) );
|
||||
}
|
||||
else if (ctx->num_stencil_bits > 1)
|
||||
{
|
||||
@ -561,10 +561,10 @@ _cogl_add_stencil_clip (ClutterFixed x_offset,
|
||||
rectangle */
|
||||
GE( glStencilFunc (GL_NEVER, 0x1, 0x3) );
|
||||
GE( glStencilOp (GL_INCR, GL_INCR, GL_INCR) );
|
||||
GE( glRectf (CLUTTER_FIXED_TO_FLOAT (x_offset),
|
||||
CLUTTER_FIXED_TO_FLOAT (y_offset),
|
||||
CLUTTER_FIXED_TO_FLOAT (x_offset + width),
|
||||
CLUTTER_FIXED_TO_FLOAT (y_offset + height)) );
|
||||
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)) );
|
||||
|
||||
/* Subtract one from all pixels in the stencil buffer so that
|
||||
only pixels where both the original stencil buffer and the
|
||||
@ -592,17 +592,17 @@ _cogl_add_stencil_clip (ClutterFixed x_offset,
|
||||
int i;
|
||||
GLfloat points[16] =
|
||||
{
|
||||
CLUTTER_FIXED_TO_FLOAT (x_offset),
|
||||
CLUTTER_FIXED_TO_FLOAT (y_offset),
|
||||
COGL_FIXED_TO_FLOAT (x_offset),
|
||||
COGL_FIXED_TO_FLOAT (y_offset),
|
||||
0, 1,
|
||||
CLUTTER_FIXED_TO_FLOAT (x_offset + width),
|
||||
CLUTTER_FIXED_TO_FLOAT (y_offset),
|
||||
COGL_FIXED_TO_FLOAT (x_offset + width),
|
||||
COGL_FIXED_TO_FLOAT (y_offset),
|
||||
0, 1,
|
||||
CLUTTER_FIXED_TO_FLOAT (x_offset),
|
||||
CLUTTER_FIXED_TO_FLOAT (y_offset + height),
|
||||
COGL_FIXED_TO_FLOAT (x_offset),
|
||||
COGL_FIXED_TO_FLOAT (y_offset + height),
|
||||
0, 1,
|
||||
CLUTTER_FIXED_TO_FLOAT (x_offset + width),
|
||||
CLUTTER_FIXED_TO_FLOAT (y_offset + height),
|
||||
COGL_FIXED_TO_FLOAT (x_offset + width),
|
||||
COGL_FIXED_TO_FLOAT (y_offset + height),
|
||||
0, 1
|
||||
};
|
||||
|
||||
@ -708,13 +708,13 @@ _cogl_add_stencil_clip (ClutterFixed x_offset,
|
||||
}
|
||||
|
||||
void
|
||||
_cogl_set_matrix (const ClutterFixed *matrix)
|
||||
_cogl_set_matrix (const CoglFixed *matrix)
|
||||
{
|
||||
float float_matrix[16];
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 16; i++)
|
||||
float_matrix[i] = CLUTTER_FIXED_TO_FLOAT (matrix[i]);
|
||||
float_matrix[i] = COGL_FIXED_TO_FLOAT (matrix[i]);
|
||||
|
||||
GE( glLoadIdentity () );
|
||||
GE( glMultMatrixf (float_matrix) );
|
||||
@ -737,20 +737,20 @@ _cogl_disable_clip_planes (void)
|
||||
|
||||
void
|
||||
cogl_alpha_func (COGLenum func,
|
||||
ClutterFixed ref)
|
||||
CoglFixed ref)
|
||||
{
|
||||
GE( glAlphaFunc (func, CLUTTER_FIXED_TO_FLOAT(ref)) );
|
||||
GE( glAlphaFunc (func, COGL_FIXED_TO_FLOAT(ref)) );
|
||||
}
|
||||
|
||||
void
|
||||
cogl_perspective (ClutterFixed fovy,
|
||||
ClutterFixed aspect,
|
||||
ClutterFixed zNear,
|
||||
ClutterFixed zFar)
|
||||
cogl_perspective (CoglFixed fovy,
|
||||
CoglFixed aspect,
|
||||
CoglFixed zNear,
|
||||
CoglFixed zFar)
|
||||
{
|
||||
ClutterFixed xmax, ymax;
|
||||
ClutterFixed x, y, c, d;
|
||||
ClutterFixed fovy_rad_half = CLUTTER_FIXED_MUL (fovy, CFX_PI) / 360;
|
||||
CoglFixed xmax, ymax;
|
||||
CoglFixed x, y, c, d;
|
||||
CoglFixed fovy_rad_half = COGL_FIXED_MUL (fovy, COGL_FIXED_PI) / 360;
|
||||
|
||||
GLfloat m[16];
|
||||
|
||||
@ -768,22 +768,25 @@ cogl_perspective (ClutterFixed fovy,
|
||||
* same true for y, hence: a == 0 && b == 0;
|
||||
*
|
||||
* 2) When working with small numbers, we are loosing significant
|
||||
* precision, hence we use clutter_qmulx() here, not the fast macro.
|
||||
* precision
|
||||
*/
|
||||
ymax = clutter_qmulx (zNear, CLUTTER_FIXED_DIV (clutter_sinx (fovy_rad_half),
|
||||
clutter_cosx (fovy_rad_half)));
|
||||
xmax = clutter_qmulx (ymax, aspect);
|
||||
ymax =
|
||||
COGL_FIXED_MUL (zNear,
|
||||
COGL_FIXED_FAST_DIV (cogl_fixed_sin (fovy_rad_half),
|
||||
cogl_fixed_cos (fovy_rad_half)));
|
||||
|
||||
x = CLUTTER_FIXED_DIV (zNear, xmax);
|
||||
y = CLUTTER_FIXED_DIV (zNear, ymax);
|
||||
c = CLUTTER_FIXED_DIV (-(zFar + zNear), ( zFar - zNear));
|
||||
d = CLUTTER_FIXED_DIV (-(clutter_qmulx (2*zFar, zNear)), (zFar - zNear));
|
||||
xmax = COGL_FIXED_FAST_DIV (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));
|
||||
d = cogl_fixed_mul_div (-(2 * zFar), zNear, (zFar - zNear));
|
||||
|
||||
#define M(row,col) m[col*4+row]
|
||||
M(0,0) = CLUTTER_FIXED_TO_FLOAT (x);
|
||||
M(1,1) = CLUTTER_FIXED_TO_FLOAT (y);
|
||||
M(2,2) = CLUTTER_FIXED_TO_FLOAT (c);
|
||||
M(2,3) = CLUTTER_FIXED_TO_FLOAT (d);
|
||||
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(3,2) = -1.0F;
|
||||
|
||||
GE( glMultMatrixf (m) );
|
||||
@ -794,22 +797,22 @@ cogl_perspective (ClutterFixed fovy,
|
||||
memset (ctx->inverse_projection, 0, sizeof (GLfloat) * 16);
|
||||
|
||||
#define m ctx->inverse_projection
|
||||
M(0, 0) = 1.0f / CLUTTER_FIXED_TO_FLOAT (x);
|
||||
M(1, 1) = 1.0f / CLUTTER_FIXED_TO_FLOAT (y);
|
||||
M(0, 0) = 1.0f / COGL_FIXED_TO_FLOAT (x);
|
||||
M(1, 1) = 1.0f / COGL_FIXED_TO_FLOAT (y);
|
||||
M(2, 3) = -1.0f;
|
||||
M(3, 2) = 1.0f / CLUTTER_FIXED_TO_FLOAT (d);
|
||||
M(3, 3) = CLUTTER_FIXED_TO_FLOAT (c) / CLUTTER_FIXED_TO_FLOAT (d);
|
||||
M(3, 2) = 1.0f / COGL_FIXED_TO_FLOAT (d);
|
||||
M(3, 3) = COGL_FIXED_TO_FLOAT (c) / COGL_FIXED_TO_FLOAT (d);
|
||||
#undef m
|
||||
#undef M
|
||||
}
|
||||
|
||||
void
|
||||
cogl_frustum (ClutterFixed left,
|
||||
ClutterFixed right,
|
||||
ClutterFixed bottom,
|
||||
ClutterFixed top,
|
||||
ClutterFixed z_near,
|
||||
ClutterFixed z_far)
|
||||
cogl_frustum (CoglFixed left,
|
||||
CoglFixed right,
|
||||
CoglFixed bottom,
|
||||
CoglFixed top,
|
||||
CoglFixed z_near,
|
||||
CoglFixed z_far)
|
||||
{
|
||||
GLfloat c, d;
|
||||
|
||||
@ -818,32 +821,32 @@ cogl_frustum (ClutterFixed left,
|
||||
GE( glMatrixMode (GL_PROJECTION) );
|
||||
GE( glLoadIdentity () );
|
||||
|
||||
GE( glFrustum (CLUTTER_FIXED_TO_DOUBLE (left),
|
||||
CLUTTER_FIXED_TO_DOUBLE (right),
|
||||
CLUTTER_FIXED_TO_DOUBLE (bottom),
|
||||
CLUTTER_FIXED_TO_DOUBLE (top),
|
||||
CLUTTER_FIXED_TO_DOUBLE (z_near),
|
||||
CLUTTER_FIXED_TO_DOUBLE (z_far)) );
|
||||
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( glMatrixMode (GL_MODELVIEW) );
|
||||
|
||||
/* Calculate and store the inverse of the matrix */
|
||||
memset (ctx->inverse_projection, 0, sizeof (GLfloat) * 16);
|
||||
|
||||
c = -CLUTTER_FIXED_TO_FLOAT (z_far + z_near)
|
||||
/ CLUTTER_FIXED_TO_FLOAT (z_far - z_near);
|
||||
d = -CLUTTER_FIXED_TO_FLOAT (2 * CFX_QMUL (z_far, z_near))
|
||||
/ CLUTTER_FIXED_TO_FLOAT (z_far - z_near);
|
||||
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);
|
||||
|
||||
#define M(row,col) ctx->inverse_projection[col*4+row]
|
||||
M(0,0) = CLUTTER_FIXED_TO_FLOAT (right - left)
|
||||
/ CLUTTER_FIXED_TO_FLOAT (2 * z_near);
|
||||
M(0,3) = CLUTTER_FIXED_TO_FLOAT (right + left)
|
||||
/ CLUTTER_FIXED_TO_FLOAT (2 * z_near);
|
||||
M(1,1) = CLUTTER_FIXED_TO_FLOAT (top - bottom)
|
||||
/ CLUTTER_FIXED_TO_FLOAT (2 * z_near);
|
||||
M(1,3) = CLUTTER_FIXED_TO_FLOAT (top + bottom)
|
||||
/ CLUTTER_FIXED_TO_FLOAT (2 * z_near);
|
||||
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(2,3) = -1.0f;
|
||||
M(3,2) = 1.0f / d;
|
||||
M(3,3) = c / d;
|
||||
@ -860,10 +863,10 @@ cogl_viewport (guint width,
|
||||
void
|
||||
cogl_setup_viewport (guint width,
|
||||
guint height,
|
||||
ClutterFixed fovy,
|
||||
ClutterFixed aspect,
|
||||
ClutterFixed z_near,
|
||||
ClutterFixed z_far)
|
||||
CoglFixed fovy,
|
||||
CoglFixed aspect,
|
||||
CoglFixed z_near,
|
||||
CoglFixed z_far)
|
||||
{
|
||||
GLfloat z_camera;
|
||||
|
||||
@ -891,13 +894,13 @@ cogl_setup_viewport (guint width,
|
||||
z_camera = DEFAULT_Z_CAMERA;
|
||||
|
||||
|
||||
if (fovy != CFX_60)
|
||||
if (fovy != COGL_FIXED_60)
|
||||
{
|
||||
ClutterFixed fovy_rad = CFX_MUL (fovy, CFX_PI) / 180;
|
||||
CoglFixed fovy_rad = COGL_FIXED_MUL (fovy, COGL_FIXED_PI) / 180;
|
||||
|
||||
z_camera =
|
||||
CLUTTER_FIXED_TO_FLOAT (CFX_DIV (clutter_sinx (fovy_rad),
|
||||
clutter_cosx (fovy_rad)) >> 1);
|
||||
COGL_FIXED_TO_FLOAT (COGL_FIXED_DIV (cogl_fixed_sin (fovy_rad),
|
||||
cogl_fixed_cos (fovy_rad)) >> 1);
|
||||
}
|
||||
|
||||
GE( glTranslatef (-0.5f, -0.5f, -z_camera) );
|
||||
@ -1141,75 +1144,75 @@ cogl_features_available (CoglFeatureFlags features)
|
||||
}
|
||||
|
||||
void
|
||||
cogl_get_modelview_matrix (ClutterFixed m[16])
|
||||
cogl_get_modelview_matrix (CoglFixed m[16])
|
||||
{
|
||||
GLdouble md[16];
|
||||
|
||||
glGetDoublev(GL_MODELVIEW_MATRIX, &md[0]);
|
||||
|
||||
#define M(m,row,col) m[col*4+row]
|
||||
M(m,0,0) = CLUTTER_FLOAT_TO_FIXED (M(md,0,0));
|
||||
M(m,0,1) = CLUTTER_FLOAT_TO_FIXED (M(md,0,1));
|
||||
M(m,0,2) = CLUTTER_FLOAT_TO_FIXED (M(md,0,2));
|
||||
M(m,0,3) = CLUTTER_FLOAT_TO_FIXED (M(md,0,3));
|
||||
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,1,0) = CLUTTER_FLOAT_TO_FIXED (M(md,1,0));
|
||||
M(m,1,1) = CLUTTER_FLOAT_TO_FIXED (M(md,1,1));
|
||||
M(m,1,2) = CLUTTER_FLOAT_TO_FIXED (M(md,1,2));
|
||||
M(m,1,3) = CLUTTER_FLOAT_TO_FIXED (M(md,1,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,2,0) = CLUTTER_FLOAT_TO_FIXED (M(md,2,0));
|
||||
M(m,2,1) = CLUTTER_FLOAT_TO_FIXED (M(md,2,1));
|
||||
M(m,2,2) = CLUTTER_FLOAT_TO_FIXED (M(md,2,2));
|
||||
M(m,2,3) = CLUTTER_FLOAT_TO_FIXED (M(md,2,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,3,0) = CLUTTER_FLOAT_TO_FIXED (M(md,3,0));
|
||||
M(m,3,1) = CLUTTER_FLOAT_TO_FIXED (M(md,3,1));
|
||||
M(m,3,2) = CLUTTER_FLOAT_TO_FIXED (M(md,3,2));
|
||||
M(m,3,3) = CLUTTER_FLOAT_TO_FIXED (M(md,3,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));
|
||||
#undef M
|
||||
}
|
||||
|
||||
void
|
||||
cogl_get_projection_matrix (ClutterFixed m[16])
|
||||
cogl_get_projection_matrix (CoglFixed m[16])
|
||||
{
|
||||
GLdouble md[16];
|
||||
|
||||
glGetDoublev(GL_PROJECTION_MATRIX, &md[0]);
|
||||
|
||||
#define M(m,row,col) m[col*4+row]
|
||||
M(m,0,0) = CLUTTER_FLOAT_TO_FIXED (M(md,0,0));
|
||||
M(m,0,1) = CLUTTER_FLOAT_TO_FIXED (M(md,0,1));
|
||||
M(m,0,2) = CLUTTER_FLOAT_TO_FIXED (M(md,0,2));
|
||||
M(m,0,3) = CLUTTER_FLOAT_TO_FIXED (M(md,0,3));
|
||||
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,1,0) = CLUTTER_FLOAT_TO_FIXED (M(md,1,0));
|
||||
M(m,1,1) = CLUTTER_FLOAT_TO_FIXED (M(md,1,1));
|
||||
M(m,1,2) = CLUTTER_FLOAT_TO_FIXED (M(md,1,2));
|
||||
M(m,1,3) = CLUTTER_FLOAT_TO_FIXED (M(md,1,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,2,0) = CLUTTER_FLOAT_TO_FIXED (M(md,2,0));
|
||||
M(m,2,1) = CLUTTER_FLOAT_TO_FIXED (M(md,2,1));
|
||||
M(m,2,2) = CLUTTER_FLOAT_TO_FIXED (M(md,2,2));
|
||||
M(m,2,3) = CLUTTER_FLOAT_TO_FIXED (M(md,2,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,3,0) = CLUTTER_FLOAT_TO_FIXED (M(md,3,0));
|
||||
M(m,3,1) = CLUTTER_FLOAT_TO_FIXED (M(md,3,1));
|
||||
M(m,3,2) = CLUTTER_FLOAT_TO_FIXED (M(md,3,2));
|
||||
M(m,3,3) = CLUTTER_FLOAT_TO_FIXED (M(md,3,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));
|
||||
#undef M
|
||||
}
|
||||
|
||||
void
|
||||
cogl_get_viewport (ClutterFixed v[4])
|
||||
cogl_get_viewport (CoglFixed v[4])
|
||||
{
|
||||
GLdouble vd[4];
|
||||
glGetDoublev(GL_VIEWPORT, &vd[0]);
|
||||
|
||||
v[0] = CLUTTER_FLOAT_TO_FIXED (vd[0]);
|
||||
v[1] = CLUTTER_FLOAT_TO_FIXED (vd[1]);
|
||||
v[2] = CLUTTER_FLOAT_TO_FIXED (vd[2]);
|
||||
v[3] = CLUTTER_FLOAT_TO_FIXED (vd[3]);
|
||||
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]);
|
||||
}
|
||||
|
||||
void
|
||||
@ -1240,9 +1243,9 @@ cogl_get_bitmasks (gint *red, gint *green, gint *blue, gint *alpha)
|
||||
|
||||
void
|
||||
cogl_fog_set (const ClutterColor *fog_color,
|
||||
ClutterFixed density,
|
||||
ClutterFixed start,
|
||||
ClutterFixed stop)
|
||||
CoglFixed density,
|
||||
CoglFixed start,
|
||||
CoglFixed stop)
|
||||
{
|
||||
GLfloat fogColor[4];
|
||||
|
||||
@ -1258,7 +1261,7 @@ cogl_fog_set (const ClutterColor *fog_color,
|
||||
glFogi (GL_FOG_MODE, GL_LINEAR);
|
||||
glHint (GL_FOG_HINT, GL_NICEST);
|
||||
|
||||
glFogf (GL_FOG_DENSITY, CLUTTER_FIXED_TO_FLOAT (density));
|
||||
glFogf (GL_FOG_START, CLUTTER_FIXED_TO_FLOAT (start));
|
||||
glFogf (GL_FOG_END, CLUTTER_FIXED_TO_FLOAT (stop));
|
||||
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));
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
libclutterincludedir = $(includedir)/clutter-@CLUTTER_API_VERSION@/cogl
|
||||
libclutterinclude_HEADERS = $(top_builddir)/clutter/cogl/cogl.h \
|
||||
$(top_builddir)/clutter/cogl/cogl-defines-gles.h
|
||||
libclutterinclude_HEADERS = \
|
||||
$(top_builddir)/clutter/cogl/cogl.h \
|
||||
$(top_builddir)/clutter/cogl/cogl-defines-gles.h \
|
||||
$(top_builddir)/clutter/cogl/cogl-fixed.h
|
||||
|
||||
INCLUDES = \
|
||||
-I$(top_srcdir) \
|
||||
@ -21,6 +23,7 @@ noinst_LTLIBRARIES = libclutter-cogl.la
|
||||
libclutter_cogl_la_SOURCES = \
|
||||
$(top_builddir)/clutter/cogl/cogl.h \
|
||||
$(top_builddir)/clutter/cogl/cogl-defines-gles.h \
|
||||
$(top_builddir)/clutter/cogl/cogl-fixed.h \
|
||||
cogl-internal.h \
|
||||
cogl-texture.h \
|
||||
cogl-fbo.h \
|
||||
|
@ -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 (-CFX_ONE, -CFX_ONE, 0) );
|
||||
GE( cogl_wrap_glScalex (CFX_QDIV (CLUTTER_INT_TO_FIXED (2),
|
||||
CLUTTER_INT_TO_FIXED (fbo->width)),
|
||||
CFX_QDIV (CLUTTER_INT_TO_FIXED (2),
|
||||
CLUTTER_INT_TO_FIXED (fbo->height)),
|
||||
CFX_ONE) );
|
||||
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) );
|
||||
|
||||
/* Bind offscreen framebuffer object */
|
||||
GE( glBindFramebuffer (GL_FRAMEBUFFER, fbo->gl_handle) );
|
||||
|
@ -118,7 +118,7 @@ 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, CFX_ONE);
|
||||
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);
|
||||
@ -506,10 +506,10 @@ cogl_gles2_wrapper_update_matrix (CoglGles2Wrapper *wrapper, GLenum matrix_num)
|
||||
void
|
||||
cogl_wrap_glClearColorx (GLclampx r, GLclampx g, GLclampx b, GLclampx a)
|
||||
{
|
||||
glClearColor (CLUTTER_FIXED_TO_FLOAT (r),
|
||||
CLUTTER_FIXED_TO_FLOAT (g),
|
||||
CLUTTER_FIXED_TO_FLOAT (b),
|
||||
CLUTTER_FIXED_TO_FLOAT (a));
|
||||
glClearColor (COGL_FIXED_TO_FLOAT (r),
|
||||
COGL_FIXED_TO_FLOAT (g),
|
||||
COGL_FIXED_TO_FLOAT (b),
|
||||
COGL_FIXED_TO_FLOAT (a));
|
||||
}
|
||||
|
||||
void
|
||||
@ -661,7 +661,7 @@ cogl_wrap_glMultMatrixx (const GLfixed *m)
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 16; i++)
|
||||
new_matrix[i] = CLUTTER_FIXED_TO_FLOAT (m[i]);
|
||||
new_matrix[i] = COGL_FIXED_TO_FLOAT (m[i]);
|
||||
|
||||
cogl_wrap_glMultMatrix (new_matrix);
|
||||
}
|
||||
@ -672,21 +672,21 @@ cogl_wrap_glFrustumx (GLfixed left, GLfixed right,
|
||||
GLfixed z_near, GLfixed z_far)
|
||||
{
|
||||
float matrix[16];
|
||||
float two_near = CLUTTER_FIXED_TO_FLOAT (2 * z_near);
|
||||
float two_near = COGL_FIXED_TO_FLOAT (2 * z_near);
|
||||
|
||||
memset (matrix, 0, sizeof (matrix));
|
||||
|
||||
matrix[0] = two_near / CLUTTER_FIXED_TO_FLOAT (right - left);
|
||||
matrix[5] = two_near / CLUTTER_FIXED_TO_FLOAT (top - bottom);
|
||||
matrix[8] = CLUTTER_FIXED_TO_FLOAT (right + left)
|
||||
/ CLUTTER_FIXED_TO_FLOAT (right - left);
|
||||
matrix[9] = CLUTTER_FIXED_TO_FLOAT (top + bottom)
|
||||
/ CLUTTER_FIXED_TO_FLOAT (top - bottom);
|
||||
matrix[10] = -CLUTTER_FIXED_TO_FLOAT (z_far + z_near)
|
||||
/ CLUTTER_FIXED_TO_FLOAT (z_far - z_near);
|
||||
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[11] = -1.0f;
|
||||
matrix[14] = -two_near * CLUTTER_FIXED_TO_FLOAT (z_far)
|
||||
/ CLUTTER_FIXED_TO_FLOAT (z_far - z_near);
|
||||
matrix[14] = -two_near * COGL_FIXED_TO_FLOAT (z_far)
|
||||
/ COGL_FIXED_TO_FLOAT (z_far - z_near);
|
||||
|
||||
cogl_wrap_glMultMatrix (matrix);
|
||||
}
|
||||
@ -697,9 +697,9 @@ cogl_wrap_glScalex (GLfixed x, GLfixed y, GLfixed z)
|
||||
float matrix[16];
|
||||
|
||||
memset (matrix, 0, sizeof (matrix));
|
||||
matrix[0] = CLUTTER_FIXED_TO_FLOAT (x);
|
||||
matrix[5] = CLUTTER_FIXED_TO_FLOAT (y);
|
||||
matrix[10] = CLUTTER_FIXED_TO_FLOAT (z);
|
||||
matrix[0] = COGL_FIXED_TO_FLOAT (x);
|
||||
matrix[5] = COGL_FIXED_TO_FLOAT (y);
|
||||
matrix[10] = COGL_FIXED_TO_FLOAT (z);
|
||||
matrix[15] = 1.0f;
|
||||
|
||||
cogl_wrap_glMultMatrix (matrix);
|
||||
@ -714,9 +714,9 @@ cogl_wrap_glTranslatex (GLfixed x, GLfixed y, GLfixed z)
|
||||
matrix[0] = 1.0f;
|
||||
matrix[5] = 1.0f;
|
||||
matrix[10] = 1.0f;
|
||||
matrix[12] = CLUTTER_FIXED_TO_FLOAT (x);
|
||||
matrix[13] = CLUTTER_FIXED_TO_FLOAT (y);
|
||||
matrix[14] = CLUTTER_FIXED_TO_FLOAT (z);
|
||||
matrix[12] = COGL_FIXED_TO_FLOAT (x);
|
||||
matrix[13] = COGL_FIXED_TO_FLOAT (y);
|
||||
matrix[14] = COGL_FIXED_TO_FLOAT (z);
|
||||
matrix[15] = 1.0f;
|
||||
|
||||
cogl_wrap_glMultMatrix (matrix);
|
||||
@ -726,10 +726,10 @@ void
|
||||
cogl_wrap_glRotatex (GLfixed angle, GLfixed x, GLfixed y, GLfixed z)
|
||||
{
|
||||
float matrix[16];
|
||||
float xf = CLUTTER_FIXED_TO_FLOAT (x);
|
||||
float yf = CLUTTER_FIXED_TO_FLOAT (y);
|
||||
float zf = CLUTTER_FIXED_TO_FLOAT (z);
|
||||
float anglef = CLUTTER_FIXED_TO_FLOAT (angle) * G_PI / 180.0f;
|
||||
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 c = cosf (anglef);
|
||||
float s = sinf (anglef);
|
||||
|
||||
@ -761,17 +761,17 @@ cogl_wrap_glOrthox (GLfixed left, GLfixed right, GLfixed bottom, GLfixed top,
|
||||
GLfixed near, GLfixed far)
|
||||
{
|
||||
float matrix[16];
|
||||
float xrange = CLUTTER_FIXED_TO_FLOAT (right - left);
|
||||
float yrange = CLUTTER_FIXED_TO_FLOAT (top - bottom);
|
||||
float zrange = CLUTTER_FIXED_TO_FLOAT (far - near);
|
||||
float xrange = COGL_FIXED_TO_FLOAT (right - left);
|
||||
float yrange = COGL_FIXED_TO_FLOAT (top - bottom);
|
||||
float zrange = COGL_FIXED_TO_FLOAT (far - near);
|
||||
|
||||
memset (matrix, 0, sizeof (matrix));
|
||||
matrix[0] = 2.0f / xrange;
|
||||
matrix[5] = 2.0f / yrange;
|
||||
matrix[10] = 2.0f / zrange;
|
||||
matrix[12] = CLUTTER_FIXED_TO_FLOAT (right + left) / xrange;
|
||||
matrix[13] = CLUTTER_FIXED_TO_FLOAT (top + bottom) / yrange;
|
||||
matrix[14] = CLUTTER_FIXED_TO_FLOAT (far + near) / 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[15] = 1.0f;
|
||||
|
||||
cogl_wrap_glMultMatrix (matrix);
|
||||
@ -1030,10 +1030,10 @@ void
|
||||
cogl_wrap_glColor4x (GLclampx r, GLclampx g, GLclampx b, GLclampx a)
|
||||
{
|
||||
glVertexAttrib4f (COGL_GLES2_WRAPPER_COLOR_ATTRIB,
|
||||
CLUTTER_FIXED_TO_FLOAT (r),
|
||||
CLUTTER_FIXED_TO_FLOAT (g),
|
||||
CLUTTER_FIXED_TO_FLOAT (b),
|
||||
CLUTTER_FIXED_TO_FLOAT (a));
|
||||
COGL_FIXED_TO_FLOAT (r),
|
||||
COGL_FIXED_TO_FLOAT (g),
|
||||
COGL_FIXED_TO_FLOAT (b),
|
||||
COGL_FIXED_TO_FLOAT (a));
|
||||
}
|
||||
|
||||
void
|
||||
@ -1043,11 +1043,12 @@ cogl_wrap_glClipPlanex (GLenum plane, GLfixed *equation)
|
||||
}
|
||||
|
||||
static void
|
||||
cogl_gles2_float_array_to_fixed (int size, const GLfloat *floats,
|
||||
GLfixed *fixeds)
|
||||
cogl_gles2_float_array_to_fixed (int size,
|
||||
const GLfloat *floats,
|
||||
GLfixed *fixeds)
|
||||
{
|
||||
while (size-- > 0)
|
||||
*(fixeds++) = CLUTTER_FLOAT_TO_FIXED (*(floats++));
|
||||
*(fixeds++) = COGL_FIXED_FROM_FLOAT (*(floats++));
|
||||
}
|
||||
|
||||
void
|
||||
@ -1110,17 +1111,17 @@ cogl_wrap_glFogx (GLenum pname, GLfixed param)
|
||||
|
||||
case GL_FOG_DENSITY:
|
||||
_COGL_GLES2_CHANGE_UNIFORM (w, FOG_DENSITY, fog_density,
|
||||
CLUTTER_FIXED_TO_FLOAT (param));
|
||||
COGL_FIXED_TO_FLOAT (param));
|
||||
break;
|
||||
|
||||
case GL_FOG_START:
|
||||
_COGL_GLES2_CHANGE_UNIFORM (w, FOG_START, fog_start,
|
||||
CLUTTER_FIXED_TO_FLOAT (param));
|
||||
COGL_FIXED_TO_FLOAT (param));
|
||||
break;
|
||||
|
||||
case GL_FOG_END:
|
||||
_COGL_GLES2_CHANGE_UNIFORM (w, FOG_END, fog_end,
|
||||
CLUTTER_FIXED_TO_FLOAT (param));
|
||||
COGL_FIXED_TO_FLOAT (param));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1134,7 +1135,8 @@ cogl_wrap_glFogxv (GLenum pname, const GLfixed *params)
|
||||
if (pname == GL_FOG_COLOR)
|
||||
{
|
||||
for (i = 0; i < 4; i++)
|
||||
w->fog_color[i] = CLUTTER_FIXED_TO_FLOAT (params[i]);
|
||||
w->fog_color[i] = COGL_FIXED_TO_FLOAT (params[i]);
|
||||
|
||||
w->dirty_uniforms |= COGL_GLES2_DIRTY_FOG_COLOR;
|
||||
}
|
||||
}
|
||||
|
@ -64,10 +64,10 @@ _cogl_rectangle (gint x,
|
||||
|
||||
|
||||
void
|
||||
_cogl_rectanglex (ClutterFixed x,
|
||||
ClutterFixed y,
|
||||
ClutterFixed width,
|
||||
ClutterFixed height)
|
||||
_cogl_rectanglex (CoglFixed x,
|
||||
CoglFixed y,
|
||||
CoglFixed width,
|
||||
CoglFixed height)
|
||||
{
|
||||
GLfixed rect_verts[8] = {
|
||||
x, y,
|
||||
@ -102,8 +102,8 @@ _cogl_path_clear_nodes ()
|
||||
}
|
||||
|
||||
void
|
||||
_cogl_path_add_node (ClutterFixed x,
|
||||
ClutterFixed y)
|
||||
_cogl_path_add_node (CoglFixed x,
|
||||
CoglFixed y)
|
||||
{
|
||||
CoglFixedVec2 *new_nodes = NULL;
|
||||
|
||||
@ -168,10 +168,10 @@ _cogl_path_fill_nodes ()
|
||||
|
||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||
|
||||
bounds_x = CLUTTER_FIXED_FLOOR (ctx->path_nodes_min.x);
|
||||
bounds_y = CLUTTER_FIXED_FLOOR (ctx->path_nodes_min.y);
|
||||
bounds_w = CLUTTER_FIXED_CEIL (ctx->path_nodes_max.x - ctx->path_nodes_min.x);
|
||||
bounds_h = CLUTTER_FIXED_CEIL (ctx->path_nodes_max.y - ctx->path_nodes_min.y);
|
||||
bounds_x = COGL_FIXED_FLOOR (ctx->path_nodes_min.x);
|
||||
bounds_y = COGL_FIXED_FLOOR (ctx->path_nodes_min.y);
|
||||
bounds_w = COGL_FIXED_CEIL (ctx->path_nodes_max.x - ctx->path_nodes_min.x);
|
||||
bounds_h = COGL_FIXED_CEIL (ctx->path_nodes_max.y - ctx->path_nodes_min.y);
|
||||
|
||||
if (cogl_features_available (COGL_FEATURE_STENCIL_BUFFER))
|
||||
{
|
||||
@ -223,14 +223,14 @@ _cogl_path_fill_nodes ()
|
||||
for (i=0; i < bounds_h; i++)
|
||||
scanlines[i]=NULL;
|
||||
|
||||
first_x = prev_x = CLUTTER_FIXED_TO_INT (ctx->path_nodes[0].x);
|
||||
first_y = prev_y = CLUTTER_FIXED_TO_INT (ctx->path_nodes[0].y);
|
||||
first_x = prev_x = COGL_FIXED_TO_INT (ctx->path_nodes[0].x);
|
||||
first_y = prev_y = COGL_FIXED_TO_INT (ctx->path_nodes[0].y);
|
||||
|
||||
/* create scanline intersection list */
|
||||
for (i=1; i<ctx->path_nodes_size; i++)
|
||||
{
|
||||
gint dest_x = CLUTTER_FIXED_TO_INT (ctx->path_nodes[i].x);
|
||||
gint dest_y = CLUTTER_FIXED_TO_INT (ctx->path_nodes[i].y);
|
||||
gint dest_x = COGL_FIXED_TO_INT (ctx->path_nodes[i].x);
|
||||
gint dest_y = COGL_FIXED_TO_INT (ctx->path_nodes[i].y);
|
||||
gint ydir;
|
||||
gint dx;
|
||||
gint dy;
|
||||
@ -326,10 +326,10 @@ _cogl_path_fill_nodes ()
|
||||
if (!next)
|
||||
break;
|
||||
|
||||
x0 = CLUTTER_INT_TO_FIXED (GPOINTER_TO_INT (iter->data));
|
||||
x1 = CLUTTER_INT_TO_FIXED (GPOINTER_TO_INT (next->data));
|
||||
y0 = CLUTTER_INT_TO_FIXED (bounds_y + i);
|
||||
y1 = CLUTTER_INT_TO_FIXED (bounds_y + i + 1) + 2048;
|
||||
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;
|
||||
/* render scanlines 1.0625 high to avoid gaps when
|
||||
transformed */
|
||||
|
||||
|
@ -55,15 +55,15 @@ struct _CoglSpanIter
|
||||
gint index;
|
||||
GArray *array;
|
||||
CoglTexSliceSpan *span;
|
||||
ClutterFixed pos;
|
||||
ClutterFixed next_pos;
|
||||
ClutterFixed origin;
|
||||
ClutterFixed cover_start;
|
||||
ClutterFixed cover_end;
|
||||
ClutterFixed intersect_start;
|
||||
ClutterFixed intersect_end;
|
||||
ClutterFixed intersect_start_local;
|
||||
ClutterFixed intersect_end_local;
|
||||
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;
|
||||
gboolean intersects;
|
||||
};
|
||||
|
||||
@ -108,7 +108,7 @@ _cogl_span_iter_update (CoglSpanIter *iter)
|
||||
|
||||
/* Offset next position by span size */
|
||||
iter->next_pos = iter->pos +
|
||||
CLUTTER_INT_TO_FIXED (iter->span->size - iter->span->waste);
|
||||
COGL_FIXED_FROM_INT (iter->span->size - iter->span->waste);
|
||||
|
||||
/* Check if span intersects the area to cover */
|
||||
if (iter->next_pos <= iter->cover_start ||
|
||||
@ -137,9 +137,9 @@ _cogl_span_iter_update (CoglSpanIter *iter)
|
||||
static void
|
||||
_cogl_span_iter_begin (CoglSpanIter *iter,
|
||||
GArray *array,
|
||||
ClutterFixed origin,
|
||||
ClutterFixed cover_start,
|
||||
ClutterFixed cover_end)
|
||||
CoglFixed origin,
|
||||
CoglFixed cover_start,
|
||||
CoglFixed cover_end)
|
||||
{
|
||||
/* Copy info */
|
||||
iter->index = 0;
|
||||
@ -342,10 +342,10 @@ _cogl_texture_draw_and_read (CoglTexture *tex,
|
||||
GLint *viewport)
|
||||
{
|
||||
gint bpp;
|
||||
ClutterFixed rx1, ry1;
|
||||
ClutterFixed rx2, ry2;
|
||||
ClutterFixed tx1, ty1;
|
||||
ClutterFixed tx2, ty2;
|
||||
CoglFixed rx1, ry1;
|
||||
CoglFixed rx2, ry2;
|
||||
CoglFixed tx1, ty1;
|
||||
CoglFixed tx2, ty2;
|
||||
int bw, bh;
|
||||
CoglBitmap rect_bmp;
|
||||
CoglHandle handle;
|
||||
@ -366,9 +366,9 @@ _cogl_texture_draw_and_read (CoglTexture *tex,
|
||||
/* Draw the texture image */
|
||||
cogl_texture_rectangle (handle,
|
||||
0, 0,
|
||||
CLUTTER_INT_TO_FIXED (tex->bitmap.width),
|
||||
CLUTTER_INT_TO_FIXED (tex->bitmap.height),
|
||||
0, 0, CFX_ONE, CFX_ONE);
|
||||
COGL_FIXED_FROM_INT (tex->bitmap.width),
|
||||
COGL_FIXED_FROM_INT (tex->bitmap.height),
|
||||
0, 0, COGL_FIXED_1, COGL_FIXED_1);
|
||||
|
||||
/* Read into target bitmap */
|
||||
GE( glPixelStorei (GL_PACK_ALIGNMENT, 1) );
|
||||
@ -383,7 +383,7 @@ _cogl_texture_draw_and_read (CoglTexture *tex,
|
||||
ry1 = 0; ry2 = 0;
|
||||
ty1 = 0; ty2 = 0;
|
||||
|
||||
#define CFIX CLUTTER_INT_TO_FIXED
|
||||
#define CFIX COGL_FIXED_FROM_INT
|
||||
|
||||
/* Walk Y axis until whole bitmap height consumed */
|
||||
for (bh = tex->bitmap.height; bh > 0; bh -= viewport[3])
|
||||
@ -394,7 +394,7 @@ _cogl_texture_draw_and_read (CoglTexture *tex,
|
||||
|
||||
/* Normalized texture Y coords */
|
||||
ty1 = ty2;
|
||||
ty2 = CFX_QDIV (CFIX (ry2), CFIX (tex->bitmap.height));
|
||||
ty2 = COGL_FIXED_DIV (CFIX (ry2), CFIX (tex->bitmap.height));
|
||||
|
||||
rx1 = 0; rx2 = 0;
|
||||
tx1 = 0; tx2 = 0;
|
||||
@ -408,7 +408,7 @@ _cogl_texture_draw_and_read (CoglTexture *tex,
|
||||
|
||||
/* Normalized texture X coords */
|
||||
tx1 = tx2;
|
||||
tx2 = CFX_QDIV (CFIX (rx2), CFIX (tex->bitmap.width));
|
||||
tx2 = COGL_FIXED_DIV (CFIX (rx2), CFIX (tex->bitmap.width));
|
||||
|
||||
/* Clear buffer with transparent black, draw with white
|
||||
for direct copy to framebuffer */
|
||||
@ -486,10 +486,10 @@ _cogl_texture_download_from_gl (CoglTexture *tex,
|
||||
GE( cogl_wrap_glPushMatrix () );
|
||||
GE( cogl_wrap_glLoadIdentity () );
|
||||
|
||||
GE( cogl_wrap_glOrthox (0, CLUTTER_INT_TO_FIXED (viewport[2]),
|
||||
0, CLUTTER_INT_TO_FIXED (viewport[3]),
|
||||
CLUTTER_INT_TO_FIXED (0),
|
||||
CLUTTER_INT_TO_FIXED (100)) );
|
||||
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_glMatrixMode (GL_MODELVIEW) );
|
||||
GE( cogl_wrap_glPushMatrix () );
|
||||
@ -608,8 +608,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, CLUTTER_INT_TO_FIXED (dst_y),
|
||||
CLUTTER_INT_TO_FIXED (dst_y + height));
|
||||
0, COGL_FIXED_FROM_INT (dst_y),
|
||||
COGL_FIXED_FROM_INT (dst_y + height));
|
||||
|
||||
!_cogl_span_iter_end (&y_iter);
|
||||
|
||||
@ -629,8 +629,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, CLUTTER_INT_TO_FIXED (dst_x),
|
||||
CLUTTER_INT_TO_FIXED (dst_x + width));
|
||||
0, COGL_FIXED_FROM_INT (dst_x),
|
||||
COGL_FIXED_FROM_INT (dst_x + width));
|
||||
|
||||
!_cogl_span_iter_end (&x_iter);
|
||||
|
||||
@ -648,16 +648,16 @@ _cogl_texture_upload_subregion_to_gl (CoglTexture *tex,
|
||||
x_iter.index);
|
||||
|
||||
/* Pick intersection width and height */
|
||||
inter_w = CLUTTER_FIXED_TO_INT (x_iter.intersect_end -
|
||||
x_iter.intersect_start);
|
||||
inter_h = CLUTTER_FIXED_TO_INT (y_iter.intersect_end -
|
||||
y_iter.intersect_start);
|
||||
inter_w = COGL_FIXED_TO_INT (x_iter.intersect_end -
|
||||
x_iter.intersect_start);
|
||||
inter_h = COGL_FIXED_TO_INT (y_iter.intersect_end -
|
||||
y_iter.intersect_start);
|
||||
|
||||
/* Localize intersection top-left corner to slice*/
|
||||
local_x = CLUTTER_FIXED_TO_INT (x_iter.intersect_start -
|
||||
x_iter.pos);
|
||||
local_y = CLUTTER_FIXED_TO_INT (y_iter.intersect_start -
|
||||
y_iter.pos);
|
||||
local_x = COGL_FIXED_TO_INT (x_iter.intersect_start -
|
||||
x_iter.pos);
|
||||
local_y = COGL_FIXED_TO_INT (y_iter.intersect_start -
|
||||
y_iter.pos);
|
||||
|
||||
/* Pick slice GL handle */
|
||||
gl_handle = g_array_index (tex->slice_gl_handles, GLuint,
|
||||
@ -702,7 +702,7 @@ _cogl_texture_upload_subregion_to_gl (CoglTexture *tex,
|
||||
&& local_x + inter_w >= x_span->size - x_span->waste)
|
||||
{
|
||||
const guchar *src = source_bmp->data
|
||||
+ (src_y + CLUTTER_FIXED_TO_INT (y_iter.intersect_start)
|
||||
+ (src_y + COGL_FIXED_TO_INT (y_iter.intersect_start)
|
||||
- dst_y) * source_bmp->rowstride
|
||||
+ (src_x + x_span->start + x_span->size - x_span->waste
|
||||
- dst_x - 1) * bpp;
|
||||
@ -734,7 +734,7 @@ _cogl_texture_upload_subregion_to_gl (CoglTexture *tex,
|
||||
&& local_y + inter_h >= y_span->size - y_span->waste)
|
||||
{
|
||||
const guchar *src = source_bmp->data
|
||||
+ (src_x + CLUTTER_FIXED_TO_INT (x_iter.intersect_start)
|
||||
+ (src_x + COGL_FIXED_TO_INT (x_iter.intersect_start)
|
||||
- dst_x) * bpp
|
||||
+ (src_y + y_span->start + y_span->size - y_span->waste
|
||||
- dst_y - 1) * source_bmp->rowstride;
|
||||
@ -1886,24 +1886,24 @@ cogl_texture_get_data (CoglHandle handle,
|
||||
|
||||
static void
|
||||
_cogl_texture_quad_sw (CoglTexture *tex,
|
||||
ClutterFixed x1,
|
||||
ClutterFixed y1,
|
||||
ClutterFixed x2,
|
||||
ClutterFixed y2,
|
||||
ClutterFixed tx1,
|
||||
ClutterFixed ty1,
|
||||
ClutterFixed tx2,
|
||||
ClutterFixed ty2)
|
||||
CoglFixed x1,
|
||||
CoglFixed y1,
|
||||
CoglFixed x2,
|
||||
CoglFixed y2,
|
||||
CoglFixed tx1,
|
||||
CoglFixed ty1,
|
||||
CoglFixed tx2,
|
||||
CoglFixed ty2)
|
||||
{
|
||||
CoglSpanIter iter_x , iter_y;
|
||||
ClutterFixed tw , th;
|
||||
ClutterFixed tqx , tqy;
|
||||
ClutterFixed first_tx , first_ty;
|
||||
ClutterFixed first_qx , first_qy;
|
||||
ClutterFixed slice_tx1 , slice_ty1;
|
||||
ClutterFixed slice_tx2 , slice_ty2;
|
||||
ClutterFixed slice_qx1 , slice_qy1;
|
||||
ClutterFixed slice_qx2 , slice_qy2;
|
||||
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;
|
||||
GLfixed tex_coords[8];
|
||||
GLfixed quad_coords[8];
|
||||
GLuint gl_handle;
|
||||
@ -1933,27 +1933,27 @@ _cogl_texture_quad_sw (CoglTexture *tex,
|
||||
GE( cogl_wrap_glVertexPointer (2, GL_FIXED, 0, quad_coords) );
|
||||
|
||||
/* Scale ratio from texture to quad widths */
|
||||
tw = CLUTTER_INT_TO_FIXED (tex->bitmap.width);
|
||||
th = CLUTTER_INT_TO_FIXED (tex->bitmap.height);
|
||||
tw = COGL_FIXED_FROM_INT (tex->bitmap.width);
|
||||
th = COGL_FIXED_FROM_INT (tex->bitmap.height);
|
||||
|
||||
tqx = CFX_QDIV (x2-x1, CFX_QMUL (tw, (tx2 - tx1)));
|
||||
tqy = CFX_QDIV (y2-y1, CFX_QMUL (th, (ty2 - ty1)));
|
||||
tqx = COGL_FIXED_DIV (x2-x1, COGL_FIXED_MUL (tw, (tx2 - tx1)));
|
||||
tqy = COGL_FIXED_DIV (y2-y1, COGL_FIXED_MUL (th, (ty2 - ty1)));
|
||||
|
||||
/* Integral texture coordinate for first tile */
|
||||
first_tx = CLUTTER_INT_TO_FIXED (CLUTTER_FIXED_FLOOR (tx1));
|
||||
first_ty = CLUTTER_INT_TO_FIXED (CLUTTER_FIXED_FLOOR (ty1));
|
||||
first_tx = COGL_FIXED_FROM_INT (COGL_FIXED_FLOOR (tx1));
|
||||
first_ty = COGL_FIXED_FROM_INT (COGL_FIXED_FLOOR (ty1));
|
||||
|
||||
/* Denormalize texture coordinates */
|
||||
first_tx = CFX_QMUL (first_tx, tw);
|
||||
first_ty = CFX_QMUL (first_ty, th);
|
||||
tx1 = CFX_QMUL (tx1, tw);
|
||||
ty1 = CFX_QMUL (ty1, th);
|
||||
tx2 = CFX_QMUL (tx2, tw);
|
||||
ty2 = CFX_QMUL (ty2, th);
|
||||
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);
|
||||
|
||||
/* Quad coordinate of the first tile */
|
||||
first_qx = x1 - CFX_QMUL (tx1 - first_tx, tqx);
|
||||
first_qy = y1 - CFX_QMUL (ty1 - first_ty, tqy);
|
||||
first_qx = x1 - COGL_FIXED_MUL (tx1 - first_tx, tqx);
|
||||
first_qy = y1 - COGL_FIXED_MUL (ty1 - first_ty, tqy);
|
||||
|
||||
|
||||
/* Iterate until whole quad height covered */
|
||||
@ -1967,10 +1967,10 @@ _cogl_texture_quad_sw (CoglTexture *tex,
|
||||
|
||||
/* Span-quad intersection in quad coordinates */
|
||||
slice_qy1 = first_qy +
|
||||
CFX_QMUL (iter_y.intersect_start - first_ty, tqy);
|
||||
COGL_FIXED_MUL (iter_y.intersect_start - first_ty, tqy);
|
||||
|
||||
slice_qy2 = first_qy +
|
||||
CFX_QMUL (iter_y.intersect_end - first_ty, tqy);
|
||||
COGL_FIXED_MUL (iter_y.intersect_end - first_ty, tqy);
|
||||
|
||||
/* Localize slice texture coordinates */
|
||||
slice_ty1 = iter_y.intersect_start - iter_y.pos;
|
||||
@ -1992,10 +1992,10 @@ _cogl_texture_quad_sw (CoglTexture *tex,
|
||||
|
||||
/* Span-quad intersection in quad coordinates */
|
||||
slice_qx1 = first_qx +
|
||||
CFX_QMUL (iter_x.intersect_start - first_tx, tqx);
|
||||
COGL_FIXED_MUL (iter_x.intersect_start - first_tx, tqx);
|
||||
|
||||
slice_qx2 = first_qx +
|
||||
CFX_QMUL (iter_x.intersect_end - first_tx, tqx);
|
||||
COGL_FIXED_MUL (iter_x.intersect_end - first_tx, tqx);
|
||||
|
||||
/* Localize slice texture coordinates */
|
||||
slice_tx1 = iter_x.intersect_start - iter_x.pos;
|
||||
@ -2007,14 +2007,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", CLUTTER_FIXED_TO_FLOAT (slice_qx1));
|
||||
printf("qy1: %f\n", CLUTTER_FIXED_TO_FLOAT (slice_qy1));
|
||||
printf("qx2: %f\n", CLUTTER_FIXED_TO_FLOAT (slice_qx2));
|
||||
printf("qy2: %f\n", CLUTTER_FIXED_TO_FLOAT (slice_qy2));
|
||||
printf("tx1: %f\n", CLUTTER_FIXED_TO_FLOAT (slice_tx1));
|
||||
printf("ty1: %f\n", CLUTTER_FIXED_TO_FLOAT (slice_ty1));
|
||||
printf("tx2: %f\n", CLUTTER_FIXED_TO_FLOAT (slice_tx2));
|
||||
printf("ty2: %f\n", CLUTTER_FIXED_TO_FLOAT (slice_ty2));
|
||||
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));
|
||||
#endif
|
||||
|
||||
/* Pick and bind opengl texture object */
|
||||
@ -2043,14 +2043,14 @@ _cogl_texture_quad_sw (CoglTexture *tex,
|
||||
|
||||
static void
|
||||
_cogl_texture_quad_hw (CoglTexture *tex,
|
||||
ClutterFixed x1,
|
||||
ClutterFixed y1,
|
||||
ClutterFixed x2,
|
||||
ClutterFixed y2,
|
||||
ClutterFixed tx1,
|
||||
ClutterFixed ty1,
|
||||
ClutterFixed tx2,
|
||||
ClutterFixed ty2)
|
||||
CoglFixed x1,
|
||||
CoglFixed y1,
|
||||
CoglFixed x2,
|
||||
CoglFixed y2,
|
||||
CoglFixed tx1,
|
||||
CoglFixed ty1,
|
||||
CoglFixed tx2,
|
||||
CoglFixed ty2)
|
||||
{
|
||||
GLfixed tex_coords[8];
|
||||
GLfixed quad_coords[8];
|
||||
@ -2111,17 +2111,17 @@ _cogl_texture_quad_hw (CoglTexture *tex,
|
||||
|
||||
void
|
||||
cogl_texture_rectangle (CoglHandle handle,
|
||||
ClutterFixed x1,
|
||||
ClutterFixed y1,
|
||||
ClutterFixed x2,
|
||||
ClutterFixed y2,
|
||||
ClutterFixed tx1,
|
||||
ClutterFixed ty1,
|
||||
ClutterFixed tx2,
|
||||
ClutterFixed ty2)
|
||||
CoglFixed x1,
|
||||
CoglFixed y1,
|
||||
CoglFixed x2,
|
||||
CoglFixed y2,
|
||||
CoglFixed tx1,
|
||||
CoglFixed ty1,
|
||||
CoglFixed tx2,
|
||||
CoglFixed ty2)
|
||||
{
|
||||
CoglTexture *tex;
|
||||
ClutterFixed tempx;
|
||||
CoglFixed tempx;
|
||||
|
||||
/* Check if valid texture */
|
||||
if (!cogl_is_texture (handle))
|
||||
@ -2170,9 +2170,9 @@ cogl_texture_rectangle (CoglHandle handle,
|
||||
}
|
||||
|
||||
/* Tile textured quads */
|
||||
if (tex->slice_gl_handles->len == 1
|
||||
&& tx1 >= -CFX_ONE && tx2 <= CFX_ONE
|
||||
&& ty1 >= -CFX_ONE && ty2 <= CFX_ONE)
|
||||
if (tex->slice_gl_handles->len == 1 &&
|
||||
tx1 >= -COGL_FIXED_1 && tx2 <= COGL_FIXED_1 &&
|
||||
ty1 >= -COGL_FIXED_1 && ty2 <= COGL_FIXED_1)
|
||||
{
|
||||
_cogl_texture_quad_hw (tex, x1,y1, x2,y2, tx1,ty1, tx2,ty2);
|
||||
}
|
||||
|
237
gles/cogl.c
237
gles/cogl.c
@ -116,13 +116,13 @@ cogl_pop_matrix (void)
|
||||
}
|
||||
|
||||
void
|
||||
cogl_scale (ClutterFixed x, ClutterFixed y)
|
||||
cogl_scale (CoglFixed x, CoglFixed y)
|
||||
{
|
||||
GE( cogl_wrap_glScalex (x, y, CFX_ONE) );
|
||||
GE( cogl_wrap_glScalex (x, y, COGL_FIXED_1) );
|
||||
}
|
||||
|
||||
void
|
||||
cogl_translatex (ClutterFixed x, ClutterFixed y, ClutterFixed z)
|
||||
cogl_translatex (CoglFixed x, CoglFixed y, CoglFixed z)
|
||||
{
|
||||
GE( cogl_wrap_glTranslatex (x, y, z) );
|
||||
}
|
||||
@ -130,16 +130,16 @@ cogl_translatex (ClutterFixed x, ClutterFixed y, ClutterFixed z)
|
||||
void
|
||||
cogl_translate (gint x, gint y, gint z)
|
||||
{
|
||||
GE( cogl_wrap_glTranslatex (CLUTTER_INT_TO_FIXED(x),
|
||||
CLUTTER_INT_TO_FIXED(y),
|
||||
CLUTTER_INT_TO_FIXED(z)) );
|
||||
GE( cogl_wrap_glTranslatex (COGL_FIXED_FROM_INT(x),
|
||||
COGL_FIXED_FROM_INT(y),
|
||||
COGL_FIXED_FROM_INT(z)) );
|
||||
}
|
||||
|
||||
void
|
||||
cogl_rotatex (ClutterFixed angle,
|
||||
ClutterFixed x,
|
||||
ClutterFixed y,
|
||||
ClutterFixed z)
|
||||
cogl_rotatex (CoglFixed angle,
|
||||
CoglFixed x,
|
||||
CoglFixed y,
|
||||
CoglFixed z)
|
||||
{
|
||||
GE( cogl_wrap_glRotatex (angle,x,y,z) );
|
||||
}
|
||||
@ -147,10 +147,10 @@ cogl_rotatex (ClutterFixed angle,
|
||||
void
|
||||
cogl_rotate (gint angle, gint x, gint y, gint z)
|
||||
{
|
||||
GE( cogl_wrap_glRotatex (CLUTTER_INT_TO_FIXED(angle),
|
||||
CLUTTER_INT_TO_FIXED(x),
|
||||
CLUTTER_INT_TO_FIXED(y),
|
||||
CLUTTER_INT_TO_FIXED(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)) );
|
||||
}
|
||||
|
||||
static inline gboolean
|
||||
@ -326,22 +326,22 @@ cogl_color (const ClutterColor *color)
|
||||
}
|
||||
|
||||
static void
|
||||
apply_matrix (const ClutterFixed *matrix, ClutterFixed *vertex)
|
||||
apply_matrix (const CoglFixed *matrix, CoglFixed *vertex)
|
||||
{
|
||||
int x, y;
|
||||
ClutterFixed vertex_out[4] = { 0 };
|
||||
CoglFixed vertex_out[4] = { 0 };
|
||||
|
||||
for (y = 0; y < 4; y++)
|
||||
for (x = 0; x < 4; x++)
|
||||
vertex_out[y] += CFX_QMUL (vertex[x], matrix[y + x * 4]);
|
||||
vertex_out[y] += cogl_fixed_mul (vertex[x], matrix[y + x * 4]);
|
||||
|
||||
memcpy (vertex, vertex_out, sizeof (vertex_out));
|
||||
}
|
||||
|
||||
static void
|
||||
project_vertex (ClutterFixed *modelview,
|
||||
ClutterFixed *project,
|
||||
ClutterFixed *vertex)
|
||||
project_vertex (CoglFixed *modelview,
|
||||
CoglFixed *project,
|
||||
CoglFixed *vertex)
|
||||
{
|
||||
int i;
|
||||
|
||||
@ -351,13 +351,13 @@ project_vertex (ClutterFixed *modelview,
|
||||
apply_matrix (project, vertex);
|
||||
/* Convert from homogenized coordinates */
|
||||
for (i = 0; i < 4; i++)
|
||||
vertex[i] = CFX_QDIV (vertex[i], vertex[3]);
|
||||
vertex[i] = cogl_fixed_div (vertex[i], vertex[3]);
|
||||
}
|
||||
|
||||
static void
|
||||
set_clip_plane (GLint plane_num,
|
||||
const ClutterFixed *vertex_a,
|
||||
const ClutterFixed *vertex_b)
|
||||
const CoglFixed *vertex_a,
|
||||
const CoglFixed *vertex_b)
|
||||
{
|
||||
GLfixed plane[4];
|
||||
GLfixed angle;
|
||||
@ -365,9 +365,9 @@ set_clip_plane (GLint plane_num,
|
||||
|
||||
/* Calculate the angle between the axes and the line crossing the
|
||||
two points */
|
||||
angle = CFX_QMUL (clutter_atan2i (vertex_b[1] - vertex_a[1],
|
||||
vertex_b[0] - vertex_a[0]),
|
||||
CFX_RADIANS_TO_DEGREES);
|
||||
angle = cogl_fixed_mul (cogl_fixed_atan2 (vertex_b[1] - vertex_a[1],
|
||||
vertex_b[0] - vertex_a[0]),
|
||||
COGL_RADIANS_TO_DEGREES);
|
||||
|
||||
GE( cogl_wrap_glPushMatrix () );
|
||||
/* Load the identity matrix and multiply by the reverse of the
|
||||
@ -383,7 +383,7 @@ set_clip_plane (GLint plane_num,
|
||||
GE( cogl_wrap_glTranslatex (-vertex_a[0], -vertex_a[1], -vertex_a[2]) );
|
||||
|
||||
plane[0] = 0;
|
||||
plane[1] = -CFX_ONE;
|
||||
plane[1] = -COGL_FIXED_1;
|
||||
plane[2] = 0;
|
||||
plane[3] = vertex_a[1];
|
||||
GE( cogl_wrap_glClipPlanex (plane_num, plane) );
|
||||
@ -394,18 +394,18 @@ set_clip_plane (GLint plane_num,
|
||||
}
|
||||
|
||||
void
|
||||
_cogl_set_clip_planes (ClutterFixed x_offset,
|
||||
ClutterFixed y_offset,
|
||||
ClutterFixed width,
|
||||
ClutterFixed height)
|
||||
_cogl_set_clip_planes (CoglFixed x_offset,
|
||||
CoglFixed y_offset,
|
||||
CoglFixed width,
|
||||
CoglFixed height)
|
||||
{
|
||||
GLfixed modelview[16], projection[16];
|
||||
|
||||
ClutterFixed vertex_tl[4] = { x_offset, y_offset, 0, CFX_ONE };
|
||||
ClutterFixed vertex_tr[4] = { x_offset + width, y_offset, 0, CFX_ONE };
|
||||
ClutterFixed vertex_bl[4] = { x_offset, y_offset + height, 0, CFX_ONE };
|
||||
ClutterFixed vertex_br[4] = { x_offset + width, y_offset + height,
|
||||
0, CFX_ONE };
|
||||
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 };
|
||||
|
||||
GE( cogl_wrap_glGetFixedv (GL_MODELVIEW_MATRIX, modelview) );
|
||||
GE( cogl_wrap_glGetFixedv (GL_PROJECTION_MATRIX, projection) );
|
||||
@ -423,7 +423,7 @@ _cogl_set_clip_planes (ClutterFixed x_offset,
|
||||
if ((vertex_tl[0] < vertex_tr[0] ? 1 : 0)
|
||||
!= (vertex_bl[1] < vertex_tl[1] ? 1 : 0))
|
||||
{
|
||||
ClutterFixed temp[4];
|
||||
CoglFixed temp[4];
|
||||
memcpy (temp, vertex_tl, sizeof (temp));
|
||||
memcpy (vertex_tl, vertex_tr, sizeof (temp));
|
||||
memcpy (vertex_tr, temp, sizeof (temp));
|
||||
@ -448,10 +448,10 @@ compare_y_coordinate (const void *a, const void *b)
|
||||
}
|
||||
|
||||
void
|
||||
_cogl_add_stencil_clip (ClutterFixed x_offset,
|
||||
ClutterFixed y_offset,
|
||||
ClutterFixed width,
|
||||
ClutterFixed height,
|
||||
_cogl_add_stencil_clip (CoglFixed x_offset,
|
||||
CoglFixed y_offset,
|
||||
CoglFixed width,
|
||||
CoglFixed height,
|
||||
gboolean first)
|
||||
{
|
||||
gboolean has_clip_planes
|
||||
@ -498,9 +498,9 @@ _cogl_add_stencil_clip (ClutterFixed x_offset,
|
||||
GE( cogl_wrap_glMatrixMode (GL_PROJECTION) );
|
||||
GE( cogl_wrap_glPushMatrix () );
|
||||
GE( cogl_wrap_glLoadIdentity () );
|
||||
cogl_rectanglex (-CFX_ONE, -CFX_ONE,
|
||||
CLUTTER_INT_TO_FIXED (2),
|
||||
CLUTTER_INT_TO_FIXED (2));
|
||||
cogl_rectanglex (-COGL_FIXED_1, -COGL_FIXED_1,
|
||||
COGL_FIXED_FROM_INT (2),
|
||||
COGL_FIXED_FROM_INT (2));
|
||||
GE( cogl_wrap_glPopMatrix () );
|
||||
GE( cogl_wrap_glMatrixMode (GL_MODELVIEW) );
|
||||
GE( cogl_wrap_glPopMatrix () );
|
||||
@ -517,10 +517,10 @@ _cogl_add_stencil_clip (ClutterFixed x_offset,
|
||||
int i;
|
||||
GLfixed points[16] =
|
||||
{
|
||||
x_offset, y_offset, 0, CFX_ONE,
|
||||
x_offset + width, y_offset, 0, CFX_ONE,
|
||||
x_offset, y_offset + height, 0, CFX_ONE,
|
||||
x_offset + width, y_offset + height, 0, CFX_ONE
|
||||
x_offset, y_offset, 0, COGL_FIXED_1,
|
||||
x_offset + width, y_offset, 0, COGL_FIXED_1,
|
||||
x_offset, y_offset + height, 0, COGL_FIXED_1,
|
||||
x_offset + width, y_offset + height, 0, COGL_FIXED_1
|
||||
};
|
||||
GLfixed draw_points[12];
|
||||
|
||||
@ -551,10 +551,10 @@ _cogl_add_stencil_clip (ClutterFixed x_offset,
|
||||
|
||||
/* If the clip rect goes outside of the screen then use the
|
||||
extents of the rect instead */
|
||||
left_edge = MIN (-CFX_ONE, MIN (points[0], points[8]));
|
||||
right_edge = MAX ( CFX_ONE, MAX (points[4], points[12]));
|
||||
bottom_edge = MIN (-CFX_ONE, MIN (points[1], points[5]));
|
||||
top_edge = MAX ( CFX_ONE, MAX (points[9], points[13]));
|
||||
left_edge = MIN (-COGL_FIXED_1, MIN (points[0], points[8]));
|
||||
right_edge = MAX ( COGL_FIXED_1, MAX (points[4], points[12]));
|
||||
bottom_edge = MIN (-COGL_FIXED_1, MIN (points[1], points[5]));
|
||||
top_edge = MAX ( COGL_FIXED_1, MAX (points[9], points[13]));
|
||||
|
||||
/* Using the identity matrix for the projection and
|
||||
modelview matrix, draw the triangles around the inner
|
||||
@ -626,7 +626,7 @@ _cogl_add_stencil_clip (ClutterFixed x_offset,
|
||||
}
|
||||
|
||||
void
|
||||
_cogl_set_matrix (const ClutterFixed *matrix)
|
||||
_cogl_set_matrix (const CoglFixed *matrix)
|
||||
{
|
||||
GE( cogl_wrap_glLoadIdentity () );
|
||||
GE( cogl_wrap_glMultMatrixx (matrix) );
|
||||
@ -649,23 +649,23 @@ _cogl_disable_clip_planes (void)
|
||||
|
||||
void
|
||||
cogl_alpha_func (COGLenum func,
|
||||
ClutterFixed ref)
|
||||
CoglFixed ref)
|
||||
{
|
||||
GE( cogl_wrap_glAlphaFunc (func, CLUTTER_FIXED_TO_FLOAT(ref)) );
|
||||
GE( cogl_wrap_glAlphaFunc (func, COGL_FIXED_TO_FLOAT(ref)) );
|
||||
}
|
||||
|
||||
/*
|
||||
* Fixed point implementation of the perspective function
|
||||
*/
|
||||
void
|
||||
cogl_perspective (ClutterFixed fovy,
|
||||
ClutterFixed aspect,
|
||||
ClutterFixed zNear,
|
||||
ClutterFixed zFar)
|
||||
cogl_perspective (CoglFixed fovy,
|
||||
CoglFixed aspect,
|
||||
CoglFixed zNear,
|
||||
CoglFixed zFar)
|
||||
{
|
||||
ClutterFixed xmax, ymax;
|
||||
ClutterFixed x, y, c, d;
|
||||
ClutterFixed fovy_rad_half = CFX_MUL (fovy, CFX_PI) / 360;
|
||||
CoglFixed xmax, ymax;
|
||||
CoglFixed x, y, c, d;
|
||||
CoglFixed fovy_rad_half = cogl_fixed_mul (fovy, COGL_FIXED_PI) / 360;
|
||||
|
||||
GLfixed m[16];
|
||||
|
||||
@ -683,51 +683,52 @@ cogl_perspective (ClutterFixed fovy,
|
||||
* same true for y, hence: a == 0 && b == 0;
|
||||
*
|
||||
* 2) When working with small numbers, we can are loosing significant
|
||||
* precision, hence we use clutter_qmulx() here, not the fast macro.
|
||||
* precision
|
||||
*/
|
||||
ymax = clutter_qmulx (zNear, CFX_DIV (clutter_sinx (fovy_rad_half),
|
||||
clutter_cosx (fovy_rad_half)));
|
||||
xmax = clutter_qmulx (ymax, aspect);
|
||||
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);
|
||||
|
||||
x = CFX_DIV (zNear, xmax);
|
||||
y = CFX_DIV (zNear, ymax);
|
||||
c = CFX_DIV (-(zFar + zNear), ( zFar - zNear));
|
||||
d = CFX_DIV (-(clutter_qmulx (2*zFar, zNear)), (zFar - zNear));
|
||||
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));
|
||||
|
||||
#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) = 1 + ~CFX_ONE;
|
||||
M(3,2) = 1 + ~COGL_FIXED_1;
|
||||
|
||||
GE( cogl_wrap_glMultMatrixx (m) );
|
||||
|
||||
GE( cogl_wrap_glMatrixMode (GL_MODELVIEW) );
|
||||
|
||||
/* Calculate and store the inverse of the matrix */
|
||||
memset (ctx->inverse_projection, 0, sizeof (ClutterFixed) * 16);
|
||||
memset (ctx->inverse_projection, 0, sizeof (CoglFixed) * 16);
|
||||
|
||||
#define m ctx->inverse_projection
|
||||
M(0, 0) = CFX_QDIV (CFX_ONE, x);
|
||||
M(1, 1) = CFX_QDIV (CFX_ONE, y);
|
||||
M(2, 3) = -CFX_ONE;
|
||||
M(3, 2) = CFX_QDIV (CFX_ONE, d);
|
||||
M(3, 3) = CFX_QDIV (c, d);
|
||||
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);
|
||||
#undef m
|
||||
|
||||
#undef M
|
||||
}
|
||||
|
||||
void
|
||||
cogl_frustum (ClutterFixed left,
|
||||
ClutterFixed right,
|
||||
ClutterFixed bottom,
|
||||
ClutterFixed top,
|
||||
ClutterFixed z_near,
|
||||
ClutterFixed z_far)
|
||||
cogl_frustum (CoglFixed left,
|
||||
CoglFixed right,
|
||||
CoglFixed bottom,
|
||||
CoglFixed top,
|
||||
CoglFixed z_near,
|
||||
CoglFixed z_far)
|
||||
{
|
||||
ClutterFixed c, d;
|
||||
CoglFixed c, d;
|
||||
|
||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||
|
||||
@ -741,19 +742,19 @@ cogl_frustum (ClutterFixed left,
|
||||
GE( cogl_wrap_glMatrixMode (GL_MODELVIEW) );
|
||||
|
||||
/* Calculate and store the inverse of the matrix */
|
||||
memset (ctx->inverse_projection, 0, sizeof (ClutterFixed) * 16);
|
||||
memset (ctx->inverse_projection, 0, sizeof (CoglFixed) * 16);
|
||||
|
||||
c = -CFX_QDIV (z_far + z_near, z_far - z_near);
|
||||
d = -CFX_QDIV (2 * CFX_QMUL (z_far, z_near), z_far - z_near);
|
||||
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);
|
||||
|
||||
#define M(row,col) ctx->inverse_projection[col*4+row]
|
||||
M(0,0) = CFX_QDIV (right - left, 2 * z_near);
|
||||
M(0,3) = CFX_QDIV (right + left, 2 * z_near);
|
||||
M(1,1) = CFX_QDIV (top - bottom, 2 * z_near);
|
||||
M(1,3) = CFX_QDIV (top + bottom, 2 * z_near);
|
||||
M(2,3) = -CFX_ONE;
|
||||
M(3,2) = CFX_QDIV (CFX_ONE, d);
|
||||
M(3,3) = CFX_QDIV (c, d);
|
||||
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);
|
||||
#undef M
|
||||
}
|
||||
|
||||
@ -767,14 +768,14 @@ cogl_viewport (guint width,
|
||||
void
|
||||
cogl_setup_viewport (guint w,
|
||||
guint h,
|
||||
ClutterFixed fovy,
|
||||
ClutterFixed aspect,
|
||||
ClutterFixed z_near,
|
||||
ClutterFixed z_far)
|
||||
CoglFixed fovy,
|
||||
CoglFixed aspect,
|
||||
CoglFixed z_near,
|
||||
CoglFixed z_far)
|
||||
{
|
||||
gint width = (gint) w;
|
||||
gint height = (gint) h;
|
||||
ClutterFixed z_camera;
|
||||
CoglFixed z_camera;
|
||||
|
||||
GE( glViewport (0, 0, width, height) );
|
||||
|
||||
@ -792,24 +793,24 @@ cogl_setup_viewport (guint w,
|
||||
* See comments in ../gl/cogl.c
|
||||
*/
|
||||
#define DEFAULT_Z_CAMERA 0.869f
|
||||
z_camera = CLUTTER_FLOAT_TO_FIXED (DEFAULT_Z_CAMERA);
|
||||
z_camera = COGL_FIXED_FROM_FLOAT (DEFAULT_Z_CAMERA);
|
||||
|
||||
if (fovy != CFX_60)
|
||||
{
|
||||
ClutterFixed fovy_rad = CFX_MUL (fovy, CFX_PI) / 180;
|
||||
if (fovy != COGL_FIXED_60)
|
||||
{
|
||||
CoglFixed fovy_rad = cogl_fixed_mul (fovy, COGL_FIXED_PI) / 180;
|
||||
|
||||
z_camera = CFX_DIV (clutter_sinx (fovy_rad),
|
||||
clutter_cosx (fovy_rad)) >> 1;
|
||||
}
|
||||
z_camera = cogl_fixed_div (cogl_fixed_sin (fovy_rad),
|
||||
cogl_fixed_cos (fovy_rad)) >> 1;
|
||||
}
|
||||
|
||||
|
||||
GE( cogl_wrap_glTranslatex (-1 << 15, -1 << 15, -z_camera));
|
||||
GE( cogl_wrap_glTranslatex (-1 << 15, -1 << 15, -z_camera) );
|
||||
|
||||
GE( cogl_wrap_glScalex ( CFX_ONE / width,
|
||||
-CFX_ONE / height,
|
||||
CFX_ONE / width));
|
||||
GE( cogl_wrap_glScalex ( COGL_FIXED_1 / width,
|
||||
-COGL_FIXED_1 / height,
|
||||
COGL_FIXED_1 / width) );
|
||||
|
||||
GE( cogl_wrap_glTranslatex (0, -CFX_ONE * height, 0) );
|
||||
GE( cogl_wrap_glTranslatex (0, -COGL_FIXED_1 * height, 0) );
|
||||
}
|
||||
|
||||
static void
|
||||
@ -860,19 +861,19 @@ cogl_features_available (CoglFeatureFlags features)
|
||||
}
|
||||
|
||||
void
|
||||
cogl_get_modelview_matrix (ClutterFixed m[16])
|
||||
cogl_get_modelview_matrix (CoglFixed m[16])
|
||||
{
|
||||
cogl_wrap_glGetFixedv(GL_MODELVIEW_MATRIX, &m[0]);
|
||||
}
|
||||
|
||||
void
|
||||
cogl_get_projection_matrix (ClutterFixed m[16])
|
||||
cogl_get_projection_matrix (CoglFixed m[16])
|
||||
{
|
||||
cogl_wrap_glGetFixedv(GL_PROJECTION_MATRIX, &m[0]);
|
||||
}
|
||||
|
||||
void
|
||||
cogl_get_viewport (ClutterFixed v[4])
|
||||
cogl_get_viewport (CoglFixed v[4])
|
||||
{
|
||||
GLint viewport[4];
|
||||
int i;
|
||||
@ -880,7 +881,7 @@ cogl_get_viewport (ClutterFixed v[4])
|
||||
cogl_wrap_glGetIntegerv (GL_VIEWPORT, viewport);
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
v[i] = CLUTTER_INT_TO_FIXED (viewport[i]);
|
||||
v[i] = COGL_FIXED_FROM_INT (viewport[i]);
|
||||
}
|
||||
|
||||
void
|
||||
@ -898,9 +899,9 @@ cogl_get_bitmasks (gint *red, gint *green, gint *blue, gint *alpha)
|
||||
|
||||
void
|
||||
cogl_fog_set (const ClutterColor *fog_color,
|
||||
ClutterFixed density,
|
||||
ClutterFixed z_near,
|
||||
ClutterFixed z_far)
|
||||
CoglFixed density,
|
||||
CoglFixed z_near,
|
||||
CoglFixed z_far)
|
||||
{
|
||||
GLfixed fogColor[4];
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user