jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=84e3dd5c34f3ee7a8f07311eab6c950d1c76ea51

commit 84e3dd5c34f3ee7a8f07311eab6c950d1c76ea51
Author: Jean-Philippe Andre <jp.an...@samsung.com>
Date:   Fri Jun 19 17:38:28 2015 +0900

    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.
---
 doc/previews/preview_text_filter.c       |  2 +-
 src/lib/edje/edje_calc.c                 | 12 +++++++-----
 src/lib/edje/edje_load.c                 |  2 ++
 src/lib/edje/edje_private.h              |  1 +
 src/lib/efl/interfaces/efl_gfx_filter.eo |  1 +
 src/lib/evas/canvas/evas_filter_mixin.c  | 19 +++++++++++--------
 src/lib/evas/canvas/evas_object_image.c  | 11 +++++------
 src/lib/evas/canvas/evas_object_main.c   |  2 +-
 src/lib/evas/canvas/evas_object_text.c   | 11 +++++------
 src/lib/evas/include/evas_private.h      |  1 +
 src/tests/evas/evas_test_filters.c       |  6 +++---
 11 files changed, 38 insertions(+), 30 deletions(-)

diff --git a/doc/previews/preview_text_filter.c 
b/doc/previews/preview_text_filter.c
index 24c51cd..778cb7a 100644
--- a/doc/previews/preview_text_filter.c
+++ b/doc/previews/preview_text_filter.c
@@ -111,7 +111,7 @@ main(int argc, char **argv)
    evas_object_color_set(o, 255, 255, 255, 255);
    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);
    evas_object_geometry_get(o, NULL, NULL, &w, &h);
diff --git a/src/lib/edje/edje_calc.c b/src/lib/edje/edje_calc.c
index a1cd9c1..48a4d81 100644
--- a/src/lib/edje/edje_calc.c
+++ b/src/lib/edje/edje_calc.c
@@ -2404,7 +2404,7 @@ _edje_part_recalc_single_map(Edje *ed,
 }
 
 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 (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);
         if (st)
           {
-             eina_stringshare_del(filter->code);
+             filter->name = filter->code;
              filter->code = st->str;
              filter->no_free = 1;
           }
+        else
+          filter->name = eina_stringshare_add(ep->part->name);
      }
    return filter->code;
 }
@@ -2465,15 +2467,15 @@ _edje_part_recalc_single_filter(Edje *ed,
      }
 
    /* common code below */
