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:
parent
c178cac4b8
commit
97dd890ae1
29
ChangeLog
29
ChangeLog
@ -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>
|
2007-12-21 Emmanuele Bassi <ebassi@openedhand.com>
|
||||||
|
|
||||||
* clutter/clutter-actor.h: Remove the unused ::set_depth() and
|
* clutter/clutter-actor.h: Remove the unused ::set_depth() and
|
||||||
|
@ -151,29 +151,53 @@
|
|||||||
|
|
||||||
static guint32 __id = 0;
|
static guint32 __id = 0;
|
||||||
|
|
||||||
|
typedef struct _ShaderData ShaderData;
|
||||||
|
|
||||||
#define CLUTTER_ACTOR_GET_PRIVATE(obj) \
|
#define CLUTTER_ACTOR_GET_PRIVATE(obj) \
|
||||||
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), CLUTTER_TYPE_ACTOR, ClutterActorPrivate))
|
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), CLUTTER_TYPE_ACTOR, ClutterActorPrivate))
|
||||||
|
|
||||||
typedef struct _ShaderData ShaderData;
|
|
||||||
|
|
||||||
struct _ClutterActorPrivate
|
struct _ClutterActorPrivate
|
||||||
{
|
{
|
||||||
ClutterActorBox coords;
|
ClutterActorBox coords;
|
||||||
|
|
||||||
ClutterGeometry clip; /* FIXME: Should be Units */
|
ClutterUnit clip[4];
|
||||||
guint has_clip : 1;
|
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;
|
ClutterUnit z;
|
||||||
|
|
||||||
guint8 opacity;
|
guint8 opacity;
|
||||||
|
|
||||||
ClutterActor *parent_actor;
|
ClutterActor *parent_actor;
|
||||||
|
|
||||||
gchar *name;
|
gchar *name;
|
||||||
ClutterFixed scale_x, scale_y;
|
|
||||||
guint32 id; /* Unique ID */
|
guint32 id; /* Unique ID */
|
||||||
|
|
||||||
|
ClutterFixed scale_x;
|
||||||
|
ClutterFixed scale_y;
|
||||||
|
|
||||||
ShaderData *shader_data;
|
ShaderData *shader_data;
|
||||||
ClutterUnit anchor_x, anchor_y;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
enum
|
enum
|
||||||
@ -841,7 +865,10 @@ _clutter_actor_apply_modelview_transform (ClutterActor * self)
|
|||||||
cogl_translatex (0, 0, priv->z);
|
cogl_translatex (0, 0, priv->z);
|
||||||
|
|
||||||
if (priv->has_clip)
|
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
|
/* 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);
|
g_value_set_boolean (value, priv->has_clip);
|
||||||
break;
|
break;
|
||||||
case PROP_CLIP:
|
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;
|
break;
|
||||||
case PROP_SCALE_X:
|
case PROP_SCALE_X:
|
||||||
g_value_set_double (value, CLUTTER_FIXED_TO_DOUBLE (priv->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 width,
|
||||||
gint height)
|
gint height)
|
||||||
{
|
{
|
||||||
ClutterGeometry *clip;
|
ClutterActorPrivate *priv;
|
||||||
|
|
||||||
g_return_if_fail (CLUTTER_IS_ACTOR (self));
|
g_return_if_fail (CLUTTER_IS_ACTOR (self));
|
||||||
|
|
||||||
clip = &(self->priv->clip);
|
priv = self->priv;
|
||||||
|
|
||||||
clip->x = xoff;
|
priv->clip[0] = CLUTTER_UNITS_FROM_DEVICE (xoff);
|
||||||
clip->y = yoff;
|
priv->clip[1] = CLUTTER_UNITS_FROM_DEVICE (yoff);
|
||||||
clip->width = width;
|
priv->clip[2] = CLUTTER_UNITS_FROM_DEVICE (width);
|
||||||
clip->height = height;
|
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), "has-clip");
|
||||||
g_object_notify (G_OBJECT (self), "clip");
|
g_object_notify (G_OBJECT (self), "clip");
|
||||||
@ -3437,7 +3473,6 @@ clutter_actor_get_clip (ClutterActor *self,
|
|||||||
gint *height)
|
gint *height)
|
||||||
{
|
{
|
||||||
ClutterActorPrivate *priv;
|
ClutterActorPrivate *priv;
|
||||||
ClutterGeometry clip = { 0, };
|
|
||||||
|
|
||||||
g_return_if_fail (CLUTTER_IS_ACTOR (self));
|
g_return_if_fail (CLUTTER_IS_ACTOR (self));
|
||||||
|
|
||||||
@ -3446,16 +3481,17 @@ clutter_actor_get_clip (ClutterActor *self,
|
|||||||
if (!priv->has_clip)
|
if (!priv->has_clip)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
clip = priv->clip;
|
|
||||||
|
|
||||||
if (xoff)
|
if (xoff)
|
||||||
*xoff = clip.x;
|
*xoff = CLUTTER_UNITS_TO_DEVICE (priv->clip[0]);
|
||||||
|
|
||||||
if (yoff)
|
if (yoff)
|
||||||
*yoff = clip.y;
|
*yoff = CLUTTER_UNITS_TO_DEVICE (priv->clip[1]);
|
||||||
|
|
||||||
if (width)
|
if (width)
|
||||||
*width = clip.width;
|
*width = CLUTTER_UNITS_TO_DEVICE (priv->clip[2]);
|
||||||
|
|
||||||
if (height)
|
if (height)
|
||||||
*height = clip.height;
|
*height = CLUTTER_UNITS_TO_DEVICE (priv->clip[3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -107,7 +107,10 @@ void
|
|||||||
cogl_color (const ClutterColor *color);
|
cogl_color (const ClutterColor *color);
|
||||||
|
|
||||||
void
|
void
|
||||||
cogl_clip_set (const ClutterGeometry *clip);
|
cogl_clip_set (ClutterFixed x_offset,
|
||||||
|
ClutterFixed y_offset,
|
||||||
|
ClutterFixed width,
|
||||||
|
ClutterFixed height);
|
||||||
|
|
||||||
void
|
void
|
||||||
cogl_clip_unset (void);
|
cogl_clip_unset (void);
|
||||||
|
@ -299,7 +299,10 @@ cogl_color (const ClutterColor *color)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
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) );
|
GE( glEnable (GL_STENCIL_TEST) );
|
||||||
|
|
||||||
@ -311,13 +314,13 @@ cogl_clip_set (const ClutterGeometry *clip)
|
|||||||
|
|
||||||
GE( glColor3f (1.0f, 1.0f, 1.0f) );
|
GE( glColor3f (1.0f, 1.0f, 1.0f) );
|
||||||
|
|
||||||
GE( glRecti (clip->x,
|
GE( glRectf (CLUTTER_FIXED_TO_FLOAT (x_offset),
|
||||||
clip->y,
|
CLUTTER_FIXED_TO_FLOAT (y_offset),
|
||||||
clip->x + clip->width,
|
CLUTTER_FIXED_TO_FLOAT (x_offset + width),
|
||||||
clip->y + clip->height) );
|
CLUTTER_FIXED_TO_FLOAT (y_offset + height)) );
|
||||||
|
|
||||||
GE( glStencilFunc (GL_EQUAL, 0x1, 0x1) );
|
GE( glStencilFunc (GL_EQUAL, 0x1, 0x1) );
|
||||||
; GE( glStencilOp (GL_KEEP, GL_KEEP, GL_KEEP) );
|
GE( glStencilOp (GL_KEEP, GL_KEEP, GL_KEEP) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -262,8 +262,30 @@ cogl_color (const ClutterColor *color)
|
|||||||
#endif
|
#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
|
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) );
|
GE( glEnable (GL_STENCIL_TEST) );
|
||||||
|
|
||||||
@ -275,7 +297,7 @@ cogl_clip_set (const ClutterGeometry *clip)
|
|||||||
|
|
||||||
GE( glColor4x (CFX_ONE, CFX_ONE, CFX_ONE, CFX_ONE ) );
|
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( glStencilFunc (GL_EQUAL, 0x1, 0x1) );
|
||||||
GE( glStencilOp (GL_KEEP, GL_KEEP, GL_KEEP) );
|
GE( glStencilOp (GL_KEEP, GL_KEEP, GL_KEEP) );
|
||||||
@ -432,23 +454,15 @@ cogl_texture_sub_image_2d (COGLenum target,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
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
|
cogl_rectangle_internal (CLUTTER_INT_TO_FIXED (x),
|
||||||
|
CLUTTER_INT_TO_FIXED (y),
|
||||||
GLfixed rect_verts[] = {
|
CLUTTER_INT_TO_FIXED (width),
|
||||||
FIX(x), FIX(y),
|
CLUTTER_INT_TO_FIXED (height));
|
||||||
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) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME: Should use ClutterReal or Fixed */
|
/* FIXME: Should use ClutterReal or Fixed */
|
||||||
|
Loading…
Reference in New Issue
Block a user