[gtk+] draw: call vfunc rather then emit signal for the common case
- From: Alexander Larsson <alexl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] draw: call vfunc rather then emit signal for the common case
- Date: Mon, 14 Sep 2015 11:50:21 +0000 (UTC)
commit cdd951e927ad37933eb12f62fc6eaafe542a7c29
Author: Alexander Larsson <alexl redhat com>
Date: Mon Sep 14 11:36:43 2015 +0200
draw: call vfunc rather then emit signal for the common case
This avoids a lot of overhead in the common case where a signal
is not connected and we're just using the class vfunc (which is true
for all in-libgtk widgets). Additionally it makes backtraces in
debuggers and profiles much much nicer to look at.
https://bugzilla.gnome.org/show_bug.cgi?id=754986
gtk/gtkwidget.c | 15 ++++++++++++---
1 files changed, 12 insertions(+), 3 deletions(-)
---
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index ef279f4..4206c40 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -6834,9 +6834,18 @@ _gtk_widget_draw_internal (GtkWidget *widget,
gdk_window_mark_paint_from_clip (window, cr);
- g_signal_emit (widget, widget_signals[DRAW],
- 0, cr,
- &result);
+ if (g_signal_has_handler_pending (widget, widget_signals[DRAW], 0, FALSE))
+ {
+ g_signal_emit (widget, widget_signals[DRAW],
+ 0, cr,
+ &result);
+ }
+ else if (GTK_WIDGET_GET_CLASS (widget)->draw)
+ {
+ cairo_save (cr);
+ GTK_WIDGET_GET_CLASS (widget)->draw (widget, cr);
+ cairo_restore (cr);
+ }
#ifdef G_ENABLE_DEBUG
if (GTK_DEBUG_CHECK (BASELINES))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]