forked from enlightenment/efl
edje/style/optimization: Enable lazy computaion of styles.
Summary: As user request for the evas_textblock_style through _edje_textblock_style_get() api and that api implements lazy computation of the styles. By just marking the style dirty (stl->cache=false) will be enough. no need to calculate the style computaion at that time. Reviewers: Hermet, ali.alzyod, kimcinoo, woohyun Reviewed By: Hermet Subscribers: cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D9776
This commit is contained in:
parent
5f70cacd92
commit
e2663ba8f3
|
@ -126,10 +126,11 @@ _edje_format_reparse(Edje_File *edf, const char *str, Edje_Style_Tag *tag_ret, E
|
|||
*
|
||||
* @param ed The edje containing the given style which need to be updated
|
||||
* @param style The style which need to be updated
|
||||
* @param force Update the given style forcely or not
|
||||
* As now edje_style supports lazy computation of evas_textblock_style
|
||||
* only call this function from _edje_textblock_style_get()
|
||||
*/
|
||||
void
|
||||
_edje_textblock_style_update(Edje *ed, Edje_Style *stl, Eina_Bool force)
|
||||
_edje_textblock_style_update(Edje *ed, Edje_Style *stl)
|
||||
{
|
||||
Eina_List *l;
|
||||
Eina_Strbuf *txt = NULL;
|
||||
|
@ -142,11 +143,19 @@ _edje_textblock_style_update(Edje *ed, Edje_Style *stl, Eina_Bool force)
|
|||
/* Make sure the style is already defined */
|
||||
if (!stl->style) return;
|
||||
|
||||
/* we are sure it dosen't have any text_class */
|
||||
if (stl->readonly) return;
|
||||
/* this check is only here to catch misuse of this function */
|
||||
if (stl->readonly)
|
||||
{
|
||||
ERR("style_update() shouldn't be called for readonly style. performance regression : %s", stl->name);
|
||||
return;
|
||||
}
|
||||
|
||||
/* No need to compute it again and again and again */
|
||||
if (!force && stl->cache) return;
|
||||
/* this check is only here to catch misuse of this function */
|
||||
if (stl->cache)
|
||||
{
|
||||
ERR("style_update() shouldn't be called for cached style. performance regression : %s", stl->name);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!txt)
|
||||
txt = eina_strbuf_new();
|
||||
|
@ -282,7 +291,8 @@ _edje_textblock_style_add(Edje *ed, Edje_Style *stl)
|
|||
|
||||
_edje_textblock_style_observer_add(stl, ed->obj);
|
||||
|
||||
_edje_textblock_style_update(ed, stl, EINA_TRUE);
|
||||
// mark it dirty to recompute it later.
|
||||
stl->cache = EINA_FALSE;
|
||||
}
|
||||
|
||||
static inline void
|
||||
|
@ -370,7 +380,7 @@ _edje_textblock_style_get(Edje *ed, const char *style)
|
|||
|
||||
/* if style is dirty recompute */
|
||||
if (!stl->cache)
|
||||
_edje_textblock_style_update(ed, stl, EINA_FALSE);
|
||||
_edje_textblock_style_update(ed, stl);
|
||||
|
||||
return stl->style;
|
||||
}
|
||||
|
@ -400,7 +410,9 @@ _edje_textblock_style_all_update_text_class(Edje *ed, const char *text_class)
|
|||
|
||||
if (!strcmp(tag->text_class, text_class))
|
||||
{
|
||||
_edje_textblock_style_update(ed, stl, EINA_TRUE);
|
||||
// just mark it dirty so the next request
|
||||
// for this style will trigger recomputation.
|
||||
stl->cache = EINA_FALSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue