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 ef26dc078e
commit 471da532a3
3 changed files with 46 additions and 26 deletions

5
cogl.h
View File

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

View File

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

View File

@ -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,8 +297,8 @@ 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 */