2007-12-24 Emmanuele Bassi <ebassi@openedhand.com>

* clutter/cogl/cogl.h: Update cogl_clip_set() to accept the
	clip components as ClutterFixed values

	* clutter/cogl/gl/cogl.c (cogl_clip_set): Update the GL implementation
	of cogl_clip_set()

	* clutter/cogl/gles/cogl.c:
	(cogl_rectangle_internal): Provide an internal, inlined rectangle
	drawing	function using fixed point values, to be shared by
	cogl_clip_set() and cogl_rectangle()

	(cogl_clip_set), (cogl_rectangle): Update the GLES implementation
	of cogl_clip_set() and cogl_rectangle() to use the new internal
	rectangle drawing function

	* clutter/clutter-actor.c: Make the clip an array of ClutterUnit
	values instead of pixel-based; this allows higher precision and
	device independence

	(_clutter_actor_apply_modelview_transform): Pass the clip
	components converting from units to fixed point values, using
	the new cogl_clip_set() signature

	(clutter_actor_get_property), (clutter_actor_set_clip),
	(clutter_actor_get_clip): Update the accessors of the clip
	property
This commit is contained in:
Emmanuele Bassi 2007-12-24 12:53:04 +00:00
parent c178cac4b8
commit 97dd890ae1
5 changed files with 134 additions and 49 deletions

View File

@ -1,3 +1,32 @@
2007-12-24 Emmanuele Bassi <ebassi@openedhand.com>
* clutter/cogl/cogl.h: Update cogl_clip_set() to accept the
clip components as ClutterFixed values
* clutter/cogl/gl/cogl.c (cogl_clip_set): Update the GL implementation
of cogl_clip_set()
* clutter/cogl/gles/cogl.c:
(cogl_rectangle_internal): Provide an internal, inlined rectangle
drawing function using fixed point values, to be shared by
cogl_clip_set() and cogl_rectangle()
(cogl_clip_set), (cogl_rectangle): Update the GLES implementation
of cogl_clip_set() and cogl_rectangle() to use the new internal
rectangle drawing function
* clutter/clutter-actor.c: Make the clip an array of ClutterUnit
values instead of pixel-based; this allows higher precision and
device independence
(_clutter_actor_apply_modelview_transform): Pass the clip
components converting from units to fixed point values, using
the new cogl_clip_set() signature
(clutter_actor_get_property), (clutter_actor_set_clip),
(clutter_actor_get_clip): Update the accessors of the clip
property
2007-12-21 Emmanuele Bassi <ebassi@openedhand.com>
* clutter/clutter-actor.h: Remove the unused ::set_depth() and

View File

