summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2015-06-23 16:40:51 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2015-06-25 14:36:09 +0900
commitd15308efef24d3e23860a6888b9f321dedb025cc (patch)
tree636e983de69e5ec4aff37a02fe465a6ce04443c6
parentf4825006b0994074dacd594b3d239305b4e7963e (diff)
Evas filters: Add explicit exec flag in data_set
This flag should be set iif the string passed is to be executed rather than assigned. This is used to pass complex arguments as data, like tables (eg. color class).
-rw-r--r--src/lib/edje/edje_calc.c8
-rw-r--r--src/lib/efl/interfaces/efl_gfx_filter.eo5
-rw-r--r--src/lib/evas/canvas/evas_filter_mixin.c51
-rw-r--r--src/lib/evas/filters/evas_filter_parser.c25
-rw-r--r--src/lib/evas/include/evas_filter.h10
-rw-r--r--src/lib/evas/include/evas_private.h3
6 files changed, 67 insertions, 35 deletions
diff --git a/src/lib/edje/edje_calc.c b/src/lib/edje/edje_calc.c
index f06a6374ea..adeef5ce64 100644
--- a/src/lib/edje/edje_calc.c
+++ b/src/lib/edje/edje_calc.c
@@ -2486,7 +2486,7 @@ _edje_part_recalc_single_filter(Edje *ed,
2486 char *value = tup->data; 2486 char *value = tup->data;
2487 if (!value) 2487 if (!value)
2488 { 2488 {
2489 efl_gfx_filter_data_set(name, NULL); 2489 efl_gfx_filter_data_set(name, NULL, EINA_FALSE);
2490 } 2490 }
2491 else if (!strncmp(value, "color_class('", sizeof("color_class('") - 1)) 2491 else if (!strncmp(value, "color_class('", sizeof("color_class('") - 1))
2492 { 2492 {
@@ -2504,7 +2504,7 @@ _edje_part_recalc_single_filter(Edje *ed,
2504 cc = _edje_color_class_find(ed, ccname); 2504 cc = _edje_color_class_find(ed, ccname);
2505 if (cc) 2505 if (cc)
2506 { 2506 {
2507 static const char fmt[] = "--\n" 2507 static const char fmt[] =
2508 "%s={r=%d,g=%d,b=%d,a=%d," 2508 "%s={r=%d,g=%d,b=%d,a=%d,"
2509 "r2=%d,g2=%d,b2=%d,a2=%d," 2509 "r2=%d,g2=%d,b2=%d,a2=%d,"
2510 "r3=%d,g3=%d,b3=%d,a3=%d}"; 2510 "r3=%d,g3=%d,b3=%d,a3=%d}";
@@ -2516,7 +2516,7 @@ _edje_part_recalc_single_filter(Edje *ed,
2516 (int) cc->r2, (int) cc->g2, (int) cc->b2, (int) cc->a2, 2516 (int) cc->r2, (int) cc->g2, (int) cc->b2, (int) cc->a2,
2517 (int) cc->r3, (int) cc->g3, (int) cc->b3, (int) cc->a3); 2517 (int) cc->r3, (int) cc->g3, (int) cc->b3, (int) cc->a3);
2518 buffer[len - 1] = 0; 2518 buffer[len - 1] = 0;
2519 efl_gfx_filter_data_set(name, buffer); 2519 efl_gfx_filter_data_set(name, buffer, EINA_TRUE);
2520 } 2520 }
2521 else 2521 else
2522 { 2522 {
@@ -2533,7 +2533,7 @@ _edje_part_recalc_single_filter(Edje *ed,
2533 } 2533 }
2534 } 2534 }
2535 else 2535 else
2536 efl_gfx_filter_data_set(name, value); 2536 efl_gfx_filter_data_set(name, value, EINA_FALSE);
2537 } 2537 }
2538 eina_iterator_free(it); 2538 eina_iterator_free(it);
2539 } 2539 }
diff --git a/src/lib/efl/interfaces/efl_gfx_filter.eo b/src/lib/efl/interfaces/efl_gfx_filter.eo
index 2140acf4da..a633c48e0f 100644
--- a/src/lib/efl/interfaces/efl_gfx_filter.eo
+++ b/src/lib/efl/interfaces/efl_gfx_filter.eo
@@ -75,8 +75,9 @@ interface Efl.Gfx.Filter
75 75
76 This sets a global value as a string.]] 76 This sets a global value as a string.]]
77 params { 77 params {
78 @in name: const(char)*; [[name of the global variable]] 78 @in name: const(char)*; [[Name of the global variable]]
79 @in value: const(char)*; [[string value to use as data]] 79 @in value: const(char)*; [[String value to use as data]]
80 @in execute: bool; [[If true, execute 'name = value']]
80 } 81 }
81 } 82 }
82 } 83 }
diff --git a/src/lib/evas/canvas/evas_filter_mixin.c b/src/lib/evas/canvas/evas_filter_mixin.c
index 5c4746817d..70e37b0991 100644
--- a/src/lib/evas/canvas/evas_filter_mixin.c
+++ b/src/lib/evas/canvas/evas_filter_mixin.c
@@ -493,6 +493,8 @@ EOLIAN void
493_evas_filter_destructor(Eo *eo_obj, Evas_Filter_Data *pd) 493_evas_filter_destructor(Eo *eo_obj, Evas_Filter_Data *pd)
494{ 494{
495 Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJECT_CLASS); 495 Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJECT_CLASS);
496 Evas_Filter_Data_Binding *db;
497 Eina_Inlist *il;
496 498
497 if (!pd->data) return; 499 if (!pd->data) return;
498 if (evas_object_filter_cow_default == pd->data) return; 500 if (evas_object_filter_cow_default == pd->data) return;
@@ -500,7 +502,12 @@ _evas_filter_destructor(Eo *eo_obj, Evas_Filter_Data *pd)
500 if (pd->data->output) 502 if (pd->data->output)
501 ENFN->image_free(ENDT, pd->data->output); 503 ENFN->image_free(ENDT, pd->data->output);
502 eina_hash_free(pd->data->sources); 504 eina_hash_free(pd->data->sources);
503 eina_hash_free(pd->data->data); 505 EINA_INLIST_FOREACH_SAFE(pd->data->data, il, db)
506 {
507 eina_stringshare_del(db->name);
508 eina_stringshare_del(db->value);
509 free(db);
510 }
504 evas_filter_program_del(pd->data->chain); 511 evas_filter_program_del(pd->data->chain);
505 eina_stringshare_del(pd->data->code); 512 eina_stringshare_del(pd->data->code);
506 eina_cow_free(evas_object_filter_cow, (const Eina_Cow_Data **) &pd->data); 513 eina_cow_free(evas_object_filter_cow, (const Eina_Cow_Data **) &pd->data);
@@ -508,25 +515,45 @@ _evas_filter_destructor(Eo *eo_obj, Evas_Filter_Data *pd)
508 515
509EOLIAN void 516EOLIAN void
510_evas_filter_efl_gfx_filter_data_set(Eo *obj EINA_UNUSED, Evas_Filter_Data *pd, 517_evas_filter_efl_gfx_filter_data_set(Eo *obj EINA_UNUSED, Evas_Filter_Data *pd,
511 const char *name, const char *value) 518 const char *name, const char *value,
519 Eina_Bool execute)
512{ 520{
513 const char *check = NULL; 521 Evas_Filter_Data_Binding *db, *found = NULL;
514 522
515 if (!pd->data) return; 523 EINA_SAFETY_ON_NULL_RETURN(pd->data);
524 EINA_SAFETY_ON_NULL_RETURN(name);
516 525
517 if (pd->data->data && ((check = eina_hash_find(pd->data->data, name)) != NULL)) 526 EINA_INLIST_FOREACH(pd->data->data, db)
518 { 527 {
519 if (!strcmp(check, value)) 528 if (!strcmp(name, db->name))
520 return; 529 {
530 if (db->execute == execute)
531 {
532 if ((value == db->value) || (value && db->value && !strcmp(value, db->value)))
533 return;
534 }
535 found = db;
536 break;
537 }
521 } 538 }
522 539
523 EINA_COW_WRITE_BEGIN(evas_object_filter_cow, pd->data, Evas_Object_Filter_Data, fcow) 540 EINA_COW_WRITE_BEGIN(evas_object_filter_cow, pd->data, Evas_Object_Filter_Data, fcow)
524 { 541 {
525 if (!fcow->data) 542 if (found)
526 fcow->data = eina_hash_string_small_new(free); 543 {
527 eina_hash_set(fcow->data, name, value ? strdup(value) : NULL); 544 // Note: we are keeping references to NULL values here.
528 if (fcow->chain) 545 eina_stringshare_replace(&found->value, value);
529 evas_filter_program_data_set_all(fcow->chain, fcow->data); 546 found->execute = execute;
547 }
548 else if (value)
549 {
550 db = calloc(1, sizeof(Evas_Filter_Data_Binding));
551 db->name = eina_stringshare_add(name);
552 db->value = eina_stringshare_add(value);
553 db->execute = execute;
554 fcow->data = eina_inlist_append(fcow->data, EINA_INLIST_GET(db));
555 }
556 evas_filter_program_data_set_all(fcow->chain, fcow->data);
530 fcow->changed = 1; 557 fcow->changed = 1;
531 } 558 }
532 EINA_COW_WRITE_END(evas_object_filter_cow, pd->data, fcow); 559 EINA_COW_WRITE_END(evas_object_filter_cow, pd->data, fcow);
diff --git a/src/lib/evas/filters/evas_filter_parser.c b/src/lib/evas/filters/evas_filter_parser.c
index 58f75b858b..7c4082c51d 100644
--- a/src/lib/evas/filters/evas_filter_parser.c
+++ b/src/lib/evas/filters/evas_filter_parser.c
@@ -341,7 +341,7 @@ struct _Evas_Filter_Program
341 int l, r, t, b; 341 int l, r, t, b;
342 } pad; 342 } pad;
343 Evas_Filter_Program_State state; 343 Evas_Filter_Program_State state;
344 Eina_Hash /* str -> str */ *data; 344 Eina_Inlist *data; // Evas_Filter_Data_Binding
345 lua_State *L; 345 lua_State *L;
346 int lua_func; 346 int lua_func;
347 int last_bufid; 347 int last_bufid;
@@ -2636,36 +2636,31 @@ _filter_program_state_set(Evas_Filter_Program *pgm)
2636 /* now push all extra data */ 2636 /* now push all extra data */
2637 if (pgm->data) 2637 if (pgm->data)
2638 { 2638 {
2639 Eina_Iterator *it = eina_hash_iterator_tuple_new(pgm->data); 2639 Evas_Filter_Data_Binding *db;
2640 Eina_Hash_Tuple *tup; 2640 EINA_INLIST_FOREACH(pgm->data, db)
2641 EINA_ITERATOR_FOREACH(it, tup)
2642 { 2641 {
2643 const char *name = tup->key; 2642 if (db->value)
2644 const char *value = tup->data;
2645 if (value)
2646 { 2643 {
2647 if ((value[0] == '-') && (value[1] == '-') && value[2] == '\n') 2644 if (db->execute)
2648 { 2645 {
2649 if (luaL_dostring(L, value) != 0) 2646 if (luaL_dostring(L, db->value) != 0)
2650 { 2647 {
2651 eina_iterator_free(it);
2652 ERR("Failed to run value: %s", lua_tostring(L, -1)); 2648 ERR("Failed to run value: %s", lua_tostring(L, -1));
2653 return EINA_FALSE; 2649 return EINA_FALSE;
2654 } 2650 }
2655 } 2651 }
2656 else 2652 else
2657 { 2653 {
2658 lua_pushstring(L, value); 2654 lua_pushstring(L, db->value);
2659 lua_setglobal(L, name); 2655 lua_setglobal(L, db->name);
2660 } 2656 }
2661 } 2657 }
2662 else 2658 else
2663 { 2659 {
2664 lua_pushnil(L); 2660 lua_pushnil(L);
2665 lua_setglobal(L, name); 2661 lua_setglobal(L, db->name);
2666 } 2662 }
2667 } 2663 }
2668 eina_iterator_free(it);
2669 } 2664 }
2670 2665
2671 return EINA_TRUE; 2666 return EINA_TRUE;
@@ -2959,7 +2954,7 @@ evas_filter_program_source_set_all(Evas_Filter_Program *pgm,
2959} 2954}
2960 2955
2961void 2956void
2962evas_filter_program_data_set_all(Evas_Filter_Program *pgm, Eina_Hash *data) 2957evas_filter_program_data_set_all(Evas_Filter_Program *pgm, Eina_Inlist *data)
2963{ 2958{
2964 if (!pgm) return; 2959 if (!pgm) return;
2965 pgm->data = data; 2960 pgm->data = data;
diff --git a/src/lib/evas/include/evas_filter.h b/src/lib/evas/include/evas_filter.h
index 6784a0d9e7..f1cbffb31c 100644
--- a/src/lib/evas/include/evas_filter.h
+++ b/src/lib/evas/include/evas_filter.h
@@ -133,7 +133,7 @@ Eina_Bool evas_filter_context_program_use(Evas_Filter_Context *ct
133EAPI Eina_Bool evas_filter_program_padding_get(Evas_Filter_Program *pgm, int *l, int *r, int *t, int *b); 133EAPI Eina_Bool evas_filter_program_padding_get(Evas_Filter_Program *pgm, int *l, int *r, int *t, int *b);
134EAPI void evas_filter_program_source_set_all(Evas_Filter_Program *pgm, Eina_Hash *sources); 134EAPI void evas_filter_program_source_set_all(Evas_Filter_Program *pgm, Eina_Hash *sources);
135void evas_filter_context_proxy_render_all(Evas_Filter_Context *ctx, Eo *eo_obj, Eina_Bool do_async); 135void evas_filter_context_proxy_render_all(Evas_Filter_Context *ctx, Eo *eo_obj, Eina_Bool do_async);
136void evas_filter_program_data_set_all(Evas_Filter_Program *pgm, Eina_Hash *data); 136void evas_filter_program_data_set_all(Evas_Filter_Program *pgm, Eina_Inlist *data);
137 137
138/* Filter context (low level) */ 138/* Filter context (low level) */
139Evas_Filter_Context *evas_filter_context_new(Evas_Public_Data *evas, Eina_Bool async); 139Evas_Filter_Context *evas_filter_context_new(Evas_Public_Data *evas, Eina_Bool async);
@@ -294,6 +294,14 @@ struct _Evas_Filter_Proxy_Binding
294 Eina_Stringshare *name; 294 Eina_Stringshare *name;
295}; 295};
296 296
297struct _Evas_Filter_Data_Binding
298{
299 EINA_INLIST;
300 Eina_Stringshare *name;
301 Eina_Stringshare *value;
302 Eina_Bool execute : 1;
303};
304
297#undef EAPI 305#undef EAPI
298#define EAPI 306#define EAPI
299 307
diff --git a/src/lib/evas/include/evas_private.h b/src/lib/evas/include/evas_private.h
index c94c5edbd4..872dbade8e 100644
--- a/src/lib/evas/include/evas_private.h
+++ b/src/lib/evas/include/evas_private.h
@@ -78,6 +78,7 @@ typedef struct _Evas_Object_Protected_Data Evas_Object_Protected_Data;
78 78
79typedef struct _Evas_Filter_Program Evas_Filter_Program; 79typedef struct _Evas_Filter_Program Evas_Filter_Program;
80typedef struct _Evas_Object_Filter_Data Evas_Object_Filter_Data; 80typedef struct _Evas_Object_Filter_Data Evas_Object_Filter_Data;
81typedef struct _Evas_Filter_Data_Binding Evas_Filter_Data_Binding;
81 82
82// 3D stuff 83// 3D stuff
83 84
@@ -1178,7 +1179,7 @@ struct _Evas_Object_Filter_Data
1178 Eina_Stringshare *code; 1179 Eina_Stringshare *code;
1179 Evas_Filter_Program *chain; 1180 Evas_Filter_Program *chain;
1180 Eina_Hash *sources; // Evas_Filter_Proxy_Binding 1181 Eina_Hash *sources; // Evas_Filter_Proxy_Binding
1181 Eina_Hash *data; // str -> str 1182 Eina_Inlist *data; // Evas_Filter_Data_Binding
1182 void *output; 1183 void *output;
1183 struct { 1184 struct {
1184 struct { 1185 struct {