[gtk+] debug: Add GTK_DEBUG=snapshot
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] debug: Add GTK_DEBUG=snapshot
- Date: Tue, 20 Dec 2016 18:27:18 +0000 (UTC)
commit def94f03e240babfd589c8ba8e7cc4961a3d6aab
Author: Benjamin Otte <otte redhat com>
Date: Tue Dec 20 19:20:02 2016 +0100
debug: Add GTK_DEBUG=snapshot
This causes the snapshotting algorithm to dump all widget nodes into
their own container node. We then name that group accordingly (ie
"GtkSwitch<0xdeadbeef>") so you can easily see which node belongs where.
The feature is toggleable in the inspector's visual tab.
There's a few problems with it, becuse GtkSnapshot optimized container
nodes away if they are not needed, so we are losing some widgets...
docs/reference/gtk/running.sgml | 4 ++++
gtk/gtkdebug.h | 3 ++-
gtk/gtkmain.c | 3 ++-
gtk/gtkwidget.c | 6 ++++++
gtk/inspector/visual.c | 16 ++++++++++++++++
gtk/inspector/visual.ui | 35 +++++++++++++++++++++++++++++++++++
6 files changed, 65 insertions(+), 2 deletions(-)
---
diff --git a/docs/reference/gtk/running.sgml b/docs/reference/gtk/running.sgml
index 3bc8f35..e8708ce 100644
--- a/docs/reference/gtk/running.sgml
+++ b/docs/reference/gtk/running.sgml
@@ -210,6 +210,10 @@ additional environment variables.
<term>layout</term>
<listitem><para>Show layout borders</para></listitem>
</varlistentry>
+ <varlistentry>
+ <term>snapshot</term>
+ <listitem><para>Include debug render nodes in the generated snapshots</para></listitem>
+ </varlistentry>
</variablelist>
The special value <literal>all</literal> can be used to turn on all
debug options. The special value <literal>help</literal> can be used
diff --git a/gtk/gtkdebug.h b/gtk/gtkdebug.h
index 3f624a9..e550a32 100644
--- a/gtk/gtkdebug.h
+++ b/gtk/gtkdebug.h
@@ -53,7 +53,8 @@ typedef enum {
GTK_DEBUG_TOUCHSCREEN = 1 << 15,
GTK_DEBUG_ACTIONS = 1 << 16,
GTK_DEBUG_RESIZE = 1 << 17,
- GTK_DEBUG_LAYOUT = 1 << 18
+ GTK_DEBUG_LAYOUT = 1 << 18,
+ GTK_DEBUG_SNAPSHOT = 1 << 19
} GtkDebugFlag;
#ifdef G_ENABLE_DEBUG
diff --git a/gtk/gtkmain.c b/gtk/gtkmain.c
index 21d1870..ba7b3c6 100644
--- a/gtk/gtkmain.c
+++ b/gtk/gtkmain.c
@@ -171,7 +171,8 @@ static const GDebugKey gtk_debug_keys[] = {
{ "touchscreen", GTK_DEBUG_TOUCHSCREEN },
{ "actions", GTK_DEBUG_ACTIONS },
{ "resize", GTK_DEBUG_RESIZE },
- { "layout", GTK_DEBUG_LAYOUT }
+ { "layout", GTK_DEBUG_LAYOUT },
+ { "snapshot", GTK_DEBUG_SNAPSHOT }
};
#endif /* G_ENABLE_DEBUG */
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 8c54364..04dfc04 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -15560,6 +15560,9 @@ gtk_widget_snapshot (GtkWidget *widget,
*/
mode = get_render_mode (klass);
+ if (GTK_DEBUG_CHECK (SNAPSHOT))
+ gtk_snapshot_push (snapshot, TRUE, "%s<%p>", gtk_widget_get_name (widget), widget);
+
if (mode == RENDER_DRAW)
{
cairo_t *cr;
@@ -15595,6 +15598,9 @@ gtk_widget_snapshot (GtkWidget *widget,
if (opacity < 1.0)
gtk_snapshot_pop_and_append (snapshot);
}
+
+ if (GTK_DEBUG_CHECK (SNAPSHOT))
+ gtk_snapshot_pop_and_append (snapshot);
}
void
diff --git a/gtk/inspector/visual.c b/gtk/inspector/visual.c
index 400a751..dadead3 100644
--- a/gtk/inspector/visual.c
+++ b/gtk/inspector/visual.c
@@ -270,6 +270,21 @@ layout_activate (GtkSwitch *sw)
}
static void
+snapshot_activate (GtkSwitch *sw)
+{
+ guint flags;
+
+ flags = gtk_get_debug_flags ();
+
+ if (gtk_switch_get_active (sw))
+ flags |= GTK_DEBUG_SNAPSHOT;
+ else
+ flags &= ~GTK_DEBUG_SNAPSHOT;
+
+ gtk_set_debug_flags (flags);
+}
+
+static void
widget_resize_activate (GtkSwitch *sw)
{
guint flags = gtk_get_debug_flags ();
@@ -919,6 +934,7 @@ gtk_inspector_visual_class_init (GtkInspectorVisualClass *klass)
gtk_widget_class_bind_template_callback (widget_class, rendering_mode_changed);
gtk_widget_class_bind_template_callback (widget_class, baselines_activate);
gtk_widget_class_bind_template_callback (widget_class, layout_activate);
+ gtk_widget_class_bind_template_callback (widget_class, snapshot_activate);
gtk_widget_class_bind_template_callback (widget_class, widget_resize_activate);
gtk_widget_class_bind_template_callback (widget_class, software_gl_activate);
gtk_widget_class_bind_template_callback (widget_class, software_surface_activate);
diff --git a/gtk/inspector/visual.ui b/gtk/inspector/visual.ui
index 7e28451..ea8d0f8 100644
--- a/gtk/inspector/visual.ui
+++ b/gtk/inspector/visual.ui
@@ -610,6 +610,40 @@
<property name="margin">10</property>
<property name="spacing">40</property>
<child>
+ <object class="GtkLabel" id="snapshot_label">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Snapshot Debug Nodes</property>
+ <property name="halign">start</property>
+ <property name="valign">baseline</property>
+ <property name="xalign">0.0</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkSwitch" id="snapshot_switch">
+ <property name="visible">True</property>
+ <property name="halign">end</property>
+ <property name="valign">baseline</property>
+ <signal name="notify::active" handler="snapshot_activate"/>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkListBoxRow">
+ <property name="visible">True</property>
+ <property name="activatable">False</property>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="orientation">horizontal</property>
+ <property name="margin">10</property>
+ <property name="spacing">40</property>
+ <child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">Show Widget Resizes</property>
@@ -841,6 +875,7 @@
<widget name="updates_label"/>
<widget name="baselines_label"/>
<widget name="layout_label"/>
+ <widget name="snapshot_label"/>
<widget name="touchscreen_label"/>
<widget name="gl_label"/>
<widget name="software_gl_label"/>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]