From 60a31628c1c98d37ab16ca616906b9be63f4fd21 Mon Sep 17 00:00:00 2001 From: subhransu mohanty Date: Thu, 29 Aug 2019 15:01:13 +0900 Subject: [PATCH] edje/textblock: total refactoring after the upstream patches. Change-Id: I39b1d82c6179e8cdee634d6d065e94dc6ad13ce0 --- src/lib/edje/edje_cache.c | 73 +---- src/lib/edje/edje_load.c | 25 +- src/lib/edje/edje_private.h | 37 ++- src/lib/edje/edje_smart.c | 6 +- src/lib/edje/edje_textblock.c | 37 +-- src/lib/edje/edje_textblock_styles.c | 586 ++++++++++++----------------------- src/lib/edje/edje_util.c | 42 +-- 7 files changed, 255 insertions(+), 551 deletions(-) diff --git a/src/lib/edje/edje_cache.c b/src/lib/edje/edje_cache.c index 7f157c4..d51fc73 100644 --- a/src/lib/edje/edje_cache.c +++ b/src/lib/edje/edje_cache.c @@ -568,7 +568,7 @@ _edje_file_open(const Eina_File *f, int *error_ret, time_t mtime, Eina_Bool coll edf->references = 1; /* This should be done at edje generation time */ - _edje_textblock_style_parse_and_fix(edf); + _edje_file_textblock_style_parse_and_fix(edf); edf->style_hash = eina_hash_string_small_new(NULL); EINA_LIST_FOREACH(edf->styles, l, stl) @@ -900,53 +900,15 @@ static Eina_Bool _textblock_styles_color_class_cache_free(const Eina_Hash *hash EINA_UNUSED, const void *key EINA_UNUSED, void *data, void *fdata) { Edje_File *edf = data; - char *class_name = fdata; - Eina_List *l, *ll; - Edje_Style *stl; - Edje_Color_Class *cc = NULL, *tag_cc; - - if (!class_name) return EINA_FALSE; - - cc = _edje_color_class_recursive_find(NULL, edf, class_name); - - if (!cc) - { - ERR("There is no Edje_Color_Class for file color_class: %s", class_name); - return EINA_FALSE; - } - - EINA_LIST_FOREACH(edf->styles, l, stl) - { - Edje_Style_Tag *tag; - Eina_Bool found = EINA_FALSE; - - if (!stl->cache) continue; - - EINA_LIST_FOREACH(stl->tags, ll, tag) - { - if (!tag->color_class) continue; + char *color_class = fdata; - tag_cc = _edje_color_class_recursive_find(NULL, edf, tag->color_class); - if (tag_cc == cc) - { - found = EINA_TRUE; - break; - } - if (tag_cc && cc && !strcmp(tag_cc->name, cc->name)) - { - found = EINA_TRUE; - break; - } - } - if (found) - stl->cache = EINA_FALSE; - } + _edje_file_textblock_style_all_update_color_class(edf, color_class); return EINA_TRUE; } void -_edje_file_textblock_styles_color_class_cache_free(const char *class_name) +_edje_global_textblock_styles_color_class_cache_free(const char *class_name) { if (!class_name) return; if (!_edje_file_hash) return; @@ -958,36 +920,15 @@ static Eina_Bool _textblock_styles_text_class_cache_free(const Eina_Hash *hash EINA_UNUSED, const void *key EINA_UNUSED, void *data, void *fdata) { Edje_File *edf = data; - char *class_name = fdata; - Eina_List *l, *ll; - Edje_Style *stl; - - EINA_LIST_FOREACH(edf->styles, l, stl) - { - Edje_Style_Tag *tag; - Eina_Bool found = EINA_FALSE; + char *text_class = fdata; - if (!stl->cache) continue; - - EINA_LIST_FOREACH(stl->tags, ll, tag) - { - if (!tag->text_class) continue; - - if (!strcmp(tag->text_class, class_name)) - { - found = EINA_TRUE; - break; - } - } - if (found) - stl->cache = EINA_FALSE; - } + _edje_file_textblock_style_all_update_text_class(edf, text_class); return EINA_TRUE; } void -_edje_file_textblock_styles_text_class_cache_free(const char *class_name) +_edje_global_textblock_styles_text_class_cache_free(const char *class_name) { if (!class_name) return; if (!_edje_file_hash) return; diff --git a/src/lib/edje/edje_load.c b/src/lib/edje/edje_load.c index da460ac..e2732e5 100644 --- a/src/lib/edje/edje_load.c +++ b/src/lib/edje/edje_load.c @@ -1725,26 +1725,13 @@ _edje_object_file_set_internal(Evas_Object *obj, const Eina_File *file, const ch if (rp->part->default_desc) { Edje_Part_Description_Text *text; - Edje_Style *stl = NULL; - const char *style; + Evas_Textblock_Style *style = NULL; text = (Edje_Part_Description_Text *)rp->part->default_desc; - style = edje_string_get(&text->text.style); - if (style) - { - Eina_List *l; - - EINA_LIST_FOREACH(ed->file->styles, l, stl) - { - if ((stl->name) && (!strcmp(stl->name, style))) break; - stl = NULL; - } - } - if (stl) - { - if (evas_object_textblock_style_get(rp->object) != stl->style) - evas_object_textblock_style_set(rp->object, stl->style); - } + style = _edje_textblock_style_get(ed, edje_string_get(&text->text.style)); + + if (evas_object_textblock_style_get(rp->object) != style) + evas_object_textblock_style_set(rp->object, style); } } _edje_entry_init(ed); @@ -2351,7 +2338,7 @@ _edje_file_free(Edje_File *edf) if (edf->path) eina_stringshare_del(edf->path); if (edf->free_strings && edf->compiler) eina_stringshare_del(edf->compiler); eina_hash_free(edf->style_hash); - _edje_textblock_style_cleanup(edf); + _edje_file_textblock_style_cleanup(edf); if (edf->ef) eet_close(edf->ef); if (edf->f) eina_file_close(edf->f); // close matching open (in _edje_file_open) OK free(edf); diff --git a/src/lib/edje/edje_private.h b/src/lib/edje/edje_private.h index bb09a95..0bdb0f7 100644 --- a/src/lib/edje/edje_private.h +++ b/src/lib/edje/edje_private.h @@ -2946,26 +2946,31 @@ void _edje_message_queue_process (void); void _edje_message_queue_clear (void); void _edje_message_del (Edje *ed); +// Edje object level textblock style api +Evas_Textblock_Style * _edje_textblock_style_get(Edje *ed, const char *style); void _edje_textblock_styles_add(Edje *ed, Edje_Real_Part *ep); void _edje_textblock_styles_del(Edje *ed, Edje_Part *pt); -/*********************************************************************************** - * TIZEN_ONLY_FEATURE: apply Tizen's color_class features. * - *********************************************************************************** +//tizen only object level style api +void _edje_textblock_style_all_update_color_class(Edje *ed, const char *color_class); void _edje_textblock_style_all_update_text_class(Edje *ed, const char *text_class); void _edje_textblock_style_all_update(Edje *ed); - */ -void _edje_file_textblock_styles_color_class_cache_free(const char *class_name); -void _edje_file_textblock_styles_text_class_cache_free(const char *class_name); -void _edje_file_textblock_styles_cache_update(void); -void _edje_file_textblock_style_all_update(Edje_File *edf); -void _edje_textblock_styles_color_class_cache_free(Edje *ed, const char *class_name); -void _edje_textblock_styles_text_class_cache_free(Edje *ed, const char *class_name); -void _edje_textblock_style_all_update(Edje *ed, Eina_Bool force); -/******* - * END * - *******/ -void _edje_textblock_style_parse_and_fix(Edje_File *edf); -void _edje_textblock_style_cleanup(Edje_File *edf); +void _edje_textblock_style_cleanup(Edje *ed); +//end + +// Edje File level textblock style api +void _edje_file_textblock_style_all_update(Edje_File *ed); +void _edje_file_textblock_style_all_update_text_class(Edje_File *edf, const char *text_class); +void _edje_file_textblock_style_parse_and_fix(Edje_File *edf); +void _edje_file_textblock_style_cleanup(Edje_File *edf); +// tizen only file level style api +void _edje_file_textblock_style_all_update_color_class(Edje_File *edf, const char *color_class); +// end + +// tizen only global level (all the opend files) style api +void _edje_global_textblock_styles_color_class_cache_free(const char *color_class); +void _edje_global_textblock_styles_text_class_cache_free(const char *text_class); +// end + Edje_File *_edje_cache_file_coll_open(const Eina_File *file, const char *coll, int *error_ret, Edje_Part_Collection **edc_ret, Edje *ed); void _edje_cache_coll_clean(Edje_File *edf); void _edje_cache_coll_flush(Edje_File *edf); diff --git a/src/lib/edje/edje_smart.c b/src/lib/edje/edje_smart.c index 9f5c0a6..8b104e0 100644 --- a/src/lib/edje/edje_smart.c +++ b/src/lib/edje/edje_smart.c @@ -520,16 +520,14 @@ _efl_canvas_layout_efl_observer_update(Eo *obj EINA_UNUSED, Edje *ed, Efl_Object } else if (obs == _edje_text_class_member) { - _edje_textblock_styles_text_class_cache_free(ed, key); - _edje_textblock_style_all_update(ed, EINA_FALSE); + _edje_textblock_style_all_update_text_class(ed, key); #ifdef EDJE_CALC_CACHE ed->text_part_change = EINA_TRUE; #endif } else if (obs == _edje_color_class_member) { - _edje_textblock_styles_color_class_cache_free(ed, key); - _edje_textblock_style_all_update(ed, EINA_FALSE); + _edje_textblock_style_all_update_color_class(ed, key); #ifdef EDJE_CALC_CACHE ed->text_part_change = EINA_TRUE; ed->all_part_change = EINA_TRUE; diff --git a/src/lib/edje/edje_textblock.c b/src/lib/edje/edje_textblock.c index e3e77de..423584d 100644 --- a/src/lib/edje/edje_textblock.c +++ b/src/lib/edje/edje_textblock.c @@ -505,9 +505,8 @@ _edje_part_recalc_single_textblock(FLOAT_T sc, Evas_Coord tw, th; const char *text = ""; const char *style = ""; - Edje_Style *stl = NULL; + Evas_Textblock_Style *stl = NULL; const char *tmp; - Eina_List *l; if (chosen_desc->text.id_source >= 0) { @@ -555,42 +554,14 @@ _edje_part_recalc_single_textblock(FLOAT_T sc, if (ep->typedata.text->text) text = ep->typedata.text->text; } - /*********************************************************************************** - * TIZEN_ONLY_FEATURE: apply Tizen's color_class features. * - *********************************************************************************** - EINA_LIST_FOREACH(ed->file->styles, l, stl) - { - if ((stl->name) && (!strcmp(stl->name, style))) break; - stl = NULL; - } - */ - /* check object level styles */ - EINA_LIST_FOREACH(ed->styles, l, stl) - { - if ((stl->name) && (!strcmp(stl->name, style))) break; - stl = NULL; - } - - /* check file level styles */ - if (!stl) - { - EINA_LIST_FOREACH(ed->file->styles, l, stl) - { - if ((stl->name) && (!strcmp(stl->name, style))) break; - stl = NULL; - } - } - /******* - * END * - *******/ - if (ep->part->scale) evas_object_scale_set(ep->object, TO_DOUBLE(sc)); + stl = _edje_textblock_style_get(ed, style); if (stl) { - if (evas_object_textblock_style_get(ep->object) != stl->style) - evas_object_textblock_style_set(ep->object, stl->style); + 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) { diff --git a/src/lib/edje/edje_textblock_styles.c b/src/lib/edje/edje_textblock_styles.c index fbbe5d9..87b9540 100644 --- a/src/lib/edje/edje_textblock_styles.c +++ b/src/lib/edje/edje_textblock_styles.c @@ -3,7 +3,7 @@ /*********************************************************************************** * TIZEN_ONLY_FEATURE: apply Tizen's color_class features. * ***********************************************************************************/ -void _edje_textblock_style_update(Edje *ed, Edje_Style *stl, Eina_Bool force); +void _edje_textblock_style_update(Edje *ed, Edje_Style *stl); static int _hex_string_get(char ch) @@ -85,132 +85,165 @@ _edje_textblock_color_calc(const char *color, unsigned char r, unsigned char g, return ret; } +void _edje_textblock_style_all_update(Edje *ed) +{ + Eina_List *l; + Edje_Style *stl; + + if (!ed) return; + + EINA_LIST_FOREACH(ed->styles, l, stl) + if (stl && !stl->readonly) stl->cache = EINA_FALSE; +} + +/* + * Finds all the styles having text class tag as text_class and + * updates them in object level. + */ +void +_edje_textblock_style_all_update_text_class(Edje *ed, const char *text_class) +{ + Eina_List *l, *ll; + Edje_Style *stl; + + if (!ed) return; + if (!text_class) return; + + EINA_LIST_FOREACH(ed->styles, l, stl) + { + Edje_Style_Tag *tag; + + if (stl->readonly) continue; + + EINA_LIST_FOREACH(stl->tags, ll, tag) + { + if (!tag->text_class) continue; + + if (!strcmp(tag->text_class, text_class)) + { + // just mark it dirty so the next request + // for this style will trigger recomputation. + stl->cache = EINA_FALSE; + break; + } + } + } +} + +/* + * Finds all the styles having text class tag as text_class and + * updates them in object level. + */ +void +_edje_textblock_style_all_update_color_class(Edje *ed, const char *color_class) +{ + Eina_List *l, *ll; + Edje_Style *stl; + + if (!ed) return; + if (!color_class) return; + + EINA_LIST_FOREACH(ed->styles, l, stl) + { + Edje_Style_Tag *tag; + + if (stl->readonly) continue; + + EINA_LIST_FOREACH(stl->tags, ll, tag) + { + if (!tag->color_class) continue; + + if (!strcmp(tag->color_class, color_class)) + { + // just mark it dirty so the next request + // for this style will trigger recomputation. + stl->cache = EINA_FALSE; + break; + } + } + } +} + static Edje_Style * _edje_textblock_style_copy(Edje_Style *stl) { Edje_Style *new_stl; - Eina_List *l; - Edje_Style_Tag *tag; - Edje_Style_Tag *new_tag; new_stl = calloc(1, sizeof(Edje_Style)); if (!new_stl) return NULL; - new_stl->name = (char *)eina_stringshare_add(stl->name); new_stl->style = evas_textblock_style_new(); evas_textblock_style_set(new_stl->style, NULL); - EINA_LIST_FOREACH(stl->tags, l, tag) - { - new_tag = calloc(1, sizeof(Edje_Style_Tag)); - if (!new_tag) continue; - - new_tag->key = eina_stringshare_add(tag->key); - new_tag->value = eina_stringshare_add(tag->value); - new_tag->font = eina_stringshare_add(tag->font); - new_tag->font_size = tag->font_size; - new_tag->text_class = eina_stringshare_add(tag->text_class); - new_tag->color_class = eina_stringshare_add(tag->color_class); - new_tag->color = eina_stringshare_add(tag->color); - new_tag->outline_color = eina_stringshare_add(tag->outline_color); - new_tag->shadow_color = eina_stringshare_add(tag->shadow_color); - - new_stl->tags = eina_list_append(new_stl->tags, new_tag); - } + // just keep a reference. + new_stl->tags = stl->tags; + new_stl->name = stl->name; return new_stl; } -static void -_edje_textblock_styles_cache_add(Edje *ed, Edje_Style *stl) +static Edje_Style * +_edje_object_styles_cache_add(Edje *ed, Edje_Style *stl) { - Eina_List *l; - Edje_Style *new_stl; - - if (!stl) return; + Edje_Style *new_stl = _edje_textblock_style_copy(stl); - EINA_LIST_FOREACH(ed->styles, l, new_stl) - { - if (!strcmp(stl->name, new_stl->name)) - return; - } - - new_stl = _edje_textblock_style_copy(stl); if (new_stl) { ed->styles = eina_list_append(ed->styles, new_stl); - _edje_textblock_style_update(ed, new_stl, EINA_TRUE); + _edje_textblock_style_update(ed, new_stl); } + + return new_stl; } static void -_edje_textblock_styles_cache_del(Edje *ed, Edje_Style *stl) +_edje_object_styles_cache_cleanup(Edje *ed) { - Eina_List *l; - Edje_Style *new_stl; - Eina_Bool found = EINA_FALSE; + Edje_Style *obj_stl = NULL; - if (!stl) return; + EINA_LIST_FREE(ed->styles, obj_stl) + { + if (obj_stl->style) evas_textblock_style_free(obj_stl->style); + free(obj_stl); + } +} - EINA_LIST_FOREACH(ed->styles, l, new_stl) +static Evas_Textblock_Style * +_edje_textblock_styles_cache_get(Edje *ed, Edje_Style *stl) +{ + Eina_List *l; + Edje_Style *obj_stl; + + // Find the style in the object cache + EINA_LIST_FOREACH(ed->styles, l, obj_stl) { - if (!strcmp(stl->name, new_stl->name)) - { - found = EINA_TRUE; - break; - } + if (!strcmp(stl->name, obj_stl->name)) break; } - if (found) + + // if not found add it into the cache + if (!obj_stl) { - Edje_Style_Tag *tag; + obj_stl = _edje_object_styles_cache_add(ed, stl); + } - EINA_LIST_FREE(new_stl->tags, tag) - { - if (tag->value) eina_stringshare_del(tag->value); - if (tag->key) eina_stringshare_del(tag->key); - if (tag->text_class) eina_stringshare_del(tag->text_class); - if (tag->font) eina_stringshare_del(tag->font); - if (tag->color_class) eina_stringshare_del(tag->color_class); - if (tag->color) eina_stringshare_del(tag->color); - if (tag->outline_color) eina_stringshare_del(tag->outline_color); - if (tag->shadow_color) eina_stringshare_del(tag->shadow_color); - free(tag); - } - if (new_stl->name) eina_stringshare_del(new_stl->name); - if (new_stl->style) evas_textblock_style_free(new_stl->style); - free(new_stl); + // recompute if its dirty + if (!obj_stl->cache) + _edje_textblock_style_update(ed, obj_stl); - ed->styles = eina_list_remove_list(ed->styles, l); - } + // return the object style + return obj_stl->style; } /******* * END * *******/ static int -_edje_font_is_embedded(Edje_File *edf, char *font) +_edje_font_is_embedded(Edje_File *edf, const char *font) { if (!eina_hash_find(edf->fonts, font)) return 0; return 1; } -static void -_edje_format_param_parse(char *item, char **key, char **val) -{ - char *p, *k, *v; - - p = strchr(item, '='); - if (!p) return; - - k = malloc(p - item + 1); - strncpy(k, item, p - item); - k[p - item] = 0; - *key = k; - p++; - v = strdup(p); - *val = v; -} - static char * _edje_format_parse(const char **s) { @@ -256,14 +289,7 @@ _edje_format_parse(const char **s) return NULL; } -static int -_edje_format_is_param(char *item) -{ - if (strchr(item, '=')) return 1; - return 0; -} - -static char * +static void _edje_format_reparse(Edje_File *edf, const char *str, Edje_Style_Tag *tag_ret, Eina_Strbuf *result) { char *s2, *item; @@ -272,16 +298,18 @@ _edje_format_reparse(Edje_File *edf, const char *str, Edje_Style_Tag *tag_ret, E s = str; while ((item = _edje_format_parse(&s))) { - if (_edje_format_is_param(item)) + const char *pos = strchr(item, '='); + if (pos) { - char *key = NULL, *val = NULL; + size_t key_len = pos - item; + const char *key = item; + const char *val = pos + 1; - _edje_format_param_parse(item, &key, &val); - if (!strcmp(key, "font_source")) + if (!strncmp(key, "font_source", key_len)) { /* dont allow font sources */ } - else if (!strcmp(key, "text_class")) + else if (!strncmp(key, "text_class", key_len)) { if (tag_ret) tag_ret->text_class = eina_stringshare_add(val); @@ -292,12 +320,12 @@ _edje_format_reparse(Edje_File *edf, const char *str, Edje_Style_Tag *tag_ret, E free(item); continue; } - else if (!strcmp(key, "font_size")) + else if (!strncmp(key, "font_size", key_len)) { if (tag_ret) tag_ret->font_size = atof(val); } - else if (!strcmp(key, "font")) /* Fix fonts */ + else if (!strncmp(key, "font", key_len)) /* Fix fonts */ { if (tag_ret) { @@ -346,8 +374,6 @@ _edje_format_reparse(Edje_File *edf, const char *str, Edje_Style_Tag *tag_ret, E eina_strbuf_append(result, s2); free(s2); } - free(key); - free(val); } else { @@ -358,14 +384,16 @@ _edje_format_reparse(Edje_File *edf, const char *str, Edje_Style_Tag *tag_ret, E } } + /* Update the given evas_style * * @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; @@ -378,11 +406,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(); @@ -537,33 +573,17 @@ _edje_textblock_style_update(Edje *ed, Edje_Style *stl, Eina_Bool force) * * @param ed The edje containing styles which need to be updated */ -/*********************************************************************************** - * TIZEN_ONLY_FEATURE: apply Tizen's color_class features. * - *********************************************************************************** void -_edje_textblock_style_all_update(Edje *ed) +_edje_file_textblock_style_all_update(Edje_File *edf) { Eina_List *l; Edje_Style *stl; - if (!ed->file) return; + if (!edf) return; - EINA_LIST_FOREACH(ed->file->styles, l, stl) + EINA_LIST_FOREACH(edf->styles, l, stl) if (stl && !stl->readonly) stl->cache = EINA_FALSE; } - */ -void -_edje_textblock_style_all_update(Edje *ed, Eina_Bool force) -{ - Eina_List *l; - Edje_Style *stl; - - EINA_LIST_FOREACH(ed->styles, l, stl) - _edje_textblock_style_update(ed, stl, force); -} -/******* - * END * - *******/ static inline Edje_Style * _edje_textblock_style_search(Edje *ed, const char *style) @@ -616,7 +636,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 @@ -682,123 +703,107 @@ _edje_textblock_styles_del(Edje *ed, Edje_Part *pt) _edje_textblock_style_del(ed, stl); } + + //tizen only clear the object cache + _edje_object_styles_cache_cleanup(ed); + // end } -/*********************************************************************************** - * TIZEN_ONLY_FEATURE: apply Tizen's color_class features. * - *********************************************************************************** - * Finds all the styles having text class tag as text_class and - * updates them. -void -_edje_textblock_style_all_update_text_class(Edje *ed, const char *text_class) +/* + * returns a evas_textblock style for a given style_string. + * does lazy computation of the evas_textblock_style + * It will compute and cache it if not computed yet and + * will return the final textblock style. + */ +Evas_Textblock_Style * +_edje_textblock_style_get(Edje *ed, const char *style) { - Eina_List *l, *ll; - Edje_Style *stl; + if (!style) return NULL; - if (!ed->file) return; - if (!text_class) return; + Edje_Style *stl = _edje_textblock_style_search(ed, style); - EINA_LIST_FOREACH(ed->file->styles, l, stl) - { - Edje_Style_Tag *tag; + if (!stl) return NULL; - if (stl->readonly) continue; + /* readonly style naver change */ + if (stl->readonly) return stl->style; - EINA_LIST_FOREACH(stl->tags, ll, tag) - { - if (!tag->text_class) continue; + //tizen only object level style feature + /* if style is dirty recompute */ + //if (!stl->cache) + // _edje_textblock_style_update(ed, stl); + //return stl->style; - if (!strcmp(tag->text_class, text_class)) - { - _edje_textblock_style_update(ed, stl, EINA_TRUE); - break; - } - } - } + return _edje_textblock_styles_cache_get(ed, stl); + //end } -*/ +/* + * Finds all the styles having text class tag as text_class and + * updates them. + */ void -_edje_textblock_styles_color_class_cache_free(Edje *ed, const char *class_name) +_edje_file_textblock_style_all_update_text_class(Edje_File *edf, const char *text_class) { Eina_List *l, *ll; Edje_Style *stl; - Edje_Color_Class *cc = NULL, *tag_cc; - - if (!class_name) return; - - cc = _edje_color_class_recursive_find(ed, ed->file, class_name); - if (!cc) - { - ERR("There is no Edje_Color_Class for color_class: %s", class_name); - return; - } + if (!edf) return; + if (!text_class) return; - EINA_LIST_FOREACH(ed->styles, l, stl) + EINA_LIST_FOREACH(edf->styles, l, stl) { Edje_Style_Tag *tag; - Eina_Bool found = EINA_FALSE; - if (!stl->cache) continue; + if (stl->readonly) continue; EINA_LIST_FOREACH(stl->tags, ll, tag) { - if (!tag->color_class) continue; + if (!tag->text_class) continue; - if (tag->color_class) + if (!strcmp(tag->text_class, text_class)) { - tag_cc = _edje_color_class_recursive_find(ed, ed->file, tag->color_class); - if (tag_cc == cc) - { - found = EINA_TRUE; - break; - } - if (tag_cc && cc && !strcmp(tag_cc->name, cc->name)) - { - found = EINA_TRUE; - break; - } + // just mark it dirty so the next request + // for this style will trigger recomputation. + stl->cache = EINA_FALSE; + break; } } - if (found) - stl->cache = EINA_FALSE; } } +/* + * Finds all the styles having text class tag as text_class and + * updates them. + */ void -_edje_textblock_styles_text_class_cache_free(Edje *ed, const char *class_name) +_edje_file_textblock_style_all_update_color_class(Edje_File *edf, const char *color_class) { Eina_List *l, *ll; Edje_Style *stl; - if (!class_name) return; + if (!edf) return; + if (!color_class) return; - EINA_LIST_FOREACH(ed->styles, l, stl) + EINA_LIST_FOREACH(edf->styles, l, stl) { Edje_Style_Tag *tag; - Eina_Bool found = EINA_FALSE; - if (!stl->cache) continue; + if (stl->readonly) continue; EINA_LIST_FOREACH(stl->tags, ll, tag) { - if (!tag->text_class) continue; + if (!tag->color_class) continue; - if (tag->text_class && class_name && - !strcmp(tag->text_class, class_name)) + if (!strcmp(tag->color_class, color_class)) { - found = EINA_TRUE; + // just mark it dirty so the next request + // for this style will trigger recomputation. + stl->cache = EINA_FALSE; break; } } - if (found) - stl->cache = EINA_FALSE; } } -/******* - * END * - *******/ /* When we get to here the edje file had been read into memory * the name of the style is established as well as the name and @@ -807,7 +812,7 @@ _edje_textblock_styles_text_class_cache_free(Edje *ed, const char *class_name) * followed by a list of tags. */ void -_edje_textblock_style_parse_and_fix(Edje_File *edf) +_edje_file_textblock_style_parse_and_fix(Edje_File *edf) { Eina_List *l, *ll; Edje_Style *stl; @@ -879,7 +884,7 @@ _edje_textblock_style_parse_and_fix(Edje_File *edf) } void -_edje_textblock_style_cleanup(Edje_File *edf) +_edje_file_textblock_style_cleanup(Edje_File *edf) { Edje_Style *stl; @@ -918,188 +923,3 @@ _edje_textblock_style_cleanup(Edje_File *edf) } } -/*********************************************************************************** - * TIZEN_ONLY_FEATURE: apply Tizen's color_class features. * - ***********************************************************************************/ -void -_edje_file_textblock_style_all_update(Edje_File *edf) -{ - Eina_List *l, *ll; - Edje_Style *stl; - Eina_Strbuf *txt = NULL; - - if (!edf) return; - - EINA_LIST_FOREACH(edf->styles, l, stl) - { - Edje_Style_Tag *tag; - Edje_Text_Class *tc; - Edje_Color_Class *cc; - int found = 0; - char *fontset = NULL, *fontsource = NULL; - - /* Make sure the style is already defined */ - if (!stl->style) break; - - /* No need to compute it again and again and again */ - if (stl->cache) continue; - - /* Make sure the style contains a text_class */ - EINA_LIST_FOREACH(stl->tags, ll, tag) - { - if (tag->text_class) - { - found = 1; - break; - } - if (tag->color_class) - { - found = 1; - break; - } - } - - /* No text classes or color classes, goto next style */ - if (!found) continue; - if (!txt) - txt = eina_strbuf_new(); - - if (_edje_fontset_append) - fontset = eina_str_escape(_edje_fontset_append); - fontsource = eina_str_escape(edf->path); - - /* Build the style from each tag */ - EINA_LIST_FOREACH(stl->tags, ll, tag) - { - if (!tag->key) continue; - - /* Add Tag Key */ - eina_strbuf_append(txt, tag->key); - eina_strbuf_append(txt, "='"); - - /* Configure fonts from text class if it exists */ - tc = _edje_text_class_find(NULL, tag->text_class); - - /* Configure color from color class if it exists */ - cc = _edje_color_class_recursive_find(NULL, edf, tag->color_class); - - /* Add and Handle tag parsed data */ - eina_strbuf_append(txt, tag->value); - - if (!strcmp(tag->key, "DEFAULT")) - { - if (fontset) - { - eina_strbuf_append(txt, " "); - eina_strbuf_append(txt, "font_fallbacks="); - eina_strbuf_append(txt, fontset); - } - eina_strbuf_append(txt, " "); - eina_strbuf_append(txt, "font_source="); - eina_strbuf_append(txt, fontsource); - } - if (tag->font_size != 0) - { - char font_size[32]; - - if (tc && tc->size) - snprintf(font_size, sizeof(font_size), "%f", - (double)_edje_text_size_calc(tag->font_size, tc)); - else - snprintf(font_size, sizeof(font_size), "%f", - tag->font_size); - - eina_strbuf_append(txt, " "); - eina_strbuf_append(txt, "font_size="); - eina_strbuf_append(txt, font_size); - } - /* Add font name last to save evas from multiple loads */ - if (tag->font) - { - const char *f; - char *sfont = NULL; - - eina_strbuf_append(txt, " "); - eina_strbuf_append(txt, "font="); - - if (tc) f = _edje_text_font_get(tag->font, tc->font, &sfont); - else f = tag->font; - - eina_strbuf_append_escaped(txt, f); - - if (sfont) free(sfont); - } - if (tag->color) - { - eina_strbuf_append(txt, " "); - eina_strbuf_append(txt, "color="); - - if (cc) - { - char *color; - - color = _edje_textblock_color_calc(tag->color, - cc->r, cc->g, cc->b, cc->a); - eina_strbuf_append_escaped(txt, (const char *)color); - if (color) free(color); - } - else - { - eina_strbuf_append_escaped(txt, tag->color); - } - } - if (tag->outline_color) - { - eina_strbuf_append(txt, " "); - eina_strbuf_append(txt, "outline_color="); - - if (cc) - { - char *color; - - color = _edje_textblock_color_calc(tag->outline_color, - cc->r2, cc->g2, cc->b2, cc->a2); - eina_strbuf_append_escaped(txt, (const char *)color); - if (color) free(color); - } - else - { - eina_strbuf_append_escaped(txt, tag->outline_color); - } - } - if (tag->shadow_color) - { - eina_strbuf_append(txt, " "); - eina_strbuf_append(txt, "shadow_color="); - - if (cc) - { - char *color; - - color = _edje_textblock_color_calc(tag->shadow_color, - cc->r3, cc->g3, cc->b3, cc->a3); - eina_strbuf_append_escaped(txt, (const char *)color); - if (color) free(color); - } - else - { - eina_strbuf_append_escaped(txt, tag->shadow_color); - } - } - - eina_strbuf_append(txt, "'"); - } - if (fontset) free(fontset); - if (fontsource) free(fontsource); - - /* Configure the style */ - stl->cache = EINA_TRUE; - evas_textblock_style_set(stl->style, eina_strbuf_string_get(txt)); - eina_strbuf_reset(txt); - } - if (txt) - eina_strbuf_free(txt); -} -/******* - * END * - *******/ diff --git a/src/lib/edje/edje_util.c b/src/lib/edje/edje_util.c index dc2e3fe..ea0f74a 100644 --- a/src/lib/edje/edje_util.c +++ b/src/lib/edje/edje_util.c @@ -85,14 +85,7 @@ _edje_color_class_children_update(Edje *ed, const char *color_class) cc_child_ed->all_part_change = EINA_TRUE; #endif if (color_class) - { - _edje_textblock_styles_color_class_cache_free(cc_child_ed, color_class); - _edje_textblock_style_all_update(cc_child_ed, EINA_FALSE); - } - else - { - _edje_textblock_style_all_update(cc_child_ed, EINA_TRUE); - } + _edje_textblock_style_all_update_color_class(cc_child_ed, color_class); _edje_recalc(cc_child_ed); } @@ -748,8 +741,7 @@ _edje_global_efl_gfx_color_class_color_class_set(Eo *obj EINA_UNUSED, void *pd E */ if ((int_ret) && (need_update)) { - _edje_file_textblock_styles_color_class_cache_free(color_class); - _edje_file_textblock_styles_cache_update(); + _edje_global_textblock_styles_color_class_cache_free(color_class); efl_observable_observers_update(_edje_color_class_member, color_class, "color_class,set"); } @@ -809,8 +801,7 @@ _edje_global_efl_gfx_color_class_color_class_del(Eo *obj EINA_UNUSED, void *pd E /*********************************************************************************** * TIZEN_ONLY_FEATURE: apply Tizen's color_class features. * ***********************************************************************************/ - _edje_file_textblock_styles_color_class_cache_free(color_class); - _edje_file_textblock_styles_cache_update(); + _edje_global_textblock_styles_color_class_cache_free(color_class); /******* * END * *******/ @@ -971,8 +962,7 @@ _efl_canvas_layout_efl_gfx_color_class_color_class_set(Eo *obj EINA_UNUSED, Edje /*********************************************************************************** * TIZEN_ONLY_FEATURE: apply Tizen's color_class features. * ***********************************************************************************/ - _edje_textblock_styles_color_class_cache_free(ed, color_class); - _edje_textblock_style_all_update(ed, EINA_FALSE); + _edje_textblock_style_all_update_color_class(ed, color_class); /******* * END * *******/ @@ -1058,7 +1048,7 @@ _efl_canvas_layout_efl_gfx_color_class_color_class_del(Eo *obj EINA_UNUSED, Edje ***********************************************************************************/ /* _edje_textblock_styles_color_class_cache_free() should be called before * deleting color_class from the hash. */ - _edje_textblock_styles_color_class_cache_free(ed, color_class); + _edje_textblock_style_all_update_color_class(ed, color_class); /******* * END * *******/ @@ -1083,14 +1073,6 @@ _efl_canvas_layout_efl_gfx_color_class_color_class_del(Eo *obj EINA_UNUSED, Edje ed->all_part_change = EINA_TRUE; #endif - /*********************************************************************************** - * TIZEN_ONLY_FEATURE: apply Tizen's color_class features. * - ***********************************************************************************/ - _edje_textblock_style_all_update(ed, EINA_FALSE); - /******* - * END * - *******/ - _edje_recalc(ed); _edje_emit(ed, "color_class,del", color_class); @@ -1147,7 +1129,8 @@ _efl_canvas_layout_efl_gfx_color_class_color_class_clear(Eo *obj EINA_UNUSED, Ed /*********************************************************************************** * TIZEN_ONLY_FEATURE: apply Tizen's color_class features. * ***********************************************************************************/ - _edje_textblock_style_all_update(ed, EINA_TRUE); + //@TODO do we need it here ?? + _edje_textblock_style_all_update(ed); /******* * END * *******/ @@ -1291,8 +1274,7 @@ _edje_global_efl_gfx_text_class_text_class_set(Eo *obj EINA_UNUSED, void *pd EIN /*********************************************************************************** * TIZEN_ONLY_FEATURE: apply Tizen's color_class features. * ***********************************************************************************/ - _edje_file_textblock_styles_text_class_cache_free(text_class); - _edje_file_textblock_styles_cache_update(); + _edje_global_textblock_styles_text_class_cache_free(text_class); /******* * END * *******/ @@ -1358,8 +1340,7 @@ _edje_global_efl_gfx_text_class_text_class_del(Eo *obj EINA_UNUSED, void *pd EIN /*********************************************************************************** * TIZEN_ONLY_FEATURE: apply Tizen's color_class features. * ***********************************************************************************/ - _edje_file_textblock_styles_text_class_cache_free(text_class); - _edje_file_textblock_styles_cache_update(); + _edje_global_textblock_styles_text_class_cache_free(text_class); /******* * END * *******/ @@ -7325,7 +7306,8 @@ _efl_canvas_layout_color_class_parent_set(Eo *obj, Edje *ed, Efl_Object *parent) #ifdef EDJE_CALC_CACHE ed->all_part_change = EINA_TRUE; #endif - _edje_textblock_style_all_update(ed, EINA_TRUE); + //@TODO do we need it here ?? + _edje_textblock_style_all_update(ed); _edje_recalc(ed); } @@ -7341,7 +7323,7 @@ _efl_canvas_layout_color_class_parent_unset(Eo *obj, Edje *ed) #ifdef EDJE_CALC_CACHE ed->all_part_change = EINA_TRUE; #endif - _edje_textblock_style_all_update(ed, EINA_TRUE); + _edje_textblock_style_all_update(ed); _edje_recalc(ed); } /******* -- 2.7.4