cedric pushed a commit to branch master.

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

commit 37b55172b0d46d71f772af8fba17e1fb1b7c6c2c
Author: Woochanlee <[email protected]>
Date:   Thu Nov 14 05:16:18 2019 +0000

    edje_calc: Exception handling if no calculation is required.
    
    If there is no object swllowed, do not run part_calc on it.
    This swallow will be calculated if there is an associated part, otherwise 
it will not need to be calculated.
    
    When the app is launched, a lot of edje calculation logic is executed.
    Most of the edje size is missing, so the calculation result is meaningless.
    Added code to prevent this.
    
    Reviewed-by: Cedric BAIL <[email protected]>
    Differential Revision: https://phab.enlightenment.org/D10605
---
 src/lib/edje/edje_calc.c      |  37 +++++++++++
 src/lib/edje/edje_private.h   |   1 +
 src/lib/edje/edje_textblock.c | 145 +++++++++++++++++++++++-------------------
 3 files changed, 119 insertions(+), 64 deletions(-)

diff --git a/src/lib/edje/edje_calc.c b/src/lib/edje/edje_calc.c
index 59349b40b4..736ccb4b53 100644
--- a/src/lib/edje/edje_calc.c
+++ b/src/lib/edje/edje_calc.c
@@ -988,6 +988,13 @@ _edje_recalc_table_parts(Edje *ed
    for (i = 0; i < ed->table_parts_size; i++)
      {
         ep = ed->table_parts[i];
+
+        //Ignore if the real part doesn't have swallowed object
+        if ((ep->part->type == EDJE_PART_TYPE_SWALLOW) &&
+            (ep->typedata.swallow) &&
+            (!ep->typedata.swallow->swallowed_object))
+          continue;
+
         if (ep->calculated != FLAG_XY) // FIXME: this is always true (see for 
above)
           _edje_part_recalc(ed, ep, (~ep->calculated) & FLAG_XY, NULL);
      }
@@ -996,6 +1003,25 @@ _edje_recalc_table_parts(Edje *ed
 #endif
 }
 
+void
+_edje_recalc_textblock_style_text_set(Edje *ed)
+{
+   unsigned short i;
+   Edje_Real_Part *ep;
+   Edje_Part_Description_Text *chosen_desc;
+
+   for (i = 0; i < ed->table_parts_size; i++)
+     {
+        ep = ed->table_parts[i];
+
+        if (ep->part->type == EDJE_PART_TYPE_TEXTBLOCK)
+          {
+             _edje_part_textblock_style_text_set
+               (ed, ep, (Edje_Part_Description_Text *)ep->chosen_description);
+          }
+     }
+}
+
 void
 _edje_recalc_do(Edje *ed)
 {
@@ -1005,6 +1031,17 @@ _edje_recalc_do(Edje *ed)
    Eina_Bool need_reinit_state = EINA_FALSE;
 #endif
 
+
+   //Do nothing if the edje has no size, Regardless of the edje part size calc,
+   //the text and style has to be set.
+   if ((EINA_UNLIKELY(!ed->has_size)) && (!ed->calc_only) && (ed->w == 0) && 
(ed->h == 0))
+     {
+        _edje_recalc_textblock_style_text_set(ed);
+
+        return;
+     }
+   ed->has_size = EINA_TRUE;
+
    need_calc = evas_object_smart_need_recalculate_get(ed->obj);
    evas_object_smart_need_recalculate_set(ed->obj, 0);
    if (!ed->dirty) return;
diff --git a/src/lib/edje/edje_private.h b/src/lib/edje/edje_private.h
index c3e4e1659a..676231512f 100644
--- a/src/lib/edje/edje_private.h
+++ b/src/lib/edje/edje_private.h
@@ -1807,6 +1807,7 @@ struct _Edje
    Eina_Bool          text_part_change : 1;
    Eina_Bool          all_part_change : 1;
 #endif
+   Eina_Bool          has_size : 1;
 };
 
 struct _Edje_Calc_Params_Map
diff --git a/src/lib/edje/edje_textblock.c b/src/lib/edje/edje_textblock.c
index c7e58c3148..ce1015e065 100644
--- a/src/lib/edje/edje_textblock.c
+++ b/src/lib/edje/edje_textblock.c
@@ -416,91 +416,108 @@ 
_edje_part_recalc_single_textblock_min_max_calc(Edje_Real_Part *ep,
      }
 }
 
