From 5137d0a23f19ce461f178596b687479bd62d8522 Mon Sep 17 00:00:00 2001 From: Neil Roberts Date: Mon, 24 Jan 2011 16:36:56 +0000 Subject: [PATCH] cogl-debug: Add a debug option for tracing clipping This adds a COGL_DEBUG=clipping option that reports how the clip is being flushed. This is needed to determine whether the scissor, stencil clip planes or software clipping is being used. --- clutter/cogl/cogl/cogl-clip-stack.c | 12 ++++++++++++ clutter/cogl/cogl/cogl-debug-options.h | 5 +++++ clutter/cogl/cogl/cogl-debug.c | 3 ++- clutter/cogl/cogl/cogl-debug.h | 1 + clutter/cogl/cogl/cogl-journal.c | 2 ++ 5 files changed, 22 insertions(+), 1 deletion(-) diff --git a/clutter/cogl/cogl/cogl-clip-stack.c b/clutter/cogl/cogl/cogl-clip-stack.c index c5e2fe79d..082d62358 100644 --- a/clutter/cogl/cogl/cogl-clip-stack.c +++ b/clutter/cogl/cogl/cogl-clip-stack.c @@ -597,6 +597,8 @@ _cogl_clip_stack_flush (CoglClipStack *stack) /* If the stack is empty then there's nothing else to do */ if (stack == NULL) { + COGL_NOTE (CLIPPING, "Flushed empty clip stack"); + ctx->current_clip_stack_uses_stencil = FALSE; GE (glDisable (GL_SCISSOR_TEST)); return; @@ -636,6 +638,10 @@ _cogl_clip_stack_flush (CoglClipStack *stack) } } + COGL_NOTE (CLIPPING, "Flushing scissor to (%i, %i, %i, %i)", + scissor_x0, scissor_y0, + scissor_x1, scissor_y1); + GE (glEnable (GL_SCISSOR_TEST)); GE (glScissor (scissor_x0, scissor_y_start, scissor_x1 - scissor_x0, @@ -651,6 +657,8 @@ _cogl_clip_stack_flush (CoglClipStack *stack) { CoglClipStackPath *path_entry = (CoglClipStackPath *) entry; + COGL_NOTE (CLIPPING, "Adding stencil clip for path"); + _cogl_matrix_stack_push (modelview_stack); _cogl_matrix_stack_set (modelview_stack, &path_entry->matrix); @@ -677,6 +685,8 @@ _cogl_clip_stack_flush (CoglClipStack *stack) them then use that instead */ if (has_clip_planes) { + COGL_NOTE (CLIPPING, "Adding clip planes clip for rectangle"); + set_clip_planes (rect->x0, rect->y0, rect->x1, @@ -687,6 +697,8 @@ _cogl_clip_stack_flush (CoglClipStack *stack) } else { + COGL_NOTE (CLIPPING, "Adding stencil clip for rectangle"); + add_stencil_clip_rectangle (rect->x0, rect->y0, rect->x1, diff --git a/clutter/cogl/cogl/cogl-debug-options.h b/clutter/cogl/cogl/cogl-debug-options.h index 578568353..38027f58f 100644 --- a/clutter/cogl/cogl/cogl-debug-options.h +++ b/clutter/cogl/cogl/cogl-debug-options.h @@ -174,3 +174,8 @@ OPT (DISABLE_FAST_READ_PIXEL, "Disable read pixel optimization", "Disable optimization for reading 1px for simple " "scenes of opaque rectangles") +OPT (CLIPPING, + "Cogl Tracing", + "clipping", + "Trace clipping", + "Logs information about how Cogl is implementing clipping") diff --git a/clutter/cogl/cogl/cogl-debug.c b/clutter/cogl/cogl/cogl-debug.c index 864f8c7be..d12050257 100644 --- a/clutter/cogl/cogl/cogl-debug.c +++ b/clutter/cogl/cogl/cogl-debug.c @@ -54,7 +54,8 @@ static const GDebugKey cogl_log_debug_keys[] = { { "show-source", COGL_DEBUG_SHOW_SOURCE}, { "offscreen", COGL_DEBUG_OFFSCREEN }, { "texture-pixmap", COGL_DEBUG_TEXTURE_PIXMAP }, - { "bitmap", COGL_DEBUG_BITMAP } + { "bitmap", COGL_DEBUG_BITMAP }, + { "clipping", COGL_DEBUG_CLIPPING } }; static const int n_cogl_log_debug_keys = G_N_ELEMENTS (cogl_log_debug_keys); diff --git a/clutter/cogl/cogl/cogl-debug.h b/clutter/cogl/cogl/cogl-debug.h index 2f5c5cfbf..0cd039f2a 100644 --- a/clutter/cogl/cogl/cogl-debug.h +++ b/clutter/cogl/cogl/cogl-debug.h @@ -62,6 +62,7 @@ typedef enum { COGL_DEBUG_DISABLE_SOFTWARE_CLIP, COGL_DEBUG_DISABLE_PROGRAM_CACHES, COGL_DEBUG_DISABLE_FAST_READ_PIXEL, + COGL_DEBUG_CLIPPING, COGL_DEBUG_N_FLAGS } CoglDebugFlags; diff --git a/clutter/cogl/cogl/cogl-journal.c b/clutter/cogl/cogl/cogl-journal.c index 76b1f3582..7ec25cdfc 100644 --- a/clutter/cogl/cogl/cogl-journal.c +++ b/clutter/cogl/cogl/cogl-journal.c @@ -1046,6 +1046,8 @@ maybe_software_clip_entries (CoglJournalEntry *batch_start, /* If we make it here then we know we can software clip the entire batch */ + COGL_NOTE (CLIPPING, "Software clipping a batch of length %i", batch_len); + for (entry_num = 0; entry_num < batch_len; entry_num++) { CoglJournalEntry *journal_entry = batch_start + entry_num;