@ -151,29 +151,53 @@
static guint32 __id = 0;
typedef struct _ShaderData ShaderData;
#define CLUTTER_ACTOR_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), CLUTTER_TYPE_ACTOR, ClutterActorPrivate))
typedef struct _ShaderData ShaderData;
struct _ClutterActorPrivate
{
ClutterActorBox coords;
ClutterGeometry clip; /* FIXME: Should be Units */
ClutterUnit clip[4];
guint has_clip : 1;
ClutterFixed rxang, ryang, rzang; /* Rotation*/
ClutterUnit rzx, rzy, rxy, rxz, ryx, ryz;
/* Rotation angles */
ClutterFixed rxang;
ClutterFixed ryang;
ClutterFixed rzang;
/* Rotation center: X axis */
ClutterUnit rxy;
ClutterUnit rxz;
/* Rotation center: Y axis */
ClutterUnit ryx;
ClutterUnit ryz;
/* Rotation center: Z axis */
ClutterUnit rzx;
ClutterUnit rzy;
/* Anchor point coordinates */
ClutterUnit anchor_x;
ClutterUnit anchor_y;
/* depth */
ClutterUnit z;
guint8 opacity;
ClutterActor *parent_actor;
gchar *name;
ClutterFixed scale_x, scale_y;
guint32 id; /* Unique ID */
ClutterFixed scale_x;
ClutterFixed scale_y;
ShaderData *shader_data;
ClutterUnit anchor_x, anchor_y;
};
enum
@ -841,7 +865,10 @@ _clutter_actor_apply_modelview_transform (ClutterActor * self)
cogl_translatex (0, 0, priv->z);
if (priv->has_clip)
cogl_clip_set (&(priv->clip));
cogl_clip_set (CLUTTER_UNITS_TO_FIXED (priv->clip[0]),
CLUTTER_UNITS_TO_FIXED (priv->clip[1]),
CLUTTER_UNITS_TO_FIXED (priv->clip[2]),
CLUTTER_UNITS_TO_FIXED (priv->clip[3]));
}
/* Recursively applies the transforms associated with this actor and
@ -1223,7 +1250,16 @@ clutter_actor_get_property (GObject *object,
g_value_set_boolean (value, priv->has_clip);
break;
case PROP_CLIP:
g_value_set_boxed (value, &(priv->clip));
{
ClutterGeometry clip = { 0, };
clip.x = CLUTTER_UNITS_TO_DEVICE (priv->clip[0]);
clip.y = CLUTTER_UNITS_TO_DEVICE (priv->clip[1]);
clip.width = CLUTTER_UNITS_TO_DEVICE (priv->clip[2]);
clip.height = CLUTTER_UNITS_TO_DEVICE (priv->clip[3]);
g_value_set_boxed (value, &clip);
}
break;
case PROP_SCALE_X:
g_value_set_double (value, CLUTTER_FIXED_TO_DOUBLE (priv->scale_x));
@ -3366,18 +3402,18 @@ clutter_actor_set_clip (ClutterActor *self,
gint width,
gint height)
{
ClutterGeometry *clip;
ClutterActorPrivate *priv;
g_return_if_fail (CLUTTER_IS_ACTOR (self));
clip = &(self->priv->clip);
priv = self->priv;
clip->x = xoff;
clip->y = yoff;
clip->width = width;
clip->height = height;
priv->clip[0] = CLUTTER_UNITS_FROM_DEVICE (xoff);
priv->clip[1] = CLUTTER_UNITS_FROM_DEVICE (yoff);
priv->clip[2] = CLUTTER_UNITS_FROM_DEVICE (width);
priv->clip[3] = CLUTTER_UNITS_FROM_DEVICE (height);
self->priv->has_clip = TRUE;
priv->has_clip = TRUE;
g_object_notify (G_OBJECT (self), "has-clip");
g_object_notify (G_OBJECT (self), "clip");
@ -3437,7 +3473,6 @@ clutter_actor_get_clip (ClutterActor *self,
gint *height)
{
ClutterActorPrivate *priv;
ClutterGeometry clip = { 0, };
g_return_if_fail (CLUTTER_IS_ACTOR (self));
@ -3446,16 +3481,17 @@ clutter_actor_get_clip (ClutterActor *self,
if (!priv->has_clip)
return;
clip = priv->clip;
if (xoff)
*xoff = clip.x;
*xoff = CLUTTER_UNITS_TO_DEVICE (priv->clip[0]);
if (yoff)
*yoff = clip.y;
*yoff = CLUTTER_UNITS_TO_DEVICE (priv->clip[1]);
if (width)
*width = clip.width;
*width = CLUTTER_UNITS_TO_DEVICE (priv->clip[2]);
if (height)
*height = clip.height;
*height = CLUTTER_UNITS_TO_DEVICE (priv->clip[3]);
}
/**

View File

@ -107,7 +107,10 @@ void
cogl_color (const ClutterColor *color);
void
cogl_clip_set (const ClutterGeometry *clip);
cogl_clip_set (ClutterFixed x_offset,
ClutterFixed y_offset,
ClutterFixed width,
ClutterFixed height);
void
cogl_clip_unset (void);

View File

@ -299,7 +299,10 @@ cogl_color (const ClutterColor *color)
}
void
cogl_clip_set (const ClutterGeometry *clip)
cogl_clip_set (ClutterFixed x_offset,
ClutterFixed y_offset,
ClutterFixed width,
ClutterFixed height)
{
GE( glEnable (GL_STENCIL_TEST) );
@ -311,13 +314,13 @@ cogl_clip_set (const ClutterGeometry *clip)
GE( glColor3f (1.0f, 1.0f, 1.0f) );
GE( glRecti (clip->x,
clip->y,
clip->x + clip->width,
clip->y + clip->height) );
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( glStencilFunc (GL_EQUAL, 0x1, 0x1) );
; GE( glStencilOp (GL_KEEP, GL_KEEP, GL_KEEP) );
GE( glStencilOp (GL_KEEP, GL_KEEP, GL_KEEP) );
}
void

View File

@ -262,8 +262,30 @@ cogl_color (const ClutterColor *color)
#endif
}
static inline void
cogl_rectangle_internal (ClutterFixed x,
ClutterFixed y,
ClutterFixed width,
ClutterFixed height)
{
GLfixed rect_verts[4] = {
x, y,
x + width, y,
x, y + height,
x + width, y + height
};
GE( glEnableClientState (GL_VERTEX_ARRAY) );
GE( glVertexPointer (2, GL_FIXED, 0, rect_verts) );
GE( glDrawArrays (GL_TRIANGLE_STRIP, 0, 4) );
GE( glDisableClientState (GL_VERTEX_ARRAY) );
}
void
cogl_clip_set (const ClutterGeometry *clip)
cogl_clip_set (ClutterFixed x_offset,
ClutterFixed y_offset,
ClutterFixed width,
ClutterFixed height)
{
GE( glEnable (GL_STENCIL_TEST) );
@ -275,8 +297,8 @@ cogl_clip_set (const ClutterGeometry *clip)
GE( glColor4x (CFX_ONE, CFX_ONE, CFX_ONE, CFX_ONE ) );
cogl_rectangle (clip->x, clip->y, clip->width, clip->height);
cogl_rectangle_internal (x_offset, y_offset, width, height);
GE( glStencilFunc (GL_EQUAL, 0x1, 0x1) );
GE( glStencilOp (GL_KEEP, GL_KEEP, GL_KEEP) );
}
@ -432,23 +454,15 @@ cogl_texture_sub_image_2d (COGLenum target,
}
void
cogl_rectangle (gint x, gint y, guint width, guint height)
cogl_rectangle (gint x,
gint y,
guint width,
guint height)
{
#define FIX CLUTTER_INT_TO_FIXED
GLfixed rect_verts[] = {
FIX(x), FIX(y),
FIX((x + width)), FIX(y),
FIX(x), FIX((y + height)),
FIX((x + width)), FIX((y + height)),
};
#undef FIX
GE( glEnableClientState(GL_VERTEX_ARRAY) );
GE( glVertexPointer(2, GL_FIXED, 0, rect_verts) );
GE( glDrawArrays(GL_TRIANGLE_STRIP, 0, 4) );
GE( glDisableClientState(GL_VERTEX_ARRAY) );
cogl_rectangle_internal (CLUTTER_INT_TO_FIXED (x),
CLUTTER_INT_TO_FIXED (y),
CLUTTER_INT_TO_FIXED (width),
CLUTTER_INT_TO_FIXED (height));
}
/* FIXME: Should use ClutterReal or Fixed */