[gnome-shell] st-theme-node-drawing: Fix implementation of cover and contain



commit 3dbf06420df0ad669f12939a788ed44061dcc1e1
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Sun Mar 18 05:55:50 2012 -0400

    st-theme-node-drawing: Fix implementation of cover and contain
    
    The math was incorrect for non-square containers
    
    https://bugzilla.gnome.org/show_bug.cgi?id=672321

 src/st/st-theme-node-drawing.c |   12 ++++--------
 1 files changed, 4 insertions(+), 8 deletions(-)
---
diff --git a/src/st/st-theme-node-drawing.c b/src/st/st-theme-node-drawing.c
index 04a3547..cab2542 100644
--- a/src/st/st-theme-node-drawing.c
+++ b/src/st/st-theme-node-drawing.c
@@ -409,16 +409,12 @@ get_background_scale (StThemeNode *node,
         *scale_w = 1.0;
         break;
       case ST_BACKGROUND_SIZE_CONTAIN:
-        if (background_image_width > background_image_height)
-          *scale_w = painting_area_width / background_image_width;
-        else
-          *scale_w = painting_area_height / background_image_height;
+        *scale_w = MIN (painting_area_width / background_image_width,
+                        painting_area_height / background_image_height);
         break;
       case ST_BACKGROUND_SIZE_COVER:
-        if (background_image_width < background_image_height)
-          *scale_w = painting_area_width / background_image_width;
-        else
-          *scale_w = painting_area_height / background_image_height;
+        *scale_w = MAX (painting_area_width / background_image_width,
+                        painting_area_height / background_image_height);
         break;
       case ST_BACKGROUND_SIZE_FIXED:
         if (node->background_size_w > -1)



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