forked from enlightenment/efl
Evas filters: Add name to the filters
Deep down internally there was already a name, but no API could really set it properly. Here Edje will set the name of the filter based on the part name or the data item name if relevant.
This commit is contained in:
parent
29402b2ce9
commit
84e3dd5c34
|
@ -111,7 +111,7 @@ main(int argc, char **argv)
|
||||||
evas_object_color_set(o, 255, 255, 255, 255);
|
evas_object_color_set(o, 255, 255, 255, 255);
|
||||||
evas_object_show(o);
|
evas_object_show(o);
|
||||||
|
|
||||||
eo_do(o, efl_gfx_filter_program_set(filter));
|
eo_do(o, efl_gfx_filter_program_set(filter, wpd.file));
|
||||||
|
|
||||||
ecore_evas_manual_render(wpd.ee);
|
ecore_evas_manual_render(wpd.ee);
|
||||||
evas_object_geometry_get(o, NULL, NULL, &w, &h);
|
evas_object_geometry_get(o, NULL, NULL, &w, &h);
|
||||||
|
|
|
@ -2404,7 +2404,7 @@ _edje_part_recalc_single_map(Edje *ed,
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline const char *
|
static inline const char *
|
||||||
_edje_filter_get(Edje *ed, Edje_Part_Description_Spec_Filter *filter)
|
_edje_filter_get(Edje *ed, Edje_Real_Part *ep, Edje_Part_Description_Spec_Filter *filter)
|
||||||
{
|
{
|
||||||
if (!filter->code) return NULL;
|
if (!filter->code) return NULL;
|
||||||
if (EINA_UNLIKELY(!filter->checked_data))
|
if (EINA_UNLIKELY(!filter->checked_data))
|
||||||
|
@ -2414,10 +2414,12 @@ _edje_filter_get(Edje *ed, Edje_Part_Description_Spec_Filter *filter)
|
||||||
st = eina_hash_find(ed->file->data, filter->code);
|
st = eina_hash_find(ed->file->data, filter->code);
|
||||||
if (st)
|
if (st)
|
||||||
{
|
{
|
||||||
eina_stringshare_del(filter->code);
|
filter->name = filter->code;
|
||||||
filter->code = st->str;
|
filter->code = st->str;
|
||||||
filter->no_free = 1;
|
filter->no_free = 1;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
filter->name = eina_stringshare_add(ep->part->name);
|
||||||
}
|
}
|
||||||
return filter->code;
|
return filter->code;
|
||||||
}
|
}
|
||||||
|
@ -2465,15 +2467,15 @@ _edje_part_recalc_single_filter(Edje *ed,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* common code below */
|
/* common code below */
|
||||||
code = _edje_filter_get(ed, filter);
|
code = _edje_filter_get(ed, ep, filter);
|
||||||
if (!code)
|
if (!code)
|
||||||
{
|
{
|
||||||
eo_do(obj, efl_gfx_filter_program_set(NULL));
|
eo_do(obj, efl_gfx_filter_program_set(NULL, NULL));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
eo_do(obj,
|
eo_do(obj,
|
||||||
efl_gfx_filter_program_set(code);
|
efl_gfx_filter_program_set(code, filter->name);
|
||||||
if (prev_sources != filter_sources)
|
if (prev_sources != filter_sources)
|
||||||
{
|
{
|
||||||
/* remove sources that are not there anymore
|
/* remove sources that are not there anymore
|
||||||
|
|
|
@ -1507,6 +1507,7 @@ _edje_file_del(Edje *ed)
|
||||||
eina_stringshare_del(rp->typedata.text->cache.out_str);
|
eina_stringshare_del(rp->typedata.text->cache.out_str);
|
||||||
if (!rp->typedata.text->filter.no_free)
|
if (!rp->typedata.text->filter.no_free)
|
||||||
eina_stringshare_del(rp->typedata.text->filter.code);
|
eina_stringshare_del(rp->typedata.text->filter.code);
|
||||||
|
eina_stringshare_del(rp->typedata.text->filter.name);
|
||||||
free(rp->typedata.text);
|
free(rp->typedata.text);
|
||||||
}
|
}
|
||||||
else if ((rp->type == EDJE_RP_TYPE_SWALLOW) &&
|
else if ((rp->type == EDJE_RP_TYPE_SWALLOW) &&
|
||||||
|
@ -1932,6 +1933,7 @@ _edje_collection_free_part_description_clean(int type, Edje_Part_Description_Com
|
||||||
eina_stringshare_del(text->text.font.str);
|
eina_stringshare_del(text->text.font.str);
|
||||||
if (!text->text.filter.no_free)
|
if (!text->text.filter.no_free)
|
||||||
eina_stringshare_del(text->text.filter.code);
|
eina_stringshare_del(text->text.filter.code);
|
||||||
|
eina_stringshare_del(text->text.filter.name);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1281,6 +1281,7 @@ struct _Edje_Part_Description_Spec_Border
|
||||||
struct _Edje_Part_Description_Spec_Filter
|
struct _Edje_Part_Description_Spec_Filter
|
||||||
{
|
{
|
||||||
const char *code;
|
const char *code;
|
||||||
|
const char *name;
|
||||||
Eina_List *sources; /* "part" or "buffer:part" */
|
Eina_List *sources; /* "part" or "buffer:part" */
|
||||||
Eina_Bool checked_data : 1; // checked whether this is a data item or embedded string
|
Eina_Bool checked_data : 1; // checked whether this is a data item or embedded string
|
||||||
Eina_Bool no_free : 1;
|
Eina_Bool no_free : 1;
|
||||||
|
|
|
@ -24,6 +24,7 @@ interface Efl.Gfx.Filter
|
||||||
}
|
}
|
||||||
values {
|
values {
|
||||||
code: const(char)*; [[filter program source code]]
|
code: const(char)*; [[filter program source code]]
|
||||||
|
name: const(char)*(0); [[filter name (optional)]]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@property state {
|
@property state {
|
||||||
|
|
|
@ -121,7 +121,7 @@ evas_filter_object_render(Eo *eo_obj, Evas_Object_Protected_Data *obj,
|
||||||
if (!fcow->chain)
|
if (!fcow->chain)
|
||||||
{
|
{
|
||||||
Evas_Filter_Program *pgm;
|
Evas_Filter_Program *pgm;
|
||||||
pgm = evas_filter_program_new(obj->name ? obj->name : obj->type, alpha);
|
pgm = evas_filter_program_new(fcow->name, alpha);
|
||||||
evas_filter_program_source_set_all(pgm, fcow->sources);
|
evas_filter_program_source_set_all(pgm, fcow->sources);
|
||||||
evas_filter_program_state_set(pgm, eo_obj, obj,
|
evas_filter_program_state_set(pgm, eo_obj, obj,
|
||||||
fcow->state.cur.name, fcow->state.cur.value,
|
fcow->state.cur.name, fcow->state.cur.value,
|
||||||
|
@ -252,25 +252,27 @@ evas_filter_object_render(Eo *eo_obj, Evas_Object_Protected_Data *obj,
|
||||||
|
|
||||||
EOLIAN void
|
EOLIAN void
|
||||||
_evas_filter_efl_gfx_filter_program_set(Eo *eo_obj, Evas_Filter_Data *pd,
|
_evas_filter_efl_gfx_filter_program_set(Eo *eo_obj, Evas_Filter_Data *pd,
|
||||||
const char *code)
|
const char *code, const char *name)
|
||||||
{
|
{
|
||||||
Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJECT_CLASS);
|
Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJECT_CLASS);
|
||||||
Evas_Filter_Program *pgm = NULL;
|
Evas_Filter_Program *pgm = NULL;
|
||||||
Eina_Bool alpha;
|
Eina_Bool alpha;
|
||||||
|
|
||||||
if (!pd) return;
|
if (!pd) return;
|
||||||
if (pd->data->code == code) return;
|
if ((pd->data->code == code) && (!name || (pd->data->name == name))) return;
|
||||||
if (pd->data->code && code && !strcmp(code, pd->data->code)) return;
|
if (pd->data->code && code && !strcmp(code, pd->data->code) &&
|
||||||
|
pd->data->name && name && !strcmp(name, pd->data->name)) return;
|
||||||
|
|
||||||
evas_object_async_block(obj);
|
evas_object_async_block(obj);
|
||||||
EINA_COW_WRITE_BEGIN(evas_object_filter_cow, pd->data, Evas_Object_Filter_Data, fcow)
|
EINA_COW_WRITE_BEGIN(evas_object_filter_cow, pd->data, Evas_Object_Filter_Data, fcow)
|
||||||
{
|
{
|
||||||
// Parse filter program
|
// Parse filter program
|
||||||
evas_filter_program_del(fcow->chain);
|
evas_filter_program_del(fcow->chain);
|
||||||
|
eina_stringshare_replace(&fcow->name, name);
|
||||||
if (code)
|
if (code)
|
||||||
{
|
{
|
||||||
alpha = eo_do_ret(eo_obj, alpha, evas_filter_input_alpha());
|
alpha = eo_do_ret(eo_obj, alpha, evas_filter_input_alpha());
|
||||||
pgm = evas_filter_program_new("Evas.Filter", alpha);
|
pgm = evas_filter_program_new(fcow->name, alpha);
|
||||||
evas_filter_program_source_set_all(pgm, fcow->sources);
|
evas_filter_program_source_set_all(pgm, fcow->sources);
|
||||||
evas_filter_program_state_set(pgm, eo_obj, obj,
|
evas_filter_program_state_set(pgm, eo_obj, obj,
|
||||||
fcow->state.cur.name, fcow->state.cur.value,
|
fcow->state.cur.name, fcow->state.cur.value,
|
||||||
|
@ -298,10 +300,11 @@ _evas_filter_efl_gfx_filter_program_set(Eo *eo_obj, Evas_Filter_Data *pd,
|
||||||
evas_object_inform_call_resize(eo_obj);
|
evas_object_inform_call_resize(eo_obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
EOLIAN const char *
|
EOLIAN void
|
||||||
_evas_filter_efl_gfx_filter_program_get(Eo *eo_obj EINA_UNUSED, Evas_Filter_Data *pd)
|
_evas_filter_efl_gfx_filter_program_get(Eo *eo_obj EINA_UNUSED, Evas_Filter_Data *pd, const char **code, const char **name)
|
||||||
{
|
{
|
||||||
return pd->data->code;
|
if (code) *code = pd->data->code;
|
||||||
|
if (name) *name = pd->data->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
EOLIAN void
|
EOLIAN void
|
||||||
|
|
|
@ -4729,17 +4729,16 @@ evas_object_image_smooth_scale_get(const Eo *obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
EOLIAN void
|
EOLIAN void
|
||||||
_evas_image_efl_gfx_filter_program_set(Eo *obj, Evas_Image_Data *pd EINA_UNUSED, const char *code)
|
_evas_image_efl_gfx_filter_program_set(Eo *obj, Evas_Image_Data *pd EINA_UNUSED, const char *code, const char *name)
|
||||||
{
|
{
|
||||||
pd->has_filter = (code != NULL);
|
pd->has_filter = (code != NULL);
|
||||||
eo_do_super(obj, MY_CLASS, efl_gfx_filter_program_set(code));
|
eo_do_super(obj, MY_CLASS, efl_gfx_filter_program_set(code, name));
|
||||||
}
|
}
|
||||||
|
|
||||||
EOLIAN const char *
|
EOLIAN void
|
||||||
_evas_image_efl_gfx_filter_program_get(Eo *obj, Evas_Image_Data *pd EINA_UNUSED)
|
_evas_image_efl_gfx_filter_program_get(Eo *obj, Evas_Image_Data *pd EINA_UNUSED, const char **code, const char **name)
|
||||||
{
|
{
|
||||||
const char *code;
|
eo_do_super(obj, MY_CLASS, efl_gfx_filter_program_get(code, name));
|
||||||
return eo_do_super_ret(obj, MY_CLASS, code, efl_gfx_filter_program_get());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EOLIAN void
|
EOLIAN void
|
||||||
|
|
|
@ -33,7 +33,7 @@ static const Evas_Object_Protected_State default_state = {
|
||||||
1.0, 0, EVAS_RENDER_BLEND, EINA_FALSE, EINA_FALSE, EINA_FALSE, EINA_FALSE, EINA_FALSE, EINA_FALSE
|
1.0, 0, EVAS_RENDER_BLEND, EINA_FALSE, EINA_FALSE, EINA_FALSE, EINA_FALSE, EINA_FALSE, EINA_FALSE
|
||||||
};
|
};
|
||||||
static const Evas_Object_Filter_Data default_filter = {
|
static const Evas_Object_Filter_Data default_filter = {
|
||||||
NULL, NULL, NULL, NULL, { { "default", 0.0 }, { "default", 0.0 }, 0.0 }, EINA_FALSE, EINA_FALSE
|
NULL, NULL, NULL, NULL, NULL, { { "default", 0.0 }, { "default", 0.0 }, 0.0 }, EINA_FALSE, EINA_FALSE
|
||||||
};
|
};
|
||||||
const void * const evas_object_filter_cow_default = &default_filter;
|
const void * const evas_object_filter_cow_default = &default_filter;
|
||||||
static const Evas_Object_Mask_Data default_mask = {
|
static const Evas_Object_Mask_Data default_mask = {
|
||||||
|
|
|
@ -2227,17 +2227,16 @@ evas_object_text_text_get(const Eo *obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
EOLIAN void
|
EOLIAN void
|
||||||
_evas_text_efl_gfx_filter_program_set(Eo *obj, Evas_Text_Data *pd EINA_UNUSED, const char *code)
|
_evas_text_efl_gfx_filter_program_set(Eo *obj, Evas_Text_Data *pd EINA_UNUSED, const char *code, const char *name)
|
||||||
{
|
{
|
||||||
pd->has_filter = (code != NULL);
|
pd->has_filter = (code != NULL);
|
||||||
eo_do_super(obj, MY_CLASS, efl_gfx_filter_program_set(code));
|
eo_do_super(obj, MY_CLASS, efl_gfx_filter_program_set(code, name));
|
||||||
}
|
}
|
||||||
|
|
||||||
EOLIAN const char *
|
EOLIAN void
|
||||||
_evas_text_efl_gfx_filter_program_get(Eo *obj, Evas_Text_Data *pd EINA_UNUSED)
|
_evas_text_efl_gfx_filter_program_get(Eo *obj, Evas_Text_Data *pd EINA_UNUSED, const char **code, const char **name)
|
||||||
{
|
{
|
||||||
const char *code;
|
eo_do_super(obj, MY_CLASS, efl_gfx_filter_program_get(code, name));
|
||||||
return eo_do_super_ret(obj, MY_CLASS, code, efl_gfx_filter_program_get());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EOLIAN void
|
EOLIAN void
|
||||||
|
|
|
@ -1174,6 +1174,7 @@ struct _Evas_Device
|
||||||
|
|
||||||
struct _Evas_Object_Filter_Data
|
struct _Evas_Object_Filter_Data
|
||||||
{
|
{
|
||||||
|
Eina_Stringshare *name;
|
||||||
Eina_Stringshare *code;
|
Eina_Stringshare *code;
|
||||||
Evas_Filter_Program *chain;
|
Evas_Filter_Program *chain;
|
||||||
Eina_Hash *sources; // Evas_Filter_Proxy_Binding
|
Eina_Hash *sources; // Evas_Filter_Proxy_Binding
|
||||||
|
|
|
@ -311,7 +311,7 @@ START_TEST(evas_filter_text_padding_test)
|
||||||
// Don't test proxy cases here.
|
// Don't test proxy cases here.
|
||||||
if (tc->source) continue;
|
if (tc->source) continue;
|
||||||
|
|
||||||
eo_do(to, efl_gfx_filter_program_set(tc->code));
|
eo_do(to, efl_gfx_filter_program_set(tc->code, "evas_test_filter"));
|
||||||
evas_object_text_style_pad_get(to, &l, &r, &t, &b);
|
evas_object_text_style_pad_get(to, &l, &r, &t, &b);
|
||||||
evas_object_geometry_get(to, NULL, NULL, &W, &H);
|
evas_object_geometry_get(to, NULL, NULL, &W, &H);
|
||||||
//fprintf(stderr, "Case %d: %dx%d for padding %d,%d,%d,%d\n", k, W, H, l, r, t, b);
|
//fprintf(stderr, "Case %d: %dx%d for padding %d,%d,%d,%d\n", k, W, H, l, r, t, b);
|
||||||
|
@ -400,13 +400,13 @@ START_TEST(evas_filter_text_render_test)
|
||||||
eo_do(to,
|
eo_do(to,
|
||||||
efl_gfx_color_set(255, 255, 255, 255),
|
efl_gfx_color_set(255, 255, 255, 255),
|
||||||
efl_gfx_filter_source_set(tc->source, o),
|
efl_gfx_filter_source_set(tc->source, o),
|
||||||
efl_gfx_filter_program_set(tc->code));
|
efl_gfx_filter_program_set(tc->code, , "evas_test_filter"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
eo_do(to,
|
eo_do(to,
|
||||||
efl_gfx_color_set(255, 255, 255, 255),
|
efl_gfx_color_set(255, 255, 255, 255),
|
||||||
efl_gfx_filter_program_set(tc->code));
|
efl_gfx_filter_program_set(tc->code, , "evas_test_filter"));
|
||||||
}
|
}
|
||||||
|
|
||||||
evas_object_geometry_get(to, NULL, NULL, &w, &h);
|
evas_object_geometry_get(to, NULL, NULL, &w, &h);
|
||||||
|
|
Loading…
Reference in New Issue