summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2015-05-28 10:12:18 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2015-06-25 14:36:08 +0900
commit1b2819f2cbe3aa1970ea2467f01b07b24f793f4d (patch)
treede5b686b787ec150c467af6562655b8331784b65
parentffea07a0493df3423d633d4ef3ce401fc15c0fd4 (diff)
Evas filters: Implement __index for Lua buffer objects
-rw-r--r--src/lib/evas/canvas/evas_object_image.c5
-rw-r--r--src/lib/evas/canvas/evas_object_text.c2
-rw-r--r--src/lib/evas/filters/evas_filter.c2
-rw-r--r--src/lib/evas/filters/evas_filter_parser.c60
4 files changed, 64 insertions, 5 deletions
diff --git a/src/lib/evas/canvas/evas_object_image.c b/src/lib/evas/canvas/evas_object_image.c
index a272206bc6..bca2af5393 100644
--- a/src/lib/evas/canvas/evas_object_image.c
+++ b/src/lib/evas/canvas/evas_object_image.c
@@ -3268,6 +3268,9 @@ start_draw:
3268 W = obj->cur->geometry.w; 3268 W = obj->cur->geometry.w;
3269 H = obj->cur->geometry.h; 3269 H = obj->cur->geometry.h;
3270 3270
3271 if (pgm && evas_filter_program_state_set(pgm, eo_obj, obj))
3272 redraw = EINA_TRUE;
3273
3271 if (!redraw && o->cur->filter->output) 3274 if (!redraw && o->cur->filter->output)
3272 { 3275 {
3273 if (eina_hash_population(o->cur->filter->sources) > 0) 3276 if (eina_hash_population(o->cur->filter->sources) > 0)
@@ -3306,6 +3309,7 @@ start_draw:
3306 { 3309 {
3307 pgm = evas_filter_program_new("Image", EINA_FALSE); 3310 pgm = evas_filter_program_new("Image", EINA_FALSE);
3308 evas_filter_program_source_set_all(pgm, o->cur->filter->sources); 3311 evas_filter_program_source_set_all(pgm, o->cur->filter->sources);
3312 evas_filter_program_state_set(pgm, eo_obj, obj);
3309 ok = evas_filter_program_parse(pgm, o->cur->filter->code); 3313 ok = evas_filter_program_parse(pgm, o->cur->filter->code);
3310 if (!ok) goto state_write; 3314 if (!ok) goto state_write;
3311 } 3315 }
@@ -4836,6 +4840,7 @@ _evas_image_filter_program_set(Eo *eo_obj, Evas_Image_Data *o, const char *arg)
4836 { 4840 {
4837 pgm = evas_filter_program_new("Evas_Text: Filter Program", EINA_FALSE); 4841 pgm = evas_filter_program_new("Evas_Text: Filter Program", EINA_FALSE);
4838 evas_filter_program_source_set_all(pgm, fcow->sources); 4842 evas_filter_program_source_set_all(pgm, fcow->sources);
4843 evas_filter_program_state_set(pgm, eo_obj, obj);
4839 if (!evas_filter_program_parse(pgm, arg)) 4844 if (!evas_filter_program_parse(pgm, arg))
4840 { 4845 {
4841 ERR("Parsing failed!"); 4846 ERR("Parsing failed!");
diff --git a/src/lib/evas/canvas/evas_object_text.c b/src/lib/evas/canvas/evas_object_text.c
index 39e6c62865..6fb4335d23 100644
--- a/src/lib/evas/canvas/evas_object_text.c
+++ b/src/lib/evas/canvas/evas_object_text.c
@@ -1783,6 +1783,7 @@ evas_object_text_render(Evas_Object *eo_obj,
1783 Evas_Filter_Program *pgm; 1783 Evas_Filter_Program *pgm;
1784 pgm = evas_filter_program_new("Evas_Text", EINA_TRUE); 1784 pgm = evas_filter_program_new("Evas_Text", EINA_TRUE);
1785 evas_filter_program_source_set_all(pgm, fcow->sources); 1785 evas_filter_program_source_set_all(pgm, fcow->sources);
1786 evas_filter_program_state_set(pgm, eo_obj, obj);
1786 if (!evas_filter_program_parse(pgm, fcow->code)) 1787 if (!evas_filter_program_parse(pgm, fcow->code))
1787 { 1788 {
1788 ERR("Filter program parsing failed"); 1789 ERR("Filter program parsing failed");
@@ -1795,7 +1796,6 @@ evas_object_text_render(Evas_Object *eo_obj,
1795 } 1796 }
1796 fcow->chain = pgm; 1797 fcow->chain = pgm;
1797 fcow->invalid = EINA_FALSE; 1798 fcow->invalid = EINA_FALSE;
1798 evas_filter_program_state_set(fcow->chain, eo_obj, obj);
1799 } 1799 }
1800 else if (previous && !fcow->changed) 1800 else if (previous && !fcow->changed)
1801 { 1801 {
diff --git a/src/lib/evas/filters/evas_filter.c b/src/lib/evas/filters/evas_filter.c
index 1a8c2ed291..dd9fdc5e6f 100644
--- a/src/lib/evas/filters/evas_filter.c
+++ b/src/lib/evas/filters/evas_filter.c
@@ -1905,7 +1905,7 @@ _filter_command_run(Evas_Filter_Command *cmd)
1905 1905
1906 if (!func) 1906 if (!func)
1907 { 1907 {
1908 CRI("No function to process this filter!"); 1908 ERR("No function to process this filter!");
1909 return EINA_FALSE; 1909 return EINA_FALSE;
1910 } 1910 }
1911 1911
diff --git a/src/lib/evas/filters/evas_filter_parser.c b/src/lib/evas/filters/evas_filter_parser.c
index e1a59d20a7..60a93fe8db 100644
--- a/src/lib/evas/filters/evas_filter_parser.c
+++ b/src/lib/evas/filters/evas_filter_parser.c
@@ -663,6 +663,62 @@ _lua_buffer_tostring(lua_State *L)
663} 663}
664 664
665static int 665static int
666_lua_buffer_index(lua_State *L)
667{
668 Buffer *buf, **pbuf;
669 const char *key;
670
671 pbuf = lua_touserdata(L, 1);
672 buf = pbuf ? *pbuf : NULL;
673 if (!buf) return 0;
674
675 key = lua_tostring(L, 2);
676 if (!key) return 0;
677
678 if (!strcmp(key, "width"))
679 {
680 lua_pushinteger(L, buf->w);
681 return 1;
682 }
683 else if (!strcmp(key, "height"))
684 {
685 lua_pushinteger(L, buf->h);
686 return 1;
687 }
688 else if (!strcmp(key, "type"))
689 {
690 lua_pushstring(L, buf->alpha ? "alpha" : "rgba");
691 return 1;
692 }
693 else if (!strcmp(key, "alpha"))
694 {
695 lua_pushboolean(L, buf->alpha);
696 return 1;
697 }
698 else if (!strcmp(key, "rgba"))
699 {
700 lua_pushboolean(L, !buf->alpha);
701 return 1;
702 }
703 else if (!strcmp(key, "name"))
704 {
705 lua_pushstring(L, buf->name);
706 return 1;
707 }
708 else if (!strcmp(key, "source"))
709 {
710 if (!buf->proxy) return 0;
711 lua_pushstring(L, buf->proxy);
712 return 1;
713 }
714 else
715 {
716 DBG("Unknown index '%s' for a buffer", key);
717 return 0;
718 }
719}
720
721static int
666_lua_buffer_width(lua_State *L) 722_lua_buffer_width(lua_State *L)
667{ 723{
668 Buffer *buf, **pbuf; 724 Buffer *buf, **pbuf;
@@ -2052,6 +2108,7 @@ static const luaL_Reg buffer_methods[] = {
2052 2108
2053static const luaL_Reg buffer_meta[] = { 2109static const luaL_Reg buffer_meta[] = {
2054 { "__tostring", _lua_buffer_tostring }, 2110 { "__tostring", _lua_buffer_tostring },
2111 { "__index", _lua_buffer_index },
2055 { NULL, NULL } 2112 { NULL, NULL }
2056}; 2113};
2057 2114
@@ -2159,9 +2216,6 @@ _lua_state_create(Evas_Filter_Program *pgm)
2159 luaL_openlib(L, _lua_buffer_meta, buffer_methods, 0); 2216 luaL_openlib(L, _lua_buffer_meta, buffer_methods, 0);
2160 luaL_newmetatable(L, _lua_buffer_meta); 2217 luaL_newmetatable(L, _lua_buffer_meta);
2161 luaL_openlib(L, NULL, buffer_meta, 0); 2218 luaL_openlib(L, NULL, buffer_meta, 0);
2162 lua_pushliteral(L, "__index");
2163 lua_pushvalue(L, -3);
2164 lua_rawset(L, -3);
2165 lua_pushliteral(L, "__metatable"); 2219 lua_pushliteral(L, "__metatable");
2166 lua_pushvalue(L, -3); 2220 lua_pushvalue(L, -3);
2167 lua_rawset(L, -3); 2221 lua_rawset(L, -3);