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:
Emmanuele Bassi 2008-10-30 16:37:55 +00:00
parent 04ce490c0a
commit 911b395c8a
43 changed files with 3150 additions and 2356 deletions

View File

@ -1,3 +1,67 @@
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.
2008-10-29 Neil Roberts <neil@linux.intel.com>
Bug 1074 - FBOs on GLES

9
README
View File

@ -167,6 +167,15 @@ RELEASE NOTES
Relevant information for developers with existing Clutter applications
wanting to port to newer releases (See NEWS for general new feature info).
Release Notes for Clutter 1.0
-------------------------------
* The fixed point API implementation Clutter uses internally has been
moved from the Clutter namespace to the COGL one. The ClutterFixed
type and relative API is just a wrapper around CoglFixed and its
API. The change removed the private (yet publicly exported) and
the already deprecated ClutterFixed API.
Release Notes for Clutter 0.8
-------------------------------

View File

@ -789,17 +789,25 @@ mtx_transform (ClutterFixed m[16],
_w = *w;
/* We care lot about precision here, so have to use QMUL */
*x = CFX_QMUL (M (m, 0, 0), _x) + CFX_QMUL (M (m, 0, 1), _y) +
CFX_QMUL (M (m, 0, 2), _z) + CFX_QMUL (M (m, 0, 3), _w);
*x = COGL_FIXED_MUL (M (m, 0, 0), _x)
+ COGL_FIXED_MUL (M (m, 0, 1), _y)
+ COGL_FIXED_MUL (M (m, 0, 2), _z)
+ COGL_FIXED_MUL (M (m, 0, 3), _w);
*y = CFX_QMUL (M (m, 1, 0), _x) + CFX_QMUL (M (m, 1, 1), _y) +
CFX_QMUL (M (m, 1, 2), _z) + CFX_QMUL (M (m, 1, 3), _w);
*y = COGL_FIXED_MUL (M (m, 1, 0), _x)
+ COGL_FIXED_MUL (M (m, 1, 1), _y)
+ COGL_FIXED_MUL (M (m, 1, 2), _z)
+ COGL_FIXED_MUL (M (m, 1, 3), _w);
*z = CFX_QMUL (M (m, 2, 0), _x) + CFX_QMUL (M (m, 2, 1), _y) +
CFX_QMUL (M (m, 2, 2), _z) + CFX_QMUL (M (m, 2, 3), _w);
*z = COGL_FIXED_MUL (M (m, 2, 0), _x)
+ COGL_FIXED_MUL (M (m, 2, 1), _y)
+ COGL_FIXED_MUL (M (m, 2, 2), _z)
+ COGL_FIXED_MUL (M (m, 2, 3), _w);
*w = CFX_QMUL (M (m, 3, 0), _x) + CFX_QMUL (M (m, 3, 1), _y) +
CFX_QMUL (M (m, 3, 2), _z) + CFX_QMUL (M (m, 3, 3), _w);
*w = COGL_FIXED_MUL (M (m, 3, 0), _x)
+ COGL_FIXED_MUL (M (m, 3, 1), _y)
+ COGL_FIXED_MUL (M (m, 3, 2), _z)
+ COGL_FIXED_MUL (M (m, 3, 3), _w);
/* Specially for Matthew: was going to put a comment here, but could not
* think of anything at all to say ;)
@ -856,8 +864,8 @@ clutter_actor_transform_point (ClutterActor *actor,
/* Help macros to scale from OpenGL <-1,1> coordinates system to our
* X-window based <0,window-size> coordinates
*/
#define MTX_GL_SCALE_X(x,w,v1,v2) (CFX_QMUL (((CFX_QDIV ((x), (w)) + CFX_ONE) >> 1), (v1)) + (v2))
#define MTX_GL_SCALE_Y(y,w,v1,v2) ((v1) - CFX_QMUL (((CFX_QDIV ((y), (w)) + CFX_ONE) >> 1), (v1)) + (v2))
#define MTX_GL_SCALE_X(x,w,v1,v2) (COGL_FIXED_MUL (((COGL_FIXED_DIV ((x), (w)) + COGL_FIXED_1) >> 1), (v1)) + (v2))
#define MTX_GL_SCALE_Y(y,w,v1,v2) ((v1) - COGL_FIXED_MUL (((COGL_FIXED_DIV ((y), (w)) + COGL_FIXED_1) >> 1), (v1)) + (v2))
#define MTX_GL_SCALE_Z(z,w,v1,v2) (MTX_GL_SCALE_X ((z), (w), (v1), (v2)))
/**
@ -886,7 +894,7 @@ clutter_actor_apply_relative_transform_to_point (ClutterActor *self,
ClutterVertex *vertex)
{
ClutterFixed v[4];
ClutterFixed w = CFX_ONE;
ClutterFixed w = COGL_FIXED_1;
g_return_if_fail (CLUTTER_IS_ACTOR (self));
g_return_if_fail (ancestor == NULL || CLUTTER_IS_ACTOR (ancestor));
@ -902,9 +910,9 @@ clutter_actor_apply_relative_transform_to_point (ClutterActor *self,
* The w[3] parameter should always be 1.0 here, so we ignore it; otherwise
* we would have to divide the original verts with it.
*/
vertex->x = CFX_QMUL ((point->x + CFX_ONE / 2), v[2]);
vertex->y = CFX_QMUL ((CFX_ONE / 2 - point->y), v[3]);
vertex->z = CFX_QMUL ((point->z + CFX_ONE / 2), v[2]);
vertex->x = COGL_FIXED_MUL ((point->x + COGL_FIXED_0_5), v[2]);
vertex->y = COGL_FIXED_MUL ((COGL_FIXED_0_5 - point->y), v[3]);
vertex->z = COGL_FIXED_MUL ((point->z + COGL_FIXED_0_5), v[2]);
}
/**
@ -926,7 +934,7 @@ clutter_actor_apply_transform_to_point (ClutterActor *self,
{
ClutterFixed mtx_p[16];
ClutterFixed v[4];
ClutterFixed w = CFX_ONE;
ClutterFixed w = COGL_FIXED_1;
g_return_if_fail (CLUTTER_IS_ACTOR (self));
@ -966,7 +974,7 @@ clutter_actor_transform_vertices_relative (ClutterActor *self,
_x = 0;
_y = 0;
_z = 0;
_w = CFX_ONE;
_w = COGL_FIXED_1;
mtx_transform (mtx, &_x, &_y, &_z, &_w);
@ -978,7 +986,7 @@ clutter_actor_transform_vertices_relative (ClutterActor *self,
_x = self->priv->allocation.x2 - self->priv->allocation.x1;
_y = 0;
_z = 0;
_w = CFX_ONE;
_w = COGL_FIXED_1;
mtx_transform (mtx, &_x, &_y, &_z, &_w);
@ -990,7 +998,7 @@ clutter_actor_transform_vertices_relative (ClutterActor *self,
_x = 0;
_y = self->priv->allocation.y2 - self->priv->allocation.y1;
_z = 0;
_w = CFX_ONE;
_w = COGL_FIXED_1;
mtx_transform (mtx, &_x, &_y, &_z, &_w);
@ -1002,7 +1010,7 @@ clutter_actor_transform_vertices_relative (ClutterActor *self,
_x = self->priv->allocation.x2 - self->priv->allocation.x1;
_y = self->priv->allocation.y2 - self->priv->allocation.y1;
_z = 0;
_w = CFX_ONE;
_w = COGL_FIXED_1;
mtx_transform (mtx, &_x, &_y, &_z, &_w);
@ -1057,7 +1065,7 @@ clutter_actor_transform_and_project_box (ClutterActor *self,
_x = 0;
_y = 0;
_z = 0;
_w = CFX_ONE;
_w = COGL_FIXED_1;
mtx_transform (mtx, &_x, &_y, &_z, &_w);
@ -1069,7 +1077,7 @@ clutter_actor_transform_and_project_box (ClutterActor *self,
_x = box->x2 - box->x1;
_y = 0;
_z = 0;
_w = CFX_ONE;
_w = COGL_FIXED_1;
mtx_transform (mtx, &_x, &_y, &_z, &_w);
@ -1081,7 +1089,7 @@ clutter_actor_transform_and_project_box (ClutterActor *self,
_x = 0;
_y = box->y2 - box->y1;
_z = 0;
_w = CFX_ONE;
_w = COGL_FIXED_1;
mtx_transform (mtx, &_x, &_y, &_z, &_w);
@ -1093,7 +1101,7 @@ clutter_actor_transform_and_project_box (ClutterActor *self,
_x = box->x2 - box->x1;
_y = box->y2 - box->y1;
_z = 0;
_w = CFX_ONE;
_w = COGL_FIXED_1;
mtx_transform (mtx, &_x, &_y, &_z, &_w);
@ -1220,21 +1228,21 @@ clutter_actor_get_allocation_vertices (ClutterActor *self,
* The w[3] parameter should always be 1.0 here, so we ignore it; otherwise
* we would have to devide the original verts with it.
*/
verts[0].x = CFX_QMUL ((verts[0].x + CFX_ONE / 2), v[2]);
verts[0].y = CFX_QMUL ((CFX_ONE / 2 - verts[0].y), v[3]);
verts[0].z = CFX_QMUL ((verts[0].z + CFX_ONE / 2), v[2]);
verts[0].x = COGL_FIXED_MUL ((verts[0].x + COGL_FIXED_0_5), v[2]);
verts[0].y = COGL_FIXED_MUL ((COGL_FIXED_0_5 - verts[0].y), v[3]);
verts[0].z = COGL_FIXED_MUL ((verts[0].z + COGL_FIXED_0_5), v[2]);
verts[1].x = CFX_QMUL ((verts[1].x + CFX_ONE / 2), v[2]);
verts[1].y = CFX_QMUL ((CFX_ONE / 2 - verts[1].y), v[3]);
verts[1].z = CFX_QMUL ((verts[1].z + CFX_ONE / 2), v[2]);
verts[1].x = COGL_FIXED_MUL ((verts[1].x + COGL_FIXED_0_5), v[2]);
verts[1].y = COGL_FIXED_MUL ((COGL_FIXED_0_5 - verts[1].y), v[3]);
verts[1].z = COGL_FIXED_MUL ((verts[1].z + COGL_FIXED_0_5), v[2]);
verts[2].x = CFX_QMUL ((verts[2].x + CFX_ONE / 2), v[2]);
verts[2].y = CFX_QMUL ((CFX_ONE / 2 - verts[2].y), v[3]);
verts[2].z = CFX_QMUL ((verts[2].z + CFX_ONE / 2), v[2]);
verts[2].x = COGL_FIXED_MUL ((verts[2].x + COGL_FIXED_0_5), v[2]);
verts[2].y = COGL_FIXED_MUL ((COGL_FIXED_0_5 - verts[2].y), v[3]);
verts[2].z = COGL_FIXED_MUL ((verts[2].z + COGL_FIXED_0_5), v[2]);
verts[3].x = CFX_QMUL ((verts[3].x + CFX_ONE / 2), v[2]);
verts[3].y = CFX_QMUL ((CFX_ONE / 2 - verts[3].y), v[3]);
verts[3].z = CFX_QMUL ((verts[3].z + CFX_ONE / 2), v[2]);
verts[3].x = COGL_FIXED_MUL ((verts[3].x + COGL_FIXED_0_5), v[2]);
verts[3].y = COGL_FIXED_MUL ((COGL_FIXED_0_5 - verts[3].y), v[3]);
verts[3].z = COGL_FIXED_MUL ((verts[3].z + COGL_FIXED_0_5), v[2]);
}
/**
@ -1310,7 +1318,7 @@ _clutter_actor_apply_modelview_transform (ClutterActor *self)
* the translations included in the rotation are not scaled and so the
* entire object will move on the screen as a result of rotating it).
*/
if (priv->scale_x != CFX_ONE || priv->scale_y != CFX_ONE)
if (priv->scale_x != COGL_FIXED_1 || priv->scale_y != COGL_FIXED_1)
cogl_scale (priv->scale_x, priv->scale_y);
if (priv->rzang)
@ -1319,7 +1327,7 @@ _clutter_actor_apply_modelview_transform (ClutterActor *self)
CLUTTER_UNITS_TO_FIXED (priv->rzy),
0);
cogl_rotatex (priv->rzang, 0, 0, CFX_ONE);
cogl_rotatex (priv->rzang, 0, 0, COGL_FIXED_1);
cogl_translatex (CLUTTER_UNITS_TO_FIXED (-priv->rzx),
CLUTTER_UNITS_TO_FIXED (-priv->rzy),
@ -1332,7 +1340,7 @@ _clutter_actor_apply_modelview_transform (ClutterActor *self)
0,
CLUTTER_UNITS_TO_FIXED (priv->z + priv->ryz));
cogl_rotatex (priv->ryang, 0, CFX_ONE, 0);
cogl_rotatex (priv->ryang, 0, COGL_FIXED_1, 0);
cogl_translatex (CLUTTER_UNITS_TO_FIXED (-priv->ryx),
0,
@ -1345,7 +1353,7 @@ _clutter_actor_apply_modelview_transform (ClutterActor *self)
CLUTTER_UNITS_TO_FIXED (priv->rxy),
CLUTTER_UNITS_TO_FIXED (priv->z + priv->rxz));
cogl_rotatex (priv->rxang, CFX_ONE, 0, 0);
cogl_rotatex (priv->rxang, COGL_FIXED_1, 0, 0);
cogl_translatex (0,
CLUTTER_UNITS_TO_FIXED (-priv->rxy),
@ -1605,14 +1613,14 @@ clutter_actor_set_property (GObject *object,
case PROP_SCALE_X:
clutter_actor_set_scalex
(actor,
CLUTTER_FLOAT_TO_FIXED (g_value_get_double (value)),
COGL_FIXED_FROM_FLOAT (g_value_get_double (value)),
priv->scale_y);
break;
case PROP_SCALE_Y:
clutter_actor_set_scalex
(actor,
priv->scale_x,
CLUTTER_FLOAT_TO_FIXED (g_value_get_double (value)));
COGL_FIXED_FROM_FLOAT (g_value_get_double (value)));
break;
case PROP_CLIP:
{
@ -1630,7 +1638,7 @@ clutter_actor_set_property (GObject *object,
{
ClutterFixed angle;
angle = CLUTTER_FLOAT_TO_FIXED (g_value_get_double (value));
angle = COGL_FIXED_FROM_FLOAT (g_value_get_double (value));
clutter_actor_set_rotation_internal (actor,
CLUTTER_X_AXIS,
angle,
@ -1643,7 +1651,7 @@ clutter_actor_set_property (GObject *object,
{
ClutterFixed angle;
angle = CLUTTER_FLOAT_TO_FIXED (g_value_get_double (value));
angle = COGL_FIXED_FROM_FLOAT (g_value_get_double (value));
clutter_actor_set_rotation_internal (actor,
CLUTTER_Y_AXIS,
angle,
@ -1656,7 +1664,7 @@ clutter_actor_set_property (GObject *object,
{
ClutterFixed angle;
angle = CLUTTER_FLOAT_TO_FIXED (g_value_get_double (value));
angle = COGL_FIXED_FROM_FLOAT (g_value_get_double (value));
clutter_actor_set_rotation_internal (actor,
CLUTTER_Z_AXIS,
angle,
@ -1823,22 +1831,22 @@ clutter_actor_get_property (GObject *object,
}
break;
case PROP_SCALE_X:
g_value_set_double (value, CLUTTER_FIXED_TO_DOUBLE (priv->scale_x));
g_value_set_double (value, COGL_FIXED_TO_DOUBLE (priv->scale_x));
break;
case PROP_SCALE_Y:
g_value_set_double (value, CLUTTER_FIXED_TO_DOUBLE (priv->scale_y));
g_value_set_double (value, COGL_FIXED_TO_DOUBLE (priv->scale_y));
break;
case PROP_REACTIVE:
g_value_set_boolean (value, clutter_actor_get_reactive (actor));
break;
case PROP_ROTATION_ANGLE_X:
g_value_set_double (value, CLUTTER_FIXED_TO_DOUBLE (priv->rxang));
g_value_set_double (value, COGL_FIXED_TO_DOUBLE (priv->rxang));
break;
case PROP_ROTATION_ANGLE_Y:
g_value_set_double (value, CLUTTER_FIXED_TO_DOUBLE (priv->ryang));
g_value_set_double (value, COGL_FIXED_TO_DOUBLE (priv->ryang));
break;
case PROP_ROTATION_ANGLE_Z:
g_value_set_double (value, CLUTTER_FIXED_TO_DOUBLE (priv->rzang));
g_value_set_double (value, COGL_FIXED_TO_DOUBLE (priv->rzang));
break;
case PROP_ROTATION_CENTER_X:
{
@ -2960,8 +2968,8 @@ clutter_actor_init (ClutterActor *self)
priv->has_clip = FALSE;
priv->opacity = 0xff;
priv->id = clutter_id_pool_add (CLUTTER_CONTEXT()->id_pool, self);
priv->scale_x = CFX_ONE;
priv->scale_y = CFX_ONE;
priv->scale_x = COGL_FIXED_1;
priv->scale_y = COGL_FIXED_1;
priv->shader_data = NULL;
priv->show_on_set_parent = TRUE;
@ -4854,8 +4862,8 @@ clutter_actor_set_scale (ClutterActor *self,
g_return_if_fail (CLUTTER_IS_ACTOR (self));
clutter_actor_set_scalex (self,
CLUTTER_FLOAT_TO_FIXED (scale_x),
CLUTTER_FLOAT_TO_FIXED (scale_y));
COGL_FIXED_FROM_FLOAT (scale_x),
COGL_FIXED_FROM_FLOAT (scale_y));
}
/**
@ -4902,10 +4910,10 @@ clutter_actor_get_scale (ClutterActor *self,
g_return_if_fail (CLUTTER_IS_ACTOR (self));
if (scale_x)
*scale_x = CLUTTER_FIXED_TO_FLOAT (self->priv->scale_x);
*scale_x = COGL_FIXED_TO_FLOAT (self->priv->scale_x);
if (scale_y)
*scale_y = CLUTTER_FIXED_TO_FLOAT (self->priv->scale_y);
*scale_y = COGL_FIXED_TO_FLOAT (self->priv->scale_y);
}
/**
@ -5162,7 +5170,7 @@ clutter_actor_set_rotationu (ClutterActor *self,
g_return_if_fail (CLUTTER_IS_ACTOR (self));
clutter_actor_set_rotation_internal (self, axis,
CLUTTER_FLOAT_TO_FIXED (angle),
COGL_FIXED_FROM_FLOAT (angle),
x, y, z);
}
@ -5232,7 +5240,7 @@ clutter_actor_set_rotation (ClutterActor *self,
g_return_if_fail (CLUTTER_IS_ACTOR (self));
clutter_actor_set_rotationx (self, axis,
CLUTTER_FLOAT_TO_FIXED (angle),
COGL_FIXED_FROM_FLOAT (angle),
x, y, z);
}
@ -5273,7 +5281,7 @@ clutter_actor_get_rotationu (ClutterActor *self,
switch (axis)
{
case CLUTTER_X_AXIS:
retval = CLUTTER_FIXED_TO_DOUBLE (priv->rxang);
retval = COGL_FIXED_TO_DOUBLE (priv->rxang);
if (y)
*y = priv->rxy;
if (z)
@ -5281,7 +5289,7 @@ clutter_actor_get_rotationu (ClutterActor *self,
break;
case CLUTTER_Y_AXIS:
retval = CLUTTER_FIXED_TO_DOUBLE (priv->ryang);
retval = COGL_FIXED_TO_DOUBLE (priv->ryang);
if (x)
*x = priv->ryx;
if (z)
@ -5289,7 +5297,7 @@ clutter_actor_get_rotationu (ClutterActor *self,
break;
case CLUTTER_Z_AXIS:
retval = CLUTTER_FIXED_TO_DOUBLE (priv->rzang);
retval = COGL_FIXED_TO_DOUBLE (priv->rzang);
if (x)
*x = priv->rzx;
if (y)
@ -5388,9 +5396,9 @@ clutter_actor_get_rotation (ClutterActor *self,
{
g_return_val_if_fail (CLUTTER_IS_ACTOR (self), 0.0);
return CLUTTER_FIXED_TO_FLOAT (clutter_actor_get_rotationx (self,
axis,
x, y, z));
return COGL_FIXED_TO_FLOAT (clutter_actor_get_rotationx (self,
axis,
x, y, z));
}
/**
@ -6521,7 +6529,7 @@ parse_rotation_array (ClutterActor *actor,
/* angle */
element = json_array_get_element (array, 0);
if (JSON_NODE_TYPE (element) == JSON_NODE_VALUE)
info->angle = CLUTTER_FLOAT_TO_FIXED (json_node_get_double (element));
info->angle = COGL_FIXED_FROM_FLOAT (json_node_get_double (element));
else
return FALSE;
@ -6825,11 +6833,11 @@ clutter_actor_transform_stage_point (ClutterActor *self,
if (!du || !dv)
return FALSE;
#define FP2FX CLUTTER_FLOAT_TO_FIXED
#define FX2FP CLUTTER_FIXED_TO_DOUBLE
#define FP2FX COGL_FIXED_FROM_FLOAT
#define FX2FP COGL_FIXED_TO_DOUBLE
#define FP2INT CLUTTER_FLOAT_TO_INT
#define DET2X(a,b, c,d) (CFX_QMUL(a,d) - CFX_QMUL(b,c))
#define DET2FP(a,b, c,d) (a*d - b*c)
#define DET2X(a,b,c,d) (COGL_FIXED_MUL (a, d) - COGL_FIXED_MUL (b, c))
#define DET2FP(a,b,c,d) (a*d - b*c)
/*
* First, find mapping from unit uv square to xy quadrilateral; this
@ -6850,7 +6858,7 @@ clutter_actor_transform_stage_point (ClutterActor *self,
RQ[2][1] = v[0].y;
RQ[0][2] = 0;
RQ[1][2] = 0;
RQ[2][2] = CFX_ONE;
RQ[2][2] = COGL_FIXED_1;
}
else
{ /*
@ -6881,12 +6889,12 @@ clutter_actor_transform_stage_point (ClutterActor *self,
RQ[0][2] = FP2FX (DET2FP (FX2FP(px),dx2, FX2FP(py),dy2) / del);
RQ[1][2] = FP2FX (DET2FP (dx1,FX2FP(px), dy1,FX2FP(py)) / del);
RQ[1][2] = FP2FX (DET2FP(dx1,FX2FP(px), dy1,FX2FP(py))/del);
RQ[2][2] = CFX_ONE;
RQ[0][0] = v[1].x - v[0].x + CFX_QMUL (RQ[0][2], v[1].x);
RQ[1][0] = v[2].x - v[0].x + CFX_QMUL (RQ[1][2], v[2].x);
RQ[2][2] = COGL_FIXED_1;
RQ[0][0] = v[1].x - v[0].x + COGL_FIXED_MUL (RQ[0][2], v[1].x);
RQ[1][0] = v[2].x - v[0].x + COGL_FIXED_MUL (RQ[1][2], v[2].x);
RQ[2][0] = v[0].x;
RQ[0][1] = v[1].y - v[0].y + CFX_QMUL (RQ[0][2], v[1].y);
RQ[1][1] = v[2].y - v[0].y + CFX_QMUL (RQ[1][2], v[2].y);
RQ[0][1] = v[1].y - v[0].y + COGL_FIXED_MUL (RQ[0][2], v[1].y);
RQ[1][1] = v[2].y - v[0].y + COGL_FIXED_MUL (RQ[1][2], v[2].y);
RQ[2][1] = v[0].y;
}
@ -6918,8 +6926,9 @@ clutter_actor_transform_stage_point (ClutterActor *self,
/*
* Check the resutling martix is OK.
*/
det = CFX_QMUL (RQ[0][0], ST[0][0]) + CFX_QMUL (RQ[0][1], ST[0][1]) +
CFX_QMUL (RQ[0][2], ST[0][2]);
det = COGL_FIXED_MUL (RQ[0][0], ST[0][0])
+ COGL_FIXED_MUL (RQ[0][1], ST[0][1])
+ COGL_FIXED_MUL (RQ[0][2], ST[0][2]);
if (!det)
return FALSE;
@ -7332,7 +7341,7 @@ clutter_actor_is_scaled (ClutterActor *self)
priv = self->priv;
if (priv->scale_x != CFX_ONE || priv->scale_y != CFX_ONE)
if (priv->scale_x != COGL_FIXED_1 || priv->scale_y != COGL_FIXED_1)
return TRUE;
return FALSE;

View File

@ -571,7 +571,7 @@ sincx1024_func (ClutterAlpha *alpha,
ClutterTimeline *timeline;
gint current_frame_num, n_frames;
ClutterAngle x;
unsigned int sine;
ClutterFixed sine;
timeline = clutter_alpha_get_timeline (alpha);
@ -582,12 +582,12 @@ sincx1024_func (ClutterAlpha *alpha,
x -= (512 * 512 / angle);
sine = ((clutter_sini (x) + offset)/2) * CLUTTER_ALPHA_MAX_ALPHA;
sine = ((cogl_angle_sin (x) + offset) / 2)
* CLUTTER_ALPHA_MAX_ALPHA;
sine = sine >> CFX_Q;
return sine;
return COGL_FIXED_TO_INT (sine);
}
#if 0
/*
* The following two functions are left in place for reference
@ -608,13 +608,14 @@ sincx_func (ClutterAlpha *alpha,
n_frames = clutter_timeline_get_n_frames (timeline);
x = angle * current_frame_num / n_frames;
x = CLUTTER_FIXED_MUL (x, CFX_PI) - CLUTTER_FIXED_DIV (CFX_PI, angle);
x = COGL_FIXED_FAST_MUL (x, COGL_FIXED_PI)
- COGL_FIXED_FAST_DIV (COGL_FIXED_PI, angle);
sine = (clutter_fixed_sin (x) + offset)/2;
sine = (cogl_fixed_sin (x) + offset) / 2;
CLUTTER_NOTE (ALPHA, "sine: %2f\n", CLUTTER_FIXED_TO_DOUBLE (sine));
CLUTTER_NOTE (ALPHA, "sine: %2f\n", COGL_FIXED_TO_DOUBLE (sine));
return CLUTTER_FIXED_TO_INT (sine * CLUTTER_ALPHA_MAX_ALPHA);
return COGL_FIXED_TO_INT (sine * CLUTTER_ALPHA_MAX_ALPHA);
}
/* NB: angle is not in radians but in muliples of PI, i.e., 2.0
@ -641,7 +642,7 @@ sinc_func (ClutterAlpha *alpha,
CLUTTER_NOTE (ALPHA, "sine: %2f\n",sine);
return CLUTTER_FLOAT_TO_INT ((sine * (gdouble) CLUTTER_ALPHA_MAX_ALPHA));
return COGL_FLOAT_TO_INT ((sine * (gdouble) CLUTTER_ALPHA_MAX_ALPHA));
}
#endif
@ -673,7 +674,7 @@ clutter_sine_func (ClutterAlpha *alpha,
return sinc_func (alpha, 2.0, 1.0);
#else
/* 2.0 above represents full circle */
return sincx1024_func (alpha, 1024, CFX_ONE);
return sincx1024_func (alpha, 1024, COGL_FIXED_1);
#endif
}
@ -714,9 +715,9 @@ clutter_sine_inc_func (ClutterAlpha *alpha,
x = 256 * frame / n_frames;
sine = clutter_sini (x) * CLUTTER_ALPHA_MAX_ALPHA;
sine = cogl_angle_sin (x) * CLUTTER_ALPHA_MAX_ALPHA;
return ((guint32)sine) >> CFX_Q;
return COGL_FIXED_TO_INT (sine);
}
/**
@ -756,9 +757,9 @@ clutter_sine_dec_func (ClutterAlpha *alpha,
x = 256 * frame / n_frames + 256;
sine = clutter_sini (x) * CLUTTER_ALPHA_MAX_ALPHA;
sine = cogl_angle_sin (x) * CLUTTER_ALPHA_MAX_ALPHA;
return ((guint32)sine) >> CFX_Q;
return COGL_FIXED_TO_INT (sine);
}
/**
@ -798,9 +799,9 @@ clutter_sine_half_func (ClutterAlpha *alpha,
x = 512 * frame / n_frames;
sine = clutter_sini (x) * CLUTTER_ALPHA_MAX_ALPHA;
sine = cogl_angle_sin (x) * CLUTTER_ALPHA_MAX_ALPHA;
return ((guint32)sine) >> CFX_Q;
return COGL_FIXED_TO_INT (sine);
}
/**
@ -882,7 +883,7 @@ clutter_smoothstep_inc_func (ClutterAlpha *alpha,
/*
* Convert x to 8.24 for next step.
*/
x = CFX_DIV (frame, n_frames) << 8;
x = COGL_FIXED_FAST_DIV (frame, n_frames) << 8;
/*
* f(x) = -2x^3 + 3x^2
@ -891,7 +892,7 @@ clutter_smoothstep_inc_func (ClutterAlpha *alpha,
*/
r = ((x >> 12) * (x >> 12) * 3 - (x >> 15) * (x >> 16) * (x >> 16)) >> 8;
return CFX_INT (r * CLUTTER_ALPHA_MAX_ALPHA);
return COGL_FIXED_TO_INT (r * CLUTTER_ALPHA_MAX_ALPHA);
}
/**
@ -967,7 +968,7 @@ clutter_exp_inc_func (ClutterAlpha *alpha,
x = x_alpha_max * frame / n_frames;
result = CLAMP (clutter_pow2x (x) - 1, 0, CLUTTER_ALPHA_MAX_ALPHA);
result = CLAMP (cogl_fixed_pow2 (x) - 1, 0, CLUTTER_ALPHA_MAX_ALPHA);
return result;
}
@ -1018,7 +1019,7 @@ clutter_exp_dec_func (ClutterAlpha *alpha,
x = (x_alpha_max * (n_frames - frame)) / n_frames;
result = CLAMP (clutter_pow2x (x) - 1, 0, CLUTTER_ALPHA_MAX_ALPHA);
result = CLAMP (cogl_fixed_pow2 (x) - 1, 0, CLUTTER_ALPHA_MAX_ALPHA);
return result;
}

View File

@ -383,13 +383,13 @@ clutter_backend_set_resolution (ClutterBackend *backend,
priv = backend->priv;
fixed_dpi = CLUTTER_FLOAT_TO_FIXED (dpi);
fixed_dpi = COGL_FIXED_FROM_FLOAT (dpi);
if (priv->resolution != fixed_dpi)
priv->resolution = fixed_dpi;
if (CLUTTER_CONTEXT ()->font_map)
pango_clutter_font_map_set_resolution (CLUTTER_CONTEXT ()->font_map,
CLUTTER_FIXED_TO_FLOAT (fixed_dpi));
COGL_FIXED_TO_FLOAT (fixed_dpi));
}
/**
@ -409,7 +409,7 @@ clutter_backend_get_resolution (ClutterBackend *backend)
{
g_return_val_if_fail (CLUTTER_IS_BACKEND (backend), -1.0);
return CLUTTER_FIXED_TO_FLOAT (backend->priv->resolution);
return COGL_FIXED_TO_FLOAT (backend->priv->resolution);
}
/**

View File

@ -83,10 +83,9 @@ clutter_behaviour_depth_alpha_notify (ClutterBehaviour *behaviour,
priv = CLUTTER_BEHAVIOUR_DEPTH (behaviour)->priv;
/* Need to create factor as to avoid borking signedness */
factor = CLUTTER_INT_TO_FIXED (alpha_value) / CLUTTER_ALPHA_MAX_ALPHA;
factor = COGL_FIXED_FROM_INT (alpha_value) / CLUTTER_ALPHA_MAX_ALPHA;
depth = priv->depth_start
+ CLUTTER_FIXED_TO_INT (factor
* (priv->depth_end - priv->depth_start));
+ COGL_FIXED_TO_INT (factor * (priv->depth_end - priv->depth_start));
CLUTTER_NOTE (BEHAVIOUR, "alpha: %d, depth: %d", alpha_value, depth);

View File

@ -109,8 +109,8 @@ clutter_behaviour_ellipse_advance (ClutterBehaviourEllipse *e,
ClutterBehaviourEllipsePrivate *priv = e->priv;
gint x, y, z;
x = CLUTTER_FIXED_TO_INT (priv->a * clutter_cosi (angle));
y = CLUTTER_FIXED_TO_INT (priv->b * clutter_sini (angle));
x = COGL_FIXED_TO_INT (priv->a * cogl_angle_cos (angle));
y = COGL_FIXED_TO_INT (priv->b * cogl_angle_sin (angle));
z = 0;
if (priv->angle_tilt_z)
@ -125,40 +125,40 @@ clutter_behaviour_ellipse_advance (ClutterBehaviourEllipse *e,
*/
ClutterFixed x2, y2;
x2 = x * clutter_cosi (priv->angle_tilt_z)
- y * clutter_sini (priv->angle_tilt_z);
x2 = x * cogl_angle_cos (priv->angle_tilt_z)
- y * cogl_angle_sin (priv->angle_tilt_z);
y2 = y * clutter_cosi (priv->angle_tilt_z)
+ x * clutter_sini (priv->angle_tilt_z);
y2 = y * cogl_angle_cos (priv->angle_tilt_z)
+ x * cogl_angle_sin (priv->angle_tilt_z);
x = CLUTTER_FIXED_TO_INT (x2);
y = CLUTTER_FIXED_TO_INT (y2);
x = COGL_FIXED_TO_INT (x2);
y = COGL_FIXED_TO_INT (y2);
}
if (priv->angle_tilt_x)
{
ClutterFixed z2, y2;
z2 = - y * clutter_sini (priv->angle_tilt_x);
z2 = - y * cogl_angle_sin (priv->angle_tilt_x);
y2 = y * clutter_cosi (priv->angle_tilt_x);
y2 = y * cogl_angle_cos (priv->angle_tilt_x);
z = CLUTTER_FIXED_TO_INT (z2);
y = CLUTTER_FIXED_TO_INT (y2);
z = COGL_FIXED_TO_INT (z2);
y = COGL_FIXED_TO_INT (y2);
}
if (priv->angle_tilt_y)
{
ClutterFixed x2, z2;
x2 = x * clutter_cosi (priv->angle_tilt_y)
- z * clutter_sini (priv->angle_tilt_y);
x2 = x * cogl_angle_cos (priv->angle_tilt_y)
- z * cogl_angle_sin (priv->angle_tilt_y);
z2 = z * clutter_cosi (priv->angle_tilt_y)
+ x * clutter_sini (priv->angle_tilt_y);
z2 = z * cogl_angle_cos (priv->angle_tilt_y)
+ x * cogl_angle_sin (priv->angle_tilt_y);
x = CLUTTER_FIXED_TO_INT (x2);
z = CLUTTER_FIXED_TO_INT (z2);
x = COGL_FIXED_TO_INT (x2);
z = COGL_FIXED_TO_INT (z2);
}
knot->x = x;
@ -192,7 +192,7 @@ clamp_angle (ClutterAngle a)
/* Need to add the 256 offset here, since the user space 0 maps to our
* -256
*/
rounds = (a+256) / 1024;
rounds = (a + 256) / 1024;
a1 = rounds * 1024;
a2 = a - a1;
@ -244,23 +244,23 @@ clutter_behaviour_ellipse_set_property (GObject *gobject,
{
case PROP_ANGLE_START:
priv->angle_start =
CLUTTER_ANGLE_FROM_DEG (g_value_get_double (value)) - 256;
COGL_ANGLE_FROM_DEG (g_value_get_double (value)) - 256;
break;
case PROP_ANGLE_END:
priv->angle_end =
CLUTTER_ANGLE_FROM_DEG (g_value_get_double (value)) - 256;
COGL_ANGLE_FROM_DEG (g_value_get_double (value)) - 256;
break;
case PROP_ANGLE_TILT_X:
priv->angle_tilt_x =
CLUTTER_ANGLE_FROM_DEG (g_value_get_double (value));
COGL_ANGLE_FROM_DEG (g_value_get_double (value));
break;
case PROP_ANGLE_TILT_Y:
priv->angle_tilt_y =
CLUTTER_ANGLE_FROM_DEG (g_value_get_double (value));
COGL_ANGLE_FROM_DEG (g_value_get_double (value));
break;
case PROP_ANGLE_TILT_Z:
priv->angle_tilt_z =
CLUTTER_ANGLE_FROM_DEG (g_value_get_double (value));
COGL_ANGLE_FROM_DEG (g_value_get_double (value));
break;
case PROP_WIDTH:
priv->a = g_value_get_int (value) >> 1;
@ -298,23 +298,23 @@ clutter_behaviour_ellipse_get_property (GObject *gobject,
{
case PROP_ANGLE_START:
g_value_set_double (value,
CLUTTER_ANGLE_TO_DEG (priv->angle_start + 256));
COGL_ANGLE_TO_DEG (priv->angle_start + 256));
break;
case PROP_ANGLE_END:
g_value_set_double (value,
CLUTTER_ANGLE_TO_DEG (priv->angle_end + 256));
COGL_ANGLE_TO_DEG (priv->angle_end + 256));
break;
case PROP_ANGLE_TILT_X:
g_value_set_double (value,
CLUTTER_ANGLE_TO_DEG (priv->angle_tilt_x));
COGL_ANGLE_TO_DEG (priv->angle_tilt_x));
break;
case PROP_ANGLE_TILT_Y:
g_value_set_double (value,
CLUTTER_ANGLE_TO_DEG (priv->angle_tilt_y));
COGL_ANGLE_TO_DEG (priv->angle_tilt_y));
break;
case PROP_ANGLE_TILT_Z:
g_value_set_double (value,
CLUTTER_ANGLE_TO_DEG (priv->angle_tilt_z));
COGL_ANGLE_TO_DEG (priv->angle_tilt_z));
break;
case PROP_WIDTH:
g_value_set_int (value, (priv->a << 1));
@ -609,8 +609,8 @@ clutter_behaviour_ellipse_newx (ClutterAlpha * alpha,
"width", width,
"height", height,
"direction", direction,
"angle-start", CLUTTER_ANGLE_FROM_DEGX (start),
"angle-end", CLUTTER_ANGLE_FROM_DEGX (end),
"angle-start", COGL_ANGLE_FROM_DEGX (start),
"angle-end", COGL_ANGLE_FROM_DEGX (end),
NULL);
}
@ -781,7 +781,7 @@ clutter_behaviour_ellipse_set_angle_start (ClutterBehaviourEllipse *self,
g_return_if_fail (CLUTTER_IS_BEHAVIOUR_ELLIPSE (self));
clutter_behaviour_ellipse_set_angle_startx (self,
CLUTTER_FLOAT_TO_FIXED (angle_start));
COGL_FIXED_FROM_FLOAT (angle_start));
}
/**
@ -803,7 +803,7 @@ clutter_behaviour_ellipse_set_angle_startx (ClutterBehaviourEllipse *self,
ClutterAngle new_angle;
g_return_if_fail (CLUTTER_IS_BEHAVIOUR_ELLIPSE (self));
new_angle = clamp_angle (CLUTTER_ANGLE_FROM_DEGX (angle_start) - 256);
new_angle = clamp_angle (COGL_ANGLE_FROM_DEGX (angle_start) - 256);
priv = self->priv;
if (priv->angle_start != new_angle)
@ -828,7 +828,7 @@ clutter_behaviour_ellipse_get_angle_start (ClutterBehaviourEllipse *self)
{
g_return_val_if_fail (CLUTTER_IS_BEHAVIOUR_ELLIPSE (self), 0.0);
return CLUTTER_ANGLE_TO_DEG (self->priv->angle_start + 256);
return COGL_ANGLE_TO_DEG (self->priv->angle_start + 256);
}
/**
@ -846,7 +846,7 @@ clutter_behaviour_ellipse_get_angle_startx (ClutterBehaviourEllipse *self)
{
g_return_val_if_fail (CLUTTER_IS_BEHAVIOUR_ELLIPSE (self), 0);
return CLUTTER_ANGLE_TO_DEGX (self->priv->angle_start);
return COGL_ANGLE_TO_DEGX (self->priv->angle_start);
}
/**
@ -866,7 +866,7 @@ clutter_behaviour_ellipse_set_angle_end (ClutterBehaviourEllipse *self,
g_return_if_fail (CLUTTER_IS_BEHAVIOUR_ELLIPSE (self));
clutter_behaviour_ellipse_set_angle_endx (self,
CLUTTER_FLOAT_TO_FIXED (angle_end));
COGL_FIXED_FROM_FLOAT (angle_end));
}
/**
@ -889,7 +889,7 @@ clutter_behaviour_ellipse_set_angle_endx (ClutterBehaviourEllipse *self,
g_return_if_fail (CLUTTER_IS_BEHAVIOUR_ELLIPSE (self));
new_angle = clamp_angle (CLUTTER_ANGLE_FROM_DEGX (angle_end) - 256);
new_angle = clamp_angle (COGL_ANGLE_FROM_DEGX (angle_end) - 256);
priv = self->priv;
@ -916,7 +916,7 @@ clutter_behaviour_ellipse_get_angle_end (ClutterBehaviourEllipse *self)
{
g_return_val_if_fail (CLUTTER_IS_BEHAVIOUR_ELLIPSE (self), 0.0);
return CLUTTER_ANGLE_TO_DEG (self->priv->angle_end + 256);
return COGL_ANGLE_TO_DEG (self->priv->angle_end + 256);
}
/**
@ -934,7 +934,7 @@ clutter_behaviour_ellipse_get_angle_endx (ClutterBehaviourEllipse *self)
{
g_return_val_if_fail (CLUTTER_IS_BEHAVIOUR_ELLIPSE (self), 0);
return CLUTTER_ANGLE_TO_DEGX (self->priv->angle_end);
return COGL_ANGLE_TO_DEGX (self->priv->angle_end);
}
/**
@ -956,8 +956,8 @@ clutter_behaviour_ellipse_set_angle_tilt (ClutterBehaviourEllipse *self,
g_return_if_fail (CLUTTER_IS_BEHAVIOUR_ELLIPSE (self));
clutter_behaviour_ellipse_set_angle_tiltx (self,
axis,
CLUTTER_FLOAT_TO_FIXED (angle_tilt));
axis,
COGL_FIXED_FROM_FLOAT (angle_tilt));
}
/**
@ -981,7 +981,7 @@ clutter_behaviour_ellipse_set_angle_tiltx (ClutterBehaviourEllipse *self,
g_return_if_fail (CLUTTER_IS_BEHAVIOUR_ELLIPSE (self));
new_angle = CLUTTER_ANGLE_FROM_DEGX (angle_tilt);
new_angle = COGL_ANGLE_FROM_DEGX (angle_tilt);
priv = self->priv;
@ -1036,11 +1036,11 @@ clutter_behaviour_ellipse_get_angle_tilt (ClutterBehaviourEllipse *self,
switch (axis)
{
case CLUTTER_X_AXIS:
return CLUTTER_ANGLE_TO_DEG (self->priv->angle_tilt_x);
return COGL_ANGLE_TO_DEG (self->priv->angle_tilt_x);
case CLUTTER_Y_AXIS:
return CLUTTER_ANGLE_TO_DEG (self->priv->angle_tilt_y);
return COGL_ANGLE_TO_DEG (self->priv->angle_tilt_y);
case CLUTTER_Z_AXIS:
return CLUTTER_ANGLE_TO_DEG (self->priv->angle_tilt_z);
return COGL_ANGLE_TO_DEG (self->priv->angle_tilt_z);
}
return 0;
@ -1066,11 +1066,11 @@ clutter_behaviour_ellipse_get_angle_tiltx (ClutterBehaviourEllipse *self,
switch (axis)
{
case CLUTTER_X_AXIS:
return CLUTTER_ANGLE_TO_DEGX (self->priv->angle_tilt_x);
return COGL_ANGLE_TO_DEGX (self->priv->angle_tilt_x);
case CLUTTER_Y_AXIS:
return CLUTTER_ANGLE_TO_DEGX (self->priv->angle_tilt_y);
return COGL_ANGLE_TO_DEGX (self->priv->angle_tilt_y);
case CLUTTER_Z_AXIS:
return CLUTTER_ANGLE_TO_DEGX (self->priv->angle_tilt_z);
return COGL_ANGLE_TO_DEGX (self->priv->angle_tilt_z);
}
return 0;
@ -1098,9 +1098,9 @@ clutter_behaviour_ellipse_set_tilt (ClutterBehaviourEllipse *self,
g_return_if_fail (CLUTTER_IS_BEHAVIOUR_ELLIPSE (self));
new_angle_x = CLUTTER_ANGLE_FROM_DEG (angle_tilt_x);
new_angle_y = CLUTTER_ANGLE_FROM_DEG (angle_tilt_y);
new_angle_z = CLUTTER_ANGLE_FROM_DEG (angle_tilt_z);
new_angle_x = COGL_ANGLE_FROM_DEG (angle_tilt_x);
new_angle_y = COGL_ANGLE_FROM_DEG (angle_tilt_y);
new_angle_z = COGL_ANGLE_FROM_DEG (angle_tilt_z);
priv = self->priv;
@ -1152,9 +1152,9 @@ clutter_behaviour_ellipse_set_tiltx (ClutterBehaviourEllipse *self,
g_return_if_fail (CLUTTER_IS_BEHAVIOUR_ELLIPSE (self));
new_angle_x = CLUTTER_ANGLE_FROM_DEGX (angle_tilt_x);
new_angle_y = CLUTTER_ANGLE_FROM_DEGX (angle_tilt_y);
new_angle_z = CLUTTER_ANGLE_FROM_DEGX (angle_tilt_z);
new_angle_x = COGL_ANGLE_FROM_DEGX (angle_tilt_x);
new_angle_y = COGL_ANGLE_FROM_DEGX (angle_tilt_y);
new_angle_z = COGL_ANGLE_FROM_DEGX (angle_tilt_z);
priv = self->priv;
@ -1208,13 +1208,13 @@ clutter_behaviour_ellipse_get_tilt (ClutterBehaviourEllipse *self,
priv = self->priv;
if (angle_tilt_x)
*angle_tilt_x = CLUTTER_ANGLE_TO_DEG (priv->angle_tilt_x);
*angle_tilt_x = COGL_ANGLE_TO_DEG (priv->angle_tilt_x);
if (angle_tilt_y)
*angle_tilt_y = CLUTTER_ANGLE_TO_DEG (priv->angle_tilt_y);
*angle_tilt_y = COGL_ANGLE_TO_DEG (priv->angle_tilt_y);
if (angle_tilt_z)
*angle_tilt_z = CLUTTER_ANGLE_TO_DEG (priv->angle_tilt_z);
*angle_tilt_z = COGL_ANGLE_TO_DEG (priv->angle_tilt_z);
}
/**
@ -1244,13 +1244,13 @@ clutter_behaviour_ellipse_get_tiltx (ClutterBehaviourEllipse *self,
priv = self->priv;
if (angle_tilt_x)
*angle_tilt_x = CLUTTER_ANGLE_TO_DEGX (priv->angle_tilt_x);
*angle_tilt_x = COGL_ANGLE_TO_DEGX (priv->angle_tilt_x);
if (angle_tilt_y)
*angle_tilt_y = CLUTTER_ANGLE_TO_DEGX (priv->angle_tilt_y);
*angle_tilt_y = COGL_ANGLE_TO_DEGX (priv->angle_tilt_y);
if (angle_tilt_z)
*angle_tilt_z = CLUTTER_ANGLE_TO_DEGX (priv->angle_tilt_z);
*angle_tilt_z = COGL_ANGLE_TO_DEGX (priv->angle_tilt_z);
}
/**

View File

@ -116,8 +116,8 @@ interpolate (const ClutterKnot *start,
ClutterKnot *out,
ClutterFixed t)
{
out->x = start->x + CLUTTER_FIXED_TO_INT (t * (end->x - start->x));
out->y = start->y + CLUTTER_FIXED_TO_INT (t * (end->y - start->y));
out->x = start->x + COGL_FIXED_TO_INT (t * (end->x - start->x));
out->y = start->y + COGL_FIXED_TO_INT (t * (end->y - start->y));
}
static gint
@ -140,12 +140,12 @@ node_distance (const ClutterKnot *start,
* clib sqrt if the precission would be less than 10%
*/
#if INT_MAX > CLUTTER_SQRTI_ARG_10_PERCENT
if (t <= CLUTTER_SQRTI_ARG_10_PERCENT)
return clutter_sqrti (t);
if (t <= COGL_SQRTI_ARG_10_PERCENT)
return cogl_sqrti (t);
else
return CLUTTER_FLOAT_TO_INT(sqrt(t));
return COGL_FLOAT_TO_INT (sqrt(t));
#else
return clutter_sqrti (t);
return cogl_sqrti (t);
#endif
}
@ -246,7 +246,7 @@ path_alpha_to_position (ClutterBehaviourPath *behave,
ClutterKnot new;
ClutterFixed t;
t = CLUTTER_INT_TO_FIXED (offset - dist) / dist_to_next;
t = COGL_FIXED_FROM_INT (offset - dist) / dist_to_next;
interpolate (knot, next, &new, t);

View File

@ -108,8 +108,8 @@ ClutterFixed clamp_angle (ClutterFixed a)
ClutterFixed a1, a2;
gint rounds;
rounds = a / CFX_360;
a1 = rounds * CFX_360;
rounds = a / COGL_FIXED_360;
a1 = rounds * COGL_FIXED_360;
a2 = a - a1;
return a2;
@ -126,7 +126,7 @@ clutter_behaviour_rotate_alpha_notify (ClutterBehaviour *behaviour,
rotate_behaviour = CLUTTER_BEHAVIOUR_ROTATE (behaviour);
priv = rotate_behaviour->priv;
factor = CLUTTER_INT_TO_FIXED (alpha_value) / CLUTTER_ALPHA_MAX_ALPHA;
factor = COGL_FIXED_FROM_INT (alpha_value) / CLUTTER_ALPHA_MAX_ALPHA;
angle = 0;
start = priv->angle_start;
@ -134,14 +134,14 @@ clutter_behaviour_rotate_alpha_notify (ClutterBehaviour *behaviour,
if (priv->direction == CLUTTER_ROTATE_CW && start >= end)
{
end += CFX_360;
end += COGL_FIXED_360;
}
else if (priv->direction == CLUTTER_ROTATE_CCW && start <= end)
{
end -= CFX_360;
end -= COGL_FIXED_360;
}
angle = CFX_MUL ((end - start), factor) + start;
angle = COGL_FIXED_FAST_MUL ((end - start), factor) + start;
clutter_behaviour_actors_foreach (behaviour,
alpha_notify_foreach,
@ -163,10 +163,10 @@ clutter_behaviour_rotate_set_property (GObject *gobject,
switch (prop_id)
{
case PROP_ANGLE_START:
priv->angle_start = CLUTTER_FLOAT_TO_FIXED (g_value_get_double (value));
priv->angle_start = COGL_FIXED_FROM_FLOAT (g_value_get_double (value));
break;
case PROP_ANGLE_END:
priv->angle_end = CLUTTER_FLOAT_TO_FIXED (g_value_get_double (value));
priv->angle_end = COGL_FIXED_FROM_FLOAT (g_value_get_double (value));
break;
case PROP_AXIS:
priv->axis = g_value_get_enum (value);
@ -211,10 +211,10 @@ clutter_behaviour_rotate_get_property (GObject *gobject,
switch (prop_id)
{
case PROP_ANGLE_START:
g_value_set_double (value, CLUTTER_FIXED_TO_DOUBLE (priv->angle_start));
g_value_set_double (value, COGL_FIXED_TO_DOUBLE (priv->angle_start));
break;
case PROP_ANGLE_END:
g_value_set_double (value, CLUTTER_FIXED_TO_DOUBLE (priv->angle_end));
g_value_set_double (value, COGL_FIXED_TO_DOUBLE (priv->angle_end));
break;
case PROP_AXIS:
g_value_set_enum (value, priv->axis);
@ -367,8 +367,8 @@ clutter_behaviour_rotate_init (ClutterBehaviourRotate *rotate)
rotate->priv = priv = CLUTTER_BEHAVIOUR_ROTATE_GET_PRIVATE (rotate);
priv->angle_start = CLUTTER_FLOAT_TO_FIXED (0.0);
priv->angle_end = CLUTTER_FLOAT_TO_FIXED (0.0);
priv->angle_start = COGL_FIXED_FROM_FLOAT (0.0);
priv->angle_end = COGL_FIXED_FROM_FLOAT (0.0);
priv->axis = CLUTTER_Z_AXIS;
priv->direction = CLUTTER_ROTATE_CW;
priv->center_x = priv->center_y = priv->center_z = 0;
@ -568,10 +568,10 @@ clutter_behaviour_rotate_get_bounds (ClutterBehaviourRotate *rotate,
priv = rotate->priv;
if (angle_start)
*angle_start = CLUTTER_FIXED_TO_DOUBLE (priv->angle_start);
*angle_start = COGL_FIXED_TO_DOUBLE (priv->angle_start);
if (angle_end)
*angle_end = CLUTTER_FIXED_TO_DOUBLE (priv->angle_end);
*angle_end = COGL_FIXED_TO_DOUBLE (priv->angle_end);
}
/**
@ -593,8 +593,8 @@ clutter_behaviour_rotate_set_bounds (ClutterBehaviourRotate *rotate,
g_return_if_fail (CLUTTER_IS_BEHAVIOUR_ROTATE (rotate));
clutter_behaviour_rotate_set_boundsx (rotate,
CLUTTER_FLOAT_TO_FIXED (angle_start),
CLUTTER_FLOAT_TO_FIXED (angle_end));
COGL_FIXED_FROM_FLOAT (angle_start),
COGL_FIXED_FROM_FLOAT (angle_end));
}
/**

View File

@ -115,14 +115,14 @@ clutter_behaviour_scale_alpha_notify (ClutterBehaviour *behave,
{
ClutterFixed factor;
factor = CLUTTER_INT_TO_FIXED (alpha_value) / CLUTTER_ALPHA_MAX_ALPHA;
factor = COGL_FIXED_FROM_INT (alpha_value) / CLUTTER_ALPHA_MAX_ALPHA;
scale_x = CLUTTER_FIXED_MUL (factor,
(priv->x_scale_end - priv->x_scale_start));
scale_x =
COGL_FIXED_FAST_MUL (factor, (priv->x_scale_end - priv->x_scale_start));
scale_x += priv->x_scale_start;
scale_y = CLUTTER_FIXED_MUL (factor,
(priv->y_scale_end - priv->y_scale_start));
scale_y =
COGL_FIXED_FAST_MUL (factor, (priv->y_scale_end - priv->y_scale_start));
scale_y += priv->y_scale_start;
}
@ -147,16 +147,16 @@ clutter_behaviour_scale_set_property (GObject *gobject,
switch (prop_id)
{
case PROP_X_SCALE_START:
priv->x_scale_start = CLUTTER_FLOAT_TO_FIXED (g_value_get_double (value));
priv->x_scale_start = COGL_FIXED_FROM_FLOAT (g_value_get_double (value));
break;
case PROP_X_SCALE_END:
priv->x_scale_end = CLUTTER_FLOAT_TO_FIXED (g_value_get_double (value));
priv->x_scale_end = COGL_FIXED_FROM_FLOAT (g_value_get_double (value));
break;
case PROP_Y_SCALE_START:
priv->y_scale_start = CLUTTER_FLOAT_TO_FIXED (g_value_get_double (value));
priv->y_scale_start = COGL_FIXED_FROM_FLOAT (g_value_get_double (value));
break;
case PROP_Y_SCALE_END:
priv->y_scale_end = CLUTTER_FLOAT_TO_FIXED (g_value_get_double (value));
priv->y_scale_end = COGL_FIXED_FROM_FLOAT (g_value_get_double (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
@ -177,16 +177,16 @@ clutter_behaviour_scale_get_property (GObject *gobject,
switch (prop_id)
{
case PROP_X_SCALE_START:
g_value_set_double (value, CLUTTER_FIXED_TO_FLOAT (priv->x_scale_start));
g_value_set_double (value, COGL_FIXED_TO_FLOAT (priv->x_scale_start));
break;
case PROP_X_SCALE_END:
g_value_set_double (value, CLUTTER_FIXED_TO_FLOAT (priv->x_scale_end));
g_value_set_double (value, COGL_FIXED_TO_FLOAT (priv->x_scale_end));
break;
case PROP_Y_SCALE_START:
g_value_set_double (value, CLUTTER_FIXED_TO_FLOAT (priv->y_scale_start));
g_value_set_double (value, COGL_FIXED_TO_FLOAT (priv->y_scale_start));
break;
case PROP_Y_SCALE_END:
g_value_set_double (value, CLUTTER_FIXED_TO_FLOAT (priv->y_scale_end));
g_value_set_double (value, COGL_FIXED_TO_FLOAT (priv->y_scale_end));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
@ -276,8 +276,8 @@ clutter_behaviour_scale_init (ClutterBehaviourScale *self)
self->priv = priv = CLUTTER_BEHAVIOUR_SCALE_GET_PRIVATE (self);
priv->x_scale_start = priv->x_scale_end = CFX_ONE;
priv->y_scale_start = priv->y_scale_end = CFX_ONE;
priv->x_scale_start = priv->x_scale_end = COGL_FIXED_1;
priv->y_scale_start = priv->y_scale_end = COGL_FIXED_1;
}
/**
@ -304,10 +304,10 @@ clutter_behaviour_scale_new (ClutterAlpha *alpha,
g_return_val_if_fail (alpha == NULL || CLUTTER_IS_ALPHA (alpha), NULL);
return clutter_behaviour_scale_newx (alpha,
CLUTTER_FLOAT_TO_FIXED (x_scale_start),
CLUTTER_FLOAT_TO_FIXED (y_scale_start),
CLUTTER_FLOAT_TO_FIXED (x_scale_end),
CLUTTER_FLOAT_TO_FIXED (y_scale_end));
COGL_FIXED_FROM_FLOAT (x_scale_start),
COGL_FIXED_FROM_FLOAT (y_scale_start),
COGL_FIXED_FROM_FLOAT (x_scale_end),
COGL_FIXED_FROM_FLOAT (y_scale_end));
}
/**
@ -367,10 +367,10 @@ clutter_behaviour_scale_set_bounds (ClutterBehaviourScale *scale,
g_return_if_fail (CLUTTER_IS_BEHAVIOUR_SCALE (scale));
clutter_behaviour_scale_set_boundsx (scale,
CLUTTER_FLOAT_TO_FIXED (x_scale_start),
CLUTTER_FLOAT_TO_FIXED (y_scale_start),
CLUTTER_FLOAT_TO_FIXED (x_scale_end),
CLUTTER_FLOAT_TO_FIXED (y_scale_end));
COGL_FIXED_FROM_FLOAT (x_scale_start),
COGL_FIXED_FROM_FLOAT (y_scale_start),
COGL_FIXED_FROM_FLOAT (x_scale_end),
COGL_FIXED_FROM_FLOAT (y_scale_end));
}
/**
@ -403,16 +403,16 @@ clutter_behaviour_scale_get_bounds (ClutterBehaviourScale *scale,
priv = scale->priv;
if (x_scale_start)
*x_scale_start = CLUTTER_FIXED_TO_DOUBLE (priv->x_scale_start);
*x_scale_start = COGL_FIXED_TO_DOUBLE (priv->x_scale_start);
if (x_scale_end)
*x_scale_end = CLUTTER_FIXED_TO_DOUBLE (priv->x_scale_end);
*x_scale_end = COGL_FIXED_TO_DOUBLE (priv->x_scale_end);
if (y_scale_start)
*y_scale_start = CLUTTER_FIXED_TO_DOUBLE (priv->y_scale_start);
*y_scale_start = COGL_FIXED_TO_DOUBLE (priv->y_scale_start);
if (y_scale_end)
*y_scale_end = CLUTTER_FIXED_TO_DOUBLE (priv->y_scale_end);
*y_scale_end = COGL_FIXED_TO_DOUBLE (priv->y_scale_end);
}
/**

View File

@ -184,20 +184,20 @@ clutter_clone_texture_paint (ClutterActor *self)
tex_height = cogl_texture_get_height (cogl_texture);
if (priv->repeat_x && tex_width > 0)
t_w = CFX_QDIV (CLUTTER_INT_TO_FIXED (x_2 - x_1),
CLUTTER_INT_TO_FIXED (tex_width));
t_w = COGL_FIXED_DIV (COGL_FIXED_FROM_INT (x_2 - x_1),
COGL_FIXED_FROM_INT (tex_width));
else
t_w = CFX_ONE;
t_w = COGL_FIXED_1;
if (priv->repeat_y && tex_height > 0)
t_h = CFX_QDIV (CLUTTER_INT_TO_FIXED (y_2 - y_1),
CLUTTER_INT_TO_FIXED (tex_height));
t_h = COGL_FIXED_DIV (COGL_FIXED_FROM_INT (y_2 - y_1),
COGL_FIXED_FROM_INT (tex_height));
else
t_h = CFX_ONE;
t_h = COGL_FIXED_1;
/* Parent paint translated us into position */
cogl_texture_rectangle (cogl_texture, 0, 0,
CLUTTER_INT_TO_FIXED (x_2 - x_1),
CLUTTER_INT_TO_FIXED (y_2 - y_1),
COGL_FIXED_FROM_INT (x_2 - x_1),
COGL_FIXED_FROM_INT (y_2 - y_1),
0, 0, t_w, t_h);
}

View File

@ -154,9 +154,9 @@ clutter_color_to_hlsx (const ClutterColor *src,
g_return_if_fail (src != NULL);
red = CLUTTER_INT_TO_FIXED (src->red) / 255;
green = CLUTTER_INT_TO_FIXED (src->green) / 255;
blue = CLUTTER_INT_TO_FIXED (src->blue) / 255;
red = COGL_FIXED_FROM_INT (src->red) / 255;
green = COGL_FIXED_FROM_INT (src->green) / 255;
blue = COGL_FIXED_FROM_INT (src->blue) / 255;
if (red > green)
{
@ -189,22 +189,31 @@ clutter_color_to_hlsx (const ClutterColor *src,
if (max != min)
{
if (l <= CFX_ONE/2)
s = CFX_DIV ((max - min), (max + min));
if (l <= COGL_FIXED_0_5)
s = COGL_FIXED_FAST_DIV ((max - min), (max + min));
else
s = CFX_DIV ((max - min), (CLUTTER_INT_TO_FIXED (2) - max - min));
s = COGL_FIXED_FAST_DIV ((max - min),
(COGL_FIXED_FROM_INT (2) - max - min));
delta = max - min;
if (red == max)
h = CFX_DIV ((green - blue), delta);
h = COGL_FIXED_FAST_DIV ((green - blue), delta);
else if (green == max)
h = CLUTTER_INT_TO_FIXED (2) + CFX_DIV ((blue - red), delta);
{
h = COGL_FIXED_FROM_INT (2)
+ COGL_FIXED_FAST_DIV ((blue - red), delta);
}
else if (blue == max)
h = CLUTTER_INT_TO_FIXED (4) + CFX_DIV ((red - green), delta);
{
h = COGL_FIXED_FROM_INT (4)
+ COGL_FIXED_FAST_DIV ((red - green), delta);
}
h *= 60;
if (h < 0)
h += CLUTTER_INT_TO_FIXED (360);
h += COGL_FIXED_360;
}
if (hue)
@ -242,66 +251,102 @@ clutter_color_from_hlsx (ClutterColor *dest,
l = luminance;
s = saturation;
if (l <= CFX_ONE/2)
m2 = CFX_MUL (l, (CFX_ONE + s));
if (l <= COGL_FIXED_0_5)
m2 = COGL_FIXED_FAST_MUL (l, (COGL_FIXED_1 + s));
else
m2 = l + s - CFX_MUL (l,s);
m2 = l + s - COGL_FIXED_FAST_MUL (l, s);
m1 = 2 * l - m2;
if (s == 0)
{
dest->red = (guint8) CFX_INT (l * 255);
dest->green = (guint8) CFX_INT (l * 255);
dest->blue = (guint8) CFX_INT (l * 255);
dest->red = (guint8) COGL_FIXED_TO_INT (l * 255);
dest->green = (guint8) COGL_FIXED_TO_INT (l * 255);
dest->blue = (guint8) COGL_FIXED_TO_INT (l * 255);
}
else
{
h = hue + CFX_120;
while (h > CFX_360)
h -= CFX_360;
while (h < 0)
h += CFX_360;
h = hue + COGL_FIXED_120;
if (h < CFX_60)
dest->red = (guint8) CFX_INT((m1 + CFX_MUL((m2-m1), h) / 60) * 255);
else if (h < CFX_180)
dest->red = (guint8) CFX_INT (m2 * 255);
else if (h < CFX_240)
dest->red = (guint8)CFX_INT((m1+CFX_MUL((m2-m1),(CFX_240-h))/60)*255);
while (h > COGL_FIXED_360)
h -= COGL_FIXED_360;
while (h < 0)
h += COGL_FIXED_360;
if (h < COGL_FIXED_60)
{
CoglFixed tmp;
tmp = (m1 + COGL_FIXED_FAST_MUL ((m2 - m1), h) / 60);
dest->red = (guint8) COGL_FIXED_TO_INT (tmp * 255);
}
else if (h < COGL_FIXED_180)
dest->red = (guint8) COGL_FIXED_TO_INT (m2 * 255);
else if (h < COGL_FIXED_240)
{
CoglFixed tmp;
tmp = (m1 + COGL_FIXED_FAST_MUL ((m2 - m1), (COGL_FIXED_240 - h)))
/ 60;
dest->red = (guint8) COGL_FIXED_TO_INT (tmp * 255);
}
else
dest->red = (guint8) CFX_INT (m1 * 255);
dest->red = (guint8) COGL_FIXED_TO_INT (m1 * 255);
h = hue;
while (h > CFX_360)
h -= CFX_360;
while (h > COGL_FIXED_360)
h -= COGL_FIXED_360;
while (h < 0)
h += CFX_360;
h += COGL_FIXED_360;
if (h < CFX_60)
dest->green = (guint8)CFX_INT((m1 + CFX_MUL((m2 - m1), h) / 60) * 255);
else if (h < CFX_180)
dest->green = (guint8) CFX_INT (m2 * 255);
else if (h < CFX_240)
dest->green =
(guint8) CFX_INT((m1 + CFX_MUL ((m2-m1), (CFX_240-h)) / 60) * 255);
if (h < COGL_FIXED_60)
{
CoglFixed tmp;
tmp = (m1 + COGL_FIXED_FAST_MUL ((m2 - m1), h) / 60);
dest->green = (guint8) COGL_FIXED_TO_INT (tmp * 255);
}
else if (h < COGL_FIXED_180)
dest->green = (guint8) COGL_FIXED_TO_INT (m2 * 255);
else if (h < COGL_FIXED_240)
{
CoglFixed tmp;
tmp = (m1 + COGL_FIXED_FAST_MUL ((m2 - m1) , (COGL_FIXED_240 - h)))
/ 60;
dest->green = (guint8) COGL_FIXED_TO_INT (tmp * 255);
}
else
dest->green = (guint8) CFX_INT (m1 * 255);
dest->green = (guint8) COGL_FIXED_TO_INT (m1 * 255);
h = hue - COGL_FIXED_120;
while (h > COGL_FIXED_360)
h -= COGL_FIXED_360;
h = hue - CFX_120;
while (h > CFX_360)
h -= CFX_360;
while (h < 0)
h += CFX_360;
h += COGL_FIXED_360;
if (h < CFX_60)
dest->blue = (guint8) CFX_INT ((m1 + CFX_MUL ((m2-m1), h) / 60) * 255);
else if (h < CFX_180)
dest->blue = (guint8) CFX_INT (m2 * 255);
else if (h < CFX_240)
dest->blue = (guint8)CFX_INT((m1+CFX_MUL((m2-m1),(CFX_240-h))/60)*255);
if (h < COGL_FIXED_60)
{
CoglFixed tmp;
tmp = (m1 + COGL_FIXED_FAST_MUL ((m2 - m1), h) / 60);
dest->blue = (guint8) COGL_FIXED_TO_INT (tmp * 255);
}
else if (h < COGL_FIXED_180)
dest->blue = (guint8) COGL_FIXED_TO_INT (m2 * 255);
else if (h < COGL_FIXED_240)
{
CoglFixed tmp;
tmp = (m1 + COGL_FIXED_FAST_MUL ((m2 - m1), (COGL_FIXED_240 - h)))
/ 60;
dest->blue = (guint8) COGL_FIXED_TO_INT (tmp * 255);
}
else
dest->blue = (guint8) CFX_INT(m1 * 255);
dest->blue = (guint8) COGL_FIXED_TO_INT (m1 * 255);
}
}
@ -326,13 +371,13 @@ clutter_color_to_hls (const ClutterColor *src,
clutter_color_to_hlsx (src, &h, &l, &s);
if (hue)
*hue = (guint8) CFX_INT (h * 255) / 360;
*hue = (guint8) COGL_FIXED_TO_INT (h * 255) / 360;
if (luminance)
*luminance = (guint8) CFX_INT (l * 255);
*luminance = (guint8) COGL_FIXED_TO_INT (l * 255);
if (saturation)
*saturation = (guint8) CFX_INT (s * 255);
*saturation = (guint8) COGL_FIXED_TO_INT (s * 255);
}
/**
@ -354,9 +399,9 @@ clutter_color_from_hls (ClutterColor *dest,
{
ClutterFixed h, l, s;
h = CLUTTER_INT_TO_FIXED (hue * 360) / 255;
l = CLUTTER_INT_TO_FIXED (luminance) / 255;
s = CLUTTER_INT_TO_FIXED (saturation) / 255;
h = COGL_FIXED_FROM_INT (hue * 360) / 255;
l = COGL_FIXED_FROM_INT (luminance) / 255;
s = COGL_FIXED_FROM_INT (saturation) / 255;
clutter_color_from_hlsx (dest, h, l, s);
}
@ -375,7 +420,7 @@ clutter_color_shade (const ClutterColor *src,
ClutterColor *dest,
gdouble shade)
{
clutter_color_shadex (src, dest, CLUTTER_FLOAT_TO_FIXED (shade));
clutter_color_shadex (src, dest, COGL_FIXED_FROM_FLOAT (shade));
}
/**
@ -403,15 +448,15 @@ clutter_color_shadex (const ClutterColor *src,
clutter_color_to_hlsx (src, &h, &l, &s);
l = CFX_MUL (l, shade);
if (l > CFX_ONE)
l = CFX_ONE;
l = COGL_FIXED_FAST_MUL (l, shade);
if (l > COGL_FIXED_1)
l = COGL_FIXED_1;
else if (l < 0)
l = 0;
s = CFX_MUL (s, shade);
if (s > CFX_ONE)
s = CFX_ONE;
s = COGL_FIXED_FAST_MUL (s, shade);
if (s > COGL_FIXED_1)
s = COGL_FIXED_1;
else if (s < 0)
s = 0;
@ -450,10 +495,10 @@ clutter_color_from_pixel (ClutterColor *dest,
{
g_return_if_fail (dest != NULL);
dest->red = pixel >> 24;
dest->red = pixel >> 24;
dest->green = (pixel >> 16) & 0xff;
dest->blue = (pixel >> 8) & 0xff;
dest->alpha = pixel & 0xff;
dest->blue = (pixel >> 8) & 0xff;
dest->alpha = pixel & 0xff;
}
/**

View File

@ -446,8 +446,9 @@ clutter_entry_paint (ClutterActor *self)
else
width = priv->width;
cogl_clip_set (0, 0, CLUTTER_INT_TO_FIXED (width),
CLUTTER_INT_TO_FIXED (clutter_actor_get_height (self)));
cogl_clip_set (0, 0,
COGL_FIXED_FROM_INT (width),
COGL_FIXED_FROM_INT (clutter_actor_get_height (self)));
actor_width = width - (2 * priv->entry_padding);
clutter_entry_ensure_layout (entry, actor_width);

File diff suppressed because it is too large Load Diff

View File

@ -28,6 +28,7 @@
#define _HAVE_CLUTTER_FIXED_H
#include <glib-object.h>
#include <cogl/cogl-fixed.h>
G_BEGIN_DECLS
@ -36,7 +37,7 @@ G_BEGIN_DECLS
*
* Fixed point number (16.16)
*/
typedef gint32 ClutterFixed;
typedef CoglFixed ClutterFixed;
/**
* ClutterAngle:
@ -44,14 +45,12 @@ typedef gint32 ClutterFixed;
* Integer representation of an angle such that 1024 corresponds to
* full circle (i.e., 2*Pi).
*/
typedef gint32 ClutterAngle; /* angle such that 1024 == 2*PI */
typedef CoglAngle ClutterAngle; /* angle such that 1024 == 2*PI */
#define CLUTTER_ANGLE_FROM_DEG(x) (CLUTTER_FLOAT_TO_INT (((x) * 1024.0) / 360.0))
#define CLUTTER_ANGLE_FROM_DEGF(x) (CLUTTER_FLOAT_TO_INT (((float)(x) * 1024.0f) / 360.0f))
#define CLUTTER_ANGLE_FROM_DEGX(x) (CFX_INT((((x)/360)*1024) + CFX_HALF))
#define CLUTTER_ANGLE_TO_DEG(x) (((x) * 360.0)/ 1024.0)
#define CLUTTER_ANGLE_TO_DEGF(x) (((float)(x) * 360.0)/ 1024.0)
#define CLUTTER_ANGLE_TO_DEGX(x) (CLUTTER_INT_TO_FIXED((x) * 45)/128)
#define CLUTTER_ANGLE_FROM_DEG(x) (COGL_ANGLE_FROM_DEG (x))
#define CLUTTER_ANGLE_FROM_DEGX(x) (COGL_ANGLE_FROM_DEGX (x))
#define CLUTTER_ANGLE_TO_DEG(x) (COGL_ANGLE_TO_DEG (x))
#define CLUTTER_ANGLE_TO_DEGX(x) (COGL_ANGLE_TO_DEGX (x))
/*
* some commonly used constants
@ -62,102 +61,102 @@ typedef gint32 ClutterAngle; /* angle such that 1024 == 2*PI */
*
* Size in bits of decimal part of floating point value.
*/
#define CFX_Q 16 /* Decimal part size in bits */
#define CFX_Q COGL_FIXED_Q
/**
* CFX_ONE:
*
* 1.0 represented as a fixed point value.
*/
#define CFX_ONE (1 << CFX_Q) /* 1 */
#define CFX_ONE COGL_FIXED_1
/**
* CFX_HALF:
*
* 0.5 represented as a fixed point value.
*/
#define CFX_HALF 32768
#define CFX_HALF COGL_FIXED_0_5
/**
* CFX_MAX:
*
* Maximum fixed point value.
*/
#define CFX_MAX 0x7fffffff
#define CFX_MAX COGL_FIXED_MAX
/**
* CFX_MIN:
*
* Minimum fixed point value.
*/
#define CFX_MIN 0x80000000
#define CFX_MIN COGL_FIXED_MIN
/**
* CFX_PI:
*
* Fixed point representation of Pi
*/
#define CFX_PI 0x0003243f
#define CFX_PI COGL_FIXED_PI
/**
* CFX_2PI:
*
* Fixed point representation of Pi*2
*/
#define CFX_2PI 0x0006487f
#define CFX_2PI COGL_FIXED_2_PI
/**
* CFX_PI_2:
*
* Fixed point representation of Pi/2
*/
#define CFX_PI_2 0x00019220 /* pi/2 */
#define CFX_PI_2 COGL_FIXED_PI_2
/**
* CFX_PI_4:
*
* Fixed point representation of Pi/4
*/
#define CFX_PI_4 0x0000c910 /* pi/4 */
#define CFX_PI_4 COGL_FIXED_PI_4
/**
* CFX_360:
*
* Fixed point representation of the number 360
*/
#define CFX_360 CLUTTER_INT_TO_FIXED (360)
#define CFX_360 COGL_FIXED_360
/**
* CFX_240:
*
* Fixed point representation of the number 240
*/
#define CFX_240 CLUTTER_INT_TO_FIXED (240)
#define CFX_240 COGL_FIXED_240
/**
* CFX_180:
*
* Fixed point representation of the number 180
*/
#define CFX_180 CLUTTER_INT_TO_FIXED (180)
#define CFX_180 COGL_FIXED_180
/**
* CFX_120:
*
* Fixed point representation of the number 120
*/
#define CFX_120 CLUTTER_INT_TO_FIXED (120)
#define CFX_120 COGL_FIXED_120
/**
* CFX_60:
*
* Fixed point representation of the number 60
*/
#define CFX_60 CLUTTER_INT_TO_FIXED (60)
#define CFX_60 COGL_FIXED_60
/**
* CFX_RADIANS_TO_DEGREES:
*
* Fixed point representation of the number 180 / pi
*/
#define CFX_RADIANS_TO_DEGREES 0x394bb8
#define CFX_RADIANS_TO_DEGREES COGL_RADIANS_TO_DEGREES
/**
* CFX_255:
*
* Fixed point representation of the number 255
*/
#define CFX_255 CLUTTER_INT_TO_FIXED (255)
#define CFX_255 COGL_FIXED_255
/**
* CLUTTER_FIXED_TO_FLOAT:
@ -165,7 +164,7 @@ typedef gint32 ClutterAngle; /* angle such that 1024 == 2*PI */
*
* Convert a fixed point value to float.
*/
#define CLUTTER_FIXED_TO_FLOAT(x) ((float) ((int)(x) / 65536.0))
#define CLUTTER_FIXED_TO_FLOAT(x) COGL_FIXED_TO_FLOAT ((x))
/**
* CLUTTER_FIXED_TO_DOUBLE:
@ -173,7 +172,7 @@ typedef gint32 ClutterAngle; /* angle such that 1024 == 2*PI */
*
* Convert a fixed point value to double.
*/
#define CLUTTER_FIXED_TO_DOUBLE(x) ((double) ((int)(x) / 65536.0))
#define CLUTTER_FIXED_TO_DOUBLE(x) COGL_FIXED_TO_DOUBLE ((x))
/**
* CLUTTER_FLOAT_TO_FIXED:
@ -181,7 +180,7 @@ typedef gint32 ClutterAngle; /* angle such that 1024 == 2*PI */
*
* Convert a float value to fixed.
*/
#define CLUTTER_FLOAT_TO_FIXED(x) (clutter_double_to_fixed ((x)))
#define CLUTTER_FLOAT_TO_FIXED(x) COGL_FIXED_FROM_FLOAT ((x))
/**
* CLUTTER_FLOAT_TO_INT:
@ -189,7 +188,7 @@ typedef gint32 ClutterAngle; /* angle such that 1024 == 2*PI */
*
* Convert a float value to int.
*/
#define CLUTTER_FLOAT_TO_INT(x) (clutter_double_to_int ((x)))
#define CLUTTER_FLOAT_TO_INT(x) COGL_FLOAT_TO_INT ((x))
/**
* CLUTTER_FLOAT_TO_UINT:
@ -197,7 +196,7 @@ typedef gint32 ClutterAngle; /* angle such that 1024 == 2*PI */
*
* Convert a float value to unsigned int.
*/
#define CLUTTER_FLOAT_TO_UINT(x) (clutter_double_to_uint ((x)))
#define CLUTTER_FLOAT_TO_UINT(x) COGL_FLOAT_TO_UINT ((x))
/**
* CLUTTER_INT_TO_FIXED:
@ -205,7 +204,7 @@ typedef gint32 ClutterAngle; /* angle such that 1024 == 2*PI */
*
* Convert an integer value to fixed point.
*/
#define CLUTTER_INT_TO_FIXED(x) ((x) << CFX_Q)
#define CLUTTER_INT_TO_FIXED(x) COGL_FIXED_FROM_INT ((x))
/**
* CLUTTER_FIXED_TO_INT:
@ -215,21 +214,7 @@ typedef gint32 ClutterAngle; /* angle such that 1024 == 2*PI */
*
* Since: 0.6
*/
#define CLUTTER_FIXED_TO_INT(x) ((x) >> CFX_Q)
#ifndef CLUTTER_DISABLE_DEPRECATED
/**
* CLUTTER_FIXED_INT:
* @x: a fixed point value
*
* Convert a fixed point value to integer (removing decimal part).
*
* Deprecated:0.6: Use %CLUTTER_FIXED_TO_INT instead
*/
#define CLUTTER_FIXED_INT(x) CLUTTER_FIXED_TO_INT((x))
#endif /* !CLUTTER_DISABLE_DEPRECATED */
#define CLUTTER_FIXED_TO_INT(x) COGL_FIXED_TO_INT ((x))
/**
* CLUTTER_FIXED_FRACTION:
@ -237,7 +222,7 @@ typedef gint32 ClutterAngle; /* angle such that 1024 == 2*PI */
*
* Retrieves the fractionary part of a fixed point value
*/
#define CLUTTER_FIXED_FRACTION(x) ((x) & ((1 << CFX_Q) - 1))
#define CLUTTER_FIXED_FRACTION(x) COGL_FIXED_FRACTION ((x))
/**
* CLUTTER_FIXED_FLOOR:
@ -245,15 +230,15 @@ typedef gint32 ClutterAngle; /* angle such that 1024 == 2*PI */
*
* Round down a fixed point value to an integer.
*/
#define CLUTTER_FIXED_FLOOR(x) (((x) >= 0) ? ((x) >> CFX_Q) \
: ~((~(x)) >> CFX_Q))
#define CLUTTER_FIXED_FLOOR(x) COGL_FIXED_FLOOR ((x))
/**
* CLUTTER_FIXED_CEIL:
* @x: a fixed point value
*
* Round up a fixed point value to an integer.
*/
#define CLUTTER_FIXED_CEIL(x) (CLUTTER_FIXED_FLOOR (x + 0xffff))
#define CLUTTER_FIXED_CEIL(x) COGL_FIXED_CEIL ((x))
/**
* CLUTTER_FIXED_MUL:
@ -262,7 +247,7 @@ typedef gint32 ClutterAngle; /* angle such that 1024 == 2*PI */
*
* Multiply two fixed point values
*/
#define CLUTTER_FIXED_MUL(x,y) ((x) >> 8) * ((y) >> 8)
#define CLUTTER_FIXED_MUL(x,y) COGL_FIXED_MUL ((x), (y))
/**
* CLUTTER_FIXED_DIV:
@ -271,97 +256,18 @@ typedef gint32 ClutterAngle; /* angle such that 1024 == 2*PI */
*
* Divide two fixed point values
*/
#define CLUTTER_FIXED_DIV(x,y) ((((x) << 8)/(y)) << 8)
#define CLUTTER_FIXED_DIV(x,y) COGL_FIXED_DIV ((x), (y))
/* Some handy fixed point short aliases to avoid exessively long lines */
/* FIXME: Remove from public API */
/*< private >*/
#define CFX_INT CLUTTER_FIXED_INT
#define CFX_MUL CLUTTER_FIXED_MUL
#define CFX_DIV CLUTTER_FIXED_DIV
#define CFX_QMUL(x,y) clutter_qmulx (x,y)
#define CFX_QDIV(x,y) clutter_qdivx (x,y)
#define clutter_qmulx(x,y) cogl_fixed_mul ((x), (y))
#define clutter_qdivx(x,y) cogl_fixed_div ((x), (y))
/*< public >*/
/* Fixed point math routines */
G_INLINE_FUNC
ClutterFixed clutter_qmulx (ClutterFixed op1,
ClutterFixed op2);
#if defined (G_CAN_INLINE)
G_INLINE_FUNC
ClutterFixed clutter_qmulx (ClutterFixed op1,
ClutterFixed op2)
{
#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"(op1), "r"(op2), "i"(CFX_Q), "i"(32-CFX_Q));
return (ClutterFixed) res_low;
#else
long long r = (long long) op1 * (long long) op2;
return (unsigned int)(r >> CFX_Q);
#endif
}
#endif
G_INLINE_FUNC
ClutterFixed clutter_qdivx (ClutterFixed op1,
ClutterFixed op2);
#if defined (G_CAN_INLINE)
G_INLINE_FUNC
ClutterFixed clutter_qdivx (ClutterFixed op1,
ClutterFixed op2)
{
return (ClutterFixed) ((((gint64) op1) << CFX_Q) / op2);
}
#endif
ClutterFixed clutter_sinx (ClutterFixed angle);
ClutterFixed clutter_sini (ClutterAngle angle);
ClutterFixed clutter_tani (ClutterAngle angle);
ClutterFixed clutter_atani (ClutterFixed x);
ClutterFixed clutter_atan2i (ClutterFixed y, ClutterFixed x);
/* convenience macros for the cos functions */
/**
* clutter_cosx:
* @angle: a #ClutterFixed angle in radians
*
* Fixed point cosine function
*
* Return value: #ClutterFixed cosine value.
*
* Note: Implemneted as a macro.
*
* Since: 0.2
*/
#define clutter_cosx(angle) (clutter_sinx((angle) + CFX_PI_2))
/**
* clutter_cosi:
* @angle: a #ClutterAngle angle
*
* Very fast fixed point implementation of cosine function.
*
* ClutterAngle is an integer such that 1024 represents
* full circle.
*
* Return value: #ClutterFixed cosine value.
*
* Note: Implemneted as a macro.
*
* Since: 0.2
*/
#define clutter_cosi(angle) (clutter_sini ((angle) + 256))
#define clutter_sinx(a) cogl_fixed_sin ((a))
#define clutter_sini(a) cogl_angle_sin ((a))
#define clutter_tani(a) cogl_angle_tan ((a))
#define clutter_atani(a) cogl_fixed_atan ((a))
#define clutter_atan2i(x,y) cogl_fixed_atan2 ((x), (y))
#define clutter_cosx(a) cogl_fixed_cos ((a))
#define clutter_cosi(a) cogl_angle_cos ((a))
/**
* CLUTTER_SQRTI_ARG_MAX
@ -370,11 +276,7 @@ ClutterFixed clutter_atan2i (ClutterFixed y, ClutterFixed x);
*
* Since: 0.6
*/
#ifndef __SSE2__
#define CLUTTER_SQRTI_ARG_MAX 0x3fffff
#else
#define CLUTTER_SQRTI_ARG_MAX INT_MAX
#endif
#define CLUTTER_SQRTI_ARG_MAX COGL_SQRTI_ARG_MAX
/**
* CLUTTER_SQRTI_ARG_5_PERCENT
@ -384,11 +286,7 @@ ClutterFixed clutter_atan2i (ClutterFixed y, ClutterFixed x);
*
* Since: 0.6
*/
#ifndef __SSE2__
#define CLUTTER_SQRTI_ARG_5_PERCENT 210
#else
#define CLUTTER_SQRTI_ARG_5_PERCENT INT_MAX
#endif
#define CLUTTER_SQRTI_ARG_5_PERCENT COGL_SQRTI_ARG_5_PERCENT
/**
* CLUTTER_SQRTI_ARG_10_PERCENT
@ -398,18 +296,14 @@ ClutterFixed clutter_atan2i (ClutterFixed y, ClutterFixed x);
*
* Since: 0.6
*/
#ifndef __SSE2__
#define CLUTTER_SQRTI_ARG_10_PERCENT 5590
#else
#define CLUTTER_SQRTI_ARG_10_PERCENT INT_MAX
#endif
#define CLUTTER_SQRTI_ARG_10_PERCENT COGL_SQRTI_ARG_10_PERCENT
ClutterFixed clutter_sqrtx (ClutterFixed x);
gint clutter_sqrti (gint x);
#define clutter_sqrtx(x) cogl_fixed_sqrt ((x))
#define clutter_sqrti(x) cogl_sqrti ((x))
ClutterFixed clutter_log2x (guint x);
guint clutter_pow2x (ClutterFixed x);
guint clutter_powx (guint x, ClutterFixed y);
#define clutter_log2x(x) cogl_fixed_log2 ((x))
#define clutter_pow2x(x) cogl_fixed_pow2 ((x))
#define clutter_powx(x,y) cogl_fixed_pow ((x), (y))
#define CLUTTER_TYPE_FIXED (clutter_fixed_get_type ())
#define CLUTTER_TYPE_PARAM_FIXED (clutter_param_fixed_get_type ())
@ -435,7 +329,7 @@ typedef struct _ClutterParamSpecFixed ClutterParamSpecFixed;
*
* Since: 0.8
*/
#define CLUTTER_MAXFIXED CFX_MAX
#define CLUTTER_MAXFIXED COGL_FIXED_MAX
/**
* CLUTTER_MINFIXED:
@ -444,7 +338,7 @@ typedef struct _ClutterParamSpecFixed ClutterParamSpecFixed;
*
* Since: 0.8
*/
#define CLUTTER_MINFIXED CFX_MIN
#define CLUTTER_MINFIXED COGL_FIXED_MAX
/**
* ClutterParamSpecFixed
@ -482,10 +376,6 @@ GParamSpec * clutter_param_spec_fixed (const gchar *name,
ClutterFixed default_value,
GParamFlags flags);
/* <private> */
extern ClutterFixed clutter_double_to_fixed (double value);
extern gint clutter_double_to_int (double value);
extern guint clutter_double_to_unit (double value);
G_END_DECLS

View File

@ -728,15 +728,15 @@ clutter_stage_init (ClutterStage *self)
priv->color.blue = 0xff;
priv->color.alpha = 0xff;
priv->perspective.fovy = CFX_60; /* 60 Degrees */
priv->perspective.aspect = CFX_ONE;
priv->perspective.z_near = CLUTTER_FLOAT_TO_FIXED (0.1);
priv->perspective.z_far = CLUTTER_FLOAT_TO_FIXED (100.0);
priv->perspective.fovy = COGL_FIXED_60; /* 60 Degrees */
priv->perspective.aspect = COGL_FIXED_1;
priv->perspective.z_near = COGL_FIXED_FROM_FLOAT (0.1);
priv->perspective.z_far = COGL_FIXED_FROM_FLOAT (100.0);
/* depth cueing */
priv->fog.density = CLUTTER_FLOAT_TO_FIXED (0.1);
priv->fog.z_near = CLUTTER_FLOAT_TO_FIXED (1.0);
priv->fog.z_far = CLUTTER_FLOAT_TO_FIXED (2.0);
priv->fog.density = COGL_FIXED_FROM_FLOAT (0.1);
priv->fog.z_near = COGL_FIXED_FROM_FLOAT (1.0);
priv->fog.z_far = COGL_FIXED_FROM_FLOAT (2.0);
clutter_actor_set_reactive (CLUTTER_ACTOR (self), TRUE);
clutter_stage_set_key_focus (self, NULL);
@ -892,10 +892,10 @@ clutter_stage_set_perspective (ClutterStage *stage,
priv = stage->priv;
priv->perspective.fovy = CLUTTER_FLOAT_TO_FIXED (fovy);
priv->perspective.aspect = CLUTTER_FLOAT_TO_FIXED (aspect);
priv->perspective.z_near = CLUTTER_FLOAT_TO_FIXED (z_near);
priv->perspective.z_far = CLUTTER_FLOAT_TO_FIXED (z_far);
priv->perspective.fovy = COGL_FIXED_FROM_FLOAT (fovy);
priv->perspective.aspect = COGL_FIXED_FROM_FLOAT (aspect);
priv->perspective.z_near = COGL_FIXED_FROM_FLOAT (z_near);
priv->perspective.z_far = COGL_FIXED_FROM_FLOAT (z_far);
/* this will cause the viewport to be reset; see
* clutter_maybe_setup_viewport() inside clutter-main.c
@ -931,16 +931,16 @@ clutter_stage_get_perspective (ClutterStage *stage,
priv = stage->priv;
if (fovy)
*fovy = CLUTTER_FIXED_TO_FLOAT (priv->perspective.fovy);
*fovy = COGL_FIXED_TO_FLOAT (priv->perspective.fovy);
if (aspect)
*aspect = CLUTTER_FIXED_TO_FLOAT (priv->perspective.aspect);
*aspect = COGL_FIXED_TO_FLOAT (priv->perspective.aspect);
if (z_near)
*z_near = CLUTTER_FIXED_TO_FLOAT (priv->perspective.z_near);
*z_near = COGL_FIXED_TO_FLOAT (priv->perspective.z_near);
if (z_far)
*z_far = CLUTTER_FIXED_TO_FLOAT (priv->perspective.z_far);
*z_far = COGL_FIXED_TO_FLOAT (priv->perspective.z_far);
}
/**
@ -1540,11 +1540,11 @@ clutter_stage_get_fog (ClutterStage *stage,
priv = stage->priv;
if (density)
*density = CLUTTER_FIXED_TO_FLOAT (priv->fog.density);
*density = COGL_FIXED_TO_FLOAT (priv->fog.density);
if (z_near)
*z_near = CLUTTER_FIXED_TO_FLOAT (priv->fog.z_near);
*z_near = COGL_FIXED_TO_FLOAT (priv->fog.z_near);
if (z_far)
*z_far = CLUTTER_FIXED_TO_FLOAT (priv->fog.z_far);
*z_far = COGL_FIXED_TO_FLOAT (priv->fog.z_far);
}
/**
@ -1576,9 +1576,9 @@ clutter_stage_set_fog (ClutterStage *stage,
priv = stage->priv;
priv->fog.density = CLUTTER_FLOAT_TO_FIXED (density);
priv->fog.z_near = CLUTTER_FLOAT_TO_FIXED (z_near);
priv->fog.z_far = CLUTTER_FLOAT_TO_FIXED (z_far);
priv->fog.density = COGL_FIXED_FROM_FLOAT (density);
priv->fog.z_near = COGL_FIXED_FROM_FLOAT (z_near);
priv->fog.z_far = COGL_FIXED_FROM_FLOAT (z_far);
if (priv->use_fog && CLUTTER_ACTOR_IS_VISIBLE (stage))
clutter_actor_queue_redraw (CLUTTER_ACTOR (stage));
@ -1674,7 +1674,7 @@ clutter_stage_get_resolutionx (ClutterStage *stage)
res = clutter_backend_get_resolution (context->backend);
return CLUTTER_FLOAT_TO_FIXED (res);
return COGL_FIXED_FROM_FLOAT (res);
}
/*** Perspective boxed type ******/

View File

@ -351,13 +351,13 @@ clutter_texture_get_preferred_width (ClutterActor *self,
/* Set the natural width so as to preserve the aspect ratio */
ClutterFixed ratio, height;
ratio = clutter_qdivx (CLUTTER_INT_TO_FIXED (priv->width),
CLUTTER_INT_TO_FIXED (priv->height));
ratio = COGL_FIXED_MUL (COGL_FIXED_FROM_INT (priv->width),
COGL_FIXED_FROM_INT (priv->height));
height = CLUTTER_UNITS_TO_FIXED (for_height);
*natural_width_p =
CLUTTER_UNITS_FROM_FIXED (clutter_qmulx (ratio, height));
CLUTTER_UNITS_FROM_FIXED (COGL_FIXED_MUL (ratio, height));
}
}
}
@ -396,13 +396,13 @@ clutter_texture_get_preferred_height (ClutterActor *self,
/* Set the natural height so as to preserve the aspect ratio */
ClutterFixed ratio, width;
ratio = clutter_qdivx (CLUTTER_INT_TO_FIXED (priv->height),
CLUTTER_INT_TO_FIXED (priv->width));
ratio = COGL_FIXED_DIV (COGL_FIXED_FROM_INT (priv->height),
COGL_FIXED_FROM_INT (priv->width));
width = CLUTTER_UNITS_TO_FIXED (for_width);
*natural_height_p =
CLUTTER_UNITS_FROM_FIXED (clutter_qmulx (ratio, width));
CLUTTER_UNITS_FROM_FIXED (COGL_FIXED_MUL (ratio, width));
}
}
}
@ -469,20 +469,20 @@ clutter_texture_set_fbo_projection (ClutterActor *self)
/* Convert the coordinates back to [-1,1] range */
cogl_get_viewport (viewport);
x_min = CFX_QDIV (x_min, viewport[2]) * 2 - CFX_ONE;
x_max = CFX_QDIV (x_max, viewport[2]) * 2 - CFX_ONE;
y_min = CFX_QDIV (y_min, viewport[3]) * 2 - CFX_ONE;
y_max = CFX_QDIV (y_max, viewport[3]) * 2 - CFX_ONE;
x_min = COGL_FIXED_DIV (x_min, viewport[2]) * 2 - COGL_FIXED_1;
x_max = COGL_FIXED_DIV (x_max, viewport[2]) * 2 - COGL_FIXED_1;
y_min = COGL_FIXED_DIV (y_min, viewport[3]) * 2 - COGL_FIXED_1;
y_max = COGL_FIXED_DIV (y_max, viewport[3]) * 2 - COGL_FIXED_1;
/* Set up a projection matrix so that the actor will be projected as
if it was drawn at its original location */
tan_angle = clutter_tani (CLUTTER_ANGLE_FROM_DEGX (perspective.fovy / 2));
near_size = CFX_QMUL (perspective.z_near, tan_angle);
near_size = COGL_FIXED_MUL (perspective.z_near, tan_angle);
cogl_frustum (CFX_QMUL (x_min, near_size),
CFX_QMUL (x_max, near_size),
CFX_QMUL (-y_min, near_size),
CFX_QMUL (-y_max, near_size),
cogl_frustum (COGL_FIXED_MUL (x_min, near_size),
COGL_FIXED_MUL (x_max, near_size),
COGL_FIXED_MUL (-y_min, near_size),
COGL_FIXED_MUL (-y_max, near_size),
perspective.z_near, perspective.z_far);
}
@ -586,20 +586,21 @@ clutter_texture_paint (ClutterActor *self)
clutter_actor_get_opacity (self));
if (priv->repeat_x && priv->width > 0)
t_w = CFX_QDIV (CLUTTER_INT_TO_FIXED (x_2 - x_1),
CLUTTER_INT_TO_FIXED (priv->width));
t_w = COGL_FIXED_DIV (COGL_FIXED_FROM_INT (x_2 - x_1),
COGL_FIXED_FROM_INT (priv->width));
else
t_w = CFX_ONE;
t_w = COGL_FIXED_1;
if (priv->repeat_y && priv->height > 0)
t_h = CFX_QDIV (CLUTTER_INT_TO_FIXED (y_2 - y_1),
CLUTTER_INT_TO_FIXED (priv->height));
t_h = COGL_FIXED_DIV (COGL_FIXED_FROM_INT (y_2 - y_1),
COGL_FIXED_FROM_INT (priv->height));
else
t_h = CFX_ONE;
t_h = COGL_FIXED_1;
/* Paint will have translated us */
cogl_texture_rectangle (priv->texture, 0, 0,
CLUTTER_INT_TO_FIXED (x_2 - x_1),
CLUTTER_INT_TO_FIXED (y_2 - y_1),
COGL_FIXED_FROM_INT (x_2 - x_1),
COGL_FIXED_FROM_INT (y_2 - y_1),
0, 0, t_w, t_h);
}

View File

@ -1332,7 +1332,7 @@ clutter_timeline_get_progress (ClutterTimeline *timeline)
{
g_return_val_if_fail (CLUTTER_IS_TIMELINE (timeline), 0.);
return CLUTTER_FIXED_TO_DOUBLE (clutter_timeline_get_progressx (timeline));
return COGL_FIXED_TO_DOUBLE (clutter_timeline_get_progressx (timeline));
}
/**
@ -1355,11 +1355,11 @@ clutter_timeline_get_progressx (ClutterTimeline *timeline)
priv = timeline->priv;
progress = clutter_qdivx (CLUTTER_INT_TO_FIXED (priv->current_frame_num),
CLUTTER_INT_TO_FIXED (priv->n_frames));
progress = COGL_FIXED_DIV (COGL_FIXED_FROM_INT (priv->current_frame_num),
COGL_FIXED_FROM_INT (priv->n_frames));
if (priv->direction == CLUTTER_TIMELINE_BACKWARD)
progress = CFX_ONE - progress;
progress = COGL_FIXED_1 - progress;
return progress;
}

View File

@ -48,11 +48,11 @@ typedef gint32 ClutterUnit;
* decide to change this relationship in the future.
*/
#define CLUTTER_UNITS_FROM_INT(x) CLUTTER_INT_TO_FIXED ((x))
#define CLUTTER_UNITS_TO_INT(x) CLUTTER_FIXED_TO_INT ((x))
#define CLUTTER_UNITS_FROM_INT(x) (COGL_FIXED_FROM_INT ((x)))
#define CLUTTER_UNITS_TO_INT(x) (COGL_FIXED_TO_INT ((x)))
#define CLUTTER_UNITS_FROM_FLOAT(x) CLUTTER_FLOAT_TO_FIXED ((x))
#define CLUTTER_UNITS_TO_FLOAT(x) CLUTTER_FIXED_TO_FLOAT ((x))
#define CLUTTER_UNITS_FROM_FLOAT(x) (COGL_FIXED_FROM_FLOAT ((x)))
#define CLUTTER_UNITS_TO_FLOAT(x) (COGL_FIXED_TO_FLOAT ((x)))
#define CLUTTER_UNITS_FROM_FIXED(x) (x)
#define CLUTTER_UNITS_TO_FIXED(x) (x)

753
clutter/cogl/cogl-fixed.h Normal file
View 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__ */

View File

@ -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

View File

@ -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

View File

@ -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);

View 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);
}

View File

@ -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);

View File

@ -32,8 +32,8 @@ typedef struct _CoglBezCubic CoglBezCubic;
struct _CoglFixedVec2
{
ClutterFixed x;
ClutterFixed y;
CoglFixed x;
CoglFixed y;
};
#ifdef CLUTTER_COGL_HAS_GL

View File

@ -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

View File

@ -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);

View File

@ -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 () );

View File

@ -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));
}

View File

@ -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 \

View File

@ -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) );

View File

@ -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;
}
}

