From dd8e4dcd62979bf8b7c8ad0e8898888a065ba445 Mon Sep 17 00:00:00 2001 From: Robert Bragg Date: Mon, 5 Oct 2009 16:46:24 +0100 Subject: [PATCH] [debug] Guard the use of gdk_pixbuf for pick debugging by #ifdef USE_GDKPIXBUF gdk is an optional clutter dependency, so the pick buffer debugging option needs some guards so we don't break, for example, the OSX builds. This also adds a comment for the bit fiddling done on the pick colors used to ensure the pick colors are more distinguished while debugging. (we swap the nibbles of each color component so that pick buffers don't just look black.) --- clutter/clutter-main.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/clutter/clutter-main.c b/clutter/clutter-main.c index ddb76ae79..45442a505 100644 --- a/clutter/clutter-main.c +++ b/clutter/clutter-main.c @@ -38,7 +38,9 @@ #include #include +#ifdef USE_GDKPIXBUF #include +#endif #include "clutter-event.h" #include "clutter-backend.h" @@ -340,6 +342,11 @@ _clutter_id_to_color (guint id, ClutterColor *col) col->blue = blue; col->alpha = 0xff; + /* XXX: We rotate the nibbles of the colors here so that there is a + * visible variation between colors of sequential actor identifiers; + * otherwise pick buffers dumped to an image will pretty much just look + * black. + */ if (G_UNLIKELY (clutter_debug_flags & CLUTTER_DEBUG_DUMP_PICK_BUFFERS)) { col->red = (col->red << 4) | (col->red >> 4); @@ -363,6 +370,12 @@ _clutter_pixel_to_id (guchar pixel[4]) if (G_UNLIKELY (clutter_debug_flags & CLUTTER_DEBUG_DUMP_PICK_BUFFERS)) { guchar tmp; + + /* XXX: In _clutter_id_to_color we rotated the nibbles of the colors so + * that there is a visible variation between colors of sequential actor + * identifiers (otherwise pick buffers dumped to an image will pretty + * much just look black.) Here we reverse that rotation. + */ tmp = ((pixel[0] << 4) | (pixel[0] >> 4)); red = tmp >> (8 - ctx->fb_r_mask); tmp = ((pixel[1] << 4) | (pixel[1] >> 4)); @@ -389,11 +402,13 @@ _clutter_pixel_to_id (guchar pixel[4]) return id; } +#ifdef USE_GDKPIXBUF static void pixbuf_free (guchar *pixels, gpointer data) { g_free (pixels); } +#endif static void read_pixels_to_file (char *filename_stem, @@ -402,6 +417,7 @@ read_pixels_to_file (char *filename_stem, int width, int height) { +#ifdef USE_GDKPIXBUF GLubyte *data; GdkPixbuf *pixbuf; static int read_count = 0; @@ -439,6 +455,15 @@ read_pixels_to_file (char *filename_stem, g_object_unref (flipped); read_count++; } +#else + static gboolean seen = FALSE; + if (!seen) + { + g_warning ("dumping buffers to an image isn't supported on platforms " + "without gdk pixbuf support\n"); + seen = TRUE; + } +#endif } ClutterActor *