summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2015-05-18 21:04:29 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2015-06-25 14:36:08 +0900
commit148a886cc78281028a7877e05d0d0290c44ee111 (patch)
treebfc8f98b1dc6312610e668d71aad2959b36f2bfc
parentc25467ff5c58b523fdb50ca074588567ab72d799 (diff)
Evas filters: Refactor parser code
This is to prepare the changeable states (animation, color, scale...) - Remove use of Eina_Value (simplifies code) - Use proper Lua type for buffers (with pretty __tostring) This adds the buffer methods: width, height, type, name, source
-rw-r--r--src/lib/evas/filters/evas_filter_parser.c639
1 files changed, 393 insertions, 246 deletions
diff --git a/src/lib/evas/filters/evas_filter_parser.c b/src/lib/evas/filters/evas_filter_parser.c
index 16f8071fa6..6b661aa3e4 100644
--- a/src/lib/evas/filters/evas_filter_parser.c
+++ b/src/lib/evas/filters/evas_filter_parser.c
@@ -260,6 +260,8 @@ static struct
260 { "stretch_xy", EVAS_FILTER_FILL_MODE_STRETCH_XY } 260 { "stretch_xy", EVAS_FILTER_FILL_MODE_STRETCH_XY }
261}; 261};
262 262
263static const char *_lua_buffer_meta = "Filter.buffer";
264
263static Evas_Filter_Fill_Mode _fill_mode_get(Evas_Filter_Instruction *instr); 265static Evas_Filter_Fill_Mode _fill_mode_get(Evas_Filter_Instruction *instr);
264 266
265typedef enum 267typedef enum
@@ -291,7 +293,14 @@ typedef struct _Instruction_Param
291 EINA_INLIST; 293 EINA_INLIST;
292 Eina_Stringshare *name; 294 Eina_Stringshare *name;
293 Value_Type type; 295 Value_Type type;
294 Eina_Value *value; 296 union {
297 Eina_Bool b;
298 int i;
299 double f;
300 char *s;
301 unsigned int c;
302 Buffer *buf;
303 } value;
295 Eina_Bool set : 1; 304 Eina_Bool set : 1;
296 Eina_Bool allow_seq : 1; 305 Eina_Bool allow_seq : 1;
297 Eina_Bool allow_any_string : 1; 306 Eina_Bool allow_any_string : 1;
@@ -327,6 +336,7 @@ struct _Evas_Filter_Program
327 Eina_Bool padding_calc : 1; // Padding has been calculated 336 Eina_Bool padding_calc : 1; // Padding has been calculated
328 Eina_Bool padding_set : 1; // Padding has been forced 337 Eina_Bool padding_set : 1; // Padding has been forced
329 Eina_Bool changed : 1; // State (w,h) changed, needs re-run of Lua 338 Eina_Bool changed : 1; // State (w,h) changed, needs re-run of Lua
339 Eina_Bool input_alpha : 1;
330}; 340};
331 341
332/* Instructions */ 342/* Instructions */
@@ -345,36 +355,38 @@ static Eina_Bool
345_instruction_param_addv(Evas_Filter_Instruction *instr, const char *name, 355_instruction_param_addv(Evas_Filter_Instruction *instr, const char *name,
346 Value_Type format, Eina_Bool sequential, va_list args) 356 Value_Type format, Eina_Bool sequential, va_list args)
347{ 357{
348 const Eina_Value_Type *type = NULL;
349 Instruction_Param *param; 358 Instruction_Param *param;
359 char *s;
350 360
361 param = calloc(1, sizeof(Instruction_Param));
362 param->name = eina_stringshare_add(name);
363 param->type = format;
351 switch (format) 364 switch (format)
352 { 365 {
353 case VT_BOOL: 366 case VT_BOOL:
367 param->value.b = (va_arg(args, unsigned int) != 0);
368 break;
354 case VT_INT: 369 case VT_INT:
355 type = EINA_VALUE_TYPE_INT; 370 param->value.i = va_arg(args, int);
356 break; 371 break;
357 case VT_REAL: 372 case VT_REAL:
358 type = EINA_VALUE_TYPE_DOUBLE; 373 param->value.f = va_arg(args, double);
359 break; 374 break;
360 case VT_STRING: 375 case VT_STRING:
376 s = va_arg(args, char *);
377 param->value.s = s ? strdup(s) : NULL;
378 break;
361 case VT_BUFFER: 379 case VT_BUFFER:
362 type = EINA_VALUE_TYPE_STRING; 380 param->value.buf = va_arg(args, Buffer *);
363 break; 381 break;
364 case VT_COLOR: 382 case VT_COLOR:
365 type = EINA_VALUE_TYPE_UINT; 383 param->value.c = va_arg(args, DATA32);
366 break; 384 break;
367 case VT_NONE: 385 case VT_NONE:
368 default: 386 default:
369 return EINA_FALSE; 387 return EINA_FALSE;
370 } 388 }
371
372 param = calloc(1, sizeof(Instruction_Param));
373 param->name = eina_stringshare_add(name);
374 param->type = format;
375 param->value = eina_value_new(type);
376 param->allow_seq = sequential; 389 param->allow_seq = sequential;
377 eina_value_vset(param->value, args);
378 instr->params = eina_inlist_append(instr->params, EINA_INLIST_GET(param)); 390 instr->params = eina_inlist_append(instr->params, EINA_INLIST_GET(param));
379 391
380 return EINA_TRUE; 392 return EINA_TRUE;
@@ -405,7 +417,8 @@ _instruction_del(Evas_Filter_Instruction *instr)
405 if (!instr) return; 417 if (!instr) return;
406 EINA_INLIST_FREE(instr->params, param) 418 EINA_INLIST_FREE(instr->params, param)
407 { 419 {
408 eina_value_free(param->value); 420 if (param->type == VT_STRING)
421 free(param->value.s);
409 eina_stringshare_del(param->name); 422 eina_stringshare_del(param->name);
410 instr->params = eina_inlist_remove(instr->params, EINA_INLIST_GET(param)); 423 instr->params = eina_inlist_remove(instr->params, EINA_INLIST_GET(param));
411 free(param); 424 free(param);
@@ -431,17 +444,12 @@ _instruction_param_geti(Evas_Filter_Instruction *instr, const char *name,
431 Eina_Bool *isset) 444 Eina_Bool *isset)
432{ 445{
433 Instruction_Param *param; 446 Instruction_Param *param;
434 int i = 0;
435 447
436 EINA_INLIST_FOREACH(instr->params, param) 448 EINA_INLIST_FOREACH(instr->params, param)
437 if (!strcasecmp(name, param->name)) 449 if (!strcasecmp(name, param->name))
438 { 450 {
439 if (eina_value_get(param->value, &i)) 451 if (isset) *isset = param->set;
440 { 452 return param->value.i;
441 if (isset) *isset = param->set;
442 return i;
443 }
444 else return -1;
445 } 453 }
446 454
447 if (isset) *isset = EINA_FALSE; 455 if (isset) *isset = EINA_FALSE;
@@ -453,17 +461,12 @@ _instruction_param_getd(Evas_Filter_Instruction *instr, const char *name,
453 Eina_Bool *isset) 461 Eina_Bool *isset)
454{ 462{
455 Instruction_Param *param; 463 Instruction_Param *param;
456 double i = 0;
457 464
458 EINA_INLIST_FOREACH(instr->params, param) 465 EINA_INLIST_FOREACH(instr->params, param)
459 if (!strcasecmp(name, param->name)) 466 if (!strcasecmp(name, param->name))
460 { 467 {
461 if (eina_value_get(param->value, &i)) 468 if (isset) *isset = param->set;
462 { 469 return param->value.f;
463 if (isset) *isset = param->set;
464 return i;
465 }
466 else return 0.0;
467 } 470 }
468 471
469 if (isset) *isset = EINA_FALSE; 472 if (isset) *isset = EINA_FALSE;
@@ -475,17 +478,12 @@ _instruction_param_getc(Evas_Filter_Instruction *instr, const char *name,
475 Eina_Bool *isset) 478 Eina_Bool *isset)
476{ 479{
477 Instruction_Param *param; 480 Instruction_Param *param;
478 DATA32 i = 0;
479 481
480 EINA_INLIST_FOREACH(instr->params, param) 482 EINA_INLIST_FOREACH(instr->params, param)
481 if (!strcasecmp(name, param->name)) 483 if (!strcasecmp(name, param->name))
482 { 484 {
483 if (eina_value_get(param->value, &i)) 485 if (isset) *isset = param->set;
484 { 486 return param->value.c;
485 if (isset) *isset = param->set;
486 return i;
487 }
488 else return 0;
489 } 487 }
490 488
491 if (isset) *isset = EINA_FALSE; 489 if (isset) *isset = EINA_FALSE;
@@ -497,17 +495,29 @@ _instruction_param_gets(Evas_Filter_Instruction *instr, const char *name,
497 Eina_Bool *isset) 495 Eina_Bool *isset)
498{ 496{
499 Instruction_Param *param; 497 Instruction_Param *param;
500 const char *str = NULL;
501 498
502 EINA_INLIST_FOREACH(instr->params, param) 499 EINA_INLIST_FOREACH(instr->params, param)
503 if (!strcasecmp(name, param->name)) 500 if (!strcasecmp(name, param->name))
504 { 501 {
505 if (eina_value_get(param->value, &str)) 502 if (isset) *isset = param->set;
506 { 503 return param->value.s;
507 if (isset) *isset = param->set; 504 }
508 return str; 505
509 } 506 if (isset) *isset = EINA_FALSE;
510 else return NULL; 507 return NULL;
508}
509
510static Buffer *
511_instruction_param_getbuf(Evas_Filter_Instruction *instr, const char *name,
512 Eina_Bool *isset)
513{
514 Instruction_Param *param;
515
516 EINA_INLIST_FOREACH(instr->params, param)
517 if (!strcasecmp(name, param->name))
518 {
519 if (isset) *isset = param->set;
520 return param->value.buf;
511 } 521 }
512 522
513 if (isset) *isset = EINA_FALSE; 523 if (isset) *isset = EINA_FALSE;
@@ -620,6 +630,101 @@ _buffer_get(Evas_Filter_Program *pgm, const char *name)
620} 630}
621 631
622static Eina_Bool 632static Eina_Bool
633_lua_buffer_push(lua_State *L, Buffer *buf)
634{
635 Buffer **ptr;
636
637 lua_getglobal(L, buf->name);
638 if (lua_isnil(L, -1))
639 {
640 ptr = lua_newuserdata(L, sizeof(Buffer **));
641 *ptr = buf;
642 luaL_getmetatable(L, _lua_buffer_meta);
643 lua_setmetatable(L, -2);
644 lua_setglobal(L, buf->name);
645 }
646 else
647 {
648 ERR("to do");
649 }
650
651 return EINA_TRUE;
652}
653
654static int
655_lua_buffer_tostring(lua_State *L)
656{
657 Buffer *buf, **pbuf;
658 pbuf = lua_touserdata(L, 1);
659 buf = pbuf ? *pbuf : NULL;
660 if (!buf)
661 lua_pushstring(L, "nil");
662 else
663 lua_pushfstring(L, "Buffer[#%d %dx%d %s%s%s]", buf->cid, buf->w, buf->h,
664 buf->alpha ? "alpha" : "rgba",
665 buf->proxy ? " src: " : "", buf->proxy ? buf->proxy : "");
666 return 1;
667}
668
669static int
670_lua_buffer_width(lua_State *L)
671{
672 Buffer *buf, **pbuf;
673 pbuf = lua_touserdata(L, 1);
674 buf = pbuf ? *pbuf : NULL;
675 if (!buf) return 0;
676 lua_pushnumber(L, buf->w);
677 return 1;
678}
679
680static int
681_lua_buffer_height(lua_State *L)
682{
683 Buffer *buf, **pbuf;
684 pbuf = lua_touserdata(L, 1);
685 buf = pbuf ? *pbuf : NULL;
686 if (!buf) return 0;
687 lua_pushnumber(L, buf->h);
688 return 1;
689}
690
691static int
692_lua_buffer_type(lua_State *L)
693{
694 Buffer *buf, **pbuf;
695 pbuf = lua_touserdata(L, 1);
696 buf = pbuf ? *pbuf : NULL;
697 if (!buf) return 0;
698 lua_pushstring(L, buf->alpha ? "alpha" : "rgba");
699 return 1;
700}
701
702static int
703_lua_buffer_name(lua_State *L)
704{
705 Buffer *buf, **pbuf;
706 pbuf = lua_touserdata(L, 1);
707 buf = pbuf ? *pbuf : NULL;
708 if (!buf) return 0;
709 lua_pushstring(L, buf->name);
710 return 1;
711}
712
713static int
714_lua_buffer_source(lua_State *L)
715{
716 Buffer *buf, **pbuf;
717 pbuf = lua_touserdata(L, 1);
718 buf = pbuf ? *pbuf : NULL;
719 if (!buf) return 0;
720 if (!buf->proxy)
721 lua_pushnil(L);
722 else
723 lua_pushstring(L, buf->proxy);
724 return 1;
725}
726
727static Buffer *
623_buffer_add(Evas_Filter_Program *pgm, const char *name, Eina_Bool alpha, 728_buffer_add(Evas_Filter_Program *pgm, const char *name, Eina_Bool alpha,
624 const char *src) 729 const char *src)
625{ 730{
@@ -628,24 +733,27 @@ _buffer_add(Evas_Filter_Program *pgm, const char *name, Eina_Bool alpha,
628 if (_buffer_get(pgm, name)) 733 if (_buffer_get(pgm, name))
629 { 734 {
630 ERR("Buffer '%s' already exists", name); 735 ERR("Buffer '%s' already exists", name);
631 return EINA_FALSE; 736 return NULL;
632 } 737 }
633 738
634 if (alpha && src) 739 if (alpha && src)
635 { 740 {
636 ERR("Can not set proxy buffer as alpha!"); 741 ERR("Can not set proxy buffer as alpha!");
637 return EINA_FALSE; 742 return NULL;
638 } 743 }
639 744
640 buf = calloc(1, sizeof(Buffer)); 745 buf = calloc(1, sizeof(Buffer));
641 if (!buf) return EINA_FALSE; 746 if (!buf) return NULL;
642 747
643 buf->name = eina_stringshare_add(name); 748 buf->name = eina_stringshare_add(name);
644 buf->proxy = eina_stringshare_add(src); 749 buf->proxy = eina_stringshare_add(src);
645 buf->alpha = alpha; 750 buf->alpha = alpha;
751 buf->w = pgm->w;
752 buf->h = pgm->h;
646 pgm->buffers = eina_inlist_append(pgm->buffers, EINA_INLIST_GET(buf)); 753 pgm->buffers = eina_inlist_append(pgm->buffers, EINA_INLIST_GET(buf));
754 _lua_buffer_push(pgm->L, buf);
647 755
648 return EINA_TRUE; 756 return buf;
649} 757}
650 758
651static void 759static void
@@ -716,18 +824,19 @@ _buffer_instruction_parse_run(lua_State *L,
716 824
717 cnt = (pgm->buffers ? eina_inlist_count(pgm->buffers) : 0) + 1; 825 cnt = (pgm->buffers ? eina_inlist_count(pgm->buffers) : 0) + 1;
718 snprintf(bufname, sizeof(bufname), "__buffer%02d", cnt); 826 snprintf(bufname, sizeof(bufname), "__buffer%02d", cnt);
719 ok = _buffer_add(pgm, bufname, alpha, src); 827 ok = (_buffer_add(pgm, bufname, alpha, src) != NULL);
720 828
721 if (!ok) return EINA_FALSE; 829 if (!ok) return EINA_FALSE;
722 830
723 lua_pushstring(L, bufname); 831 lua_getglobal(L, bufname);
724 instr->return_count = 1; 832 instr->return_count = 1;
725 833
726 return ok; 834 return ok;
727} 835}
728 836
729static Eina_Bool 837static Eina_Bool
730_buffer_instruction_prepare(Evas_Filter_Instruction *instr) 838_buffer_instruction_prepare(Evas_Filter_Program *pgm EINA_UNUSED,
839 Evas_Filter_Instruction *instr)
731{ 840{
732 EINA_SAFETY_ON_NULL_RETURN_VAL(instr, EINA_FALSE); 841 EINA_SAFETY_ON_NULL_RETURN_VAL(instr, EINA_FALSE);
733 EINA_SAFETY_ON_NULL_RETURN_VAL(instr->name, EINA_FALSE); 842 EINA_SAFETY_ON_NULL_RETURN_VAL(instr->name, EINA_FALSE);
@@ -735,7 +844,7 @@ _buffer_instruction_prepare(Evas_Filter_Instruction *instr)
735 844
736 instr->type = EVAS_FILTER_MODE_BUFFER; 845 instr->type = EVAS_FILTER_MODE_BUFFER;
737 instr->parse_run = _buffer_instruction_parse_run; 846 instr->parse_run = _buffer_instruction_parse_run;
738 _instruction_param_seq_add(instr, "type", VT_BUFFER, "rgba"); 847 _instruction_param_seq_add(instr, "type", VT_STRING, "rgba");
739 _instruction_param_seq_add(instr, "src", VT_BUFFER, NULL); 848 _instruction_param_seq_add(instr, "src", VT_BUFFER, NULL);
740 849
741 return EINA_TRUE; 850 return EINA_TRUE;
@@ -827,7 +936,7 @@ _blend_padding_update(Evas_Filter_Program *pgm, Evas_Filter_Instruction *instr,
827 */ 936 */
828 937
829static Eina_Bool 938static Eina_Bool
830_blend_instruction_prepare(Evas_Filter_Instruction *instr) 939_blend_instruction_prepare(Evas_Filter_Program *pgm, Evas_Filter_Instruction *instr)
831{ 940{
832 EINA_SAFETY_ON_NULL_RETURN_VAL(instr, EINA_FALSE); 941 EINA_SAFETY_ON_NULL_RETURN_VAL(instr, EINA_FALSE);
833 EINA_SAFETY_ON_NULL_RETURN_VAL(instr->name, EINA_FALSE); 942 EINA_SAFETY_ON_NULL_RETURN_VAL(instr->name, EINA_FALSE);
@@ -835,8 +944,8 @@ _blend_instruction_prepare(Evas_Filter_Instruction *instr)
835 944
836 instr->type = EVAS_FILTER_MODE_BLEND; 945 instr->type = EVAS_FILTER_MODE_BLEND;
837 instr->pad.update = _blend_padding_update; 946 instr->pad.update = _blend_padding_update;
838 _instruction_param_seq_add(instr, "src", VT_BUFFER, "input"); 947 _instruction_param_seq_add(instr, "src", VT_BUFFER, _buffer_get(pgm, "input"));
839 _instruction_param_seq_add(instr, "dst", VT_BUFFER, "output"); 948 _instruction_param_seq_add(instr, "dst", VT_BUFFER, _buffer_get(pgm, "output"));
840 _instruction_param_seq_add(instr, "ox", VT_INT, 0); 949 _instruction_param_seq_add(instr, "ox", VT_INT, 0);
841 _instruction_param_seq_add(instr, "oy", VT_INT, 0); 950 _instruction_param_seq_add(instr, "oy", VT_INT, 0);
842 _instruction_param_name_add(instr, "color", VT_COLOR, 0xFFFFFFFF); 951 _instruction_param_name_add(instr, "color", VT_COLOR, 0xFFFFFFFF);
@@ -947,7 +1056,7 @@ _blur_padding_update(Evas_Filter_Program *pgm, Evas_Filter_Instruction *instr,
947 */ 1056 */
948 1057
949static Eina_Bool 1058static Eina_Bool
950_blur_instruction_prepare(Evas_Filter_Instruction *instr) 1059_blur_instruction_prepare(Evas_Filter_Program *pgm, Evas_Filter_Instruction *instr)
951{ 1060{
952 EINA_SAFETY_ON_NULL_RETURN_VAL(instr, EINA_FALSE); 1061 EINA_SAFETY_ON_NULL_RETURN_VAL(instr, EINA_FALSE);
953 EINA_SAFETY_ON_NULL_RETURN_VAL(instr->name, EINA_FALSE); 1062 EINA_SAFETY_ON_NULL_RETURN_VAL(instr->name, EINA_FALSE);
@@ -961,8 +1070,8 @@ _blur_instruction_prepare(Evas_Filter_Instruction *instr)
961 _instruction_param_seq_add(instr, "ox", VT_INT, 0); 1070 _instruction_param_seq_add(instr, "ox", VT_INT, 0);
962 _instruction_param_seq_add(instr, "oy", VT_INT, 0); 1071 _instruction_param_seq_add(instr, "oy", VT_INT, 0);
963 _instruction_param_name_add(instr, "color", VT_COLOR, 0xFFFFFFFF); 1072 _instruction_param_name_add(instr, "color", VT_COLOR, 0xFFFFFFFF);
964 _instruction_param_name_add(instr, "src", VT_BUFFER, "input"); 1073 _instruction_param_name_add(instr, "src", VT_BUFFER, _buffer_get(pgm, "input"));
965 _instruction_param_name_add(instr, "dst", VT_BUFFER, "output"); 1074 _instruction_param_name_add(instr, "dst", VT_BUFFER, _buffer_get(pgm, "output"));
966 _instruction_param_name_add(instr, "count", VT_INT, 0); 1075 _instruction_param_name_add(instr, "count", VT_INT, 0);
967 1076
968 return EINA_TRUE; 1077 return EINA_TRUE;
@@ -1009,7 +1118,7 @@ _blur_instruction_prepare(Evas_Filter_Instruction *instr)
1009 */ 1118 */
1010 1119
1011static Eina_Bool 1120static Eina_Bool
1012_bump_instruction_prepare(Evas_Filter_Instruction *instr) 1121_bump_instruction_prepare(Evas_Filter_Program *pgm, Evas_Filter_Instruction *instr)
1013{ 1122{
1014 EINA_SAFETY_ON_NULL_RETURN_VAL(instr, EINA_FALSE); 1123 EINA_SAFETY_ON_NULL_RETURN_VAL(instr, EINA_FALSE);
1015 EINA_SAFETY_ON_NULL_RETURN_VAL(instr->name, EINA_FALSE); 1124 EINA_SAFETY_ON_NULL_RETURN_VAL(instr->name, EINA_FALSE);
@@ -1023,8 +1132,8 @@ _bump_instruction_prepare(Evas_Filter_Instruction *instr)
1023 _instruction_param_seq_add(instr, "specular", VT_REAL, 0.0); 1132 _instruction_param_seq_add(instr, "specular", VT_REAL, 0.0);
1024 _instruction_param_name_add(instr, "color", VT_COLOR, 0xFFFFFFFF); 1133 _instruction_param_name_add(instr, "color", VT_COLOR, 0xFFFFFFFF);
1025 _instruction_param_name_add(instr, "compensate", VT_BOOL, EINA_FALSE); 1134 _instruction_param_name_add(instr, "compensate", VT_BOOL, EINA_FALSE);
1026 _instruction_param_name_add(instr, "src", VT_BUFFER, "input"); 1135 _instruction_param_name_add(instr, "src", VT_BUFFER, _buffer_get(pgm, "input"));
1027 _instruction_param_name_add(instr, "dst", VT_BUFFER, "output"); 1136 _instruction_param_name_add(instr, "dst", VT_BUFFER, _buffer_get(pgm, "output"));
1028 _instruction_param_name_add(instr, "black", VT_COLOR, 0xFF000000); 1137 _instruction_param_name_add(instr, "black", VT_COLOR, 0xFF000000);
1029 _instruction_param_name_add(instr, "white", VT_COLOR, 0xFFFFFFFF); 1138 _instruction_param_name_add(instr, "white", VT_COLOR, 0xFFFFFFFF);
1030 _instruction_param_name_add(instr, "fillmode", VT_STRING, "repeat"); 1139 _instruction_param_name_add(instr, "fillmode", VT_STRING, "repeat");
@@ -1078,7 +1187,7 @@ _bump_instruction_prepare(Evas_Filter_Instruction *instr)
1078 */ 1187 */
1079 1188
1080static Eina_Bool 1189static Eina_Bool
1081_curve_instruction_prepare(Evas_Filter_Instruction *instr) 1190_curve_instruction_prepare(Evas_Filter_Program *pgm, Evas_Filter_Instruction *instr)
1082{ 1191{
1083 Instruction_Param *param; 1192 Instruction_Param *param;
1084 1193
@@ -1096,8 +1205,8 @@ _curve_instruction_prepare(Evas_Filter_Instruction *instr)
1096 1205
1097 _instruction_param_seq_add(instr, "interpolation", VT_STRING, "linear"); 1206 _instruction_param_seq_add(instr, "interpolation", VT_STRING, "linear");
1098 _instruction_param_seq_add(instr, "channel", VT_STRING, "rgb"); 1207 _instruction_param_seq_add(instr, "channel", VT_STRING, "rgb");
1099 _instruction_param_name_add(instr, "src", VT_BUFFER, "input"); 1208 _instruction_param_name_add(instr, "src", VT_BUFFER, _buffer_get(pgm, "input"));
1100 _instruction_param_name_add(instr, "dst", VT_BUFFER, "output"); 1209 _instruction_param_name_add(instr, "dst", VT_BUFFER, _buffer_get(pgm, "output"));
1101 1210
1102 return EINA_TRUE; 1211 return EINA_TRUE;
1103} 1212}
@@ -1187,7 +1296,7 @@ _displace_padding_update(Evas_Filter_Program *pgm,
1187 */ 1296 */
1188 1297
1189static Eina_Bool 1298static Eina_Bool
1190_displace_instruction_prepare(Evas_Filter_Instruction *instr) 1299_displace_instruction_prepare(Evas_Filter_Program *pgm, Evas_Filter_Instruction *instr)
1191{ 1300{
1192 EINA_SAFETY_ON_NULL_RETURN_VAL(instr, EINA_FALSE); 1301 EINA_SAFETY_ON_NULL_RETURN_VAL(instr, EINA_FALSE);
1193 EINA_SAFETY_ON_NULL_RETURN_VAL(instr->name, EINA_FALSE); 1302 EINA_SAFETY_ON_NULL_RETURN_VAL(instr->name, EINA_FALSE);
@@ -1198,8 +1307,8 @@ _displace_instruction_prepare(Evas_Filter_Instruction *instr)
1198 _instruction_param_seq_add(instr, "map", VT_BUFFER, NULL); 1307 _instruction_param_seq_add(instr, "map", VT_BUFFER, NULL);
1199 _instruction_param_seq_add(instr, "intensity", VT_INT, 10); 1308 _instruction_param_seq_add(instr, "intensity", VT_INT, 10);
1200 _instruction_param_seq_add(instr, "flags", VT_STRING, "default"); 1309 _instruction_param_seq_add(instr, "flags", VT_STRING, "default");
1201 _instruction_param_name_add(instr, "src", VT_BUFFER, "input"); 1310 _instruction_param_name_add(instr, "src", VT_BUFFER, _buffer_get(pgm, "input"));
1202 _instruction_param_name_add(instr, "dst", VT_BUFFER, "output"); 1311 _instruction_param_name_add(instr, "dst", VT_BUFFER, _buffer_get(pgm, "output"));
1203 _instruction_param_name_add(instr, "fillmode", VT_STRING, "repeat"); 1312 _instruction_param_name_add(instr, "fillmode", VT_STRING, "repeat");
1204 1313
1205 return EINA_TRUE; 1314 return EINA_TRUE;
@@ -1234,14 +1343,14 @@ _displace_instruction_prepare(Evas_Filter_Instruction *instr)
1234 */ 1343 */
1235 1344
1236static Eina_Bool 1345static Eina_Bool
1237_fill_instruction_prepare(Evas_Filter_Instruction *instr) 1346_fill_instruction_prepare(Evas_Filter_Program *pgm, Evas_Filter_Instruction *instr)
1238{ 1347{
1239 EINA_SAFETY_ON_NULL_RETURN_VAL(instr, EINA_FALSE); 1348 EINA_SAFETY_ON_NULL_RETURN_VAL(instr, EINA_FALSE);
1240 EINA_SAFETY_ON_NULL_RETURN_VAL(instr->name, EINA_FALSE); 1349 EINA_SAFETY_ON_NULL_RETURN_VAL(instr->name, EINA_FALSE);
1241 EINA_SAFETY_ON_FALSE_RETURN_VAL(!strcasecmp(instr->name, "fill"), EINA_FALSE); 1350 EINA_SAFETY_ON_FALSE_RETURN_VAL(!strcasecmp(instr->name, "fill"), EINA_FALSE);
1242 1351
1243 instr->type = EVAS_FILTER_MODE_FILL; 1352 instr->type = EVAS_FILTER_MODE_FILL;
1244 _instruction_param_seq_add(instr, "dst", VT_BUFFER, "output"); 1353 _instruction_param_seq_add(instr, "dst", VT_BUFFER, _buffer_get(pgm, "output"));
1245 _instruction_param_seq_add(instr, "color", VT_COLOR, 0x0); 1354 _instruction_param_seq_add(instr, "color", VT_COLOR, 0x0);
1246 _instruction_param_seq_add(instr, "l", VT_INT, 0); 1355 _instruction_param_seq_add(instr, "l", VT_INT, 0);
1247 _instruction_param_seq_add(instr, "r", VT_INT, 0); 1356 _instruction_param_seq_add(instr, "r", VT_INT, 0);
@@ -1318,7 +1427,7 @@ _grow_padding_update(Evas_Filter_Program *pgm, Evas_Filter_Instruction *instr,
1318 */ 1427 */
1319 1428
1320static Eina_Bool 1429static Eina_Bool
1321_grow_instruction_prepare(Evas_Filter_Instruction *instr) 1430_grow_instruction_prepare(Evas_Filter_Program *pgm, Evas_Filter_Instruction *instr)
1322{ 1431{
1323 EINA_SAFETY_ON_NULL_RETURN_VAL(instr, EINA_FALSE); 1432 EINA_SAFETY_ON_NULL_RETURN_VAL(instr, EINA_FALSE);
1324 EINA_SAFETY_ON_NULL_RETURN_VAL(instr->name, EINA_FALSE); 1433 EINA_SAFETY_ON_NULL_RETURN_VAL(instr->name, EINA_FALSE);
@@ -1328,8 +1437,8 @@ _grow_instruction_prepare(Evas_Filter_Instruction *instr)
1328 instr->pad.update = _grow_padding_update; 1437 instr->pad.update = _grow_padding_update;
1329 _instruction_param_seq_add(instr, "radius", VT_INT, 0); 1438 _instruction_param_seq_add(instr, "radius", VT_INT, 0);
1330 _instruction_param_name_add(instr, "smooth", VT_BOOL, EINA_TRUE); 1439 _instruction_param_name_add(instr, "smooth", VT_BOOL, EINA_TRUE);
1331 _instruction_param_name_add(instr, "src", VT_BUFFER, "input"); 1440 _instruction_param_name_add(instr, "src", VT_BUFFER, _buffer_get(pgm, "input"));
1332 _instruction_param_name_add(instr, "dst", VT_BUFFER, "output"); 1441 _instruction_param_name_add(instr, "dst", VT_BUFFER, _buffer_get(pgm, "output"));
1333 1442
1334 return EINA_TRUE; 1443 return EINA_TRUE;
1335} 1444}
@@ -1368,7 +1477,7 @@ _grow_instruction_prepare(Evas_Filter_Instruction *instr)
1368 */ 1477 */
1369 1478
1370static Eina_Bool 1479static Eina_Bool
1371_mask_instruction_prepare(Evas_Filter_Instruction *instr) 1480_mask_instruction_prepare(Evas_Filter_Program *pgm, Evas_Filter_Instruction *instr)
1372{ 1481{
1373 EINA_SAFETY_ON_NULL_RETURN_VAL(instr, EINA_FALSE); 1482 EINA_SAFETY_ON_NULL_RETURN_VAL(instr, EINA_FALSE);
1374 EINA_SAFETY_ON_NULL_RETURN_VAL(instr->name, EINA_FALSE); 1483 EINA_SAFETY_ON_NULL_RETURN_VAL(instr->name, EINA_FALSE);
@@ -1376,8 +1485,8 @@ _mask_instruction_prepare(Evas_Filter_Instruction *instr)
1376 1485
1377 instr->type = EVAS_FILTER_MODE_MASK; 1486 instr->type = EVAS_FILTER_MODE_MASK;
1378 _instruction_param_seq_add(instr, "mask", VT_BUFFER, NULL); 1487 _instruction_param_seq_add(instr, "mask", VT_BUFFER, NULL);
1379 _instruction_param_seq_add(instr, "src", VT_BUFFER, "input"); 1488 _instruction_param_seq_add(instr, "src", VT_BUFFER, _buffer_get(pgm, "input"));
1380 _instruction_param_seq_add(instr, "dst", VT_BUFFER, "output"); 1489 _instruction_param_seq_add(instr, "dst", VT_BUFFER, _buffer_get(pgm, "output"));
1381 _instruction_param_name_add(instr, "color", VT_COLOR, 0xFFFFFFFF); 1490 _instruction_param_name_add(instr, "color", VT_COLOR, 0xFFFFFFFF);
1382 _instruction_param_name_add(instr, "fillmode", VT_STRING, "repeat"); 1491 _instruction_param_name_add(instr, "fillmode", VT_STRING, "repeat");
1383 1492
@@ -1453,7 +1562,7 @@ _transform_padding_update(Evas_Filter_Program *pgm,
1453 */ 1562 */
1454 1563
1455static Eina_Bool 1564static Eina_Bool
1456_transform_instruction_prepare(Evas_Filter_Instruction *instr) 1565_transform_instruction_prepare(Evas_Filter_Program *pgm, Evas_Filter_Instruction *instr)
1457{ 1566{
1458 EINA_SAFETY_ON_NULL_RETURN_VAL(instr, EINA_FALSE); 1567 EINA_SAFETY_ON_NULL_RETURN_VAL(instr, EINA_FALSE);
1459 EINA_SAFETY_ON_NULL_RETURN_VAL(instr->name, EINA_FALSE); 1568 EINA_SAFETY_ON_NULL_RETURN_VAL(instr->name, EINA_FALSE);
@@ -1463,7 +1572,7 @@ _transform_instruction_prepare(Evas_Filter_Instruction *instr)
1463 instr->pad.update = _transform_padding_update; 1572 instr->pad.update = _transform_padding_update;
1464 _instruction_param_seq_add(instr, "dst", VT_BUFFER, NULL); 1573 _instruction_param_seq_add(instr, "dst", VT_BUFFER, NULL);
1465 _instruction_param_seq_add(instr, "op", VT_STRING, "vflip"); 1574 _instruction_param_seq_add(instr, "op", VT_STRING, "vflip");
1466 _instruction_param_seq_add(instr, "src", VT_BUFFER, "input"); 1575 _instruction_param_seq_add(instr, "src", VT_BUFFER, _buffer_get(pgm, "input"));
1467 //_instruction_param_name_add(instr, "ox", VT_INT, 0); 1576 //_instruction_param_name_add(instr, "ox", VT_INT, 0);
1468 _instruction_param_name_add(instr, "oy", VT_INT, 0); 1577 _instruction_param_name_add(instr, "oy", VT_INT, 0);
1469 1578
@@ -1543,7 +1652,8 @@ _padding_set_padding_update(Evas_Filter_Program *pgm,
1543 */ 1652 */
1544 1653
1545static Eina_Bool 1654static Eina_Bool
1546_padding_set_instruction_prepare(Evas_Filter_Instruction *instr) 1655_padding_set_instruction_prepare(Evas_Filter_Program *pgm EINA_UNUSED,
1656 Evas_Filter_Instruction *instr)
1547{ 1657{
1548 EINA_SAFETY_ON_NULL_RETURN_VAL(instr, EINA_FALSE); 1658 EINA_SAFETY_ON_NULL_RETURN_VAL(instr, EINA_FALSE);
1549 EINA_SAFETY_ON_NULL_RETURN_VAL(instr->name, EINA_FALSE); 1659 EINA_SAFETY_ON_NULL_RETURN_VAL(instr->name, EINA_FALSE);
@@ -1605,10 +1715,9 @@ _lua_program_get(lua_State *L)
1605} 1715}
1606 1716
1607static Eina_Bool 1717static Eina_Bool
1608_lua_parameter_parse(lua_State *L, Instruction_Param *param, int i) 1718_lua_parameter_parse(Evas_Filter_Program *pgm, lua_State *L,
1719 Instruction_Param *param, int i)
1609{ 1720{
1610 Eina_Bool ok;
1611
1612 if (!param) return EINA_FALSE; 1721 if (!param) return EINA_FALSE;
1613 if (param->set) 1722 if (param->set)
1614 { 1723 {
@@ -1622,27 +1731,33 @@ _lua_parameter_parse(lua_State *L, Instruction_Param *param, int i)
1622 case VT_BOOL: 1731 case VT_BOOL:
1623 if (lua_type(L, i) == LUA_TSTRING) 1732 if (lua_type(L, i) == LUA_TSTRING)
1624 { 1733 {
1625 ok = EINA_FALSE; 1734 Eina_Bool ok = EINA_FALSE;
1626 const char *str = lua_tostring(L, i); 1735 const char *str = lua_tostring(L, i);
1627 Eina_Bool val = _bool_parse(str, &ok); 1736 Eina_Bool val = _bool_parse(str, &ok);
1628 if (!ok) goto fail; 1737 if (!ok)
1629 eina_value_set(param->value, val); 1738 goto fail;
1739 param->value.b = val;
1630 } 1740 }
1631 else if (lua_isboolean(L, i) || lua_isnumber(L, i)) 1741 else if (lua_isboolean(L, i) || lua_isnumber(L, i))
1632 eina_value_set(param->value, lua_toboolean(L, i)); 1742 param->value.b = lua_toboolean(L, i);
1633 else goto fail; 1743 else
1744 goto fail;
1634 break; 1745 break;
1635 case VT_INT: 1746 case VT_INT:
1636 if (!lua_isnumber(L, i)) goto fail; 1747 if (!lua_isnumber(L, i))
1637 eina_value_set(param->value, lua_tointeger(L, i)); 1748 goto fail;
1749 param->value.i = lua_tointeger(L, i);
1638 break; 1750 break;
1639 case VT_REAL: 1751 case VT_REAL:
1640 if (!lua_isnumber(L, i)) goto fail; 1752 if (!lua_isnumber(L, i))
1641 eina_value_set(param->value, lua_tonumber(L, i)); 1753 goto fail;
1754 param->value.f = lua_tonumber(L, i);
1642 break; 1755 break;
1643 case VT_STRING: 1756 case VT_STRING:
1644 if (lua_type(L, i) != LUA_TSTRING) goto fail; 1757 if (lua_type(L, i) != LUA_TSTRING)
1645 eina_value_set(param->value, lua_tostring(L, i)); 1758 goto fail;
1759 free(param->value.s);
1760 param->value.s = strdup(lua_tostring(L, i));
1646 break; 1761 break;
1647 case VT_COLOR: 1762 case VT_COLOR:
1648 if (lua_isnumber(L, i)) 1763 if (lua_isnumber(L, i))
@@ -1654,21 +1769,33 @@ _lua_parameter_parse(lua_State *L, Instruction_Param *param, int i)
1654 int B = B_VAL(&color); 1769 int B = B_VAL(&color);
1655 if (!A && (R || B || G)) A = 0xFF; 1770 if (!A && (R || B || G)) A = 0xFF;
1656 evas_color_argb_premul(A, &R, &G, &B); 1771 evas_color_argb_premul(A, &R, &G, &B);
1657 eina_value_set(param->value, ARGB_JOIN(A, R, G, B)); 1772 param->value.c = ARGB_JOIN(A, R, G, B);
1658 } 1773 }
1659 else if (lua_type(L, i) == LUA_TSTRING) 1774 else if (lua_type(L, i) == LUA_TSTRING)
1660 { 1775 {
1661 DATA32 color; 1776 if (!_color_parse(lua_tostring(L, i), &param->value.c))
1662 ok = _color_parse(lua_tostring(L, i), &color); 1777 goto fail;
1663 if (!ok) goto fail;
1664 eina_value_set(param->value, color);
1665 } 1778 }
1666 else goto fail; 1779 else
1780 goto fail;
1667 break; 1781 break;
1668 case VT_BUFFER: 1782 case VT_BUFFER:
1669 if (lua_type(L, i) != LUA_TSTRING) goto fail; 1783 {
1670 eina_value_set(param->value, lua_tostring(L, i)); 1784 if (lua_type(L, i) == LUA_TSTRING)
1671 break; 1785 {
1786 param->value.buf = _buffer_get(pgm, lua_tostring(L, i));
1787 if (!param->value.buf)
1788 goto fail;
1789 }
1790 else
1791 {
1792 Buffer **pbuf;
1793 luaL_checkudata(L, i, _lua_buffer_meta);
1794 pbuf = lua_touserdata(L, i);
1795 param->value.buf = pbuf ? *pbuf : NULL;
1796 }
1797 break;
1798 }
1672 case VT_NONE: 1799 case VT_NONE:
1673 default: 1800 default:
1674 // This should not happen 1801 // This should not happen
@@ -1761,7 +1888,7 @@ _lua_instruction_run(lua_State *L, Evas_Filter_Instruction *instr)
1761 goto fail; 1888 goto fail;
1762 } 1889 }
1763 1890
1764 if (!_lua_parameter_parse(L, param, -1)) 1891 if (!_lua_parameter_parse(pgm, L, param, -1))
1765 goto fail; 1892 goto fail;
1766 lua_pop(L, 1); 1893 lua_pop(L, 1);
1767 } 1894 }
@@ -1771,7 +1898,7 @@ _lua_instruction_run(lua_State *L, Evas_Filter_Instruction *instr)
1771 EINA_INLIST_FOREACH(instr->params, param) 1898 EINA_INLIST_FOREACH(instr->params, param)
1772 { 1899 {
1773 if ((++i) > argc) break; 1900 if ((++i) > argc) break;
1774 if (!_lua_parameter_parse(L, param, i)) 1901 if (!_lua_parameter_parse(pgm, L, param, i))
1775 goto fail; 1902 goto fail;
1776 } 1903 }
1777 } 1904 }
@@ -1795,14 +1922,14 @@ fail:
1795 1922
1796static int 1923static int
1797_lua_generic_function(lua_State *L, const char *name, 1924_lua_generic_function(lua_State *L, const char *name,
1798 Eina_Bool (* prepare) (Evas_Filter_Instruction *)) 1925 Eina_Bool (* prepare) (Evas_Filter_Program *pgm, Evas_Filter_Instruction *))
1799{ 1926{
1800 Evas_Filter_Program *pgm = _lua_program_get(L); 1927 Evas_Filter_Program *pgm = _lua_program_get(L);
1801 Evas_Filter_Instruction *instr; 1928 Evas_Filter_Instruction *instr;
1802 Eina_Bool ok; 1929 Eina_Bool ok;
1803 1930
1804 instr = _instruction_new(name); 1931 instr = _instruction_new(name);
1805 prepare(instr); 1932 prepare(pgm, instr);
1806 ok = _lua_instruction_run(L, instr); 1933 ok = _lua_instruction_run(L, instr);
1807 1934
1808 if (!ok) 1935 if (!ok)
@@ -1848,6 +1975,20 @@ _lua_print(lua_State *L)
1848 else 1975 else
1849 eina_strbuf_append_printf(s, "%f", d); 1976 eina_strbuf_append_printf(s, "%f", d);
1850 } 1977 }
1978 else if (luaL_checkudata(L, i, _lua_buffer_meta))
1979 {
1980 Buffer *buf, **pbuf;
1981 pbuf = lua_touserdata(L, i);
1982 buf = pbuf ? *pbuf : NULL;
1983 if (!buf)
1984 eina_strbuf_append(s, "Buffer[null]");
1985 else
1986 eina_strbuf_append_printf(s, "Buffer[#%d %dx%d %s%s%s]",
1987 buf->cid, buf->w, buf->h,
1988 buf->alpha ? "alpha" : "rgba",
1989 buf->proxy ? " src: " : "",
1990 buf->proxy ? buf->proxy : "");
1991 }
1851 else 1992 else
1852 eina_strbuf_append(s, "<>"); 1993 eina_strbuf_append(s, "<>");
1853 eina_strbuf_append_char(s, ' '); 1994 eina_strbuf_append_char(s, ' ');
@@ -1887,12 +2028,27 @@ LUA_GENERIC_FUNCTION(mask)
1887LUA_GENERIC_FUNCTION(padding_set) 2028LUA_GENERIC_FUNCTION(padding_set)
1888LUA_GENERIC_FUNCTION(transform) 2029LUA_GENERIC_FUNCTION(transform)
1889 2030
2031static const luaL_Reg buffer_methods[] = {
2032 { "width", _lua_buffer_width },
2033 { "height", _lua_buffer_height },
2034 { "type", _lua_buffer_type },
2035 { "name", _lua_buffer_name },
2036 { "source", _lua_buffer_source },
2037 { NULL, NULL }
2038};
2039
2040static const luaL_Reg buffer_meta[] = {
2041 { "__tostring", _lua_buffer_tostring },
2042 { NULL, NULL }
2043};
2044
1890static lua_State * 2045static lua_State *
1891_lua_state_create(Evas_Filter_Program *pgm) 2046_lua_state_create(Evas_Filter_Program *pgm)
1892{ 2047{
1893 lua_State *L; 2048 lua_State *L;
2049 Buffer *buf;
1894 2050
1895 L = luaL_newstate(); 2051 pgm->L = L = luaL_newstate();
1896 if (!L) 2052 if (!L)
1897 { 2053 {
1898 ERR("Could not create a new Lua state"); 2054 ERR("Could not create a new Lua state");
@@ -1967,16 +2123,20 @@ _lua_state_create(Evas_Filter_Program *pgm)
1967 lua_setglobal(L, booleans[k].name); 2123 lua_setglobal(L, booleans[k].name);
1968 } 2124 }
1969 2125
1970 // Buffers. Should be input & output only. 2126 // Register buffer meta stuff
1971 { 2127 luaL_openlib(L, _lua_buffer_meta, buffer_methods, 0);
1972 Buffer *buf; 2128 luaL_newmetatable(L, _lua_buffer_meta);
2129 luaL_openlib(L, NULL, buffer_meta, 0);
2130 lua_pushliteral(L, "__index");
2131 lua_pushvalue(L, -3);
2132 lua_rawset(L, -3);
2133 lua_pushliteral(L, "__metatable");
2134 lua_pushvalue(L, -3);
2135 lua_rawset(L, -3);
2136 lua_pop(L, 1);
1973 2137
1974 EINA_INLIST_FOREACH(pgm->buffers, buf) 2138 _buffer_add(pgm, "input", pgm->input_alpha, NULL);
1975 { 2139 _buffer_add(pgm, "output", EINA_FALSE, NULL);
1976 lua_pushstring(L, buf->name);
1977 lua_setglobal(L, buf->name);
1978 }
1979 }
1980 2140
1981 // Register proxies 2141 // Register proxies
1982 if (pgm->proxies) 2142 if (pgm->proxies)
@@ -1985,12 +2145,16 @@ _lua_state_create(Evas_Filter_Program *pgm)
1985 const char *source; 2145 const char *source;
1986 2146
1987 EINA_ITERATOR_FOREACH(it, source) 2147 EINA_ITERATOR_FOREACH(it, source)
1988 if (_buffer_get(pgm, source)) 2148 {
1989 { 2149 buf = calloc(1, sizeof(Buffer));
1990 lua_pushstring(L, source); 2150 if (!buf) break;
1991 lua_setglobal(L, source); 2151
1992 } 2152 buf->name = eina_stringshare_add(source);
1993 2153 buf->proxy = eina_stringshare_ref(buf->name);
2154 buf->alpha = EINA_FALSE;
2155 pgm->buffers = eina_inlist_append(pgm->buffers, EINA_INLIST_GET(buf));
2156 _lua_buffer_push(L, buf);
2157 }
1994 eina_iterator_free(it); 2158 eina_iterator_free(it);
1995 } 2159 }
1996 2160
@@ -2149,14 +2313,20 @@ evas_filter_program_parse(Evas_Filter_Program *pgm, const char *str)
2149 if (ok) 2313 if (ok)
2150 ok = !lua_pcall(L, 0, LUA_MULTRET, 0); 2314 ok = !lua_pcall(L, 0, LUA_MULTRET, 0);
2151 2315
2152 if (!ok || !pgm->instructions) 2316 if (!ok)
2153 { 2317 {
2154 const char *msg = lua_tostring(L, -1); 2318 const char *msg = lua_tostring(L, -1);
2155 ERR("Lua parsing failed: %s", msg); 2319 ERR("Lua parsing failed: %s", msg);
2156 lua_close(L); 2320 lua_close(L);
2321 pgm->L = NULL;
2322 }
2323 else if (!pgm->instructions)
2324 {
2325 ERR("No instructions found in Lua script");
2326 lua_close(L);
2327 ok = EINA_FALSE;
2328 pgm->L = NULL;
2157 } 2329 }
2158 else
2159 pgm->L = L;
2160 pgm->valid = ok; 2330 pgm->valid = ok;
2161 pgm->padding_calc = EINA_FALSE; 2331 pgm->padding_calc = EINA_FALSE;
2162 2332
@@ -2258,8 +2428,7 @@ evas_filter_program_new(const char *name, Eina_Bool input_alpha)
2258 pgm = calloc(1, sizeof(Evas_Filter_Program)); 2428 pgm = calloc(1, sizeof(Evas_Filter_Program));
2259 if (!pgm) return NULL; 2429 if (!pgm) return NULL;
2260 pgm->name = eina_stringshare_add(name); 2430 pgm->name = eina_stringshare_add(name);
2261 _buffer_add(pgm, "input", input_alpha, NULL); 2431 pgm->input_alpha = input_alpha;
2262 _buffer_add(pgm, "output", EINA_FALSE, NULL);
2263 2432
2264 return pgm; 2433 return pgm;
2265} 2434}
@@ -2304,6 +2473,10 @@ evas_filter_program_source_set_all(Evas_Filter_Program *pgm,
2304 ENFN->context_clip_set(ENDT, dc, l, r, t, b); } while (0) 2473 ENFN->context_clip_set(ENDT, dc, l, r, t, b); } while (0)
2305#define RESETCLIP() do { ENFN->context_clip_set(ENDT, dc, _l, _r, _t, _b); } while (0) 2474#define RESETCLIP() do { ENFN->context_clip_set(ENDT, dc, _l, _r, _t, _b); } while (0)
2306 2475
2476#define INSTR_PARAM_CHECK(a) do { if (!(a)) { \
2477 ERR("Argument %s can not be nil in %s!", #a, instr->name); return -1; } \
2478 } while (0)
2479
2307static Evas_Filter_Fill_Mode 2480static Evas_Filter_Fill_Mode
2308_fill_mode_get(Evas_Filter_Instruction *instr) 2481_fill_mode_get(Evas_Filter_Instruction *instr)
2309{ 2482{
@@ -2324,29 +2497,26 @@ _fill_mode_get(Evas_Filter_Instruction *instr)
2324} 2497}
2325 2498
2326static int 2499static int
2327_instr2cmd_blend(Evas_Filter_Context *ctx, Evas_Filter_Program *pgm, 2500_instr2cmd_blend(Evas_Filter_Context *ctx,
2328 Evas_Filter_Instruction *instr, void *dc) 2501 Evas_Filter_Instruction *instr, void *dc)
2329{ 2502{
2330 Eina_Bool isset = EINA_FALSE; 2503 Eina_Bool isset = EINA_FALSE;
2331 const char *src, *dst;
2332 DATA32 color; 2504 DATA32 color;
2333 Buffer *in, *out; 2505 Buffer *src, *dst;
2334 Evas_Filter_Fill_Mode fillmode; 2506 Evas_Filter_Fill_Mode fillmode;
2335 int cmdid, ox, oy, A, R, G, B; 2507 int cmdid, ox, oy, A, R, G, B;
2336 2508
2337 src = _instruction_param_gets(instr, "src", NULL);
2338 dst = _instruction_param_gets(instr, "dst", NULL);
2339 ox = _instruction_param_geti(instr, "ox", NULL); 2509 ox = _instruction_param_geti(instr, "ox", NULL);
2340 oy = _instruction_param_geti(instr, "oy", NULL); 2510 oy = _instruction_param_geti(instr, "oy", NULL);
2341 color = _instruction_param_getc(instr, "color", &isset); 2511 color = _instruction_param_getc(instr, "color", &isset);
2342 fillmode = _fill_mode_get(instr); 2512 fillmode = _fill_mode_get(instr);
2343 in = _buffer_get(pgm, src); 2513 src = _instruction_param_getbuf(instr, "src", NULL);
2344 out = _buffer_get(pgm, dst); 2514 dst = _instruction_param_getbuf(instr, "dst", NULL);
2345 EINA_SAFETY_ON_NULL_RETURN_VAL(in, -1); 2515 INSTR_PARAM_CHECK(src);
2346 EINA_SAFETY_ON_NULL_RETURN_VAL(out, -1); 2516 INSTR_PARAM_CHECK(dst);
2347 2517
2348 if (isset) SETCOLOR(color); 2518 if (isset) SETCOLOR(color);
2349 cmdid = evas_filter_command_blend_add(ctx, dc, in->cid, out->cid, ox, oy, 2519 cmdid = evas_filter_command_blend_add(ctx, dc, src->cid, dst->cid, ox, oy,
2350 fillmode); 2520 fillmode);
2351 if (isset) RESETCOLOR(); 2521 if (isset) RESETCOLOR();
2352 if (cmdid < 0) return cmdid; 2522 if (cmdid < 0) return cmdid;
@@ -2355,18 +2525,16 @@ _instr2cmd_blend(Evas_Filter_Context *ctx, Evas_Filter_Program *pgm,
2355} 2525}
2356 2526
2357static int 2527static int
2358_instr2cmd_blur(Evas_Filter_Context *ctx, Evas_Filter_Program *pgm, 2528_instr2cmd_blur(Evas_Filter_Context *ctx,
2359 Evas_Filter_Instruction *instr, void *dc) 2529 Evas_Filter_Instruction *instr, void *dc)
2360{ 2530{
2361 Eina_Bool colorset = EINA_FALSE, yset = EINA_FALSE, cntset = EINA_FALSE; 2531 Eina_Bool colorset = EINA_FALSE, yset = EINA_FALSE, cntset = EINA_FALSE;
2362 Evas_Filter_Blur_Type type = EVAS_FILTER_BLUR_DEFAULT; 2532 Evas_Filter_Blur_Type type = EVAS_FILTER_BLUR_DEFAULT;
2363 const char *src, *dst, *typestr; 2533 const char *typestr;
2364 DATA32 color; 2534 DATA32 color;
2365 Buffer *in, *out; 2535 Buffer *src, *dst;
2366 int cmdid, ox, oy, rx, ry, A, R, G, B, count; 2536 int cmdid, ox, oy, rx, ry, A, R, G, B, count;
2367 2537
2368 src = _instruction_param_gets(instr, "src", NULL);
2369 dst = _instruction_param_gets(instr, "dst", NULL);
2370 ox = _instruction_param_geti(instr, "ox", NULL); 2538 ox = _instruction_param_geti(instr, "ox", NULL);
2371 oy = _instruction_param_geti(instr, "oy", NULL); 2539 oy = _instruction_param_geti(instr, "oy", NULL);
2372 rx = _instruction_param_geti(instr, "rx", NULL); 2540 rx = _instruction_param_geti(instr, "rx", NULL);
@@ -2374,10 +2542,10 @@ _instr2cmd_blur(Evas_Filter_Context *ctx, Evas_Filter_Program *pgm,
2374 color = _instruction_param_getc(instr, "color", &colorset); 2542 color = _instruction_param_getc(instr, "color", &colorset);
2375 typestr = _instruction_param_gets(instr, "type", NULL); 2543 typestr = _instruction_param_gets(instr, "type", NULL);
2376 count = _instruction_param_geti(instr, "count", &cntset); 2544 count = _instruction_param_geti(instr, "count", &cntset);
2377 in = _buffer_get(pgm, src); 2545 src = _instruction_param_getbuf(instr, "src", NULL);
2378 out = _buffer_get(pgm, dst); 2546 dst = _instruction_param_getbuf(instr, "dst", NULL);
2379 EINA_SAFETY_ON_NULL_RETURN_VAL(in, -1); 2547 INSTR_PARAM_CHECK(src);
2380 EINA_SAFETY_ON_NULL_RETURN_VAL(out, -1); 2548 INSTR_PARAM_CHECK(dst);
2381 2549
2382 if (typestr) 2550 if (typestr)
2383 { 2551 {
@@ -2408,7 +2576,7 @@ _instr2cmd_blur(Evas_Filter_Context *ctx, Evas_Filter_Program *pgm,
2408 2576
2409 if (!yset) ry = rx; 2577 if (!yset) ry = rx;
2410 if (colorset) SETCOLOR(color); 2578 if (colorset) SETCOLOR(color);
2411 cmdid = evas_filter_command_blur_add(ctx, dc, in->cid, out->cid, type, 2579 cmdid = evas_filter_command_blur_add(ctx, dc, src->cid, dst->cid, type,
2412 rx, ry, ox, oy, count); 2580 rx, ry, ox, oy, count);
2413 if (colorset) RESETCOLOR(); 2581 if (colorset) RESETCOLOR();
2414 2582
@@ -2416,20 +2584,16 @@ _instr2cmd_blur(Evas_Filter_Context *ctx, Evas_Filter_Program *pgm,
2416} 2584}
2417 2585
2418static int 2586static int
2419_instr2cmd_bump(Evas_Filter_Context *ctx, Evas_Filter_Program *pgm, 2587_instr2cmd_bump(Evas_Filter_Context *ctx,
2420 Evas_Filter_Instruction *instr, void *dc) 2588 Evas_Filter_Instruction *instr, void *dc)
2421{ 2589{
2422 Evas_Filter_Bump_Flags flags = EVAS_FILTER_BUMP_NORMAL; 2590 Evas_Filter_Bump_Flags flags = EVAS_FILTER_BUMP_NORMAL;
2423 Evas_Filter_Fill_Mode fillmode; 2591 Evas_Filter_Fill_Mode fillmode;
2424 const char *src, *dst, *map;
2425 DATA32 color, black, white; 2592 DATA32 color, black, white;
2426 Buffer *in, *out, *bump; 2593 Buffer *src, *dst, *map;
2427 double azimuth, elevation, depth, specular; 2594 double azimuth, elevation, depth, specular;
2428 int cmdid, compensate; 2595 int cmdid, compensate;
2429 2596
2430 src = _instruction_param_gets(instr, "src", NULL);
2431 dst = _instruction_param_gets(instr, "dst", NULL);
2432 map = _instruction_param_gets(instr, "map", NULL);
2433 color = _instruction_param_getc(instr, "color", NULL); 2597 color = _instruction_param_getc(instr, "color", NULL);
2434 white = _instruction_param_getc(instr, "white", NULL); 2598 white = _instruction_param_getc(instr, "white", NULL);
2435 black = _instruction_param_getc(instr, "black", NULL); 2599 black = _instruction_param_getc(instr, "black", NULL);
@@ -2441,14 +2605,14 @@ _instr2cmd_bump(Evas_Filter_Context *ctx, Evas_Filter_Program *pgm,
2441 fillmode = _fill_mode_get(instr); 2605 fillmode = _fill_mode_get(instr);
2442 if (compensate) flags |= EVAS_FILTER_BUMP_COMPENSATE; 2606 if (compensate) flags |= EVAS_FILTER_BUMP_COMPENSATE;
2443 2607
2444 in = _buffer_get(pgm, src); 2608 src = _instruction_param_getbuf(instr, "src", NULL);
2445 out = _buffer_get(pgm, dst); 2609 dst = _instruction_param_getbuf(instr, "dst", NULL);
2446 bump = _buffer_get(pgm, map); 2610 map = _instruction_param_getbuf(instr, "map", NULL);
2447 EINA_SAFETY_ON_NULL_RETURN_VAL(in, -1); 2611 INSTR_PARAM_CHECK(src);
2448 EINA_SAFETY_ON_NULL_RETURN_VAL(out, -1); 2612 INSTR_PARAM_CHECK(dst);
2449 EINA_SAFETY_ON_NULL_RETURN_VAL(bump, -1); 2613 INSTR_PARAM_CHECK(map);
2450 2614
2451 cmdid = evas_filter_command_bump_map_add(ctx, dc, in->cid, bump->cid, out->cid, 2615 cmdid = evas_filter_command_bump_map_add(ctx, dc, src->cid, map->cid, dst->cid,
2452 azimuth, elevation, depth, specular, 2616 azimuth, elevation, depth, specular,
2453 black, color, white, flags, 2617 black, color, white, flags,
2454 fillmode); 2618 fillmode);
@@ -2457,23 +2621,26 @@ _instr2cmd_bump(Evas_Filter_Context *ctx, Evas_Filter_Program *pgm,
2457} 2621}
2458 2622
2459static int 2623static int
2460_instr2cmd_displace(Evas_Filter_Context *ctx, Evas_Filter_Program *pgm, 2624_instr2cmd_displace(Evas_Filter_Context *ctx,
2461 Evas_Filter_Instruction *instr, void *dc) 2625 Evas_Filter_Instruction *instr, void *dc)
2462{ 2626{
2463 Evas_Filter_Fill_Mode fillmode; 2627 Evas_Filter_Fill_Mode fillmode;
2464 Evas_Filter_Displacement_Flags flags = 2628 Evas_Filter_Displacement_Flags flags =
2465 EVAS_FILTER_DISPLACE_STRETCH | EVAS_FILTER_DISPLACE_LINEAR; 2629 EVAS_FILTER_DISPLACE_STRETCH | EVAS_FILTER_DISPLACE_LINEAR;
2466 const char *src, *dst, *map, *flagsstr; 2630 const char *flagsstr;
2467 Buffer *in, *out, *mask; 2631 Buffer *src, *dst, *map;
2468 int cmdid, intensity; 2632 int cmdid, intensity;
2469 Eina_Bool isset = EINA_FALSE; 2633 Eina_Bool isset = EINA_FALSE;
2470 2634
2471 src = _instruction_param_gets(instr, "src", NULL); 2635 src = _instruction_param_getbuf(instr, "src", NULL);
2472 dst = _instruction_param_gets(instr, "dst", NULL); 2636 dst = _instruction_param_getbuf(instr, "dst", NULL);
2473 map = _instruction_param_gets(instr, "map", NULL); 2637 map = _instruction_param_getbuf(instr, "map", NULL);
2474 intensity = _instruction_param_geti(instr, "intensity", NULL); 2638 intensity = _instruction_param_geti(instr, "intensity", NULL);
2475 flagsstr = _instruction_param_gets(instr, "flags", &isset); 2639 flagsstr = _instruction_param_gets(instr, "flags", &isset);
2476 fillmode = _fill_mode_get(instr); 2640 fillmode = _fill_mode_get(instr);
2641 INSTR_PARAM_CHECK(src);
2642 INSTR_PARAM_CHECK(dst);
2643 INSTR_PARAM_CHECK(map);
2477 2644
2478 if (!flagsstr) flagsstr = "default"; 2645 if (!flagsstr) flagsstr = "default";
2479 if (!strcasecmp(flagsstr, "nearest")) 2646 if (!strcasecmp(flagsstr, "nearest"))
@@ -2487,44 +2654,34 @@ _instr2cmd_displace(Evas_Filter_Context *ctx, Evas_Filter_Program *pgm,
2487 else if (isset) 2654 else if (isset)
2488 WRN("Invalid flags '%s' in displace operation. Using default instead", flagsstr); 2655 WRN("Invalid flags '%s' in displace operation. Using default instead", flagsstr);
2489 2656
2490 in = _buffer_get(pgm, src); 2657 cmdid = evas_filter_command_displacement_map_add(ctx, dc, src->cid, dst->cid,
2491 out = _buffer_get(pgm, dst); 2658 map->cid, flags, intensity,
2492 mask = _buffer_get(pgm, map);
2493 EINA_SAFETY_ON_NULL_RETURN_VAL(in, -1);
2494 EINA_SAFETY_ON_NULL_RETURN_VAL(out, -1);
2495 EINA_SAFETY_ON_NULL_RETURN_VAL(mask, -1);
2496
2497 cmdid = evas_filter_command_displacement_map_add(ctx, dc, in->cid, out->cid,
2498 mask->cid, flags, intensity,
2499 fillmode); 2659 fillmode);
2500 2660
2501 return cmdid; 2661 return cmdid;
2502} 2662}
2503 2663
2504static int 2664static int
2505_instr2cmd_fill(Evas_Filter_Context *ctx, Evas_Filter_Program *pgm, 2665_instr2cmd_fill(Evas_Filter_Context *ctx,
2506 Evas_Filter_Instruction *instr, void *dc) 2666 Evas_Filter_Instruction *instr, void *dc)
2507{ 2667{
2508 const char *bufname; 2668 Buffer *dst;
2509 Buffer *buf;
2510 int R, G, B, A, l, r, t, b; 2669 int R, G, B, A, l, r, t, b;
2511 Evas_Filter_Command *cmd; 2670 Evas_Filter_Command *cmd;
2512 Eina_Inlist *il; 2671 Eina_Inlist *il;
2513 DATA32 color; 2672 DATA32 color;
2514 int cmdid; 2673 int cmdid;
2515 2674
2516 bufname = _instruction_param_gets(instr, "dst", NULL); 2675 dst = _instruction_param_getbuf(instr, "dst", NULL);
2517 color = _instruction_param_getc(instr, "color", NULL); 2676 color = _instruction_param_getc(instr, "color", NULL);
2518 l = _instruction_param_geti(instr, "l", NULL); 2677 l = _instruction_param_geti(instr, "l", NULL);
2519 r = _instruction_param_geti(instr, "r", NULL); 2678 r = _instruction_param_geti(instr, "r", NULL);
2520 t = _instruction_param_geti(instr, "t", NULL); 2679 t = _instruction_param_geti(instr, "t", NULL);
2521 b = _instruction_param_geti(instr, "b", NULL); 2680 b = _instruction_param_geti(instr, "b", NULL);
2522 2681 INSTR_PARAM_CHECK(dst);
2523 buf = _buffer_get(pgm, bufname);
2524 EINA_SAFETY_ON_NULL_RETURN_VAL(buf, -1);
2525 2682
2526 SETCOLOR(color); 2683 SETCOLOR(color);
2527 cmdid = evas_filter_command_fill_add(ctx, dc, buf->cid); 2684 cmdid = evas_filter_command_fill_add(ctx, dc, dst->cid);
2528 RESETCOLOR(); 2685 RESETCOLOR();
2529 2686
2530 if (cmdid < 0) return -1; 2687 if (cmdid < 0) return -1;
@@ -2542,26 +2699,22 @@ _instr2cmd_fill(Evas_Filter_Context *ctx, Evas_Filter_Program *pgm,
2542} 2699}
2543 2700
2544static int 2701static int
2545_instr2cmd_grow(Evas_Filter_Context *ctx, Evas_Filter_Program *pgm, 2702_instr2cmd_grow(Evas_Filter_Context *ctx,
2546 Evas_Filter_Instruction *instr, void *dc) 2703 Evas_Filter_Instruction *instr, void *dc)
2547{ 2704{
2548 Evas_Filter_Command *cmd; 2705 Evas_Filter_Command *cmd;
2549 const char *src, *dst; 2706 Buffer *src, *dst;
2550 Buffer *in, *out;
2551 Eina_Bool smooth; 2707 Eina_Bool smooth;
2552 int cmdid, radius; 2708 int cmdid, radius;
2553 2709
2554 src = _instruction_param_gets(instr, "src", NULL); 2710 src = _instruction_param_getbuf(instr, "src", NULL);
2555 dst = _instruction_param_gets(instr, "dst", NULL); 2711 dst = _instruction_param_getbuf(instr, "dst", NULL);
2556 radius = _instruction_param_geti(instr, "radius", NULL); 2712 radius = _instruction_param_geti(instr, "radius", NULL);
2557 smooth = _instruction_param_geti(instr, "smooth", NULL); 2713 smooth = _instruction_param_geti(instr, "smooth", NULL);
2714 INSTR_PARAM_CHECK(src);
2715 INSTR_PARAM_CHECK(dst);
2558 2716
2559 in = _buffer_get(pgm, src); 2717 cmdid = evas_filter_command_grow_add(ctx, dc, src->cid, dst->cid,
2560 out = _buffer_get(pgm, dst);
2561 EINA_SAFETY_ON_NULL_RETURN_VAL(in, -1);
2562 EINA_SAFETY_ON_NULL_RETURN_VAL(out, -1);
2563
2564 cmdid = evas_filter_command_grow_add(ctx, dc, in->cid, out->cid,
2565 radius, smooth); 2718 radius, smooth);
2566 2719
2567 cmd = _evas_filter_command_get(ctx, cmdid); 2720 cmd = _evas_filter_command_get(ctx, cmdid);
@@ -2571,34 +2724,29 @@ _instr2cmd_grow(Evas_Filter_Context *ctx, Evas_Filter_Program *pgm,
2571} 2724}
2572 2725
2573static int 2726static int
2574_instr2cmd_mask(Evas_Filter_Context *ctx, Evas_Filter_Program *pgm, 2727_instr2cmd_mask(Evas_Filter_Context *ctx,
2575 Evas_Filter_Instruction *instr, void *dc) 2728 Evas_Filter_Instruction *instr, void *dc)
2576{ 2729{
2577 Evas_Filter_Fill_Mode fillmode; 2730 Evas_Filter_Fill_Mode fillmode;
2578 const char *src, *dst, *msk; 2731 Buffer *src, *dst, *mask;
2579 Buffer *in, *out, *mask;
2580 DATA32 color; 2732 DATA32 color;
2581 int R, G, B, A, cmdid; 2733 int R, G, B, A, cmdid;
2582 2734
2583 src = _instruction_param_gets(instr, "src", NULL); 2735 src = _instruction_param_getbuf(instr, "src", NULL);
2584 dst = _instruction_param_gets(instr, "dst", NULL); 2736 dst = _instruction_param_getbuf(instr, "dst", NULL);
2585 msk = _instruction_param_gets(instr, "mask", NULL); 2737 mask = _instruction_param_getbuf(instr, "mask", NULL);
2586 color = _instruction_param_getc(instr, "color", NULL); 2738 color = _instruction_param_getc(instr, "color", NULL);
2587 fillmode = _fill_mode_get(instr); 2739 fillmode = _fill_mode_get(instr);
2588 2740 INSTR_PARAM_CHECK(src);
2589 in = _buffer_get(pgm, src); 2741 INSTR_PARAM_CHECK(dst);
2590 out = _buffer_get(pgm, dst); 2742 INSTR_PARAM_CHECK(mask);
2591 mask = _buffer_get(pgm, msk);
2592 EINA_SAFETY_ON_NULL_RETURN_VAL(in, -1);
2593 EINA_SAFETY_ON_NULL_RETURN_VAL(out, -1);
2594 EINA_SAFETY_ON_NULL_RETURN_VAL(mask, -1);
2595 2743
2596 SETCOLOR(color); 2744 SETCOLOR(color);
2597 cmdid = evas_filter_command_mask_add(ctx, dc, in->cid, mask->cid, out->cid, fillmode); 2745 cmdid = evas_filter_command_mask_add(ctx, dc, src->cid, mask->cid, dst->cid, fillmode);
2598 RESETCOLOR(); 2746 RESETCOLOR();
2599 if (cmdid < 0) return cmdid; 2747 if (cmdid < 0) return cmdid;
2600 2748
2601 if (!in->alpha && !mask->alpha && !out->alpha) 2749 if (!src->alpha && !mask->alpha && !dst->alpha)
2602 { 2750 {
2603 Evas_Filter_Command *cmd; 2751 Evas_Filter_Command *cmd;
2604 2752
@@ -2610,23 +2758,25 @@ _instr2cmd_mask(Evas_Filter_Context *ctx, Evas_Filter_Program *pgm,
2610} 2758}
2611 2759
2612static int 2760static int
2613_instr2cmd_curve(Evas_Filter_Context *ctx, Evas_Filter_Program *pgm, 2761_instr2cmd_curve(Evas_Filter_Context *ctx,
2614 Evas_Filter_Instruction *instr, void *dc) 2762 Evas_Filter_Instruction *instr, void *dc)
2615{ 2763{
2616 Evas_Filter_Interpolation_Mode mode = EVAS_FILTER_INTERPOLATION_MODE_LINEAR; 2764 Evas_Filter_Interpolation_Mode mode = EVAS_FILTER_INTERPOLATION_MODE_LINEAR;
2617 Evas_Filter_Channel channel = EVAS_FILTER_CHANNEL_RGB; 2765 Evas_Filter_Channel channel = EVAS_FILTER_CHANNEL_RGB;
2618 const char *src, *dst, *points_str, *interpolation, *channel_name; 2766 const char *points_str, *interpolation, *channel_name;
2619 DATA8 values[256] = {0}, points[512]; 2767 DATA8 values[256] = {0}, points[512];
2620 int cmdid, point_count = 0; 2768 int cmdid, point_count = 0;
2621 char *token, *copy = NULL; 2769 char *token, *copy = NULL;
2622 Buffer *in, *out; 2770 Buffer *src, *dst;
2623 Eina_Bool parse_ok = EINA_FALSE; 2771 Eina_Bool parse_ok = EINA_FALSE;
2624 2772
2625 src = _instruction_param_gets(instr, "src", NULL); 2773 src = _instruction_param_getbuf(instr, "src", NULL);
2626 dst = _instruction_param_gets(instr, "dst", NULL); 2774 dst = _instruction_param_getbuf(instr, "dst", NULL);
2627 points_str = _instruction_param_gets(instr, "points", NULL); 2775 points_str = _instruction_param_gets(instr, "points", NULL);
2628 interpolation = _instruction_param_gets(instr, "interpolation", NULL); 2776 interpolation = _instruction_param_gets(instr, "interpolation", NULL);
2629 channel_name = _instruction_param_gets(instr, "channel", NULL); 2777 channel_name = _instruction_param_gets(instr, "channel", NULL);
2778 INSTR_PARAM_CHECK(src);
2779 INSTR_PARAM_CHECK(dst);
2630 2780
2631 if (channel_name) 2781 if (channel_name)
2632 { 2782 {
@@ -2677,30 +2827,27 @@ interpolated:
2677 values[x] = x; 2827 values[x] = x;
2678 } 2828 }
2679 2829
2680 in = _buffer_get(pgm, src); 2830 cmdid = evas_filter_command_curve_add(ctx, dc, src->cid, dst->cid, values, channel);
2681 out = _buffer_get(pgm, dst);
2682 EINA_SAFETY_ON_NULL_RETURN_VAL(in, -1);
2683 EINA_SAFETY_ON_NULL_RETURN_VAL(out, -1);
2684
2685 cmdid = evas_filter_command_curve_add(ctx, dc, in->cid, out->cid, values, channel);
2686 2831
2687 return cmdid; 2832 return cmdid;
2688} 2833}
2689 2834
2690static int 2835static int
2691_instr2cmd_transform(Evas_Filter_Context *ctx, Evas_Filter_Program *pgm, 2836_instr2cmd_transform(Evas_Filter_Context *ctx,
2692 Evas_Filter_Instruction *instr, void *dc) 2837 Evas_Filter_Instruction *instr, void *dc)
2693{ 2838{
2694 Evas_Filter_Transform_Flags flags; 2839 Evas_Filter_Transform_Flags flags;
2695 const char *src, *dst, *op; 2840 const char *op;
2696 Buffer *in, *out; 2841 Buffer *src, *dst;
2697 int ox = 0, oy; 2842 int ox = 0, oy;
2698 2843
2699 op = _instruction_param_gets(instr, "op", NULL); 2844 op = _instruction_param_gets(instr, "op", NULL);
2700 src = _instruction_param_gets(instr, "src", NULL); 2845 src = _instruction_param_getbuf(instr, "src", NULL);
2701 dst = _instruction_param_gets(instr, "dst", NULL); 2846 dst = _instruction_param_getbuf(instr, "dst", NULL);
2702 // ox = _instruction_param_geti(instr, "ox", NULL); 2847 // ox = _instruction_param_geti(instr, "ox", NULL);
2703 oy = _instruction_param_geti(instr, "oy", NULL); 2848 oy = _instruction_param_geti(instr, "oy", NULL);
2849 INSTR_PARAM_CHECK(src);
2850 INSTR_PARAM_CHECK(dst);
2704 2851
2705 if (!strcasecmp(op, "vflip")) 2852 if (!strcasecmp(op, "vflip"))
2706 flags = EVAS_FILTER_TRANSFORM_VFLIP; 2853 flags = EVAS_FILTER_TRANSFORM_VFLIP;
@@ -2710,20 +2857,14 @@ _instr2cmd_transform(Evas_Filter_Context *ctx, Evas_Filter_Program *pgm,
2710 return -1; 2857 return -1;
2711 } 2858 }
2712 2859
2713 in = _buffer_get(pgm, src); 2860 return evas_filter_command_transform_add(ctx, dc, src->cid, dst->cid, flags, ox, oy);
2714 out = _buffer_get(pgm, dst);
2715 EINA_SAFETY_ON_NULL_RETURN_VAL(in, -1);
2716 EINA_SAFETY_ON_NULL_RETURN_VAL(out, -1);
2717
2718 return evas_filter_command_transform_add(ctx, dc, in->cid, out->cid, flags, ox, oy);
2719} 2861}
2720 2862
2721static int 2863static int
2722_command_from_instruction(Evas_Filter_Context *ctx, Evas_Filter_Program *pgm, 2864_command_from_instruction(Evas_Filter_Context *ctx,
2723 Evas_Filter_Instruction *instr, void *dc) 2865 Evas_Filter_Instruction *instr, void *dc)
2724{ 2866{
2725 int (* instr2cmd) (Evas_Filter_Context *, Evas_Filter_Program *, 2867 int (* instr2cmd) (Evas_Filter_Context *, Evas_Filter_Instruction *, void *);
2726 Evas_Filter_Instruction *, void *);
2727 2868
2728 switch (instr->type) 2869 switch (instr->type)
2729 { 2870 {
@@ -2762,7 +2903,7 @@ _command_from_instruction(Evas_Filter_Context *ctx, Evas_Filter_Program *pgm,
2762 return -1; 2903 return -1;
2763 } 2904 }
2764 2905
2765 return instr2cmd(ctx, pgm, instr, dc); 2906 return instr2cmd(ctx, instr, dc);
2766} 2907}
2767 2908
2768#ifdef FILTERS_DEBUG 2909#ifdef FILTERS_DEBUG
@@ -2780,31 +2921,37 @@ _instruction_dump(Evas_Filter_Instruction *instr)
2780 eina_strbuf_append(str, "({ "); 2921 eina_strbuf_append(str, "({ ");
2781 EINA_INLIST_FOREACH(instr->params, param) 2922 EINA_INLIST_FOREACH(instr->params, param)
2782 { 2923 {
2783 int i;
2784 DATA32 c;
2785 const char *s;
2786 double d;
2787
2788 switch (param->type) 2924 switch (param->type)
2789 { 2925 {
2790 case VT_BOOL: 2926 case VT_BOOL:
2791 case VT_INT: 2927 case VT_INT:
2792 eina_value_get(param->value, &i); 2928 eina_strbuf_append_printf(str, "%s%s = %d", comma, param->name, param->value.i);
2793 eina_strbuf_append_printf(str, "%s%s = %d", comma, param->name, i);
2794 break; 2929 break;
2795 case VT_COLOR: 2930 case VT_COLOR:
2796 eina_value_get(param->value, &c); 2931 eina_strbuf_append_printf(str, "%s%s = 0x%08x", comma, param->name, param->value.c);
2797 eina_strbuf_append_printf(str, "%s%s = 0x%08x", comma, param->name, c);
2798 break; 2932 break;
2799 case VT_REAL: 2933 case VT_REAL:
2800 eina_value_get(param->value, &d); 2934 eina_strbuf_append_printf(str, "%s%s = %f", comma, param->name, param->value.f);
2801 eina_strbuf_append_printf(str, "%s%s = %f", comma, param->name, d);
2802 break; 2935 break;
2803 case VT_STRING: 2936 case VT_STRING:
2937 if (param->value.s)
2938 eina_strbuf_append_printf(str, "%s%s = \"%s\"", comma, param->name, param->value.s);
2939 else
2940 eina_strbuf_append_printf(str, "%s%s = nil", comma, param->name);
2941 break;
2804 case VT_BUFFER: 2942 case VT_BUFFER:
2805 eina_value_get(param->value, &s); 2943 if (param->value.buf)
2806 if (s) eina_strbuf_append_printf(str, "%s%s = \"%s\"", comma, param->name, s); 2944 {
2807 else eina_strbuf_append_printf(str, "%s%s = nil", comma, param->name); 2945 Buffer *buf = param->value.buf;
2946 eina_strbuf_append_printf(str, "%s%s = Buffer[#%d %dx%d %s%s%s]",
2947 comma, param->name,
2948 buf->cid, buf->w, buf->h,
2949 buf->alpha ? "alpha" : "rgba",
2950 buf->proxy ? " src: " : "",
2951 buf->proxy ? buf->proxy : "");
2952 }
2953 else
2954 eina_strbuf_append_printf(str, "%s%s = nil", comma, param->name);
2808 break; 2955 break;
2809 case VT_NONE: 2956 case VT_NONE:
2810 default: 2957 default:
@@ -2883,7 +3030,7 @@ evas_filter_context_program_use(Evas_Filter_Context *ctx,
2883 EINA_INLIST_FOREACH(pgm->instructions, instr) 3030 EINA_INLIST_FOREACH(pgm->instructions, instr)
2884 { 3031 {
2885 _instruction_dump(instr); 3032 _instruction_dump(instr);
2886 cmdid = _command_from_instruction(ctx, pgm, instr, dc); 3033 cmdid = _command_from_instruction(ctx, instr, dc);
2887 if (cmdid <= 0) 3034 if (cmdid <= 0)
2888 goto end; 3035 goto end;
2889 } 3036 }