View File

@ -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 */

View File

@ -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);
}

View File

@ -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];

View File

@ -344,13 +344,14 @@ pango_clutter_glyph_cache_set (PangoClutterGlyphCache *cache,
value = g_slice_new (PangoClutterGlyphCacheValue);
value->texture = cogl_texture_ref (band->texture);
value->tx1 = CLUTTER_INT_TO_FIXED (band->space_remaining)
/ band->texture_size;
value->tx2 = CLUTTER_INT_TO_FIXED (band->space_remaining + width)
/ band->texture_size;
value->ty1 = CLUTTER_INT_TO_FIXED (band->top) / band->texture_size;
value->ty2 = CLUTTER_INT_TO_FIXED (band->top + height)
/ band->texture_size;
value->tx1 = COGL_FIXED_FROM_INT (band->space_remaining)
/ band->texture_size;
value->tx2 = COGL_FIXED_FROM_INT (band->space_remaining + width)
/ band->texture_size;
value->ty1 = COGL_FIXED_FROM_INT (band->top)
/ band->texture_size;
value->ty2 = COGL_FIXED_FROM_INT (band->top + height)
/ band->texture_size;
value->draw_x = draw_x;
value->draw_y = draw_y;
value->draw_width = width;

View File

@ -37,9 +37,9 @@ typedef struct _PangoClutterGlyphCacheValue PangoClutterGlyphCacheValue;
struct _PangoClutterGlyphCacheValue
{
CoglHandle texture;
ClutterFixed tx1, ty1, tx2, ty2;
int draw_x, draw_y, draw_width, draw_height;
CoglHandle texture;
CoglFixed tx1, ty1, tx2, ty2;
int draw_x, draw_y, draw_width, draw_height;
};
PangoClutterGlyphCache *pango_clutter_glyph_cache_new (gboolean use_mipmapping);

View File

@ -909,7 +909,6 @@ CLUTTER_FLOAT_TO_FIXED
CLUTTER_FLOAT_TO_INT
CLUTTER_FLOAT_TO_UINT
CLUTTER_INT_TO_FIXED
CLUTTER_FIXED_INT
CLUTTER_FIXED_FRACTION
CLUTTER_FIXED_FLOOR
CLUTTER_FIXED_CEIL
@ -917,9 +916,7 @@ CLUTTER_FIXED_MUL
CLUTTER_FIXED_DIV
ClutterAngle
CLUTTER_ANGLE_FROM_DEG
CLUTTER_ANGLE_FROM_DEGF
CLUTTER_ANGLE_FROM_DEGX
CLUTTER_ANGLE_TO_DEGF
CLUTTER_ANGLE_TO_DEG
CLUTTER_ANGLE_TO_DEGX
CLUTTER_ANGLE_MAX_DEG
@ -952,14 +949,6 @@ clutter_value_set_fixed
clutter_value_get_fixed
<SUBSECTION Private>
CFX_DIV
CFX_INT
CFX_MUL
CFX_QMUL
CFX_QDIV
clutter_double_to_fixed
clutter_double_to_int
clutter_double_to_unit
CLUTTER_TYPE_FIXED
CLUTTER_TYPE_PARAM_FIXED
CLUTTER_PARAM_SPEC_FIXED

View File

@ -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>

View File

@ -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>

View File

@ -98,9 +98,9 @@ test_coglbox_paint(ClutterActor *self)
cos_frame = clutter_cosi (CLUTTER_ANGLE_FROM_DEG (priv->frame));
pingpong_frame = (priv->frame <= 180 ? priv->frame : 360 - priv->frame);
frac_frame = CFX_QDIV (CLUTTER_INT_TO_FIXED (pingpong_frame),
CLUTTER_INT_TO_FIXED (180));
frac_frame += (CFX_ONE >> 1);
frac_frame = COGL_FIXED_DIV (CLUTTER_INT_TO_FIXED (pingpong_frame),
CLUTTER_INT_TO_FIXED (180));
frac_frame += (COGL_FIXED_1 >> 1);
frac_frame <<= 1;
for (t=0; t<4; t+=2)
@ -108,8 +108,8 @@ test_coglbox_paint(ClutterActor *self)
texcoords[t] += cos_frame;
texcoords[t+1] += sin_frame;
texcoords[t] = CFX_QMUL (texcoords[t], frac_frame);
texcoords[t+1] = CFX_QMUL (texcoords[t+1], frac_frame);
texcoords[t] = COGL_FIXED_MUL (texcoords[t], frac_frame);
texcoords[t+1] = COGL_FIXED_MUL (texcoords[t+1], frac_frame);
}
priv = TEST_COGLBOX_GET_PRIVATE (self);

