[gtk/wip/baedert/transforms6] 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] widget: Only push a transform if we need to
- Date: Thu, 29 Nov 2018 08:49:46 +0000 (UTC)
commit e403d399d7a6de606ff11951b471e7d0ab830b84
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 | 15 ++++++++++++---
gtk/gtkwidgetprivate.h | 1 +
2 files changed, 13 insertions(+), 3 deletions(-)
---
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 609b549fd0..817f6ea632 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -2888,6 +2888,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
@@ -4299,6 +4300,7 @@ gtk_widget_size_allocate_transformed (GtkWidget *widget,
priv->allocated_offset_y = allocated_offset_y;
priv->allocated_baseline = baseline;
priv->transform = final_transform;
+ priv->has_transform = !graphene_matrix_is_identity (&final_transform);
if (!alloc_needed && !size_changed && !baseline_changed)
{
@@ -13542,9 +13544,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);
}
/**
@@ -13784,7 +13790,10 @@ gtk_widget_set_transform (GtkWidget *widget,
{
GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
- graphene_matrix_init_from_matrix (&priv->transform, transform);
+ priv->has_transform = !graphene_matrix_is_identity (transform);
+
+ if (priv->has_transform)
+ graphene_matrix_init_from_matrix (&priv->transform, transform);
}
void
diff --git a/gtk/gtkwidgetprivate.h b/gtk/gtkwidgetprivate.h
index 847c66672a..43c1eebb46 100644
--- a/gtk/gtkwidgetprivate.h
+++ b/gtk/gtkwidgetprivate.h
@@ -151,6 +151,7 @@ struct _GtkWidgetPrivate
int allocated_offset_x;
int allocated_offset_y;
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]