Use per-display debug flags for visual debugging

This commit is contained in:
Matthias Clasen 2016-03-11 00:18:54 -05:00
parent 02742d5332
commit 1a5cb41bd9
3 changed files with 54 additions and 49 deletions

View File

@ -31,6 +31,7 @@
#include "gtkrenderbackgroundprivate.h" #include "gtkrenderbackgroundprivate.h"
#include "gtkrenderborderprivate.h" #include "gtkrenderborderprivate.h"
#include "gtkdebug.h" #include "gtkdebug.h"
#include "gtkprivate.h"
/* /*
* Gadgets are 'next-generation widgets' - they combine a CSS node * Gadgets are 'next-generation widgets' - they combine a CSS node
@ -887,50 +888,53 @@ gtk_css_gadget_draw (GtkCssGadget *gadget,
height - margin.top - margin.bottom); height - margin.top - margin.bottom);
#if G_ENABLE_DEBUG #if G_ENABLE_DEBUG
if (GTK_DEBUG_CHECK (LAYOUT)) {
{ GdkDisplay *display = gtk_widget_get_display (gtk_css_gadget_get_owner (gadget));
cairo_save (cr); if (GTK_DISPLAY_DEBUG_CHECK (display, LAYOUT))
cairo_new_path (cr); {
cairo_rectangle (cr, cairo_save (cr);
x + margin.left, cairo_new_path (cr);
y + margin.top, cairo_rectangle (cr,
width - margin.left - margin.right, x + margin.left,
height - margin.top - margin.bottom); y + margin.top,
cairo_set_line_width (cr, 1.0); width - margin.left - margin.right,
cairo_set_source_rgba (cr, 0, 0, 1.0, 0.33); height - margin.top - margin.bottom);
cairo_stroke (cr); cairo_set_line_width (cr, 1.0);
cairo_rectangle (cr, cairo_set_source_rgba (cr, 0, 0, 1.0, 0.33);
contents_x, cairo_stroke (cr);
contents_y, cairo_rectangle (cr,
contents_width, contents_x,
contents_height); contents_y,
cairo_set_line_width (cr, 1.0); contents_width,
cairo_set_source_rgba (cr, 1.0, 0, 1.0, 0.33); contents_height);
cairo_stroke (cr); cairo_set_line_width (cr, 1.0);
cairo_restore (cr); cairo_set_source_rgba (cr, 1.0, 0, 1.0, 0.33);
} cairo_stroke (cr);
if (GTK_DEBUG_CHECK (BASELINES)) cairo_restore (cr);
{ }
int baseline = priv->allocated_baseline; if (GTK_DISPLAY_DEBUG_CHECK (display, BASELINES))
{
int baseline = priv->allocated_baseline;
if (baseline != -1) if (baseline != -1)
{ {
if (priv->owner && !gtk_widget_get_has_window (priv->owner)) if (priv->owner && !gtk_widget_get_has_window (priv->owner))
{ {
GtkAllocation widget_alloc; GtkAllocation widget_alloc;
gtk_widget_get_allocation (priv->owner, &widget_alloc); gtk_widget_get_allocation (priv->owner, &widget_alloc);
baseline -= widget_alloc.y; baseline -= widget_alloc.y;
} }
cairo_save (cr); cairo_save (cr);
cairo_new_path (cr); cairo_new_path (cr);
cairo_move_to (cr, x + margin.left, priv->allocated_baseline + 0.5); cairo_move_to (cr, x + margin.left, priv->allocated_baseline + 0.5);
cairo_rel_line_to (cr, width - margin.left - margin.right, 0); cairo_rel_line_to (cr, width - margin.left - margin.right, 0);
cairo_set_line_width (cr, 1.0); cairo_set_line_width (cr, 1.0);
cairo_set_source_rgba (cr, 1.0, 0, 0.25, 0.25); cairo_set_source_rgba (cr, 1.0, 0, 0.25, 0.25);
cairo_stroke (cr); cairo_stroke (cr);
cairo_restore (cr); cairo_restore (cr);
} }
} }
}
#endif #endif
} }

View File

@ -18,6 +18,7 @@
#include "config.h" #include "config.h"
#include "gtkdebug.h" #include "gtkdebug.h"
#include "gtkprivate.h"
#include "gtkpixelcacheprivate.h" #include "gtkpixelcacheprivate.h"
#include "gtkrenderbackgroundprivate.h" #include "gtkrenderbackgroundprivate.h"
#include "gtkstylecontextprivate.h" #include "gtkstylecontextprivate.h"
@ -186,7 +187,7 @@ _gtk_pixel_cache_create_surface_if_needed (GtkPixelCache *cache,
cairo_content_t content; cairo_content_t content;
#ifdef G_ENABLE_DEBUG #ifdef G_ENABLE_DEBUG
if (GTK_DEBUG_CHECK (NO_PIXEL_CACHE)) if (GTK_DISPLAY_DEBUG_CHECK (gdk_window_get_display (window), NO_PIXEL_CACHE))
return; return;
#endif #endif
@ -329,6 +330,7 @@ _gtk_pixel_cache_set_position (GtkPixelCache *cache,
static void static void
_gtk_pixel_cache_repaint (GtkPixelCache *cache, _gtk_pixel_cache_repaint (GtkPixelCache *cache,
GdkWindow *window,
GtkPixelCacheDrawFunc draw, GtkPixelCacheDrawFunc draw,
cairo_rectangle_int_t *view_rect, cairo_rectangle_int_t *view_rect,
cairo_rectangle_int_t *canvas_rect, cairo_rectangle_int_t *canvas_rect,
@ -361,7 +363,7 @@ _gtk_pixel_cache_repaint (GtkPixelCache *cache,
cairo_restore (backing_cr); cairo_restore (backing_cr);
#ifdef G_ENABLE_DEBUG #ifdef G_ENABLE_DEBUG
if (GTK_DEBUG_CHECK (PIXEL_CACHE)) if (GTK_DISPLAY_DEBUG_CHECK (gdk_window_get_display (window), PIXEL_CACHE))
{ {
GdkRGBA colors[] = { GdkRGBA colors[] = {
{ 1, 0, 0, 0.08}, { 1, 0, 0, 0.08},
@ -449,7 +451,7 @@ _gtk_pixel_cache_draw (GtkPixelCache *cache,
_gtk_pixel_cache_create_surface_if_needed (cache, window, _gtk_pixel_cache_create_surface_if_needed (cache, window,
view_rect, canvas_rect); view_rect, canvas_rect);
_gtk_pixel_cache_set_position (cache, view_rect, canvas_rect); _gtk_pixel_cache_set_position (cache, view_rect, canvas_rect);
_gtk_pixel_cache_repaint (cache, draw, view_rect, canvas_rect, user_data); _gtk_pixel_cache_repaint (cache, window, draw, view_rect, canvas_rect, user_data);
if (cache->surface && context_is_unscaled (cr) && if (cache->surface && context_is_unscaled (cr) &&
/* Don't use backing surface if rendering elsewhere */ /* Don't use backing surface if rendering elsewhere */

View File

@ -6988,7 +6988,7 @@ gtk_widget_draw_internal (GtkWidget *widget,
} }
#ifdef G_ENABLE_DEBUG #ifdef G_ENABLE_DEBUG
if (GTK_DEBUG_CHECK (BASELINES)) if (GTK_DISPLAY_DEBUG_CHECK (gtk_widget_get_display (widget), BASELINES))
{ {
gint baseline = gtk_widget_get_allocated_baseline (widget); gint baseline = gtk_widget_get_allocated_baseline (widget);
gint width = gtk_widget_get_allocated_width (widget); gint width = gtk_widget_get_allocated_width (widget);
@ -7005,8 +7005,7 @@ gtk_widget_draw_internal (GtkWidget *widget,
cairo_restore (cr); cairo_restore (cr);
} }
} }
if (GTK_DISPLAY_DEBUG_CHECK (gtk_widget_get_display (widget), RESIZE) &&
if (GTK_DEBUG_CHECK (RESIZE) &&
widget->priv->highlight_resize) widget->priv->highlight_resize)
{ {
GtkAllocation alloc; GtkAllocation alloc;