From 78dc59b34859686c89e9b96dc0fc78f453031262 Mon Sep 17 00:00:00 2001 From: Neil Roberts Date: Fri, 26 Mar 2010 23:09:11 +0000 Subject: [PATCH] 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 --- clutter/clutter-main.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/clutter/clutter-main.c b/clutter/clutter-main.c index fcfa33b..59bf9d7 100644 --- a/clutter/clutter-main.c +++ b/clutter/clutter-main.c @@ -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); -- 2.7.4