[gtk+/wip/baedert/drawing: 212/306] widget: Bring resize and baseline debug rendering back



commit 51e70c3d05941eb0e340c19ebf8adc693d0f8dd1
Author: Timm Bäder <mail baedert org>
Date:   Sat May 20 19:32:16 2017 +0200

    widget: Bring resize and baseline debug rendering back

 gtk/gtkwidget.c |   50 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 50 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index f45a398..e668489 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -15355,6 +15355,51 @@ gtk_widget_reset_controllers (GtkWidget *widget)
     }
 }
 
+static inline void
+gtk_widget_maybe_add_debug_render_nodes (GtkWidget             *widget,
+                                         GtkSnapshot           *snapshot)
+{
+  GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
+  GdkDisplay *display = gtk_widget_get_display (widget);
+
+  if (GTK_DISPLAY_DEBUG_CHECK (display, BASELINES))
+    {
+      int baseline = gtk_widget_get_allocated_baseline (widget);
+
+      if (baseline != -1)
+        {
+          GdkRGBA black = {1, 0, 0, 1};
+          graphene_rect_t bounds;
+
+          graphene_rect_init (&bounds,
+                              0, baseline,
+                              priv->allocation.width, 1);
+          gtk_snapshot_append_color (snapshot,
+                                     &black,
+                                     &bounds,
+                                     "Baseline Debug");
+        }
+    }
+
+  if (GTK_DISPLAY_DEBUG_CHECK (display, RESIZE) &&
+      priv->highlight_resize)
+    {
+      GdkRGBA red = {1, 0, 0, 0.2};
+      graphene_rect_t bounds;
+
+      graphene_rect_init (&bounds,
+                          0, 0,
+                          priv->allocation.width, priv->allocation.height);
+
+      gtk_snapshot_append_color (snapshot,
+                                 &red,
+                                 &bounds,
+                                 "Baseline Debug");
+      priv->highlight_resize = FALSE;
+      gtk_widget_queue_draw (widget);
+    }
+}
+
 void
 gtk_widget_snapshot (GtkWidget   *widget,
                      GtkSnapshot *snapshot)
@@ -15481,6 +15526,11 @@ gtk_widget_snapshot (GtkWidget   *widget,
 
   gtk_css_filter_value_pop_snapshot (filter_value, snapshot);
 
+#ifdef G_ENABLE_DEBUG
+  gtk_widget_maybe_add_debug_render_nodes (widget, snapshot);
+#endif
+
+
   if (GTK_DEBUG_CHECK (SNAPSHOT))
     gtk_snapshot_pop (snapshot);
 }


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