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 <cedric.bail@free.fr>
Differential Revision: https://phab.enlightenment.org/D10605
This commit is contained in:
Woochanlee 2019-11-14 05:16:18 +00:00 committed by Cedric BAIL
parent 2288c92bc5
commit 37b55172b0
3 changed files with 119 additions and 64 deletions

View File

@ -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;

View File

@ -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

View File

@ -416,6 +416,84 @@ _edje_part_recalc_single_textblock_min_max_calc(Edje_Real_Part *ep,
}
}
Eina_Bool
_edje_part_textblock_style_text_set(Edje *ed,
Edje_Real_Part *ep,
Edje_Part_Description_Text *chosen_desc)
{
const char *text = "";
const char *style = "";
Evas_Textblock_Style *stl = NULL;
const char *tmp;
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;
tmp = edje_string_get(&chosen_desc->text.style);
if (tmp) style = tmp;
}
if (chosen_desc->text.id_text_source >= 0)
{
Edje_Part_Description_Text *et;
Edje_Real_Part *rp;
ep->typedata.text->text_source = ed->table_parts[chosen_desc->text.id_text_source % ed->table_parts_size];
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)
{
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;
}
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
{
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,
@ -432,75 +510,14 @@ _edje_part_recalc_single_textblock(FLOAT_T sc,
if (chosen_desc)
{
Evas_Coord tw, th;
const char *text = "";
const char *style = "";
Evas_Textblock_Style *stl = NULL;
const char *tmp;
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;
tmp = edje_string_get(&chosen_desc->text.style);
if (tmp) style = tmp;
}
if (chosen_desc->text.id_text_source >= 0)
{
Edje_Part_Description_Text *et;
Edje_Real_Part *rp;
ep->typedata.text->text_source = ed->table_parts[chosen_desc->text.id_text_source % ed->table_parts_size];
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)
{
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;
}
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;