edje/style: optimize style_update function.

Summary:
If the style is readonly then we know for sure it dosen't have any text_class/color_class.
If a style has text_class tag then call update only once not for each text_class tag it has.

Reviewers: ali.alzyod, Hermet, cedric, raster

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D9641
This commit is contained in:
subhransu mohanty 2019-08-26 14:18:09 +09:00 committed by Hermet Park
parent de183719b3
commit e742bf67e4
1 changed files with 56 additions and 30 deletions

View File

@ -258,14 +258,57 @@ _edje_textblock_style_member_add(Edje *ed, Edje_Style *stl)
EINA_LIST_FOREACH(stl->tags, l, tag)
{
if (tag->text_class)
{
efl_observable_observer_add(_edje_text_class_member, tag->text_class, ed->obj);
/* Newly added text_class member should be updated
according to the latest text_class's status. */
_edje_textblock_style_update(ed, stl, EINA_TRUE);
}
efl_observable_observer_add(_edje_text_class_member, tag->text_class, ed->obj);
}
/* Newly added text_class member should be updated
according to the latest text_class's status. */
_edje_textblock_style_update(ed, stl, EINA_TRUE);
}
static inline void
_edje_textblock_style_observer_add(Edje_Style *stl, Efl_Observer* observer)
{
Eina_List* l;
Edje_Style_Tag *tag;
EINA_LIST_FOREACH(stl->tags, l, tag)
{
if (tag->text_class)
efl_observable_observer_add(_edje_text_class_member, tag->text_class, observer);
}
}
static inline void
_edje_textblock_style_observer_del(Edje_Style *stl, Efl_Observer* observer)
{
Eina_List* l;
Edje_Style_Tag *tag;
EINA_LIST_FOREACH(stl->tags, l, tag)
{
if (tag->text_class)
efl_observable_observer_del(_edje_text_class_member, tag->text_class, observer);
}
}
static inline void
_edje_textblock_style_add(Edje *ed, Edje_Style *stl)
{
if (!stl) return;
if (stl->readonly) return;
_edje_textblock_style_observer_add(stl, ed->obj);
_edje_textblock_style_update(ed, stl, EINA_TRUE);
}
static inline void
_edje_textblock_style_del(Edje *ed, Edje_Style *stl)
{
if (!stl) return;
_edje_textblock_style_observer_del(stl, ed->obj);
}
void
@ -284,7 +327,8 @@ _edje_textblock_styles_add(Edje *ed, Edje_Real_Part *ep)
desc = (Edje_Part_Description_Text *)pt->default_desc;
style = edje_string_get(&desc->text.style);
stl = _edje_textblock_style_search(ed, style);
_edje_textblock_style_member_add(ed, stl);
_edje_textblock_style_add(ed, stl);
/* If any other classes exist add them */
for (i = 0; i < pt->other.desc_count; ++i)
@ -292,7 +336,8 @@ _edje_textblock_styles_add(Edje *ed, Edje_Real_Part *ep)
desc = (Edje_Part_Description_Text *)pt->other.desc[i];
style = edje_string_get(&desc->text.style);
stl = _edje_textblock_style_search(ed, style);
_edje_textblock_style_member_add(ed, stl);
_edje_textblock_style_add(ed, stl);
}
}
@ -311,34 +356,15 @@ _edje_textblock_styles_del(Edje *ed, Edje_Part *pt)
stl = _edje_textblock_style_search(ed, style);
if (stl)
{
Edje_Style_Tag *tag;
Eina_List *l;
EINA_LIST_FOREACH(stl->tags, l, tag)
{
if (tag->text_class)
efl_observable_observer_del(_edje_text_class_member, tag->text_class, ed->obj);
}
}
_edje_textblock_style_del(ed, stl);
for (i = 0; i < pt->other.desc_count; ++i)
{
desc = (Edje_Part_Description_Text *)pt->other.desc[i];
style = edje_string_get(&desc->text.style);
stl = _edje_textblock_style_search(ed, style);
if (stl)
{
Edje_Style_Tag *tag;
Eina_List *l;
EINA_LIST_FOREACH(stl->tags, l, tag)
{
if (tag->text_class)
efl_observable_observer_del(_edje_text_class_member, tag->text_class, ed->obj);
}
}
_edje_textblock_style_del(ed, stl);
}
}