renderbackground: Try to omit a save/restore pair
authorTimm Bäder <mail@baedert.org>
Wed, 18 Dec 2019 10:43:26 +0000 (11:43 +0100)
committerTimm Bäder <mail@baedert.org>
Tue, 7 Jan 2020 16:27:16 +0000 (17:27 +0100)
gtk/gtkrenderbackground.c

index ed8553552983419667618c0af4821cdc7ee9df1a..b241a7e61558d5be5ad0604f4ce7ed96e9c8e2ae 100644 (file)
@@ -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
     {