raster pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=f6a39ab571253e25df5e4d59b551fe167f87f3ed

commit f6a39ab571253e25df5e4d59b551fe167f87f3ed
Author: Carsten Haitzler (Rasterman) <ras...@rasterman.com>
Date:   Wed May 13 22:22:32 2015 +0900

    evas grid smart - fix coord overflows when grid size and vsize are large
    
    if your virtual size is fairly big AND your actual object size is also
    big, you easily overflow a signed int for intermediate coordinate
    calculations, resulting in seeing only a small fractin of your objects
    correctly. this fixes that by expanding up to long longs internally to
    allow for the added space needed for the multiplications
    
    @fix
---
 src/lib/evas/canvas/evas_object_grid.c | 25 +++++++++++++++----------
 1 file changed, 15 insertions(+), 10 deletions(-)

diff --git a/src/lib/evas/canvas/evas_object_grid.c 
b/src/lib/evas/canvas/evas_object_grid.c
index 3e61201..70bfbad 100644
--- a/src/lib/evas/canvas/evas_object_grid.c
+++ b/src/lib/evas/canvas/evas_object_grid.c
@@ -209,7 +209,8 @@ _evas_object_grid_smart_calculate(Evas_Object *o)
    Eina_List *l;
    Evas_Object_Grid_Option *opt;
    Evas *e;
-   Evas_Coord x, y, w, h, vw, vh;
+   Evas_Coord x, y, w, h;
+   long long xl, yl, wl, hl, vwl, vhl;
    Eina_Bool mirror;
 
    EVAS_OBJECT_GRID_DATA_GET_OR_RETURN(o, priv);
@@ -219,25 +220,29 @@ _evas_object_grid_smart_calculate(Evas_Object *o)
    evas_event_freeze(e);
 
    evas_object_geometry_get(o, &x, &y, &w, &h);
+   xl = x;
+   yl = y;
+   wl = w;
+   hl = h;
    mirror = priv->is_mirrored;
-   vw = priv->size.w;
-   vh = priv->size.h;
+   vwl = priv->size.w;
+   vhl = priv->size.h;
    EINA_LIST_FOREACH(priv->children, l, opt)
      {
-        Evas_Coord x1, y1, x2, y2;
+        long long x1, y1, x2, y2;
 
         if (!mirror)
           {
-             x1 = x + ((w * opt->x) / vw);
-             x2 = x + ((w * (opt->x + opt->w)) / vw);
+             x1 = xl + ((wl * (long long)opt->x) / vwl);
+             x2 = xl + ((wl * (long long)(opt->x + opt->w)) / vwl);
           }
         else
           {
-             x1 = x + ((w * (vw - (opt->x + opt->w))) / vw);
-             x2 = x + ((w * (vw - opt->x)) / vw);
+             x1 = xl + ((wl * (vwl - (long long)(opt->x + opt->w))) / vwl);
+             x2 = xl + ((wl * (vwl - (long long)opt->x)) / vwl);
           }
-        y1 = y + ((h * opt->y) / vh);
-        y2 = y + ((h * (opt->y + opt->h)) / vh);
+        y1 = yl + ((hl * (long long)opt->y) / vhl);
+        y2 = yl + ((hl * (long long)(opt->y + opt->h)) / vhl);
         evas_object_move(opt->obj, x1, y1);
         evas_object_resize(opt->obj, x2 - x1, y2 - y1);
      }

-- 


Reply via email to