-void
-_edje_part_recalc_single_textblock(FLOAT_T sc,
-                                   Edje *ed,
-                                   Edje_Real_Part *ep,
-                                   Edje_Part_Description_Text *chosen_desc,
-                                   Edje_Calc_Params *params,
-                                   int *minw, int *minh,
-                                   int *maxw, int *maxh)
+Eina_Bool
+_edje_part_textblock_style_text_set(Edje *ed,
+                                    Edje_Real_Part *ep,
+                                    Edje_Part_Description_Text *chosen_desc)
 {
-   if ((ep->type != EDJE_RP_TYPE_TEXT) ||
-       (!ep->typedata.text))
-     return;
+   const char *text = "";
+   const char *style = "";
+   Evas_Textblock_Style *stl = NULL;
+   const char *tmp;
 
-   if (chosen_desc)
+   if (chosen_desc->text.id_source >= 0)
      {
-        Evas_Coord tw, th;
-        const char *text = "";
-        const char *style = "";
-        Evas_Textblock_Style *stl = NULL;
-        const char *tmp;
+        Edje_Part_Description_Text *et;
 
-        if (chosen_desc->text.id_source >= 0)
-          {
-             Edje_Part_Description_Text *et;
+        ep->typedata.text->source = 
ed->table_parts[chosen_desc->text.id_source % ed->table_parts_size];
+
+        et = _edje_real_part_text_source_description_get(ep, NULL);
+        tmp = edje_string_get(&et->text.style);
+        if (tmp) style = tmp;
+     }
+   else
+     {
+        ep->typedata.text->source = NULL;
 
-             ep->typedata.text->source = 
ed->table_parts[chosen_desc->text.id_source % ed->table_parts_size];
+        tmp = edje_string_get(&chosen_desc->text.style);
+        if (tmp) style = tmp;
+     }
 
-             et = _edje_real_part_text_source_description_get(ep, NULL);
-             tmp = edje_string_get(&et->text.style);
-             if (tmp) style = tmp;
-          }
-        else
-          {
-             ep->typedata.text->source = NULL;
+   if (chosen_desc->text.id_text_source >= 0)
+     {
+        Edje_Part_Description_Text *et;
+        Edje_Real_Part *rp;
 
-             tmp = edje_string_get(&chosen_desc->text.style);
-             if (tmp) style = tmp;
-          }
+        ep->typedata.text->text_source = 
ed->table_parts[chosen_desc->text.id_text_source % ed->table_parts_size];
 
-        if (chosen_desc->text.id_text_source >= 0)
+        et = _edje_real_part_text_text_source_description_get(ep, &rp);
+        text = edje_string_get(&et->text.text);
+
+        if (rp->typedata.text->text) text = rp->typedata.text->text;
+     }
+   else
+     {
+        ep->typedata.text->text_source = NULL;
+        text = NULL;
+        if (chosen_desc->text.domain)
           {
-             Edje_Part_Description_Text *et;
-             Edje_Real_Part *rp;
+             if (!chosen_desc->text.text.translated)
+               chosen_desc->text.text.translated = _set_translated_string(ed, 
ep);
+             if (chosen_desc->text.text.translated)
+               text = chosen_desc->text.text.translated;
+          }
 
-             ep->typedata.text->text_source = 
ed->table_parts[chosen_desc->text.id_text_source % ed->table_parts_size];
+        if (!text) text = edje_string_get(&chosen_desc->text.text);
 
-             et = _edje_real_part_text_text_source_description_get(ep, &rp);
-             text = edje_string_get(&et->text.text);
+        if (ep->typedata.text->text) text = ep->typedata.text->text;
+     }
 
-             if (rp->typedata.text->text) text = rp->typedata.text->text;
+   stl = _edje_textblock_style_get(ed, style);
+   if (stl)
+     {
+        if (evas_object_textblock_style_get(ep->object) != stl)
+          evas_object_textblock_style_set(ep->object, stl);
+        // FIXME: need to account for editing
+        if (ep->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE)
+          {
+             // do nothing - should be done elsewhere
           }
         else
           {
-             ep->typedata.text->text_source = NULL;
-             text = NULL;
-             if (chosen_desc->text.domain)
-               {
-                  if (!chosen_desc->text.text.translated)
-                    chosen_desc->text.text.translated = 
_set_translated_string(ed, ep);
-                  if (chosen_desc->text.text.translated)
-                    text = chosen_desc->text.text.translated;
-               }
-             if (!text)
-               text = edje_string_get(&chosen_desc->text.text);
-             if (ep->typedata.text->text) text = ep->typedata.text->text;
+             evas_object_textblock_text_markup_set(ep->object, text);
           }
 
+        return EINA_TRUE;
+     }
+
+   return EINA_FALSE;
+}
+
+void
+_edje_part_recalc_single_textblock(FLOAT_T sc,
+                                   Edje *ed,
+                                   Edje_Real_Part *ep,
+                                   Edje_Part_Description_Text *chosen_desc,
+                                   Edje_Calc_Params *params,
+                                   int *minw, int *minh,
+                                   int *maxw, int *maxh)
+{
+   if ((ep->type != EDJE_RP_TYPE_TEXT) ||
+       (!ep->typedata.text))
+     return;
+
+   if (chosen_desc)
+     {
+        Evas_Coord tw, th;
+
         if (ep->part->scale)
           evas_object_scale_set(ep->object, TO_DOUBLE(sc));
 
-        stl = _edje_textblock_style_get(ed, style);
-        if (stl)
+        //Gets textblock's style and text to set evas_object_textblock 
properties.
+        //If there is no style for it. don't need to calc.
+        if (_edje_part_textblock_style_text_set(ed, ep, chosen_desc))
           {
-             if (evas_object_textblock_style_get(ep->object) != stl)
-               evas_object_textblock_style_set(ep->object, stl);
-             // FIXME: need to account for editing
-             if (ep->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE)
-               {
-                  // do nothing - should be done elsewhere
-               }
-             else
-               {
-                  evas_object_textblock_text_markup_set(ep->object, text);
-               }
-
              if ((chosen_desc->text.fit_x) || (chosen_desc->text.fit_y))
                {
                   double base_s = 1.0;

-- 


Reply via email to