summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2015-06-19 17:38:28 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2015-06-25 14:36:09 +0900
commit84e3dd5c34f3ee7a8f07311eab6c950d1c76ea51 (patch)
tree5541d3fced9648bb2380002d0d6b5ba5477fd8e5 /src
parent29402b2ce965c83cdcbfa29ac08b918ab01d95d2 (diff)
Evas filters: Add name to the filters
Deep down internally there was already a name, but no API could really set it properly. Here Edje will set the name of the filter based on the part name or the data item name if relevant.
Diffstat (limited to 'src')
-rw-r--r--src/lib/edje/edje_calc.c12
-rw-r--r--src/lib/edje/edje_load.c2
-rw-r--r--src/lib/edje/edje_private.h1
-rw-r--r--src/lib/efl/interfaces/efl_gfx_filter.eo1
-rw-r--r--src/lib/evas/canvas/evas_filter_mixin.c19
-rw-r--r--src/lib/evas/canvas/evas_object_image.c11
-rw-r--r--src/lib/evas/canvas/evas_object_main.c2
-rw-r--r--src/lib/evas/canvas/evas_object_text.c11
-rw-r--r--src/lib/evas/include/evas_private.h1
-rw-r--r--src/tests/evas/evas_test_filters.c6
10 files changed, 37 insertions, 29 deletions
diff --git a/src/lib/edje/edje_calc.c b/src/lib/edje/edje_calc.c
index a1cd9c1..48a4d81 100644
--- a/src/lib/edje/edje_calc.c
+++ b/src/lib/edje/edje_calc.c
@@ -2404,7 +2404,7 @@ _edje_part_recalc_single_map(Edje *ed,
2404} 2404}
2405 2405
2406static inline const char * 2406static inline const char *
2407_edje_filter_get(Edje *ed, Edje_Part_Description_Spec_Filter *filter) 2407_edje_filter_get(Edje *ed, Edje_Real_Part *ep, Edje_Part_Description_Spec_Filter *filter)
2408{ 2408{
2409 if (!filter->code) return NULL; 2409 if (!filter->code) return NULL;
2410 if (EINA_UNLIKELY(!filter->checked_data)) 2410 if (EINA_UNLIKELY(!filter->checked_data))
@@ -2414,10 +2414,12 @@ _edje_filter_get(Edje *ed, Edje_Part_Description_Spec_Filter *filter)
2414 st = eina_hash_find(ed->file->data, filter->code); 2414 st = eina_hash_find(ed->file->data, filter->code);
2415 if (st) 2415 if (st)
2416 { 2416 {
2417 eina_stringshare_del(filter->code); 2417 filter->name = filter->code;
2418 filter->code = st->str; 2418 filter->code = st->str;
2419 filter->no_free = 1; 2419 filter->no_free = 1;
2420 } 2420 }
2421 else
2422 filter->name = eina_stringshare_add(ep->part->name);
2421 } 2423 }
2422 return filter->code; 2424 return filter->code;
2423} 2425}
@@ -2465,15 +2467,15 @@ _edje_part_recalc_single_filter(Edje *ed,
2465 } 2467 }
2466 2468
2467 /* common code below */ 2469 /* common code below */
2468 code = _edje_filter_get(ed, filter); 2470 code = _edje_filter_get(ed, ep, filter);
2469 if (!code) 2471 if (!code)
2470 { 2472 {
2471 eo_do(obj, efl_gfx_filter_program_set(NULL)); 2473 eo_do(obj, efl_gfx_filter_program_set(NULL, NULL));
2472 return; 2474 return;
2473 } 2475 }
2474 2476
2475 eo_do(obj, 2477 eo_do(obj,
2476 efl_gfx_filter_program_set(code); 2478 efl_gfx_filter_program_set(code, filter->name);
2477 if (prev_sources != filter_sources) 2479 if (prev_sources != filter_sources)
2478 { 2480 {
2479 /* remove sources that are not there anymore 2481 /* remove sources that are not there anymore
diff --git a/src/lib/edje/edje_load.c b/src/lib/edje/edje_load.c
index b4533e7..a261c2f 100644
--- a/src/lib/edje/edje_load.c
+++ b/src/lib/edje/edje_load.c
@@ -1507,6 +1507,7 @@ _edje_file_del(Edje *ed)
1507 eina_stringshare_del(rp->typedata.text->cache.out_str); 1507 eina_stringshare_del(rp->typedata.text->cache.out_str);
1508 if (!rp->typedata.text->filter.no_free) 1508 if (!rp->typedata.text->filter.no_free)
1509 eina_stringshare_del(rp->typedata.text->filter.code); 1509 eina_stringshare_del(rp->typedata.text->filter.code);
1510 eina_stringshare_del(rp->typedata.text->filter.name);
1510 free(rp->typedata.text); 1511 free(rp->typedata.text);
1511 } 1512 }
1512 else if ((rp->type == EDJE_RP_TYPE_SWALLOW) && 1513 else if ((rp->type == EDJE_RP_TYPE_SWALLOW) &&
@@ -1932,6 +1933,7 @@ _edje_collection_free_part_description_clean(int type, Edje_Part_Description_Com
1932 eina_stringshare_del(text->text.font.str); 1933 eina_stringshare_del(text->text.font.str);
1933 if (!text->text.filter.no_free) 1934 if (!text->text.filter.no_free)
1934 eina_stringshare_del(text->text.filter.code); 1935 eina_stringshare_del(text->text.filter.code);
1936 eina_stringshare_del(text->text.filter.name);
1935 } 1937 }
1936 break; 1938 break;
1937 } 1939 }
diff --git a/src/lib/edje/edje_private.h b/src/lib/edje/edje_private.h
index d8c0411..fcc463c 100644
--- a/src/lib/edje/edje_private.h
+++ b/src/lib/edje/edje_private.h
@@ -1281,6 +1281,7 @@ struct _Edje_Part_Description_Spec_Border
1281struct _Edje_Part_Description_Spec_Filter 1281struct _Edje_Part_Description_Spec_Filter
1282{ 1282{
1283 const char *code; 1283 const char *code;
1284 const char *name;
1284 Eina_List *sources; /* "part" or "buffer:part" */ 1285 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 checked_data : 1; // checked whether this is a data item or embedded string
1286 Eina_Bool no_free : 1; 1287 Eina_Bool no_free : 1;
diff --git a/src/lib/efl/interfaces/efl_gfx_filter.eo b/src/lib/efl/interfaces/efl_gfx_filter.eo
index baa6046..ed8bedc 100644
--- a/src/lib/efl/interfaces/efl_gfx_filter.eo
+++ b/src/lib/efl/interfaces/efl_gfx_filter.eo
@@ -24,6 +24,7 @@ interface Efl.Gfx.Filter
24 } 24 }
25 values { 25 values {
26 code: const(char)*; [[filter program source code]] 26 code: const(char)*; [[filter program source code]]
27 name: const(char)*(0); [[filter name (optional)]]
27 } 28 }
28 } 29 }
29 @property state { 30 @property state {
diff --git a/src/lib/evas/canvas/evas_filter_mixin.c b/src/lib/evas/canvas/evas_filter_mixin.c
index 243b359..87454a7 100644
--- a/src/lib/evas/canvas/evas_filter_mixin.c
+++ b/src/lib/evas/canvas/evas_filter_mixin.c
@@ -121,7 +121,7 @@ evas_filter_object_render(Eo *eo_obj, Evas_Object_Protected_Data *obj,
121 if (!fcow->chain) 121 if (!fcow->chain)
122 { 122 {
123 Evas_Filter_Program *pgm; 123 Evas_Filter_Program *pgm;
124 pgm = evas_filter_program_new(obj->name ? obj->name : obj->type, alpha); 124 pgm = evas_filter_program_new(fcow->name, alpha);
125 evas_filter_program_source_set_all(pgm, fcow->sources); 125 evas_filter_program_source_set_all(pgm, fcow->sources);
126 evas_filter_program_state_set(pgm, eo_obj, obj, 126 evas_filter_program_state_set(pgm, eo_obj, obj,
127 fcow->state.cur.name, fcow->state.cur.value, 127 fcow->state.cur.name, fcow->state.cur.value,
@@ -252,25 +252,27 @@ evas_filter_object_render(Eo *eo_obj, Evas_Object_Protected_Data *obj,
252 252
253EOLIAN void 253EOLIAN void
254_evas_filter_efl_gfx_filter_program_set(Eo *eo_obj, Evas_Filter_Data *pd, 254_evas_filter_efl_gfx_filter_program_set(Eo *eo_obj, Evas_Filter_Data *pd,
255 const char *code) 255 const char *code, const char *name)
256{ 256{
257 Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJECT_CLASS); 257 Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJECT_CLASS);
258 Evas_Filter_Program *pgm = NULL; 258 Evas_Filter_Program *pgm = NULL;
259 Eina_Bool alpha; 259 Eina_Bool alpha;
260 260
261 if (!pd) return; 261 if (!pd) return;
262 if (pd->data->code == code) return; 262 if ((pd->data->code == code) && (!name || (pd->data->name == name))) return;
263 if (pd->data->code && code && !strcmp(code, pd->data->code)) return; 263 if (pd->data->code && code && !strcmp(code, pd->data->code) &&
264 pd->data->name && name && !strcmp(name, pd->data->name)) return;
264 265
265 evas_object_async_block(obj); 266 evas_object_async_block(obj);
266 EINA_COW_WRITE_BEGIN(evas_object_filter_cow, pd->data, Evas_Object_Filter_Data, fcow) 267 EINA_COW_WRITE_BEGIN(evas_object_filter_cow, pd->data, Evas_Object_Filter_Data, fcow)
267 { 268 {
268 // Parse filter program 269 // Parse filter program
269 evas_filter_program_del(fcow->chain); 270 evas_filter_program_del(fcow->chain);
271 eina_stringshare_replace(&fcow->name, name);
270 if (code) 272 if (code)
271 { 273 {
272 alpha = eo_do_ret(eo_obj, alpha, evas_filter_input_alpha()); 274 alpha = eo_do_ret(eo_obj, alpha, evas_filter_input_alpha());
273 pgm = evas_filter_program_new("Evas.Filter", alpha); 275 pgm = evas_filter_program_new(fcow->name, alpha);
274 evas_filter_program_source_set_all(pgm, fcow->sources); 276 evas_filter_program_source_set_all(pgm, fcow->sources);
275 evas_filter_program_state_set(pgm, eo_obj, obj, 277 evas_filter_program_state_set(pgm, eo_obj, obj,
276 fcow->state.cur.name, fcow->state.cur.value, 278 fcow->state.cur.name, fcow->state.cur.value,
@@ -298,10 +300,11 @@ _evas_filter_efl_gfx_filter_program_set(Eo *eo_obj, Evas_Filter_Data *pd,
298 evas_object_inform_call_resize(eo_obj); 300 evas_object_inform_call_resize(eo_obj);
299} 301}
300 302
301EOLIAN const char * 303EOLIAN void
302_evas_filter_efl_gfx_filter_program_get(Eo *eo_obj EINA_UNUSED, Evas_Filter_Data *pd) 304_evas_filter_efl_gfx_filter_program_get(Eo *eo_obj EINA_UNUSED, Evas_Filter_Data *pd, const char **code, const char **name)
303{ 305{
304 return pd->data->code; 306 if (code) *code = pd->data->code;
307 if (name) *name = pd->data->name;
305} 308}
306 309
307EOLIAN void 310EOLIAN void
diff --git a/src/lib/evas/canvas/evas_object_image.c b/src/lib/evas/canvas/evas_object_image.c
index 7532c4a..7fa102f 100644
--- a/src/lib/evas/canvas/evas_object_image.c
+++ b/src/lib/evas/canvas/evas_object_image.c
@@ -4729,17 +4729,16 @@ evas_object_image_smooth_scale_get(const Eo *obj)
4729} 4729}
4730 4730
4731EOLIAN void 4731EOLIAN void
4732_evas_image_efl_gfx_filter_program_set(Eo *obj, Evas_Image_Data *pd EINA_UNUSED, const char *code) 4732_evas_image_efl_gfx_filter_program_set(Eo *obj, Evas_Image_Data *pd EINA_UNUSED, const char *code, const char *name)
4733{ 4733{
4734 pd->has_filter = (code != NULL); 4734 pd->has_filter = (code != NULL);
4735 eo_do_super(obj, MY_CLASS, efl_gfx_filter_program_set(code)); 4735 eo_do_super(obj, MY_CLASS, efl_gfx_filter_program_set(code, name));
4736} 4736}
4737 4737
4738EOLIAN const char * 4738EOLIAN void
4739_evas_image_efl_gfx_filter_program_get(Eo *obj, Evas_Image_Data *pd EINA_UNUSED) 4739_evas_image_efl_gfx_filter_program_get(Eo *obj, Evas_Image_Data *pd EINA_UNUSED, const char **code, const char **name)
4740{ 4740{
4741 const char *code; 4741 eo_do_super(obj, MY_CLASS, efl_gfx_filter_program_get(code, name));
4742 return eo_do_super_ret(obj, MY_CLASS, code, efl_gfx_filter_program_get());
4743} 4742}
4744 4743
4745EOLIAN void 4744EOLIAN void
diff --git a/src/lib/evas/canvas/evas_object_main.c b/src/lib/evas/canvas/evas_object_main.c
index 9552a44..8330f2e 100644
--- a/src/lib/evas/canvas/evas_object_main.c
+++ b/src/lib/evas/canvas/evas_object_main.c
@@ -33,7 +33,7 @@ static const Evas_Object_Protected_State default_state = {
33 1.0, 0, EVAS_RENDER_BLEND, EINA_FALSE, EINA_FALSE, EINA_FALSE, EINA_FALSE, EINA_FALSE, EINA_FALSE 33 1.0, 0, EVAS_RENDER_BLEND, EINA_FALSE, EINA_FALSE, EINA_FALSE, EINA_FALSE, EINA_FALSE, EINA_FALSE
34}; 34};
35static const Evas_Object_Filter_Data default_filter = { 35static const Evas_Object_Filter_Data default_filter = {
36 NULL, NULL, NULL, NULL, { { "default", 0.0 }, { "default", 0.0 }, 0.0 }, EINA_FALSE, EINA_FALSE 36 NULL, NULL, NULL, NULL, NULL, { { "default", 0.0 }, { "default", 0.0 }, 0.0 }, EINA_FALSE, EINA_FALSE
37}; 37};
38const void * const evas_object_filter_cow_default = &default_filter; 38const void * const evas_object_filter_cow_default = &default_filter;
39static const Evas_Object_Mask_Data default_mask = { 39static const Evas_Object_Mask_Data default_mask = {
diff --git a/src/lib/evas/canvas/evas_object_text.c b/src/lib/evas/canvas/evas_object_text.c
index 899b625..89f2523 100644
--- a/src/lib/evas/canvas/evas_object_text.c
+++ b/src/lib/evas/canvas/evas_object_text.c
@@ -2227,17 +2227,16 @@ evas_object_text_text_get(const Eo *obj)
2227} 2227}
2228 2228
2229EOLIAN void 2229EOLIAN void
2230_evas_text_efl_gfx_filter_program_set(Eo *obj, Evas_Text_Data *pd EINA_UNUSED, const char *code) 2230_evas_text_efl_gfx_filter_program_set(Eo *obj, Evas_Text_Data *pd EINA_UNUSED, const char *code, const char *name)
2231{ 2231{
2232 pd->has_filter = (code != NULL); 2232 pd->has_filter = (code != NULL);
2233 eo_do_super(obj, MY_CLASS, efl_gfx_filter_program_set(code)); 2233 eo_do_super(obj, MY_CLASS, efl_gfx_filter_program_set(code, name));
2234} 2234}
2235 2235
2236EOLIAN const char * 2236EOLIAN void
2237_evas_text_efl_gfx_filter_program_get(Eo *obj, Evas_Text_Data *pd EINA_UNUSED) 2237_evas_text_efl_gfx_filter_program_get(Eo *obj, Evas_Text_Data *pd EINA_UNUSED, const char **code, const char **name)
2238{ 2238{
2239 const char *code; 2239 eo_do_super(obj, MY_CLASS, efl_gfx_filter_program_get(code, name));
2240 return eo_do_super_ret(obj, MY_CLASS, code, efl_gfx_filter_program_get());
2241} 2240}
2242 2241
2243EOLIAN void 2242EOLIAN void
diff --git a/src/lib/evas/include/evas_private.h b/src/lib/evas/include/evas_private.h
index 33bfcd4..925aa52 100644
--- a/src/lib/evas/include/evas_private.h
+++ b/src/lib/evas/include/evas_private.h
@@ -1174,6 +1174,7 @@ struct _Evas_Device
1174 1174
1175struct _Evas_Object_Filter_Data 1175struct _Evas_Object_Filter_Data
1176{ 1176{
1177 Eina_Stringshare *name;
1177 Eina_Stringshare *code; 1178 Eina_Stringshare *code;
1178 Evas_Filter_Program *chain; 1179 Evas_Filter_Program *chain;
1179 Eina_Hash *sources; // Evas_Filter_Proxy_Binding 1180 Eina_Hash *sources; // Evas_Filter_Proxy_Binding
diff --git a/src/tests/evas/evas_test_filters.c b/src/tests/evas/evas_test_filters.c
index ac40d05..2758940 100644
--- a/src/tests/evas/evas_test_filters.c
+++ b/src/tests/evas/evas_test_filters.c
@@ -311,7 +311,7 @@ START_TEST(evas_filter_text_padding_test)
311 // Don't test proxy cases here. 311 // Don't test proxy cases here.
312 if (tc->source) continue; 312 if (tc->source) continue;
313 313
314 eo_do(to, efl_gfx_filter_program_set(tc->code)); 314 eo_do(to, efl_gfx_filter_program_set(tc->code, "evas_test_filter"));
315 evas_object_text_style_pad_get(to, &l, &r, &t, &b); 315 evas_object_text_style_pad_get(to, &l, &r, &t, &b);
316 evas_object_geometry_get(to, NULL, NULL, &W, &H); 316 evas_object_geometry_get(to, NULL, NULL, &W, &H);
317 //fprintf(stderr, "Case %d: %dx%d for padding %d,%d,%d,%d\n", k, W, H, l, r, t, b); 317 //fprintf(stderr, "Case %d: %dx%d for padding %d,%d,%d,%d\n", k, W, H, l, r, t, b);
@@ -400,13 +400,13 @@ START_TEST(evas_filter_text_render_test)
400 eo_do(to, 400 eo_do(to,
401 efl_gfx_color_set(255, 255, 255, 255), 401 efl_gfx_color_set(255, 255, 255, 255),
402 efl_gfx_filter_source_set(tc->source, o), 402 efl_gfx_filter_source_set(tc->source, o),
403 efl_gfx_filter_program_set(tc->code)); 403 efl_gfx_filter_program_set(tc->code, , "evas_test_filter"));
404 } 404 }
405 else 405 else
406 { 406 {
407 eo_do(to, 407 eo_do(to,
408 efl_gfx_color_set(255, 255, 255, 255), 408 efl_gfx_color_set(255, 255, 255, 255),
409 efl_gfx_filter_program_set(tc->code)); 409 efl_gfx_filter_program_set(tc->code, , "evas_test_filter"));
410 } 410 }
411 411
412 evas_object_geometry_get(to, NULL, NULL, &w, &h); 412 evas_object_geometry_get(to, NULL, NULL, &w, &h);