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
This commit is contained in:
Jean-Philippe Andre 2015-06-16 21:05:06 +09:00
parent d00378edcf
commit 707b979ffd
4 changed files with 33 additions and 5 deletions

View File

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

View File

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

View File

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

View File

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