edje: replace 4000x4000 min size limitarion with loop count restriction. 15/76515/3
authorYoungbok Shin <youngb.shin@samsung.com>
Thu, 23 Jun 2016 17:11:39 +0000 (10:11 -0700)
committerGerrit Code Review <gerrit@review.vlan103.tizen.org>
Thu, 30 Jun 2016 06:44:16 +0000 (23:44 -0700)
Summary:
4000x4000 min size limitation was added to prevent infinite
calculation loop. But, it can ruin calculation of some proper Edjes.
Normally, properly generated Edje runs the calculation loop below 10 times.
So, "255" could be proper limitation for calculation loop.
It also make better performance for broken Edje.

Test Plan: N/A

Reviewers: raster, Hermet, woohyun, cedric

Reviewed By: cedric

Subscribers: jpeg, z-wony, Blackmole

Differential Revision: https://phab.enlightenment.org/D4075

Change-Id: I17d7697e8aa211efcc8c2a29ac63ab148cb0afab
Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
src/lib/edje/edje_util.c

index 6eaef31..965b0ea 100644 (file)
@@ -3338,10 +3338,11 @@ _edje_object_parts_extends_calc(Eo *obj EINA_UNUSED, Edje *ed, Evas_Coord *x, Ev
 EOLIAN void
 _edje_object_size_min_restricted_calc(Eo *obj EINA_UNUSED, Edje *ed, Evas_Coord *minw, Evas_Coord *minh, Evas_Coord restrictedw, Evas_Coord restrictedh)
 {
-   const int MIN_LIMIT = 4000;
+   const int CALC_COUNT_LIMIT = 255;
 
    Evas_Coord orig_w, orig_h; //original edje size
    int max_over_w, max_over_h;  //maximum over-calculated size.
+   int calc_count = 0;
    Eina_Bool repeat_w, repeat_h;
    Eina_Bool reset_max = EINA_TRUE;
    Edje_Real_Part *pep = NULL;
@@ -3372,6 +3373,8 @@ again:
      {
         unsigned int i;
 
+        calc_count++;
+
         repeat_w = EINA_FALSE;
         repeat_h = EINA_FALSE;
         ed->dirty = EINA_TRUE;
@@ -3461,7 +3464,7 @@ again:
              if (ed->h < restrictedh) ed->h = restrictedh;
           }
 
-        if ((ed->w > MIN_LIMIT) || (ed->h > MIN_LIMIT))
+        if (reset_max && (calc_count > CALC_COUNT_LIMIT))
           {
              /* Only print it if we have a non-fixed textblock.
               * We should possibly avoid all of this if in this case, but in
@@ -3472,16 +3475,12 @@ again:
                     ERR("file %s, group %s has a non-fixed part '%s'. Adding 'fixed: 1 1;' to source EDC may help. Continuing discarding faulty part.",
                         ed->path, ed->group, pep->part->name);
                   else
-                    ERR("file %s, group %s overflowed %dx%d with minimum size of %dx%d. Continuing discarding faulty parts.",
-                        ed->path, ed->group, MIN_LIMIT, MIN_LIMIT,
-                        ed->w, ed->h);
+                    ERR("file %s, group %s runs infinite minimum calculation loops.Continuing discarding faulty parts.",
+                        ed->path, ed->group);
                }
 
-             if (reset_max)
-               {
-                  reset_max = EINA_FALSE;
-                  goto again;
-               }
+             reset_max = EINA_FALSE;
+             goto again;
           }
      }
    while (repeat_w || repeat_h);