-   code = _edje_filter_get(ed, filter);
+   code = _edje_filter_get(ed, ep, filter);
    if (!code)
      {
-        eo_do(obj, efl_gfx_filter_program_set(NULL));
+        eo_do(obj, efl_gfx_filter_program_set(NULL, NULL));
         return;
      }
 
    eo_do(obj,
-         efl_gfx_filter_program_set(code);
+         efl_gfx_filter_program_set(code, filter->name);
          if (prev_sources != filter_sources)
            {
               /* remove sources that are not there anymore
diff --git a/src/lib/edje/edje_load.c b/src/lib/edje/edje_load.c
index b4533e7..a261c2f 100644
--- a/src/lib/edje/edje_load.c
+++ b/src/lib/edje/edje_load.c
@@ -1507,6 +1507,7 @@ _edje_file_del(Edje *ed)
                   eina_stringshare_del(rp->typedata.text->cache.out_str);
                   if (!rp->typedata.text->filter.no_free)
                     eina_stringshare_del(rp->typedata.text->filter.code);
+                  eina_stringshare_del(rp->typedata.text->filter.name);
                   free(rp->typedata.text);
                }
              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);
              if (!text->text.filter.no_free)
                eina_stringshare_del(text->text.filter.code);
+             eina_stringshare_del(text->text.filter.name);
           }
         break;
      }
diff --git a/src/lib/edje/edje_private.h b/src/lib/edje/edje_private.h
index d8c0411..fcc463c 100644
--- a/src/lib/edje/edje_private.h
+++ b/src/lib/edje/edje_private.h
@@ -1281,6 +1281,7 @@ struct _Edje_Part_Description_Spec_Border
 struct _Edje_Part_Description_Spec_Filter
 {
    const char    *code;
+   const char    *name;
    Eina_List     *sources; /* "part" or "buffer:part" */
    Eina_Bool      checked_data : 1; // checked whether this is a data item or 
embedded string
    Eina_Bool      no_free : 1;
diff --git a/src/lib/efl/interfaces/efl_gfx_filter.eo 
b/src/lib/efl/interfaces/efl_gfx_filter.eo
index baa6046..ed8bedc 100644
--- a/src/lib/efl/interfaces/efl_gfx_filter.eo
+++ b/src/lib/efl/interfaces/efl_gfx_filter.eo
@@ -24,6 +24,7 @@ interface Efl.Gfx.Filter
          }
          values {
             code: const(char)*; [[filter program source code]]
+            name: const(char)*(0); [[filter name (optional)]]
          }
       }
       @property state {
diff --git a/src/lib/evas/canvas/evas_filter_mixin.c 
b/src/lib/evas/canvas/evas_filter_mixin.c
index 243b359..87454a7 100644
--- a/src/lib/evas/canvas/evas_filter_mixin.c
+++ b/src/lib/evas/canvas/evas_filter_mixin.c
@@ -121,7 +121,7 @@ evas_filter_object_render(Eo *eo_obj, 
Evas_Object_Protected_Data *obj,
         if (!fcow->chain)
           {
              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_state_set(pgm, eo_obj, obj,
                                            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
 _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_Filter_Program *pgm = NULL;
    Eina_Bool alpha;
 
    if (!pd) return;
-   if (pd->data->code == code) return;
-   if (pd->data->code && code && !strcmp(code, pd->data->code)) return;
+   if ((pd->data->code == code) && (!name || (pd->data->name == name))) 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);
    EINA_COW_WRITE_BEGIN(evas_object_filter_cow, pd->data, 
Evas_Object_Filter_Data, fcow)
      {
         // Parse filter program
         evas_filter_program_del(fcow->chain);
+        eina_stringshare_replace(&fcow->name, name);
         if (code)
           {
              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_state_set(pgm, eo_obj, obj,
                                            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);
 }
 
-EOLIAN const char *
-_evas_filter_efl_gfx_filter_program_get(Eo *eo_obj EINA_UNUSED, 
Evas_Filter_Data *pd)
+EOLIAN void
+_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
diff --git a/src/lib/evas/canvas/evas_object_image.c 
b/src/lib/evas/canvas/evas_object_image.c
index 7532c4a..7fa102f 100644
--- a/src/lib/evas/canvas/evas_object_image.c
+++ b/src/lib/evas/canvas/evas_object_image.c
@@ -4729,17 +4729,16 @@ evas_object_image_smooth_scale_get(const Eo *obj)
 }
 
 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);
-   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 *
-_evas_image_efl_gfx_filter_program_get(Eo *obj, Evas_Image_Data *pd 
EINA_UNUSED)
+EOLIAN void
+_evas_image_efl_gfx_filter_program_get(Eo *obj, Evas_Image_Data *pd 
EINA_UNUSED, const char **code, const char **name)
 {
-   const char *code;
-   return eo_do_super_ret(obj, MY_CLASS, code, efl_gfx_filter_program_get());
+   eo_do_super(obj, MY_CLASS, efl_gfx_filter_program_get(code, name));
 }
 
 EOLIAN void
diff --git a/src/lib/evas/canvas/evas_object_main.c 
b/src/lib/evas/canvas/evas_object_main.c
index 9552a44..8330f2e 100644
--- a/src/lib/evas/canvas/evas_object_main.c
+++ b/src/lib/evas/canvas/evas_object_main.c
@@ -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
 };
 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;
 static const Evas_Object_Mask_Data default_mask = {
diff --git a/src/lib/evas/canvas/evas_object_text.c 
b/src/lib/evas/canvas/evas_object_text.c
index 899b625..89f2523 100644
--- a/src/lib/evas/canvas/evas_object_text.c
+++ b/src/lib/evas/canvas/evas_object_text.c
@@ -2227,17 +2227,16 @@ evas_object_text_text_get(const Eo *obj)
 }
 
 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);
-   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 *
-_evas_text_efl_gfx_filter_program_get(Eo *obj, Evas_Text_Data *pd EINA_UNUSED)
+EOLIAN void
+_evas_text_efl_gfx_filter_program_get(Eo *obj, Evas_Text_Data *pd EINA_UNUSED, 
const char **code, const char **name)
 {
-   const char *code;
-   return eo_do_super_ret(obj, MY_CLASS, code, efl_gfx_filter_program_get());
+   eo_do_super(obj, MY_CLASS, efl_gfx_filter_program_get(code, name));
 }
 
 EOLIAN void
diff --git a/src/lib/evas/include/evas_private.h 
b/src/lib/evas/include/evas_private.h
index 33bfcd4..925aa52 100644
--- a/src/lib/evas/include/evas_private.h
+++ b/src/lib/evas/include/evas_private.h
@@ -1174,6 +1174,7 @@ struct _Evas_Device
 
 struct _Evas_Object_Filter_Data
 {
+   Eina_Stringshare    *name;
    Eina_Stringshare    *code;
    Evas_Filter_Program *chain;
    Eina_Hash           *sources; // Evas_Filter_Proxy_Binding
diff --git a/src/tests/evas/evas_test_filters.c 
b/src/tests/evas/evas_test_filters.c
index ac40d05..2758940 100644
--- a/src/tests/evas/evas_test_filters.c
+++ b/src/tests/evas/evas_test_filters.c
@@ -311,7 +311,7 @@ START_TEST(evas_filter_text_padding_test)
         // Don't test proxy cases here.
         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_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);
@@ -400,13 +400,13 @@ START_TEST(evas_filter_text_render_test)
              eo_do(to,
                    efl_gfx_color_set(255, 255, 255, 255),
                    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
           {
              eo_do(to,
                    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);

-- 


Reply via email to