2007-07-12 Matthew Allum <mallum@openedhand.com>

* clutter/clutter-actor.c: (clutter_actor_paint):
        * clutter/clutter-stage.c: (clutter_stage_get_actor_at_pos):
        * clutter/cogl/cogl.h:
        * clutter/cogl/gl/cogl.c: (cogl_get_viewport):
        * clutter/cogl/gles/cogl.c: (cogl_get_viewport):
        Based on patch from Pan Bohui, See;
        http://bugzilla.openedhand.com/show_bug.cgi?id=390

        * TODO:
        More misc updates.
This commit is contained in:
Matthew Allum 2007-07-12 10:15:19 +00:00
parent c2345a5337
commit 8fcfa9e2db
7 changed files with 57 additions and 11 deletions

View File

@ -1,3 +1,17 @@
2007-07-12 Matthew Allum <mallum@openedhand.com>
* clutter/clutter-actor.c: (clutter_actor_paint):
* clutter/clutter-stage.c: (clutter_stage_get_actor_at_pos):
* clutter/cogl/cogl.h:
* clutter/cogl/gl/cogl.c: (cogl_get_viewport):
* clutter/cogl/gles/cogl.c: (cogl_get_viewport):
Hopefully fix clutter_actor_at_pos on !32bpp displays.
Based on patch from Pan Bohui, See;
http://bugzilla.openedhand.com/show_bug.cgi?id=390
* TODO:
More misc updates.
2007-07-11 Emmanuele Bassi <ebassi@openedhand.com> 2007-07-11 Emmanuele Bassi <ebassi@openedhand.com>
* clutter/clutter-behaviour-opacity.c: * clutter/clutter-behaviour-opacity.c:

1
TODO
View File

@ -45,6 +45,7 @@ Definetly:
Nice/Maybe: Nice/Maybe:
=========== ===========
- Improve cogl massively to be be processing like.
- Gradient support ? - Gradient support ?
- Rectangle like props to all actors - Rectangle like props to all actors
- Glitz integration - Glitz integration

View File

@ -682,15 +682,18 @@ clutter_actor_paint (ClutterActor *self)
if (G_UNLIKELY(context->pick_mode == TRUE)) if (G_UNLIKELY(context->pick_mode == TRUE))
{ {
gint r, g, b;
ClutterColor col; ClutterColor col;
guint32 id; guint32 id;
id = clutter_actor_get_id (self); id = clutter_actor_get_id (self);
/* Encode the actor id into a color */ cogl_get_bitmasks (&r, &g, &b, NULL);
col.red = (id >> 16) & 0xff;
col.green = (id >> 8) & 0xff; /* Encode the actor id into a color, taking into account bpp */
col.blue = id & 0xff; col.red = ((id >> (g+b)) & (0xff>>(8-r)))<<(8-r);
col.green = ((id >> b) & (0xff>>(8-g))) << (8-g);
col.blue = (id & (0xff>>(8-b)))<<(8-b);
col.alpha = 0xff; col.alpha = 0xff;
/* Actor will then paint silhouette of itself in supplied color. /* Actor will then paint silhouette of itself in supplied color.

View File

@ -783,6 +783,7 @@ clutter_stage_get_actor_at_pos (ClutterStage *stage,
GLint viewport[4]; GLint viewport[4];
ClutterColor white = { 0xff, 0xff, 0xff, 0xff }; ClutterColor white = { 0xff, 0xff, 0xff, 0xff };
guint32 id; guint32 id;
gint r,g,b;
context = clutter_context_get_default (); context = clutter_context_get_default ();
@ -796,19 +797,17 @@ clutter_stage_get_actor_at_pos (ClutterStage *stage,
clutter_actor_paint (CLUTTER_ACTOR (stage)); clutter_actor_paint (CLUTTER_ACTOR (stage));
context->pick_mode = FALSE; context->pick_mode = FALSE;
/* Calls should work under both GL and GLES, note GLES needs RGBA /* Calls should work under both GL and GLES, note GLES needs RGBA */
*
* FIXME: of course we need to handle the case where the frame buffer isn't
* 24bpp, i.e 16bpp which could be the case with GLES ?.
*/
glGetIntegerv(GL_VIEWPORT, viewport); glGetIntegerv(GL_VIEWPORT, viewport);
glReadPixels(x, viewport[3] - y, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixel); glReadPixels(x, viewport[3] - y, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixel);
if (pixel[0] == 0xff && pixel[1] == 0xff && pixel[2] == 0xff) if (pixel[0] == 0xff && pixel[1] == 0xff && pixel[2] == 0xff)
return CLUTTER_ACTOR(stage); return CLUTTER_ACTOR(stage);
/* Decode color back into an ID */ cogl_get_bitmasks (&r, &g, &b, NULL);
id = pixel[2] | pixel[1] << 8 | pixel[0] << 16;
/* Decode color back into an ID, taking into account fb depth */
id = pixel[2]>>(8-b) | pixel[1]<<b>>(8-g) | pixel[0]<<(g+b)>>(8-r);
return clutter_group_find_child_by_id (CLUTTER_GROUP (stage), id); return clutter_group_find_child_by_id (CLUTTER_GROUP (stage), id);
} }

View File

@ -198,6 +198,9 @@ cogl_get_projection_matrix (ClutterFixed m[16]);
void void
cogl_get_viewport (ClutterFixed v[4]); cogl_get_viewport (ClutterFixed v[4]);
void
cogl_get_bitmasks (gint *red, gint *green, gint *blue, gint *alpha);
G_END_DECLS G_END_DECLS
#endif /* __COGL_H__ */ #endif /* __COGL_H__ */

View File

@ -636,3 +636,16 @@ cogl_get_viewport (ClutterFixed v[4])
v[2] = CLUTTER_FLOAT_TO_FIXED (vd[2]); v[2] = CLUTTER_FLOAT_TO_FIXED (vd[2]);
v[3] = CLUTTER_FLOAT_TO_FIXED (vd[3]); v[3] = CLUTTER_FLOAT_TO_FIXED (vd[3]);
} }
void
cogl_get_bitmasks (gint *red, gint *green, gint *blue, gint *alpha)
{
if (red)
GE( glGetIntegerv(GL_RED_BITS, red) );
if (green)
GE( glGetIntegerv(GL_GREEN_BITS, green) );
if (blue)
GE( glGetIntegerv(GL_BLUE_BITS, blue) );
if (alpha)
GE( glGetIntegerv(GL_ALPHA_BITS, alpha ) );
}

View File

@ -566,3 +566,16 @@ cogl_get_viewport (ClutterFixed v[4])
{ {
glGetFixedv(GL_VIEWPORT, &v[0]); glGetFixedv(GL_VIEWPORT, &v[0]);
} }
void
cogl_get_bitmasks (gint *red, gint *green, gint *blue, gint *alpha)
{
if (red)
GE( glGetInteger(GL_RED_BITS, red) );
if (green)
GE( glGetInteger(GL_GREEN_BITS, green) );
if (blue)
GE( glGetInteger(GL_BLUE_BITS, blue) );
if (alpha)
GE( glGetInteger(GL_ALPHA_BITS, alpha ) );
}