GtkWindow: Move cairo_save/restore from marshaller

We do the save/restore when emitting ::draw rather than in a custom
marshaller, as this saves an extra stack frame, which is helpfull now
that we do painting fully recursive. This is also likely to save a few
cycles.
This commit is contained in:
Alexander Larsson 2013-04-25 14:00:18 +02:00
parent c3bff30b50
commit 6c7689506f

View File

@ -956,64 +956,6 @@ child_property_notify_dispatcher (GObject *object,
GTK_WIDGET_GET_CLASS (object)->dispatch_child_properties_changed (GTK_WIDGET (object), n_pspecs, pspecs);
}
/* We guard against the draw signal callbacks modifying the state of the
* cairo context by surounding it with save/restore.
* Maybe we should also cairo_new_path() just to be sure?
*/
static void
gtk_widget_draw_marshaller (GClosure *closure,
GValue *return_value,
guint n_param_values,
const GValue *param_values,
gpointer invocation_hint,
gpointer marshal_data)
{
cairo_t *cr = g_value_get_boxed (&param_values[1]);
cairo_save (cr);
_gtk_marshal_BOOLEAN__BOXED (closure,
return_value,
n_param_values,
param_values,
invocation_hint,
marshal_data);
cairo_restore (cr);
}
static void
gtk_widget_draw_marshallerv (GClosure *closure,
GValue *return_value,
gpointer instance,
va_list args,
gpointer marshal_data,
int n_params,
GType *param_types)
{
cairo_t *cr;
va_list args_copy;
G_VA_COPY (args_copy, args);
cr = va_arg (args_copy, gpointer);
cairo_save (cr);
_gtk_marshal_BOOLEAN__BOXEDv (closure,
return_value,
instance,
args,
marshal_data,
n_params,
param_types);
cairo_restore (cr);
va_end (args_copy);
}
static void
gtk_widget_class_init (GtkWidgetClass *klass)
{
@ -1960,12 +1902,12 @@ G_GNUC_END_IGNORE_DEPRECATIONS
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, draw),
_gtk_boolean_handled_accumulator, NULL,
gtk_widget_draw_marshaller,
_gtk_boolean_handled_accumulator, NULL,
_gtk_marshal_BOOLEAN__BOXED,
G_TYPE_BOOLEAN, 1,
CAIRO_GOBJECT_TYPE_CONTEXT);
CAIRO_GOBJECT_TYPE_CONTEXT | G_SIGNAL_TYPE_STATIC_SCOPE);
g_signal_set_va_marshaller (widget_signals[DRAW], G_TYPE_FROM_CLASS (klass),
gtk_widget_draw_marshallerv);
_gtk_marshal_BOOLEAN__BOXEDv);
/**
* GtkWidget::mnemonic-activate:
@ -6391,10 +6333,14 @@ _gtk_widget_draw_internal (GtkWidget *widget,
{
gboolean result;
cairo_save (cr);
g_signal_emit (widget, widget_signals[DRAW],
0, cr,
&result);
cairo_restore (cr);
#ifdef G_ENABLE_DEBUG
if (G_UNLIKELY (gtk_get_debug_flags () & GTK_DEBUG_BASELINES))
{