forked from enlightenment/efl
Evas filters: Implement __index for Lua buffer objects
This commit is contained in:
parent
ffea07a049
commit
1b2819f2cb
|
@ -3268,6 +3268,9 @@ start_draw:
|
|||
W = obj->cur->geometry.w;
|
||||
H = obj->cur->geometry.h;
|
||||
|
||||
if (pgm && evas_filter_program_state_set(pgm, eo_obj, obj))
|
||||
redraw = EINA_TRUE;
|
||||
|
||||
if (!redraw && o->cur->filter->output)
|
||||
{
|
||||
if (eina_hash_population(o->cur->filter->sources) > 0)
|
||||
|
@ -3306,6 +3309,7 @@ start_draw:
|
|||
{
|
||||
pgm = evas_filter_program_new("Image", EINA_FALSE);
|
||||
evas_filter_program_source_set_all(pgm, o->cur->filter->sources);
|
||||
evas_filter_program_state_set(pgm, eo_obj, obj);
|
||||
ok = evas_filter_program_parse(pgm, o->cur->filter->code);
|
||||
if (!ok) goto state_write;
|
||||
}
|
||||
|
@ -4836,6 +4840,7 @@ _evas_image_filter_program_set(Eo *eo_obj, Evas_Image_Data *o, const char *arg)
|
|||
{
|
||||
pgm = evas_filter_program_new("Evas_Text: Filter Program", EINA_FALSE);
|
||||
evas_filter_program_source_set_all(pgm, fcow->sources);
|
||||
evas_filter_program_state_set(pgm, eo_obj, obj);
|
||||
if (!evas_filter_program_parse(pgm, arg))
|
||||
{
|
||||
ERR("Parsing failed!");
|
||||
|
|
|
@ -1783,6 +1783,7 @@ evas_object_text_render(Evas_Object *eo_obj,
|
|||
Evas_Filter_Program *pgm;
|
||||
pgm = evas_filter_program_new("Evas_Text", EINA_TRUE);
|
||||
evas_filter_program_source_set_all(pgm, fcow->sources);
|
||||
evas_filter_program_state_set(pgm, eo_obj, obj);
|
||||
if (!evas_filter_program_parse(pgm, fcow->code))
|
||||
{
|
||||
ERR("Filter program parsing failed");
|
||||
|
@ -1795,7 +1796,6 @@ evas_object_text_render(Evas_Object *eo_obj,
|
|||
}
|
||||
fcow->chain = pgm;
|
||||
fcow->invalid = EINA_FALSE;
|
||||
evas_filter_program_state_set(fcow->chain, eo_obj, obj);
|
||||
}
|
||||
else if (previous && !fcow->changed)
|
||||
{
|
||||
|
|
|
@ -1905,7 +1905,7 @@ _filter_command_run(Evas_Filter_Command *cmd)
|
|||
|
||||
if (!func)
|
||||
{
|
||||
CRI("No function to process this filter!");
|
||||
ERR("No function to process this filter!");
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
|
|
|
@ -662,6 +662,62 @@ _lua_buffer_tostring(lua_State *L)
|
|||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
_lua_buffer_index(lua_State *L)
|
||||
{
|
||||
Buffer *buf, **pbuf;
|
||||
const char *key;
|
||||
|
||||
pbuf = lua_touserdata(L, 1);
|
||||
buf = pbuf ? *pbuf : NULL;
|
||||
if (!buf) return 0;
|
||||
|
||||
key = lua_tostring(L, 2);
|
||||
if (!key) return 0;
|
||||
|
||||
if (!strcmp(key, "width"))
|
||||
{
|
||||
lua_pushinteger(L, buf->w);
|
||||
return 1;
|
||||
}
|
||||
else if (!strcmp(key, "height"))
|
||||
{
|
||||
lua_pushinteger(L, buf->h);
|
||||
return 1;
|
||||
}
|
||||
else if (!strcmp(key, "type"))
|
||||
{
|
||||
lua_pushstring(L, buf->alpha ? "alpha" : "rgba");
|
||||
return 1;
|
||||
}
|
||||
else if (!strcmp(key, "alpha"))
|
||||
{
|
||||
lua_pushboolean(L, buf->alpha);
|
||||
return 1;
|
||||
}
|
||||
else if (!strcmp(key, "rgba"))
|
||||
{
|
||||
lua_pushboolean(L, !buf->alpha);
|
||||
return 1;
|
||||
}
|
||||
else if (!strcmp(key, "name"))
|
||||
{
|
||||
lua_pushstring(L, buf->name);
|
||||
return 1;
|
||||
}
|
||||
else if (!strcmp(key, "source"))
|
||||
{
|
||||
if (!buf->proxy) return 0;
|
||||
lua_pushstring(L, buf->proxy);
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
DBG("Unknown index '%s' for a buffer", key);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
_lua_buffer_width(lua_State *L)
|
||||
{
|
||||
|
@ -2052,6 +2108,7 @@ static const luaL_Reg buffer_methods[] = {
|
|||
|
||||
static const luaL_Reg buffer_meta[] = {
|
||||
{ "__tostring", _lua_buffer_tostring },
|
||||
{ "__index", _lua_buffer_index },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
|
@ -2159,9 +2216,6 @@ _lua_state_create(Evas_Filter_Program *pgm)
|
|||
luaL_openlib(L, _lua_buffer_meta, buffer_methods, 0);
|
||||
luaL_newmetatable(L, _lua_buffer_meta);
|
||||
luaL_openlib(L, NULL, buffer_meta, 0);
|
||||
lua_pushliteral(L, "__index");
|
||||
lua_pushvalue(L, -3);
|
||||
lua_rawset(L, -3);
|
||||
lua_pushliteral(L, "__metatable");
|
||||
lua_pushvalue(L, -3);
|
||||
lua_rawset(L, -3);
|
||||
|
|
Loading…
Reference in New Issue