[gtk+] themingbackground: fix drawing for repeating positioned images



commit 65166c36b91bf990d476e63060065486b73940e2
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Wed May 30 11:56:09 2012 -0400

    themingbackground: fix drawing for repeating positioned images
    
    When we determine the fill rectangle for an image layer, and the image
    is not repeating, we should also position the rectangle according to the
    values of background-position, or we will always fill a tiny slice at
    the top/left of the clip box.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=677109

 gtk/gtkthemingbackground.c |   29 +++++++++++++++++++++++++----
 1 files changed, 25 insertions(+), 4 deletions(-)
---
diff --git a/gtk/gtkthemingbackground.c b/gtk/gtkthemingbackground.c
index 9da6abb..92ef8e2 100644
--- a/gtk/gtkthemingbackground.c
+++ b/gtk/gtkthemingbackground.c
@@ -196,6 +196,7 @@ _gtk_theming_background_paint_layer (GtkThemingBackground *bg,
       else
         {
           int surface_width, surface_height;
+          cairo_rectangle_t fill_rect;
           cairo_surface_t *surface;
           cairo_t *cr2;
 
@@ -272,10 +273,30 @@ _gtk_theming_background_paint_layer (GtkThemingBackground *bg,
           cairo_pattern_set_extend (cairo_get_source (cr), CAIRO_EXTEND_REPEAT);
           cairo_surface_destroy (surface);
 
-          cairo_rectangle (cr,
-                           0, 0,
-                           hrepeat == GTK_CSS_REPEAT_STYLE_NO_REPEAT ? image_width : width,
-                           vrepeat == GTK_CSS_REPEAT_STYLE_NO_REPEAT ? image_height : height);
+          if (hrepeat == GTK_CSS_REPEAT_STYLE_NO_REPEAT)
+            {
+              fill_rect.x = _gtk_css_position_value_get_x (pos, width - image_width);
+              fill_rect.width = image_width;
+            }
+          else
+            {
+              fill_rect.x = 0;
+              fill_rect.width = width;
+            }
+
+          if (vrepeat == GTK_CSS_REPEAT_STYLE_NO_REPEAT)
+            {
+              fill_rect.y = _gtk_css_position_value_get_y (pos, height - image_height);
+              fill_rect.height = image_height;
+            }
+          else
+            {
+              fill_rect.y = 0;
+              fill_rect.height = height;
+            }
+
+          cairo_rectangle (cr, fill_rect.x, fill_rect.y,
+                           fill_rect.width, fill_rect.height);
           cairo_fill (cr);
         }
     }



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