1
0
Fork 0

picking: Read the colour value using COGL_PIXEL_FORMAT_RGBA_8888_PRE

In commit c0a553163b I changed the format used to read the picking
pixel to COGL_PIXEL_FORMAT_RGB_888 because it was convenient to avoid
the premult conversion. However this broke picking on GLES on some
platforms because for that glReadPixels is only guaranteed to support
GL_RGBA with GL_UNSIGNED_BYTE. Since the last commit cogl_read_pixels
will always use that format but it will end up with a conversion back
to RGB_888. This patch avoids that conversion and avoids the premult
conversion by reading in RGBA_8888_PRE.

http://bugzilla.openedhand.com/show_bug.cgi?id=2057
This commit is contained in:
Neil Roberts 2010-03-26 23:09:11 +00:00
parent 0cb09cd40d
commit 78dc59b348

View file

@ -551,7 +551,7 @@ _clutter_do_pick (ClutterStage *stage,
ClutterPickMode mode)
{
ClutterMainContext *context;
guchar pixel[3] = { 0xff, 0xff, 0xff };
guchar pixel[4] = { 0xff, 0xff, 0xff, 0xff };
CoglColor stage_pick_id;
guint32 id;
GLboolean dither_was_on;
@ -632,11 +632,17 @@ _clutter_do_pick (ClutterStage *stage,
/* Make sure Cogl flushes any batched geometry to the GPU driver */
cogl_flush ();
/* Read the color of the screen co-ords pixel */
/* Read the color of the screen co-ords pixel. RGBA_8888_PRE is used
even though we don't care about the alpha component because under
GLES this is the only format that is guaranteed to work so Cogl
will end up having to do a conversion if any other format is
used. The format is requested as pre-multiplied because Cogl
assumes that all pixels in the framebuffer are premultiplied so
it avoids a conversion. */
CLUTTER_TIMER_START (_clutter_uprof_context, pick_read);
cogl_read_pixels (x, y, 1, 1,
COGL_READ_PIXELS_COLOR_BUFFER,
COGL_PIXEL_FORMAT_RGB_888,
COGL_PIXEL_FORMAT_RGBA_8888_PRE,
pixel);
CLUTTER_TIMER_STOP (_clutter_uprof_context, pick_read);