summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/lib/edje/edje_calc.c143
-rw-r--r--src/lib/edje/edje_private.h1
-rw-r--r--src/lib/evas/canvas/evas_filter.eo1
-rw-r--r--src/lib/evas/canvas/evas_filter_mixin.c4
-rw-r--r--src/lib/evas/filters/evas_filter_parser.c28
5 files changed, 95 insertions, 82 deletions
diff --git a/src/lib/edje/edje_calc.c b/src/lib/edje/edje_calc.c
index b506ef1..f06a637 100644
--- a/src/lib/edje/edje_calc.c
+++ b/src/lib/edje/edje_calc.c
@@ -2443,22 +2443,16 @@ _edje_part_recalc_single_filter(Edje *ed,
2443 Edje_Part_Description_Text *chosen_edt = (Edje_Part_Description_Text *) chosen_desc; 2443 Edje_Part_Description_Text *chosen_edt = (Edje_Part_Description_Text *) chosen_desc;
2444 Edje_Part_Description_Text *edt = (Edje_Part_Description_Text *) desc; 2444 Edje_Part_Description_Text *edt = (Edje_Part_Description_Text *) desc;
2445 filter = &chosen_edt->text.filter; 2445 filter = &chosen_edt->text.filter;
2446 if (edt->text.filter.sources != filter->sources) 2446 prev_sources = edt->text.filter.sources;
2447 { 2447 filter_sources = chosen_edt->text.filter.sources;
2448 prev_sources = ep->typedata.text->filter.sources;
2449 filter_sources = edt->text.filter.sources;
2450 }
2451 } 2448 }
2452 else if (ep->part->type == EDJE_PART_TYPE_IMAGE) 2449 else if (ep->part->type == EDJE_PART_TYPE_IMAGE)
2453 { 2450 {
2454 Edje_Part_Description_Image *chosen_edi = (Edje_Part_Description_Image *) chosen_desc; 2451 Edje_Part_Description_Image *chosen_edi = (Edje_Part_Description_Image *) chosen_desc;
2455 Edje_Part_Description_Image *edi = (Edje_Part_Description_Image *) desc; 2452 Edje_Part_Description_Image *edi = (Edje_Part_Description_Image *) desc;
2456 filter = &chosen_edi->image.filter; 2453 filter = &chosen_edi->image.filter;
2457 if (edi->image.filter.sources != filter->sources) 2454 prev_sources = edi->image.filter.sources;
2458 { 2455 filter_sources = chosen_edi->image.filter.sources;
2459 prev_sources = edi->image.filter.sources;
2460 filter_sources = chosen_edi->image.filter.sources;
2461 }
2462 } 2456 }
2463 else 2457 else
2464 { 2458 {
@@ -2474,7 +2468,75 @@ _edje_part_recalc_single_filter(Edje *ed,
2474 return; 2468 return;
2475 } 2469 }
2476 2470
2471 if (!filter->sources_set)
2472 {
2473 filter->sources_set = 1;
2474 prev_sources = NULL;
2475 }
2476
2477 eo_do(obj, 2477 eo_do(obj,
2478 /* pass extra data items */
2479 if (filter->data)
2480 {
2481 Eina_Iterator *it = eina_hash_iterator_tuple_new(filter->data);
2482 Eina_Hash_Tuple *tup;
2483 EINA_ITERATOR_FOREACH(it, tup)
2484 {
2485 const char *name = tup->key;
2486 char *value = tup->data;
2487 if (!value)
2488 {
2489 efl_gfx_filter_data_set(name, NULL);
2490 }
2491 else if (!strncmp(value, "color_class('", sizeof("color_class('") - 1))
2492 {
2493 /* special handling for color classes even tho they're not that great */
2494 char *ccname, *buffer, *r;
2495 Edje_Color_Class *cc;
2496
2497 ccname = strdup(value + sizeof("color_class('") - 1);
2498 if (ccname)
2499 {
2500 r = strchr(ccname, '\'');
2501 if (r)
2502 {
2503 *r = '\0';
2504 cc = _edje_color_class_find(ed, ccname);
2505 if (cc)
2506 {
2507 static const char fmt[] = "--\n"
2508 "%s={r=%d,g=%d,b=%d,a=%d,"
2509 "r2=%d,g2=%d,b2=%d,a2=%d,"
2510 "r3=%d,g3=%d,b3=%d,a3=%d}";
2511 int len = sizeof(fmt) + 20;
2512 len += strlen(name);
2513 buffer = alloca(len);
2514 snprintf(buffer, len - 1, fmt, name,
2515 (int) cc->r, (int) cc->g, (int) cc->b, (int) cc->a,
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);
2518 buffer[len - 1] = 0;
2519 efl_gfx_filter_data_set(name, buffer);
2520 }
2521 else
2522 {
2523 ERR("Unknown color class: %s", ccname);
2524 eina_hash_del(filter->data, tup->key, tup->data);
2525 }
2526 }
2527 else
2528 {
2529 ERR("Failed to parse color class: %s", value);
2530 eina_hash_del(filter->data, tup->key, tup->data);
2531 }
2532 free(ccname);
2533 }
2534 }
2535 else
2536 efl_gfx_filter_data_set(name, value);
2537 }
2538 eina_iterator_free(it);
2539 }
2478 efl_gfx_filter_program_set(code, filter->name); 2540 efl_gfx_filter_program_set(code, filter->name);
2479 if (prev_sources != filter_sources) 2541 if (prev_sources != filter_sources)
2480 { 2542 {
@@ -2535,67 +2597,6 @@ _edje_part_recalc_single_filter(Edje *ed,
2535 efl_gfx_filter_state_set(chosen_desc->state.name, chosen_desc->state.value, 2597 efl_gfx_filter_state_set(chosen_desc->state.name, chosen_desc->state.value,
2536 NULL, 0.0, pos); 2598 NULL, 0.0, pos);
2537 } 2599 }
2538 /* pass extra data items */
2539 if (filter->data)
2540 {
2541 Eina_Iterator *it = eina_hash_iterator_tuple_new(filter->data);
2542 Eina_Hash_Tuple *tup;
2543 EINA_ITERATOR_FOREACH(it, tup)
2544 {
2545 const char *name = tup->key;
2546 char *value = tup->data;
2547 if (!value)
2548 {
2549 efl_gfx_filter_data_set(name, NULL);
2550 }
2551 else if (!strncmp(value, "color_class('", sizeof("color_class('") - 1))
2552 {
2553 /* special handling for color classes even tho they're not that great */
2554 char *ccname, *buffer, *r;
2555 Edje_Color_Class *cc;
2556
2557 ccname = strdup(value + sizeof("color_class('") - 1);
2558 if (ccname)
2559 {
2560 r = strchr(ccname, '\'');
2561 if (r)
2562 {
2563 *r = '\0';
2564 cc = _edje_color_class_find(ed, ccname);
2565 if (cc)
2566 {
2567 static const char *fmt =
2568 "%s={r=%d,g=%d,b=%d,a=%d,"
2569 "r2=%d,g2=%d,b2=%d,a2=%d,"
2570 "r3=%d,g3=%d,b3=%d,a3=%d}";
2571 int len = sizeof(fmt);
2572 len += strlen(ccname);
2573 buffer = alloca(len);
2574 snprintf(buffer, len - 1, fmt, ccname,
2575 cc->r, cc->g, cc->b, cc->a,
2576 cc->r2, cc->g2, cc->b2, cc->a2,
2577 cc->r3, cc->g3, cc->b3, cc->a3);
2578 efl_gfx_filter_data_set(name, buffer);
2579 }
2580 else
2581 {
2582 ERR("Unknown color class: %s", ccname);
2583 eina_hash_del(filter->data, tup->key, tup->data);
2584 }
2585 }
2586 else
2587 {
2588 ERR("Failed to parse color class: %s", value);
2589 eina_hash_del(filter->data, tup->key, tup->data);
2590 }
2591 free(ccname);
2592 }
2593 }
2594 else
2595 efl_gfx_filter_data_set(name, value);
2596 }
2597 eina_iterator_free(it);
2598 }
2599 ); 2600 );
2600} 2601}
2601 2602
diff --git a/src/lib/edje/edje_private.h b/src/lib/edje/edje_private.h
index 21d156c..9125f1a 100644
--- a/src/lib/edje/edje_private.h
+++ b/src/lib/edje/edje_private.h
@@ -1285,6 +1285,7 @@ struct _Edje_Part_Description_Spec_Filter
1285 Eina_List *sources; /* "part" or "buffer:part" */ 1285 Eina_List *sources; /* "part" or "buffer:part" */
1286 Eina_Hash *data; /* "name" --> "data" */ 1286 Eina_Hash *data; /* "name" --> "data" */
1287 Eina_Bool checked_data : 1; // checked whether this is a data item or embedded string 1287 Eina_Bool checked_data : 1; // checked whether this is a data item or embedded string
1288 Eina_Bool sources_set : 1;
1288 Eina_Bool no_free : 1; 1289 Eina_Bool no_free : 1;
1289}; 1290};
1290 1291
diff --git a/src/lib/evas/canvas/evas_filter.eo b/src/lib/evas/canvas/evas_filter.eo
index 2750e10..b461de9 100644
--- a/src/lib/evas/canvas/evas_filter.eo
+++ b/src/lib/evas/canvas/evas_filter.eo
@@ -65,6 +65,7 @@ mixin Evas.Filter (Efl.Gfx.Filter)
65 Efl.Gfx.Filter.padding.get; 65 Efl.Gfx.Filter.padding.get;
66 Efl.Gfx.Filter.source_set; 66 Efl.Gfx.Filter.source_set;
67 Efl.Gfx.Filter.source_get; 67 Efl.Gfx.Filter.source_get;
68 Efl.Gfx.Filter.data_set;
68 @virtual .input_alpha; 69 @virtual .input_alpha;
69 @virtual .input_render; 70 @virtual .input_render;
70 @virtual .dirty; 71 @virtual .dirty;
diff --git a/src/lib/evas/canvas/evas_filter_mixin.c b/src/lib/evas/canvas/evas_filter_mixin.c
index 5a76b1e..5c47468 100644
--- a/src/lib/evas/canvas/evas_filter_mixin.c
+++ b/src/lib/evas/canvas/evas_filter_mixin.c
@@ -520,7 +520,7 @@ _evas_filter_efl_gfx_filter_data_set(Eo *obj EINA_UNUSED, Evas_Filter_Data *pd,
520 return; 520 return;
521 } 521 }
522 522
523 EINA_COW_WRITE_BEGIN(evas_object_filter_cow, fcow, Evas_Object_Filter_Data, fcow) 523 EINA_COW_WRITE_BEGIN(evas_object_filter_cow, pd->data, Evas_Object_Filter_Data, fcow)
524 { 524 {
525 if (!fcow->data) 525 if (!fcow->data)
526 fcow->data = eina_hash_string_small_new(free); 526 fcow->data = eina_hash_string_small_new(free);
@@ -529,7 +529,7 @@ _evas_filter_efl_gfx_filter_data_set(Eo *obj EINA_UNUSED, Evas_Filter_Data *pd,
529 evas_filter_program_data_set_all(fcow->chain, fcow->data); 529 evas_filter_program_data_set_all(fcow->chain, fcow->data);
530 fcow->changed = 1; 530 fcow->changed = 1;
531 } 531 }
532 EINA_COW_WRITE_END(evas_object_filter_cow, fcow, fcow); 532 EINA_COW_WRITE_END(evas_object_filter_cow, pd->data, fcow);
533} 533}
534 534
535#include "evas_filter.eo.c" 535#include "evas_filter.eo.c"
diff --git a/src/lib/evas/filters/evas_filter_parser.c b/src/lib/evas/filters/evas_filter_parser.c
index 2352d5d..58f75b8 100644
--- a/src/lib/evas/filters/evas_filter_parser.c
+++ b/src/lib/evas/filters/evas_filter_parser.c
@@ -2570,7 +2570,7 @@ _legacy_strdup(const char *str)
2570} 2570}
2571#endif 2571#endif
2572 2572
2573static void 2573static Eina_Bool
2574_filter_program_state_set(Evas_Filter_Program *pgm) 2574_filter_program_state_set(Evas_Filter_Program *pgm)
2575{ 2575{
2576 lua_State *L = pgm->L; 2576 lua_State *L = pgm->L;
@@ -2646,8 +2646,12 @@ _filter_program_state_set(Evas_Filter_Program *pgm)
2646 { 2646 {
2647 if ((value[0] == '-') && (value[1] == '-') && value[2] == '\n') 2647 if ((value[0] == '-') && (value[1] == '-') && value[2] == '\n')
2648 { 2648 {
2649 int i = luaL_dostring(L, value); 2649 if (luaL_dostring(L, value) != 0)
2650 ERR("i %d", i); 2650 {
2651 eina_iterator_free(it);
2652 ERR("Failed to run value: %s", lua_tostring(L, -1));
2653 return EINA_FALSE;
2654 }
2651 } 2655 }
2652 else 2656 else
2653 { 2657 {
@@ -2658,17 +2662,20 @@ _filter_program_state_set(Evas_Filter_Program *pgm)
2658 else 2662 else
2659 { 2663 {
2660 lua_pushnil(L); 2664 lua_pushnil(L);
2665 lua_setglobal(L, name);
2661 } 2666 }
2662 } 2667 }
2663 eina_iterator_free(it); 2668 eina_iterator_free(it);
2664 } 2669 }
2665 2670
2671 return EINA_TRUE;
2672
2666#undef JOINC 2673#undef JOINC
2667#undef SETFIELD 2674#undef SETFIELD
2668#undef SETCOLOR 2675#undef SETCOLOR
2669} 2676}
2670 2677
2671static void 2678static Eina_Bool
2672_filter_program_reset(Evas_Filter_Program *pgm) 2679_filter_program_reset(Evas_Filter_Program *pgm)
2673{ 2680{
2674 Evas_Filter_Instruction *instr; 2681 Evas_Filter_Instruction *instr;
@@ -2696,7 +2703,7 @@ _filter_program_reset(Evas_Filter_Program *pgm)
2696 _filter_program_buffers_set(pgm); 2703 _filter_program_buffers_set(pgm);
2697 2704
2698 // Reset state table 2705 // Reset state table
2699 _filter_program_state_set(pgm); 2706 return _filter_program_state_set(pgm);
2700} 2707}
2701 2708
2702/** Parse a style program */ 2709/** Parse a style program */
@@ -2733,10 +2740,13 @@ evas_filter_program_parse(Evas_Filter_Program *pgm, const char *str)
2733 if (ok) 2740 if (ok)
2734 { 2741 {
2735 pgm->lua_func = luaL_ref(L, LUA_REGISTRYINDEX); 2742 pgm->lua_func = luaL_ref(L, LUA_REGISTRYINDEX);
2736 _filter_program_reset(pgm); 2743 ok =_filter_program_reset(pgm);
2737 lua_getglobal(L, _lua_errfunc_name); 2744 if (ok)
2738 lua_rawgeti(L, LUA_REGISTRYINDEX, pgm->lua_func); 2745 {
2739 ok = !lua_pcall(L, 0, LUA_MULTRET, -2); 2746 lua_getglobal(L, _lua_errfunc_name);
2747 lua_rawgeti(L, LUA_REGISTRYINDEX, pgm->lua_func);
2748 ok = !lua_pcall(L, 0, LUA_MULTRET, -2);
2749 }
2740 } 2750 }
2741 2751
2742 if (!ok) 2752 if (!ok)