diff options
author | Jean-Philippe Andre <jp.andre@samsung.com> | 2015-06-16 21:05:06 +0900 |
---|---|---|
committer | Jean-Philippe Andre <jp.andre@samsung.com> | 2015-06-25 14:36:09 +0900 |
commit | 707b979ffdd25d63990c2b9c740b7331e0f94a4a (patch) | |
tree | 0cb1c284cb036e3a216cfb091c62f20cb5401ebb /src | |
parent | d00378edcf08deb6a34eeb9833a4d521ed6cca27 (diff) |
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
Diffstat (limited to 'src')
-rw-r--r-- | src/bin/edje/edje_cc_handlers.c | 5 | ||||
-rw-r--r-- | src/lib/edje/edje_load.c | 6 | ||||
-rw-r--r-- | src/lib/edje/edje_private.h | 2 | ||||
-rw-r--r-- | 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 53bf91e758..403b210f7f 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) | |||
9007 | @property | 9007 | @property |
9008 | filter.code | 9008 | filter.code |
9009 | @parameters | 9009 | @parameters |
9010 | [filter program as a string] | 9010 | [filter program] OR [data name] |
9011 | @effect | 9011 | @effect |
9012 | Applies a series of image filters to a TEXT or IMAGE part. The argument | 9012 | Applies a series of image filters to a TEXT or IMAGE part. The argument |
9013 | to this field is the source code of a Lua program invoking various | 9013 | to this field is the source code of a Lua program invoking various |
9014 | filter operations. For more information, please refer to the page | 9014 | filter operations. For more information, please refer to the page |
9015 | "Evas filters reference". | 9015 | "Evas filters reference". |
9016 | The parameter can also be a parameter name as specified in the | ||
9017 | data section (item or file property). This means external filter files | ||
9018 | can be easily embedded in an edje file. | ||
9016 | @see evasfiltersref | 9019 | @see evasfiltersref |
9017 | @endproperty | 9020 | @endproperty |
9018 | */ | 9021 | */ |
diff --git a/src/lib/edje/edje_load.c b/src/lib/edje/edje_load.c index 9708dd6592..b4533e70d8 100644 --- a/src/lib/edje/edje_load.c +++ b/src/lib/edje/edje_load.c | |||
@@ -1505,7 +1505,8 @@ _edje_file_del(Edje *ed) | |||
1505 | eina_stringshare_del(rp->typedata.text->font); | 1505 | eina_stringshare_del(rp->typedata.text->font); |
1506 | eina_stringshare_del(rp->typedata.text->cache.in_str); | 1506 | eina_stringshare_del(rp->typedata.text->cache.in_str); |
1507 | eina_stringshare_del(rp->typedata.text->cache.out_str); | 1507 | eina_stringshare_del(rp->typedata.text->cache.out_str); |
1508 | eina_stringshare_del(rp->typedata.text->filter.code); | 1508 | if (!rp->typedata.text->filter.no_free) |
1509 | eina_stringshare_del(rp->typedata.text->filter.code); | ||
1509 | free(rp->typedata.text); | 1510 | free(rp->typedata.text); |
1510 | } | 1511 | } |
1511 | else if ((rp->type == EDJE_RP_TYPE_SWALLOW) && | 1512 | else if ((rp->type == EDJE_RP_TYPE_SWALLOW) && |
@@ -1929,7 +1930,8 @@ _edje_collection_free_part_description_clean(int type, Edje_Part_Description_Com | |||
1929 | eina_stringshare_del(text->text.text_class); | 1930 | eina_stringshare_del(text->text.text_class); |
1930 | eina_stringshare_del(text->text.style.str); | 1931 | eina_stringshare_del(text->text.style.str); |
1931 | eina_stringshare_del(text->text.font.str); | 1932 | eina_stringshare_del(text->text.font.str); |
1932 | eina_stringshare_del(text->text.filter.code); | 1933 | if (!text->text.filter.no_free) |
1934 | eina_stringshare_del(text->text.filter.code); | ||
1933 | } | 1935 | } |
1934 | break; | 1936 | break; |
1935 | } | 1937 | } |
diff --git a/src/lib/edje/edje_private.h b/src/lib/edje/edje_private.h index 8aec84a227..7744f08a45 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 | |||
1282 | { | 1282 | { |
1283 | const char *code; | 1283 | const char *code; |
1284 | Eina_List *sources; /* "part" or "buffer:part" */ | 1284 | Eina_List *sources; /* "part" or "buffer:part" */ |
1285 | Eina_Bool checked_data : 1; // checked whether this is a data item or embedded string | ||
1286 | Eina_Bool no_free : 1; | ||
1285 | }; | 1287 | }; |
1286 | 1288 | ||
1287 | struct _Edje_Part_Description_Spec_Image | 1289 | struct _Edje_Part_Description_Spec_Image |
diff --git a/src/lib/edje/edje_text.c b/src/lib/edje/edje_text.c index 8ee579e34a..5e2743bcfb 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 | |||
193 | return font; | 193 | return font; |
194 | } | 194 | } |
195 | 195 | ||
196 | static inline const char * | ||
197 | _edje_filter_get(Edje *ed, Edje_Part_Description_Spec_Filter *filter) | ||
198 | { | ||
199 | if (EINA_UNLIKELY(!filter->checked_data)) | ||
200 | { | ||
201 | Edje_String *st; | ||
202 | filter->checked_data = 1; | ||
203 | st = eina_hash_find(ed->file->data, filter->code); | ||
204 | if (st) | ||
205 | { | ||
206 | eina_stringshare_del(filter->code); | ||
207 | filter->code = st->str; | ||
208 | filter->no_free = 1; | ||
209 | } | ||
210 | } | ||
211 | return filter->code; | ||
212 | } | ||
213 | |||
196 | void | 214 | void |
197 | _edje_text_recalc_apply(Edje *ed, Edje_Real_Part *ep, | 215 | _edje_text_recalc_apply(Edje *ed, Edje_Real_Part *ep, |
198 | Edje_Calc_Params *params, | 216 | Edje_Calc_Params *params, |
@@ -228,12 +246,15 @@ _edje_text_recalc_apply(Edje *ed, Edje_Real_Part *ep, | |||
228 | if (!text) | 246 | if (!text) |
229 | text = edje_string_get(&chosen_desc->text.text); | 247 | text = edje_string_get(&chosen_desc->text.text); |
230 | font = _edje_text_class_font_get(ed, chosen_desc, &size, &sfont); | 248 | font = _edje_text_class_font_get(ed, chosen_desc, &size, &sfont); |
231 | filter = chosen_desc->text.filter.code; | ||
232 | 249 | ||
233 | if (ep->typedata.text->text) text = ep->typedata.text->text; | 250 | if (ep->typedata.text->text) text = ep->typedata.text->text; |
234 | if (ep->typedata.text->font) font = ep->typedata.text->font; | 251 | if (ep->typedata.text->font) font = ep->typedata.text->font; |
235 | if (ep->typedata.text->size > 0) size = ep->typedata.text->size; | 252 | if (ep->typedata.text->size > 0) size = ep->typedata.text->size; |
236 | if (ep->typedata.text->filter.code) filter = ep->typedata.text->filter.code; | 253 | |
254 | if (ep->typedata.text->filter.code) | ||
255 | filter = _edje_filter_get(ed, &ep->typedata.text->filter); | ||
256 | else | ||
257 | filter = _edje_filter_get(ed, &chosen_desc->text.filter); | ||
237 | if (ep->typedata.text->filter.sources != chosen_desc->text.filter.sources) | 258 | if (ep->typedata.text->filter.sources != chosen_desc->text.filter.sources) |
238 | { | 259 | { |
239 | prev_sources = ep->typedata.text->filter.sources; | 260 | prev_sources = ep->typedata.text->filter.sources; |