[gtk] renderbackground: Save a snapshot_translate() call



commit 075a0ccb5e3a6c4dc6d81688499c19b3741825bf
Author: Timm Bäder <mail baedert org>
Date:   Wed Dec 18 09:40:04 2019 +0100

    renderbackground: Save a snapshot_translate() call
    
    Just add the values manually when really using the snapshot later. Also
    unifies the two if branches by pulling out getting the x/y values.

 gtk/gtkrenderbackground.c | 22 +++++++---------------
 1 file changed, 7 insertions(+), 15 deletions(-)
---
diff --git a/gtk/gtkrenderbackground.c b/gtk/gtkrenderbackground.c
index ae04ab3bac..ed85535529 100644
--- a/gtk/gtkrenderbackground.c
+++ b/gtk/gtkrenderbackground.c
@@ -92,6 +92,7 @@ gtk_theming_background_snapshot_layer (GtkCssBoxes *bg,
   const GskRoundedRect *origin, *clip;
   double image_width, image_height;
   double width, height;
+  double x, y;
 
   image = _gtk_css_image_value_get_image (
               _gtk_css_array_value_get_nth (
@@ -144,16 +145,11 @@ gtk_theming_background_snapshot_layer (GtkCssBoxes *bg,
   gtk_snapshot_push_debug (snapshot, "Layer %u", idx);
   gtk_snapshot_push_rounded_clip (snapshot, clip);
 
-  gtk_snapshot_translate (snapshot, &origin->bounds.origin);
-
+  x = _gtk_css_position_value_get_x (pos, width - image_width) + origin->bounds.origin.x;
+  y = _gtk_css_position_value_get_y (pos, height - image_height) + origin->bounds.origin.y;
   if (hrepeat == GTK_CSS_REPEAT_STYLE_NO_REPEAT && vrepeat == GTK_CSS_REPEAT_STYLE_NO_REPEAT)
     {
       /* shortcut for normal case */
-      double x, y;
-
-      x = _gtk_css_position_value_get_x (pos, width - image_width);
-      y = _gtk_css_position_value_get_y (pos, height - image_height);
-
       gtk_snapshot_save (snapshot);
       gtk_snapshot_translate (snapshot, &GRAPHENE_POINT_INIT (x, y));
 
@@ -164,7 +160,6 @@ gtk_theming_background_snapshot_layer (GtkCssBoxes *bg,
   else
     {
       float repeat_width, repeat_height;
-      float position_x, position_y;
       graphene_rect_t fill_rect;
 
       /* If ‘background-repeat’ is ‘round’ for one (or both) dimensions,
@@ -246,19 +241,16 @@ gtk_theming_background_snapshot_layer (GtkCssBoxes *bg,
           fill_rect.size.height = height;
         }
 
-      position_x = _gtk_css_position_value_get_x (pos, width - image_width);
-      position_y = _gtk_css_position_value_get_y (pos, height - image_height);
-
       gtk_snapshot_push_repeat (snapshot,
                                 &fill_rect,
                                 &GRAPHENE_RECT_INIT (
-                                    position_x, position_y,
+                                    x, y,
                                     repeat_width, repeat_height
                                 ));
-                                
+
       gtk_snapshot_translate (snapshot, &GRAPHENE_POINT_INIT (
-                              position_x + 0.5 * (repeat_width - image_width),
-                              position_y + 0.5 * (repeat_height - image_height)));
+                              x + 0.5 * (repeat_width - image_width),
+                              y + 0.5 * (repeat_height - image_height)));
       gtk_css_image_snapshot (image, snapshot, image_width, image_height);
 
       gtk_snapshot_pop (snapshot);


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