[gtk/wip/baedert/for-master: 12/24] widget: Try to reuse priv->transform when allocating



commit e6a849e94e46ebd2819f17b99cc4c7a7f5361b1d
Author: Timm Bäder <mail baedert org>
Date:   Fri Feb 21 12:49:10 2020 +0100

    widget: Try to reuse priv->transform when allocating

 gtk/gtkwidget.c | 29 ++++++++++++++++++++++++++++-
 1 file changed, 28 insertions(+), 1 deletion(-)
---
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index b56c5b4f29..e88eb91790 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -4167,8 +4167,35 @@ gtk_widget_allocate (GtkWidget    *widget,
                      border.bottom + padding.bottom;
   if (baseline >= 0)
     baseline -= margin.top + border.top + padding.top;
+
   if (adjusted.x || adjusted.y)
-    transform = gsk_transform_translate (transform, &GRAPHENE_POINT_INIT (adjusted.x, adjusted.y));
+    {
+      if (css_transform)
+        {
+          transform = gsk_transform_translate (transform, &GRAPHENE_POINT_INIT (adjusted.x, adjusted.y));
+        }
+      else
+        {
+          if (gsk_transform_get_category (priv->transform) == GSK_TRANSFORM_CATEGORY_2D_TRANSLATE &&
+              gsk_transform_get_category (transform) == GSK_TRANSFORM_CATEGORY_2D_TRANSLATE)
+            {
+              float old_x, old_y;
+              float new_x, new_y;
+
+              gsk_transform_to_translate (priv->transform, &old_x, &old_y);
+              gsk_transform_to_translate (transform, &new_x, &new_y);
+
+              if (old_x == new_x + adjusted.x && old_y == new_y + adjusted.y)
+                transform = gsk_transform_ref (priv->transform);
+              else
+                transform = gsk_transform_translate (transform, &GRAPHENE_POINT_INIT (adjusted.x, 
adjusted.y));
+            }
+          else
+            {
+              transform = gsk_transform_translate (transform, &GRAPHENE_POINT_INIT (adjusted.x, adjusted.y));
+            }
+        }
+    }
 
   gsk_transform_unref (priv->transform);
   priv->transform = transform;


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