summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2018-03-28 16:06:32 +0200
committerBenjamin Otte <otte@redhat.com>2018-04-05 14:56:38 +0200
commit7e078cd940966131eec54fc0d9f1d2d126b5481a (patch)
treef994e01412c1d9189dba150dd5355194b6dd6ec5
parent925cbeaadffddbb42dbedc1a61230a4db97c8a44 (diff)
downloadgtk+-7e078cd940966131eec54fc0d9f1d2d126b5481a.tar.gz
gtk: Remove debug updates
With the soon-to-arrive automatic updates (aka computing invalid region from render nodes), this will no longer be necessary.
-rw-r--r--gtk/gtkdebug.h31
-rw-r--r--gtk/gtkdebugupdates.c294
-rw-r--r--gtk/gtkdebugupdatesprivate.h40
-rw-r--r--gtk/gtkmain.c5
-rw-r--r--gtk/gtktextview.c4
-rw-r--r--gtk/gtkwidget.c2
-rw-r--r--gtk/gtkwindow.c3
-rw-r--r--gtk/inspector/visual.c24
-rw-r--r--gtk/inspector/visual.ui28
-rw-r--r--gtk/meson.build1
10 files changed, 15 insertions, 417 deletions
diff --git a/gtk/gtkdebug.h b/gtk/gtkdebug.h
index 1f1c09d935..87affc189a 100644
--- a/gtk/gtkdebug.h
+++ b/gtk/gtkdebug.h
@@ -37,22 +37,21 @@ G_BEGIN_DECLS
typedef enum {
GTK_DEBUG_TEXT = 1 << 0,
GTK_DEBUG_TREE = 1 << 1,
- GTK_DEBUG_UPDATES = 1 << 2,
- GTK_DEBUG_KEYBINDINGS = 1 << 3,
- GTK_DEBUG_MODULES = 1 << 4,
- GTK_DEBUG_GEOMETRY = 1 << 5,
- GTK_DEBUG_ICONTHEME = 1 << 6,
- GTK_DEBUG_PRINTING = 1 << 7,
- GTK_DEBUG_BUILDER = 1 << 8,
- GTK_DEBUG_SIZE_REQUEST = 1 << 9,
- GTK_DEBUG_NO_CSS_CACHE = 1 << 10,
- GTK_DEBUG_BASELINES = 1 << 11,
- GTK_DEBUG_INTERACTIVE = 1 << 12,
- GTK_DEBUG_TOUCHSCREEN = 1 << 13,
- GTK_DEBUG_ACTIONS = 1 << 14,
- GTK_DEBUG_RESIZE = 1 << 15,
- GTK_DEBUG_LAYOUT = 1 << 16,
- GTK_DEBUG_SNAPSHOT = 1 << 17
+ GTK_DEBUG_KEYBINDINGS = 1 << 2,
+ GTK_DEBUG_MODULES = 1 << 3,
+ GTK_DEBUG_GEOMETRY = 1 << 4,
+ GTK_DEBUG_ICONTHEME = 1 << 5,
+ GTK_DEBUG_PRINTING = 1 << 6,
+ GTK_DEBUG_BUILDER = 1 << 7,
+ GTK_DEBUG_SIZE_REQUEST = 1 << 8,
+ GTK_DEBUG_NO_CSS_CACHE = 1 << 9,
+ GTK_DEBUG_BASELINES = 1 << 10,
+ GTK_DEBUG_INTERACTIVE = 1 << 11,
+ GTK_DEBUG_TOUCHSCREEN = 1 << 12,
+ GTK_DEBUG_ACTIONS = 1 << 13,
+ GTK_DEBUG_RESIZE = 1 << 14,
+ GTK_DEBUG_LAYOUT = 1 << 15,
+ GTK_DEBUG_SNAPSHOT = 1 << 16
} GtkDebugFlag;
#ifdef G_ENABLE_DEBUG
diff --git a/gtk/gtkdebugupdates.c b/gtk/gtkdebugupdates.c
deleted file mode 100644
index b371603bc4..0000000000
--- a/gtk/gtkdebugupdates.c
+++ /dev/null
@@ -1,294 +0,0 @@
-/* GTK - The GIMP Toolkit
- * Copyright (C) 2016 Benjamin Otte <otte@gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "config.h"
-
-#include "gtkdebugupdatesprivate.h"
-
-#include "gtksnapshot.h"
-
-/* duration before we start fading in us */
-#define GDK_DRAW_REGION_MIN_DURATION 50 * 1000
-/* duration when fade is finished in us */
-#define GDK_DRAW_REGION_MAX_DURATION 200 * 1000
-
-typedef struct {
- gint64 timestamp;
- cairo_region_t *region;
-} GtkDebugUpdate;
-
-static gboolean _gtk_debug_updates_enabled = FALSE;
-
-static GQuark _gtk_debug_updates_quark = 0;
-
-static void
-gtk_debug_updates_init (void)
-{
- static gboolean inited = FALSE;
-
- if (G_LIKELY (inited))
- return;
-
- _gtk_debug_updates_quark = g_quark_from_static_string ("-gtk-debug-updates");
-
- inited = TRUE;
-}
-
-gboolean
-gtk_debug_updates_get_enabled (void)
-{
- return _gtk_debug_updates_enabled;
-}
-
-void
-gtk_debug_updates_set_enabled (gboolean enabled)
-{
- if (enabled)
- gtk_debug_updates_init ();
-
- _gtk_debug_updates_enabled = enabled;
-}
-
-gboolean
-gtk_debug_updates_get_enabled_for_display (GdkDisplay *display)
-{
- if (gtk_debug_updates_get_enabled ())
- return TRUE;
-
- if (_gtk_debug_updates_quark == 0)
- return FALSE;
-
- return g_object_get_qdata (G_OBJECT (display), _gtk_debug_updates_quark) != NULL;
-}
-
-void
-gtk_debug_updates_set_enabled_for_display (GdkDisplay *display,
- gboolean enabled)
-{
- if (enabled)
- {
- gtk_debug_updates_init ();
-
- g_object_set_qdata (G_OBJECT (display), _gtk_debug_updates_quark, GINT_TO_POINTER (TRUE));
- }
- else
- {
- if (_gtk_debug_updates_quark != 0)
- g_object_steal_qdata (G_OBJECT (display), _gtk_debug_updates_quark);
- }
-}
-
-static void
-gtk_debug_update_free (gpointer data)
-{
- GtkDebugUpdate *region = data;
-
- cairo_region_destroy (region->region);
- g_slice_free (GtkDebugUpdate, region);
-}
-
-static void
-gtk_debug_update_free_queue (gpointer data)
-{
- GQueue *queue = data;
-
- g_queue_free_full (queue, gtk_debug_update_free);
-}
-
-static void
-gtk_debug_updates_print (GQueue *queue,
- const cairo_region_t *region,
- const char *format,
- ...) G_GNUC_PRINTF(3,4);
-static void
-gtk_debug_updates_print (GQueue *queue,
- const cairo_region_t *region,
- const char *format,
- ...)
-{
-#if 0
- GString *string = g_string_new (NULL);
- va_list args;
-
- g_string_append_printf (string, "%3u: ", g_queue_get_length (queue));
-
- if (region)
- {
- cairo_rectangle_int_t extents;
-
- cairo_region_get_extents (region, &extents);
- g_string_append_printf (string, "{%u,%u,%u,%u}(%u) ",
- extents.x, extents.y,
- extents.width, extents.height,
- cairo_region_num_rectangles (region));
- }
-
- va_start (args, format);
- g_string_append_vprintf (string, format, args);
- va_end (args);
-
- g_print ("%s\n", string->str);
-
- g_string_free (string, TRUE);
-#endif
-}
-
-static gboolean
-gtk_window_manage_updates (GtkWidget *widget,
- GdkFrameClock *frame_clock,
- gpointer user_data)
-{
- GQueue *updates;
- GtkDebugUpdate *draw;
- cairo_region_t *region;
- gint64 timestamp;
- GList *l;
-
- updates = g_object_get_qdata (G_OBJECT (widget), _gtk_debug_updates_quark);
- if (updates == NULL)
- return FALSE;
- timestamp = gdk_frame_clock_get_frame_time (frame_clock);
-
- gtk_debug_updates_print (updates, NULL, "Managing updates");
- /* First queue an update for all regions.
- * While doing so, set the correct timestamp on all untimed regions */
- region = cairo_region_create ();
- for (l = g_queue_peek_head_link (updates); l != NULL; l = l->next)
- {
- draw = l->data;
-
- if (draw->timestamp == 0)
- {
- draw->timestamp = timestamp;
- gtk_debug_updates_print (updates, draw->region, "Setting timestamp to %lli\n", (long long) timestamp);
- }
-
- cairo_region_union (region, draw->region);
- }
- gtk_debug_updates_print (updates, region, "Queued update");
- gdk_surface_invalidate_region (gtk_widget_get_surface (widget), region);
- cairo_region_destroy (region);
-
- /* Then remove all outdated regions */
- do {
- draw = g_queue_peek_tail (updates);
-
- if (draw == NULL)
- {
- gtk_debug_updates_print (updates, NULL, "Empty, no more updates");
- g_object_set_qdata (G_OBJECT (widget), _gtk_debug_updates_quark, NULL);
- return FALSE;
- }
-
- if (draw->timestamp + GDK_DRAW_REGION_MAX_DURATION >= timestamp)
- break;
-
- gtk_debug_updates_print (updates, draw->region, "Popped region");
- draw = g_queue_pop_tail (updates);
- gtk_debug_update_free (draw);
- } while (TRUE);
-
- return TRUE;
-}
-
-void
-gtk_debug_updates_add (GtkWidget *widget,
- const cairo_region_t *region)
-{
- GQueue *updates;
- GtkDebugUpdate *draw;
-
- if (!gtk_debug_updates_get_enabled_for_display (gtk_widget_get_display (widget)))
- return;
-
- updates = g_object_get_qdata (G_OBJECT (widget), _gtk_debug_updates_quark);
- if (updates == NULL)
- {
- updates = g_queue_new ();
- gtk_widget_add_tick_callback (widget,
- gtk_window_manage_updates,
- NULL,
- NULL);
- g_object_set_qdata_full (G_OBJECT (widget),
- _gtk_debug_updates_quark,
- updates,
- gtk_debug_update_free_queue);
- gtk_debug_updates_print (updates, NULL, "Newly created");
- }
- else
- {
- GtkDebugUpdate *first = g_queue_peek_head (updates);
-
- if (first->timestamp == 0)
- {
- cairo_region_union (first->region, region);
- gtk_debug_updates_print (updates, first->region, "Added to existing region");
- return;
- }
- }
-
- draw = g_slice_new0 (GtkDebugUpdate);
- draw->region = cairo_region_copy (region);
- g_queue_push_head (updates, draw);
- gtk_debug_updates_print (updates, draw->region, "Added new region");
-}
-
-void
-gtk_debug_updates_snapshot (GtkWidget *widget,
- GtkSnapshot *snapshot)
-{
- GQueue *updates;
- GtkDebugUpdate *draw;
- GdkRectangle rect;
- gint64 timestamp;
- double progress;
- GList *l;
- guint i;
-
- if (!gtk_debug_updates_get_enabled_for_display (gtk_widget_get_display (widget)))
- return;
-
- updates = g_object_get_qdata (G_OBJECT (widget), _gtk_debug_updates_quark);
- if (updates == NULL)
- return;
- timestamp = gdk_frame_clock_get_frame_time (gtk_widget_get_frame_clock (widget));
-
- gtk_debug_updates_print (updates, NULL, "Painting at %lli", (long long) timestamp);
-
- for (l = g_queue_peek_head_link (updates); l != NULL; l = l->next)
- {
- draw = l->data;
- if (timestamp - draw->timestamp < GDK_DRAW_REGION_MIN_DURATION)
- progress = 0.0;
- else if (timestamp - draw->timestamp < GDK_DRAW_REGION_MAX_DURATION)
- progress = (double) (timestamp - draw->timestamp - GDK_DRAW_REGION_MIN_DURATION)
- / (GDK_DRAW_REGION_MAX_DURATION - GDK_DRAW_REGION_MIN_DURATION);
- else
- continue;
-
- gtk_debug_updates_print (updates, draw->region, "Painting with progress %g", progress);
- for (i = 0; i < cairo_region_num_rectangles (draw->region); i++)
- {
- cairo_region_get_rectangle (draw->region, i, &rect);
- gtk_snapshot_append_color (snapshot,
- &(GdkRGBA) { 1, 0, 0, 0.4 * (1 - progress) },
- &GRAPHENE_RECT_INIT(rect.x, rect.y, rect.width, rect.height),
- "Debug Updates<%g>", progress);
- }
- }
-}
-
diff --git a/gtk/gtkdebugupdatesprivate.h b/gtk/gtkdebugupdatesprivate.h
deleted file mode 100644
index e893a3d7d4..0000000000
--- a/gtk/gtkdebugupdatesprivate.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/* GTK - The GIMP Toolkit
- * Copyright (C) 2016 Benjamin Otte <otte@gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef __GTK_DEBUG_UPDATES_PRIVATE_H__
-#define __GTK_DEBUG_UPDATES_PRIVATE_H__
-
-#include "gtkwidget.h"
-
-G_BEGIN_DECLS
-
-
-gboolean gtk_debug_updates_get_enabled (void);
-void gtk_debug_updates_set_enabled (gboolean enabled);
-gboolean gtk_debug_updates_get_enabled_for_display (GdkDisplay *display);
-void gtk_debug_updates_set_enabled_for_display (GdkDisplay *display,
- gboolean enabled);
-
-void gtk_debug_updates_add (GtkWidget *widget,
- const cairo_region_t *region);
-void gtk_debug_updates_snapshot (GtkWidget *widget,
- GtkSnapshot *snapshot);
-
-
-G_END_DECLS
-
-#endif /* __GTK_DEBUG_UPDATES_PRIVATE_H__ */
diff --git a/gtk/gtkmain.c b/gtk/gtkmain.c
index 36100c03f5..9b0009e59c 100644
--- a/gtk/gtkmain.c
+++ b/gtk/gtkmain.c
@@ -116,7 +116,6 @@
#include "gtkaccelmapprivate.h"
#include "gtkbox.h"
#include "gtkdebug.h"
-#include "gtkdebugupdatesprivate.h"
#include "gtkdndprivate.h"
#include "gtkmain.h"
#include "gtkmediafileprivate.h"
@@ -157,7 +156,6 @@ DisplayDebugFlags debug_flags[N_DEBUG_DISPLAYS];
static const GDebugKey gtk_debug_keys[] = {
{ "text", GTK_DEBUG_TEXT },
{ "tree", GTK_DEBUG_TREE },
- { "updates", GTK_DEBUG_UPDATES },
{ "keybindings", GTK_DEBUG_KEYBINDINGS },
{ "modules", GTK_DEBUG_MODULES },
{ "geometry", GTK_DEBUG_GEOMETRY },
@@ -653,9 +651,6 @@ do_post_parse_initialization (void)
signal (SIGPIPE, SIG_IGN);
#endif
- if (debug_flags[0].flags & GTK_DEBUG_UPDATES)
- gtk_debug_updates_set_enabled (TRUE);
-
gtk_widget_set_default_direction (gtk_get_locale_direction ());
gsk_ensure_resources ();
diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c
index 202c5e9d0f..9ef73dee87 100644
--- a/gtk/gtktextview.c
+++ b/gtk/gtktextview.c
@@ -5667,10 +5667,6 @@ cursor_blinks (GtkTextView *text_view)
#ifdef DEBUG_VALIDATION_AND_SCROLLING
return FALSE;
#endif
-#ifdef G_ENABLE_DEBUG
- if (GTK_DEBUG_CHECK (UPDATES))
- return FALSE;
-#endif
g_object_get (settings, "gtk-cursor-blink", &blink, NULL);
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 34fa7bd9b8..92c8084cd5 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -41,7 +41,6 @@
#include "gtkcssstylepropertyprivate.h"
#include "gtkcsswidgetnodeprivate.h"
#include "gtkdebug.h"
-#include "gtkdebugupdatesprivate.h"
#include "gtkeventcontrollerlegacyprivate.h"
#include "gtkgesturedrag.h"
#include "gtkgestureprivate.h"
@@ -4383,7 +4382,6 @@ gtk_widget_queue_draw_region (GtkWidget *widget,
cairo_region_translate (region2, x, y);
invalidate:
- gtk_debug_updates_add (windowed_parent, region2);
gdk_surface_invalidate_region (_gtk_widget_get_surface (widget), region2);
cairo_region_destroy (region2);
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index c5ef1ec4f3..e84f5cb164 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -41,7 +41,6 @@
#include "gtkcssrgbavalueprivate.h"
#include "gtkcssshadowsvalueprivate.h"
#include "gtkcssstylepropertyprivate.h"
-#include "gtkdebugupdatesprivate.h"
#include "gtkdragdest.h"
#include "gtkgesturedrag.h"
#include "gtkgesturemultipress.h"
@@ -9306,8 +9305,6 @@ gtk_window_snapshot (GtkWidget *widget,
GtkWindowPopover *data = l->data;
gtk_widget_snapshot_child (widget, data->widget, snapshot);
}
-
- gtk_debug_updates_snapshot (widget, snapshot);
}
/**
diff --git a/gtk/inspector/visual.c b/gtk/inspector/visual.c
index 8e3506d47b..6619fc7d17 100644
--- a/gtk/inspector/visual.c
+++ b/gtk/inspector/visual.c
@@ -24,7 +24,6 @@
#include "gtkbox.h"
#include "gtkcomboboxtext.h"
#include "gtkcssproviderprivate.h"
-#include "gtkdebugupdatesprivate.h"
#include "gtkdebug.h"
#include "gtkprivate.h"
#include "gtksettings.h"
@@ -66,7 +65,6 @@ struct _GtkInspectorVisualPrivate
GtkWidget *debug_box;
GtkWidget *rendering_mode_combo;
- GtkWidget *updates_switch;
GtkWidget *baselines_switch;
GtkWidget *layout_switch;
GtkWidget *touchscreen_switch;
@@ -223,25 +221,6 @@ font_scale_entry_activated (GtkEntry *entry,
}
static void
-updates_activate (GtkSwitch *sw)
-{
- gboolean updates;
-
- updates = gtk_switch_get_active (sw);
- gtk_debug_updates_set_enabled_for_display (gdk_display_get_default (), updates);
- redraw_everything ();
-}
-
-static void
-init_updates (GtkInspectorVisual *vis)
-{
- gboolean updates = FALSE;
-
- updates = gtk_debug_updates_get_enabled_for_display (gdk_display_get_default ());
- gtk_switch_set_active (GTK_SWITCH (vis->priv->updates_switch), updates);
-}
-
-static void
baselines_activate (GtkSwitch *sw)
{
guint flags;
@@ -849,7 +828,6 @@ gtk_inspector_visual_init (GtkInspectorVisual *vis)
init_font_scale (vis);
init_scale (vis);
init_rendering_mode (vis);
- init_updates (vis);
init_animation (vis);
init_slowdown (vis);
init_touchscreen (vis);
@@ -882,7 +860,6 @@ gtk_inspector_visual_class_init (GtkInspectorVisualClass *klass)
gtk_widget_class_set_template_from_resource (widget_class, "/org/gtk/libgtk/inspector/visual.ui");
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorVisual, rendering_mode_combo);
- gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorVisual, updates_switch);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorVisual, direction_combo);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorVisual, baselines_switch);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorVisual, layout_switch);
@@ -908,7 +885,6 @@ gtk_inspector_visual_class_init (GtkInspectorVisualClass *klass)
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorVisual, font_scale_entry);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorVisual, font_scale_adjustment);
- gtk_widget_class_bind_template_callback (widget_class, updates_activate);
gtk_widget_class_bind_template_callback (widget_class, direction_changed);
gtk_widget_class_bind_template_callback (widget_class, rendering_mode_changed);
gtk_widget_class_bind_template_callback (widget_class, baselines_activate);
diff --git a/gtk/inspector/visual.ui b/gtk/inspector/visual.ui
index 14433754b6..aaf475cef9 100644
--- a/gtk/inspector/visual.ui
+++ b/gtk/inspector/visual.ui
@@ -413,33 +413,6 @@
<property name="margin">10</property>
<property name="spacing">40</property>
<child>
- <object class="GtkLabel" id="updates_label">
- <property name="label" translatable="yes">Show Graphic Updates</property>
- <property name="halign">start</property>
- <property name="valign">baseline</property>
- <property name="xalign">0.0</property>
- </object>
- </child>
- <child>
- <object class="GtkSwitch" id="updates_switch">
- <property name="halign">end</property>
- <property name="valign">baseline</property>
- <property name="hexpand">1</property>
- <signal name="notify::active" handler="updates_activate"/>
- </object>
- </child>
- </object>
- </child>
- </object>
- </child>
- <child>
- <object class="GtkListBoxRow">
- <property name="activatable">0</property>
- <child>
- <object class="GtkBox">
- <property name="margin">10</property>
- <property name="spacing">40</property>
- <child>
<object class="GtkLabel" id="baselines_label">
<property name="label" translatable="yes">Show Baselines</property>
<property name="halign">start</property>
@@ -652,7 +625,6 @@
<widget name="hidpi_label"/>
<widget name="animation_label"/>
<widget name="rendering_mode_label"/>
- <widget name="updates_label"/>
<widget name="baselines_label"/>
<widget name="layout_label"/>
<widget name="touchscreen_label"/>
diff --git a/gtk/meson.build b/gtk/meson.build
index 3cfbf38e0c..5507ec3037 100644
--- a/gtk/meson.build
+++ b/gtk/meson.build
@@ -87,7 +87,6 @@ gtk_private_sources = files([
'gtkcssvalue.c',
'gtkcsswidgetnode.c',
'gtkcsswin32sizevalue.c',
- 'gtkdebugupdates.c',
'gtkeventcontrollerlegacy.c',
'gtkfilechooserembed.c',
'gtkfilechooserentry.c',