[gtk/wip/baedert/gl-rework: 34/41] renderbackground: Try to omit a save/restore pair



commit 0eae7f32e6d0762f73b814d1de05a0af53685663
Author: Timm Bäder <mail baedert org>
Date:   Wed Dec 18 11:43:26 2019 +0100

    renderbackground: Try to omit a save/restore pair

 gtk/gtkrenderbackground.c | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)
---
diff --git a/gtk/gtkrenderbackground.c b/gtk/gtkrenderbackground.c
index ed85535529..b241a7e615 100644
--- a/gtk/gtkrenderbackground.c
+++ b/gtk/gtkrenderbackground.c
@@ -150,12 +150,17 @@ gtk_theming_background_snapshot_layer (GtkCssBoxes *bg,
   if (hrepeat == GTK_CSS_REPEAT_STYLE_NO_REPEAT && vrepeat == GTK_CSS_REPEAT_STYLE_NO_REPEAT)
     {
       /* shortcut for normal case */
-      gtk_snapshot_save (snapshot);
-      gtk_snapshot_translate (snapshot, &GRAPHENE_POINT_INIT (x, y));
-
-      gtk_css_image_snapshot (image, snapshot, image_width, image_height);
-
-      gtk_snapshot_restore (snapshot);
+      if (x != 0 || y != 0)
+        {
+          gtk_snapshot_save (snapshot);
+          gtk_snapshot_translate (snapshot, &GRAPHENE_POINT_INIT (x, y));
+          gtk_css_image_snapshot (image, snapshot, image_width, image_height);
+          gtk_snapshot_restore (snapshot);
+        }
+      else
+        {
+          gtk_css_image_snapshot (image, snapshot, image_width, image_height);
+        }
     }
   else
     {


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