View File

@ -21,9 +21,9 @@ init_handles ()
clutter_group_add (CLUTTER_GROUP (main_stage), p[i]);
clutter_actor_set_position (p[i],
CLUTTER_FIXED_INT (v[i].x) -
CLUTTER_FIXED_TO_INT (v[i].x) -
clutter_actor_get_width (p[i])/2,
CLUTTER_FIXED_INT (v[i].y) -
CLUTTER_FIXED_TO_INT (v[i].y) -
clutter_actor_get_height (p[i])/2);
clutter_actor_raise_top (p[i]);
@ -41,9 +41,9 @@ init_handles ()
clutter_actor_set_position (p[4], 0, 0);
clutter_group_add (CLUTTER_GROUP (main_stage), p[4]);
clutter_actor_set_position (p[4],
CLUTTER_FIXED_INT (v2.x) -
CLUTTER_FIXED_TO_INT (v2.x) -
clutter_actor_get_width (p[4])/2,
CLUTTER_FIXED_INT (v2.y) -
CLUTTER_FIXED_TO_INT (v2.y) -
clutter_actor_get_height (p[4])/2);
clutter_actor_raise_top (p[4]);
@ -62,9 +62,9 @@ place_handles ()
for (i = 0; i < 4; ++i)
{
clutter_actor_set_position (p[i],
CLUTTER_FIXED_INT (v[i].x) -
CLUTTER_FIXED_TO_INT (v[i].x) -
clutter_actor_get_width (p[i])/2,
CLUTTER_FIXED_INT (v[i].y) -
CLUTTER_FIXED_TO_INT (v[i].y) -
clutter_actor_get_height (p[i])/2);
}
@ -74,9 +74,9 @@ place_handles ()
clutter_actor_apply_transform_to_point (rect, &v1, &v2);
clutter_actor_set_position (p[4],
CLUTTER_FIXED_INT (v2.x) -
CLUTTER_FIXED_TO_INT (v2.x) -
clutter_actor_get_width (p[4])/2,
CLUTTER_FIXED_INT (v2.y) -
CLUTTER_FIXED_TO_INT (v2.y) -
clutter_actor_get_height (p[4])/2);
}
@ -148,8 +148,8 @@ on_event (ClutterStage *stage,
CLUTTER_FIXED_TO_FLOAT (yp));
clutter_actor_move_by (rect,
CLUTTER_FIXED_INT(xp),
CLUTTER_FIXED_INT(yp));
CLUTTER_FIXED_TO_INT(xp),
CLUTTER_FIXED_TO_INT(yp));
}
else
{