[gtk/wip/baedert/transforms6: 76/78] widget: Only push a transform if we need to
- From: Timm Bäder <baedert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/baedert/transforms6: 76/78] widget: Only push a transform if we need to
- Date: Tue, 11 Dec 2018 10:03:18 +0000 (UTC)
commit 48c496f50887550a41163cecfd62681ed637e851
Author: Timm Bäder <mail baedert org>
Date: Thu Nov 29 09:49:16 2018 +0100
widget: Only push a transform if we need to
gtk/gtkwidget.c | 12 ++++++++++--
gtk/gtkwidgetprivate.h | 1 +
2 files changed, 11 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index bc2bf41e07..7063fb7179 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -2890,6 +2890,7 @@ gtk_widget_init (GTypeInstance *instance, gpointer g_class)
}
graphene_matrix_init_identity (&priv->transform);
+ priv->has_transform = FALSE;
/* this will be set to TRUE if the widget gets a child or if the
* expand flag is set on the widget, but until one of those happen
@@ -4308,6 +4309,7 @@ gtk_widget_size_allocate_transformed (GtkWidget *widget,
priv->allocation = real_allocation;
priv->allocated_baseline = baseline;
priv->transform = final_transform;
+ priv->has_transform = !graphene_matrix_is_identity (&final_transform);
if (!alloc_needed && !size_changed && !baseline_changed)
{
@@ -13509,9 +13511,13 @@ gtk_widget_snapshot_child (GtkWidget *widget,
g_return_if_fail (_gtk_widget_get_parent (child) == widget);
g_return_if_fail (snapshot != NULL);
- gtk_snapshot_push_transform (snapshot, &priv->transform);
+ if (priv->has_transform)
+ gtk_snapshot_push_transform (snapshot, &priv->transform);
+
gtk_widget_snapshot (child, snapshot);
- gtk_snapshot_pop (snapshot);
+
+ if (priv->has_transform)
+ gtk_snapshot_pop (snapshot);
}
/**
@@ -13751,6 +13757,8 @@ gtk_widget_set_transform (GtkWidget *widget,
{
GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
+ priv->has_transform = !graphene_matrix_is_identity (transform);
+
graphene_matrix_init_from_matrix (&priv->transform, transform);
}
diff --git a/gtk/gtkwidgetprivate.h b/gtk/gtkwidgetprivate.h
index ec45b27205..9b172f46aa 100644
--- a/gtk/gtkwidgetprivate.h
+++ b/gtk/gtkwidgetprivate.h
@@ -145,6 +145,7 @@ struct _GtkWidgetPrivate
graphene_matrix_t allocated_transform;
graphene_matrix_t transform;
+ guint has_transform : 1;
/* The widget's requested sizes */
SizeRequestCache requests;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]