From a9941e94995d2701783f055e69fba52a64f609e0 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Tue, 16 Feb 2010 20:08:35 +0000 Subject: [PATCH] debug: Split debugging notes from behavioural modifiers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some of the ClutterDebugFlags are not meant as a logging facility: they actually change Clutter's behaviour at run-time. It would be useful to have this distinction ratified, and thus split ClutterDebugFlags into two: one DebugFlags for logging facilities and another set of flags for behavioural changes. This split is warranted because: • it should be possible to do "CLUTTER_DEBUG=all" and only have log messages on the output • it should be possible to use behavioural modifiers even on a Clutter that has been compiled without debugging messages support The commit adds two new debugging flags: ClutterPickDebugFlags - controlled by the CLUTTER_PICK environment variable ClutterPaintDebugFlags - controlled by the CLUTTER_PAINT environment variable The PickDebugFlags are: nop-picking dump-pick-buffers While the PaintDebugFlags is: disable-swap-events The mechanism is equivalent to the CLUTTER_DEBUG environment variable, but it does not depend on the debug level selected when configuring and compiling Clutter. The picking and painting debugging flags are initialized at clutter_init() time. http://bugzilla.openedhand.com/show_bug.cgi?id=1991 --- clutter/clutter-debug.h | 14 +++++++-- clutter/clutter-main.c | 51 ++++++++++++++++++++++++------- clutter/glx/clutter-backend-glx.c | 6 ++-- 3 files changed, 55 insertions(+), 16 deletions(-) diff --git a/clutter/clutter-debug.h b/clutter/clutter-debug.h index 8974954f8..c2c49585b 100644 --- a/clutter/clutter-debug.h +++ b/clutter/clutter-debug.h @@ -23,11 +23,17 @@ typedef enum { CLUTTER_DEBUG_MULTISTAGE = 1 << 13, CLUTTER_DEBUG_ANIMATION = 1 << 14, CLUTTER_DEBUG_LAYOUT = 1 << 15, - CLUTTER_DEBUG_NOP_PICKING = 1 << 16, - CLUTTER_DEBUG_DUMP_PICK_BUFFERS = 1 << 17, - CLUTTER_DEBUG_DISABLE_SWAP_EVENTS = 1 << 18, } ClutterDebugFlag; +typedef enum { + CLUTTER_DEBUG_NOP_PICKING = 1 << 0, + CLUTTER_DEBUG_DUMP_PICK_BUFFERS = 1 << 1 +} ClutterPickDebugFlag; + +typedef enum { + CLUTTER_DEBUG_DISABLE_SWAP_EVENTS = 1 << 0 +} ClutterDrawDebugFlag; + #ifdef CLUTTER_ENABLE_DEBUG #ifdef __GNUC__ @@ -88,6 +94,8 @@ typedef enum { #endif /* CLUTTER_ENABLE_DEBUG */ extern guint clutter_debug_flags; +extern guint clutter_pick_debug_flags; +extern guint clutter_paint_debug_flags; G_END_DECLS diff --git a/clutter/clutter-main.c b/clutter/clutter-main.c index fdc8c942f..531200c0c 100644 --- a/clutter/clutter-main.c +++ b/clutter/clutter-main.c @@ -137,6 +137,9 @@ static guint clutter_main_loop_level = 0; static GSList *main_loops = NULL; guint clutter_debug_flags = 0; /* global clutter debug flag */ +guint clutter_paint_debug_flags = 0; +guint clutter_pick_debug_flags = 0; + guint clutter_profile_flags = 0; /* global clutter profile flag */ const guint clutter_major_version = CLUTTER_MAJOR_VERSION; @@ -160,17 +163,23 @@ static const GDebugKey clutter_debug_keys[] = { { "shader", CLUTTER_DEBUG_SHADER }, { "multistage", CLUTTER_DEBUG_MULTISTAGE }, { "animation", CLUTTER_DEBUG_ANIMATION }, - { "layout", CLUTTER_DEBUG_LAYOUT }, - { "nop-picking", CLUTTER_DEBUG_NOP_PICKING }, - { "dump-pick-buffers", CLUTTER_DEBUG_DUMP_PICK_BUFFERS }, - { "disable-swap-events", CLUTTER_DEBUG_DISABLE_SWAP_EVENTS } + { "layout", CLUTTER_DEBUG_LAYOUT } }; #endif /* CLUTTER_ENABLE_DEBUG */ +static const GDebugKey clutter_pick_debug_keys[] = { + { "nop-picking", CLUTTER_DEBUG_NOP_PICKING }, + { "dump-pick-buffers", CLUTTER_DEBUG_DUMP_PICK_BUFFERS } +}; + +static const GDebugKey clutter_paint_debug_keys[] = { + { "disable-swap-events", CLUTTER_DEBUG_DISABLE_SWAP_EVENTS } +}; + #ifdef CLUTTER_ENABLE_PROFILE static const GDebugKey clutter_profile_keys[] = { - {"picking-only", CLUTTER_PROFILE_PICKING_ONLY }, - {"disable-report", CLUTTER_PROFILE_DISABLE_REPORT } + {"picking-only", CLUTTER_PROFILE_PICKING_ONLY }, + {"disable-report", CLUTTER_PROFILE_DISABLE_REPORT } }; #endif /* CLUTTER_ENABLE_DEBUG */ @@ -411,7 +420,7 @@ _clutter_id_to_color (guint id, ClutterColor *col) * otherwise pick buffers dumped to an image will pretty much just look * black. */ - if (G_UNLIKELY (clutter_debug_flags & CLUTTER_DEBUG_DUMP_PICK_BUFFERS)) + if (G_UNLIKELY (clutter_pick_debug_flags & CLUTTER_DEBUG_DUMP_PICK_BUFFERS)) { col->red = (col->red << 4) | (col->red >> 4); col->green = (col->green << 4) | (col->green >> 4); @@ -431,7 +440,7 @@ _clutter_pixel_to_id (guchar pixel[4]) /* reduce the pixel components to the number of bits actually used of the * 8bits. */ - if (G_UNLIKELY (clutter_debug_flags & CLUTTER_DEBUG_DUMP_PICK_BUFFERS)) + if (G_UNLIKELY (clutter_pick_debug_flags & CLUTTER_DEBUG_DUMP_PICK_BUFFERS)) { guchar tmp; @@ -590,7 +599,7 @@ _clutter_do_pick (ClutterStage *stage, /* needed for when a context switch happens */ _clutter_stage_maybe_setup_viewport (stage); - if (G_LIKELY (!(clutter_debug_flags & CLUTTER_DEBUG_DUMP_PICK_BUFFERS))) + if (G_LIKELY (!(clutter_pick_debug_flags & CLUTTER_DEBUG_DUMP_PICK_BUFFERS))) cogl_clip_push_window_rectangle (x, y, 1, 1); cogl_disable_fog (); @@ -615,7 +624,7 @@ _clutter_do_pick (ClutterStage *stage, context->pick_mode = CLUTTER_PICK_NONE; CLUTTER_TIMER_STOP (_clutter_uprof_context, pick_paint); - if (G_LIKELY (!(clutter_debug_flags & CLUTTER_DEBUG_DUMP_PICK_BUFFERS))) + if (G_LIKELY (!(clutter_pick_debug_flags & CLUTTER_DEBUG_DUMP_PICK_BUFFERS))) cogl_clip_pop (); /* Make sure Cogl flushes any batched geometry to the GPU driver */ @@ -629,7 +638,7 @@ _clutter_do_pick (ClutterStage *stage, pixel); CLUTTER_TIMER_STOP (_clutter_uprof_context, pick_read); - if (G_UNLIKELY (clutter_debug_flags & CLUTTER_DEBUG_DUMP_PICK_BUFFERS)) + if (G_UNLIKELY (clutter_pick_debug_flags & CLUTTER_DEBUG_DUMP_PICK_BUFFERS)) { read_pixels_to_file ("pick-buffer", 0, 0, clutter_actor_get_width (CLUTTER_ACTOR (stage)), @@ -1646,6 +1655,26 @@ pre_parse_hook (GOptionContext *context, } #endif /* CLUTTER_ENABLE_PROFILE */ + env_string = g_getenv ("CLUTTER_PICK"); + if (env_string != NULL) + { + clutter_pick_debug_flags = + g_parse_debug_string (env_string, + clutter_pick_debug_keys, + G_N_ELEMENTS (clutter_pick_debug_keys)); + env_string = NULL; + } + + env_string = g_getenv ("CLUTTER_PAINT"); + if (env_string != NULL) + { + clutter_paint_debug_flags = + g_parse_debug_string (env_string, + clutter_paint_debug_keys, + G_N_ELEMENTS (clutter_paint_debug_keys)); + env_string = NULL; + } + env_string = g_getenv ("CLUTTER_SHOW_FPS"); if (env_string) clutter_show_fps = TRUE; diff --git a/clutter/glx/clutter-backend-glx.c b/clutter/glx/clutter-backend-glx.c index 47cd64477..4a3eb688e 100644 --- a/clutter/glx/clutter-backend-glx.c +++ b/clutter/glx/clutter-backend-glx.c @@ -331,10 +331,12 @@ clutter_backend_glx_get_features (ClutterBackend *backend) /* GLX_INTEL_swap_event allows us to avoid blocking the CPU while * we wait for glXSwapBuffers to complete, and instead we get an X * event notifying us of completion... */ - if (!(clutter_debug_flags & CLUTTER_DEBUG_DISABLE_SWAP_EVENTS) && + if (!(clutter_paint_debug_flags & CLUTTER_DEBUG_DISABLE_SWAP_EVENTS) && _cogl_check_extension ("GLX_INTEL_swap_event", glx_extensions) && flags & CLUTTER_FEATURE_SYNC_TO_VBLANK) - flags |= CLUTTER_FEATURE_SWAP_EVENTS; + { + flags |= CLUTTER_FEATURE_SWAP_EVENTS; + } #endif /* GLX_INTEL_swap_event */ }