From a7cf98ebfc9ca13e3f84bbe33171a2218cfe039b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20H=C3=B8gsberg?= Date: Mon, 27 Sep 2010 13:25:50 -0400 Subject: [PATCH] Initialize color masks lazily When we don't use a window system drawable, we can't query the color masks at context initialization time. Do it lazily so we're sure to have a current context with a valid framebuffer. --- clutter/clutter-main.c | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/clutter/clutter-main.c b/clutter/clutter-main.c index 10535c260..8945aa54b 100644 --- a/clutter/clutter-main.c +++ b/clutter/clutter-main.c @@ -343,6 +343,26 @@ _clutter_id_to_color (guint id, ClutterColor *col) ctx = _clutter_context_get_default (); + if (ctx->fb_g_mask == 0) + { + /* Figure out framebuffer masks used for pick */ + cogl_get_bitmasks (&ctx->fb_r_mask, + &ctx->fb_g_mask, + &ctx->fb_b_mask, NULL); + + ctx->fb_r_mask_used = ctx->fb_r_mask; + ctx->fb_g_mask_used = ctx->fb_g_mask; + ctx->fb_b_mask_used = ctx->fb_b_mask; + + /* XXX - describe what "fuzzy picking" is */ + if (clutter_use_fuzzy_picking) + { + ctx->fb_r_mask_used--; + ctx->fb_g_mask_used--; + ctx->fb_b_mask_used--; + } + } + /* compute the numbers we'll store in the components */ red = (id >> (ctx->fb_g_mask_used+ctx->fb_b_mask_used)) & (0xff >> (8-ctx->fb_r_mask_used)); @@ -1606,21 +1626,6 @@ clutter_init_real (GError **error) clutter_text_direction = clutter_get_text_direction (); - /* Figure out framebuffer masks used for pick */ - cogl_get_bitmasks (&ctx->fb_r_mask, &ctx->fb_g_mask, &ctx->fb_b_mask, NULL); - - ctx->fb_r_mask_used = ctx->fb_r_mask; - ctx->fb_g_mask_used = ctx->fb_g_mask; - ctx->fb_b_mask_used = ctx->fb_b_mask; - - /* XXX - describe what "fuzzy picking" is */ - if (clutter_use_fuzzy_picking) - { - ctx->fb_r_mask_used--; - ctx->fb_g_mask_used--; - ctx->fb_b_mask_used--; - } - /* Initiate event collection */ _clutter_backend_init_events (ctx->backend);