[gtk+/wip/simple-draw3] GtkPixelCache: Add debug feature to track redraws



commit 640ead7656c0234881cbe7b00a2de69a3ab1f8a9
Author: Alexander Larsson <alexl redhat com>
Date:   Thu May 2 11:47:06 2013 +0200

    GtkPixelCache: Add debug feature to track redraws
    
    Each time we redraw we tint it in a different color so that
    you can see which regions are redrawn.

 gtk/gtkdebug.h      |    3 ++-
 gtk/gtkmain.c       |    3 ++-
 gtk/gtkpixelcache.c |   21 +++++++++++++++++++++
 3 files changed, 25 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtkdebug.h b/gtk/gtkdebug.h
index f9e01e5..a82a38c 100644
--- a/gtk/gtkdebug.h
+++ b/gtk/gtkdebug.h
@@ -48,7 +48,8 @@ typedef enum {
   GTK_DEBUG_BUILDER         = 1 << 11,
   GTK_DEBUG_SIZE_REQUEST    = 1 << 12,
   GTK_DEBUG_NO_CSS_CACHE    = 1 << 13,
-  GTK_DEBUG_BASELINES       = 1 << 14
+  GTK_DEBUG_BASELINES       = 1 << 14,
+  GTK_DEBUG_PIXEL_CACHE     = 1 << 15
 } GtkDebugFlag;
 
 #ifdef G_ENABLE_DEBUG
diff --git a/gtk/gtkmain.c b/gtk/gtkmain.c
index 4a5c7af..47c5457 100644
--- a/gtk/gtkmain.c
+++ b/gtk/gtkmain.c
@@ -172,7 +172,8 @@ static const GDebugKey gtk_debug_keys[] = {
   {"builder", GTK_DEBUG_BUILDER},
   {"size-request", GTK_DEBUG_SIZE_REQUEST},
   {"no-css-cache", GTK_DEBUG_NO_CSS_CACHE},
-  {"baselines", GTK_DEBUG_BASELINES}
+  {"baselines", GTK_DEBUG_BASELINES},
+  {"pixel-cache", GTK_DEBUG_PIXEL_CACHE}
 };
 #endif /* G_ENABLE_DEBUG */
 
diff --git a/gtk/gtkpixelcache.c b/gtk/gtkpixelcache.c
index cc56311..e93c393 100644
--- a/gtk/gtkpixelcache.c
+++ b/gtk/gtkpixelcache.c
@@ -17,6 +17,7 @@
 
 #include "config.h"
 
+#include "gtkdebug.h"
 #include "gtkpixelcacheprivate.h"
 
 /* The extra size of the offscreen surface we allocate
@@ -277,7 +278,27 @@ _gtk_pixel_cache_repaint (GtkPixelCache *cache,
 
       cairo_set_operator (backing_cr, CAIRO_OPERATOR_OVER);
 
+      cairo_save (backing_cr);
       draw (backing_cr, user_data);
+      cairo_restore (backing_cr);
+
+#ifdef G_ENABLE_DEBUG
+      if (gtk_get_debug_flags () & GTK_DEBUG_PIXEL_CACHE)
+       {
+         GdkRGBA colors[] = {
+           { 1, 0, 0, 0.08},
+           { 0, 1, 0, 0.08},
+           { 0, 0, 1, 0.08},
+           { 1, 0, 1, 0.08},
+           { 1, 1, 0, 0.08},
+           { 0, 1, 1, 0.08},
+         };
+         static int current_color = 0;
+
+         gdk_cairo_set_source_rgba (backing_cr, &colors[(current_color++) % G_N_ELEMENTS (colors)]);
+         cairo_paint (backing_cr);
+       }
+#endif
 
       cairo_destroy (backing_cr);
     }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]