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
This commit is contained in:
Alexander Larsson 2015-09-14 11:36:43 +02:00
parent d5f1754981
commit cdd951e927

View File

@ -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))