[gtk/wip/baedert/for-master: 6/7] widget: Try to reuse allocated_transform in size_allocate()



commit 6e79bd4390908b4a9a5719e4186711f4c1af316b
Author: Timm Bäder <mail baedert org>
Date:   Fri Feb 21 12:23:17 2020 +0100

    widget: Try to reuse allocated_transform in size_allocate()
    
    If they end up being the same transform anyway, just reuse the current
    transform.

 gtk/gtkwidget.c | 24 ++++++++++++++++++++++--
 1 file changed, 22 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 40663ddb45..5756ebcfff 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -3896,9 +3896,29 @@ gtk_widget_size_allocate (GtkWidget           *widget,
   GskTransform *transform;
 
   if (allocation->x || allocation->y)
-    transform = gsk_transform_translate (NULL, &GRAPHENE_POINT_INIT (allocation->x, allocation->y));
+    {
+      GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
+
+      if (gsk_transform_get_category (priv->allocated_transform) == GSK_TRANSFORM_CATEGORY_2D_TRANSLATE)
+        {
+          float x, y;
+
+          gsk_transform_to_translate (priv->allocated_transform, &x, &y);
+
+          if (x == allocation->x && y == allocation->y)
+            transform = gsk_transform_ref (priv->allocated_transform);
+          else
+            transform = gsk_transform_translate (NULL, &GRAPHENE_POINT_INIT (allocation->x, allocation->y));
+        }
+      else
+        {
+          transform = gsk_transform_translate (NULL, &GRAPHENE_POINT_INIT (allocation->x, allocation->y));
+        }
+    }
   else
-    transform = NULL;
+    {
+      transform = NULL;
+    }
 
   gtk_widget_allocate (widget,
                        allocation->width,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]