jpeg pushed a commit to branch master. http://git.enlightenment.org/core/efl.git/commit/?id=707b979ffdd25d63990c2b9c740b7331e0f94a4a
commit 707b979ffdd25d63990c2b9c740b7331e0f94a4a Author: Jean-Philippe Andre <jp.an...@samsung.com> Date: Tue Jun 16 21:05:06 2015 +0900 Edje/evas filters: Use EDJ data sections to store filters code Use the file data {item, file} block to embed filters code. It can become especially useful to keep the filters as separated Lua files, that will be embedded in the final edj file. @feature --- src/bin/edje/edje_cc_handlers.c | 5 ++++- src/lib/edje/edje_load.c | 6 ++++-- src/lib/edje/edje_private.h | 2 ++ src/lib/edje/edje_text.c | 25 +++++++++++++++++++++++-- 4 files changed, 33 insertions(+), 5 deletions(-) diff --git a/src/bin/edje/edje_cc_handlers.c b/src/bin/edje/edje_cc_handlers.c index 53bf91e..403b210 100644 --- a/src/bin/edje/edje_cc_handlers.c +++ b/src/bin/edje/edje_cc_handlers.c @@ -9007,12 +9007,15 @@ st_collections_group_parts_part_description_text_ellipsis(void) @property filter.code @parameters - [filter program as a string] + [filter program] OR [data name] @effect Applies a series of image filters to a TEXT or IMAGE part. The argument to this field is the source code of a Lua program invoking various filter operations. For more information, please refer to the page "Evas filters reference". + The parameter can also be a parameter name as specified in the + data section (item or file property). This means external filter files + can be easily embedded in an edje file. @see evasfiltersref @endproperty */ diff --git a/src/lib/edje/edje_load.c b/src/lib/edje/edje_load.c index 9708dd6..b4533e7 100644 --- a/src/lib/edje/edje_load.c +++ b/src/lib/edje/edje_load.c @@ -1505,7 +1505,8 @@ _edje_file_del(Edje *ed) eina_stringshare_del(rp->typedata.text->font); eina_stringshare_del(rp->typedata.text->cache.in_str); eina_stringshare_del(rp->typedata.text->cache.out_str); - eina_stringshare_del(rp->typedata.text->filter.code); + if (!rp->typedata.text->filter.no_free) + eina_stringshare_del(rp->typedata.text->filter.code); free(rp->typedata.text); } else if ((rp->type == EDJE_RP_TYPE_SWALLOW) && @@ -1929,7 +1930,8 @@ _edje_collection_free_part_description_clean(int type, Edje_Part_Description_Com eina_stringshare_del(text->text.text_class); eina_stringshare_del(text->text.style.str); eina_stringshare_del(text->text.font.str); - eina_stringshare_del(text->text.filter.code); + if (!text->text.filter.no_free) + eina_stringshare_del(text->text.filter.code); } break; } diff --git a/src/lib/edje/edje_private.h b/src/lib/edje/edje_private.h index 8aec84a..7744f08 100644 --- a/src/lib/edje/edje_private.h +++ b/src/lib/edje/edje_private.h @@ -1282,6 +1282,8 @@ struct _Edje_Part_Description_Spec_Filter { const char *code; Eina_List *sources; /* "part" or "buffer:part" */ + Eina_Bool checked_data : 1; // checked whether this is a data item or embedded string + Eina_Bool no_free : 1; }; struct _Edje_Part_Description_Spec_Image diff --git a/src/lib/edje/edje_text.c b/src/lib/edje/edje_text.c index 8ee579e..5e2743b 100644 --- a/src/lib/edje/edje_text.c +++ b/src/lib/edje/edje_text.c @@ -193,6 +193,24 @@ _edje_text_class_font_get(Edje *ed, Edje_Part_Description_Text *chosen_desc, int return font; } +static inline const char * +_edje_filter_get(Edje *ed, Edje_Part_Description_Spec_Filter *filter) +{ + if (EINA_UNLIKELY(!filter->checked_data)) + { + Edje_String *st; + filter->checked_data = 1; + st = eina_hash_find(ed->file->data, filter->code); + if (st) + { + eina_stringshare_del(filter->code); + filter->code = st->str; + filter->no_free = 1; + } + } + return filter->code; +} + void _edje_text_recalc_apply(Edje *ed, Edje_Real_Part *ep, Edje_Calc_Params *params, @@ -228,12 +246,15 @@ _edje_text_recalc_apply(Edje *ed, Edje_Real_Part *ep, if (!text) text = edje_string_get(&chosen_desc->text.text); font = _edje_text_class_font_get(ed, chosen_desc, &size, &sfont); - filter = chosen_desc->text.filter.code; if (ep->typedata.text->text) text = ep->typedata.text->text; if (ep->typedata.text->font) font = ep->typedata.text->font; if (ep->typedata.text->size > 0) size = ep->typedata.text->size; - if (ep->typedata.text->filter.code) filter = ep->typedata.text->filter.code; + + if (ep->typedata.text->filter.code) + filter = _edje_filter_get(ed, &ep->typedata.text->filter); + else + filter = _edje_filter_get(ed, &chosen_desc->text.filter); if (ep->typedata.text->filter.sources != chosen_desc->text.filter.sources) { prev_sources = ep->typedata.text->filter.sources; --