summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2013-05-02 11:47:06 +0200
committerAlexander Larsson <alexl@redhat.com>2013-05-02 19:03:12 +0200
commit994a1bc0162dd4974d06121eaef68b746cf9c66a (patch)
tree0f52558aa03f183f8e5b3db30b8d3cffd0e78c32
parent1d178b5464b0a1362e593f652a104334d8136967 (diff)
downloadgtk+-994a1bc0162dd4974d06121eaef68b746cf9c66a.tar.gz
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.
-rw-r--r--gtk/gtkdebug.h3
-rw-r--r--gtk/gtkmain.c3
-rw-r--r--gtk/gtkpixelcache.c21
3 files changed, 25 insertions, 2 deletions
diff --git a/gtk/gtkdebug.h b/gtk/gtkdebug.h
index f9e01e5c18..a82a38c4ef 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 4a5c7af479..47c5457d4f 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 1a8630819c..91b9d8fb26 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
@@ -289,7 +290,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);
}