summaryrefslogtreecommitdiff
path: root/src/bin/edje/edje_cc_handlers.c
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2015-06-16 14:50:43 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2015-06-25 14:36:09 +0900
commitd00378edcf08deb6a34eeb9833a4d521ed6cca27 (patch)
treee9de91da75c292b5501f243152029f822f712798 /src/bin/edje/edje_cc_handlers.c
parent0e11e0a6dc097dc5c4a53fc6b79f5d4ae10099ad (diff)
Edje/evas filters: Add filter.source support
This should preserve ABI stability with earlier versions of edje_cc while still providing more advanced control over proxy bindings for evas filters from EDC. Also fix proxy binding for filters. @feature
Diffstat (limited to '')
-rw-r--r--src/bin/edje/edje_cc_handlers.c194
1 files changed, 120 insertions, 74 deletions
diff --git a/src/bin/edje/edje_cc_handlers.c b/src/bin/edje/edje_cc_handlers.c
index 2268190134..53bf91e758 100644
--- a/src/bin/edje/edje_cc_handlers.c
+++ b/src/bin/edje/edje_cc_handlers.c
@@ -362,6 +362,7 @@ static void st_collections_group_parts_part_description_text_source(void);
362static void st_collections_group_parts_part_description_text_text_source(void); 362static void st_collections_group_parts_part_description_text_text_source(void);
363static void st_collections_group_parts_part_description_text_ellipsis(void); 363static void st_collections_group_parts_part_description_text_ellipsis(void);
364static void st_collections_group_parts_part_description_text_filter(void); 364static void st_collections_group_parts_part_description_text_filter(void);
365static void st_collections_group_parts_part_description_text_filter_source(void);
365static void st_collections_group_parts_part_description_box_layout(void); 366static void st_collections_group_parts_part_description_box_layout(void);
366static void st_collections_group_parts_part_description_box_align(void); 367static void st_collections_group_parts_part_description_box_align(void);
367static void st_collections_group_parts_part_description_box_padding(void); 368static void st_collections_group_parts_part_description_box_padding(void);
@@ -814,6 +815,8 @@ New_Statement_Handler statement_handlers[] =
814 {"collections.group.parts.part.description.text.elipsis", st_collections_group_parts_part_description_text_ellipsis}, 815 {"collections.group.parts.part.description.text.elipsis", st_collections_group_parts_part_description_text_ellipsis},
815 {"collections.group.parts.part.description.text.ellipsis", st_collections_group_parts_part_description_text_ellipsis}, 816 {"collections.group.parts.part.description.text.ellipsis", st_collections_group_parts_part_description_text_ellipsis},
816 {"collections.group.parts.part.description.text.filter", st_collections_group_parts_part_description_text_filter}, 817 {"collections.group.parts.part.description.text.filter", st_collections_group_parts_part_description_text_filter},
818 {"collections.group.parts.part.description.text.filter.code", st_collections_group_parts_part_description_text_filter}, /* dup */
819 {"collections.group.parts.part.description.text.filter.source", st_collections_group_parts_part_description_text_filter_source},
817 {"collections.group.parts.part.description.box.layout", st_collections_group_parts_part_description_box_layout}, 820 {"collections.group.parts.part.description.box.layout", st_collections_group_parts_part_description_box_layout},
818 {"collections.group.parts.part.description.box.align", st_collections_group_parts_part_description_box_align}, 821 {"collections.group.parts.part.description.box.align", st_collections_group_parts_part_description_box_align},
819 {"collections.group.parts.part.description.box.padding", st_collections_group_parts_part_description_box_padding}, 822 {"collections.group.parts.part.description.box.padding", st_collections_group_parts_part_description_box_padding},
@@ -6696,15 +6699,18 @@ st_collections_group_parts_part_description_inherit(void)
6696 ted->text.domain = STRDUP(ted->text.domain); 6699 ted->text.domain = STRDUP(ted->text.domain);
6697 ted->text.text_class = STRDUP(ted->text.text_class); 6700 ted->text.text_class = STRDUP(ted->text.text_class);
6698 ted->text.font.str = STRDUP(ted->text.font.str); 6701 ted->text.font.str = STRDUP(ted->text.font.str);
6699 ted->text.filter.code = STRDUP(ted->text.filter.code);
6700 {
6701 Eina_List *l;
6702 Eina_Stringshare *name;
6703 static int part_key = 0;
6704 6702
6705 EINA_LIST_FOREACH(ted->text.filter.sources, l, name) 6703 /* Filters stuff */
6706 data_queue_part_lookup(pc, name, &part_key); 6704 ted->text.filter.code = STRDUP(ted->text.filter.code);
6707 } 6705 if (ted->text.filter.code)
6706 {
6707 Eina_List *list, *l;
6708 const char *name;
6709 list = ted->text.filter.sources;
6710 ted->text.filter.sources = NULL;
6711 EINA_LIST_FOREACH(list, l, name)
6712 ted->text.filter.sources = eina_list_append(ted->text.filter.sources, STRDUP(name));
6713 }
6708 6714
6709 data_queue_copied_part_nest_lookup(pc, &(tparent->text.id_source), &(ted->text.id_source), &ted->text.id_source_part); 6715 data_queue_copied_part_nest_lookup(pc, &(tparent->text.id_source), &(ted->text.id_source), &ted->text.id_source_part);
6710 data_queue_copied_part_nest_lookup(pc, &(tparent->text.id_text_source), &(ted->text.id_text_source), &ted->text.id_text_source_part); 6716 data_queue_copied_part_nest_lookup(pc, &(tparent->text.id_text_source), &(ted->text.id_text_source), &ted->text.id_text_source_part);
@@ -8979,31 +8985,88 @@ st_collections_group_parts_part_description_text_ellipsis(void)
8979/** 8985/**
8980 @page edcref 8986 @page edcref
8981 8987
8988 @context
8989 part {
8990 type: TEXT; // or IMAGE
8991 description {
8992 ..
8993 text {
8994 ..
8995 filter {
8996 code: "blend {} -- ..."
8997 source: "part1" "buf";
8998 source: "part2" "otherbuf";
8999 source: "part3";
9000 }
9001 // or as short form:
9002 filter: "blend {} -- ..."
9003 }
9004 ..
9005 }
9006 }
8982 @property 9007 @property
8983 filter 9008 filter.code
8984 @parameters 9009 @parameters
8985 [filter program as a string] 9010 [filter program as a string]
8986 @effect 9011 @effect
8987 Applies a series of filtering operations to the text. 9012 Applies a series of image filters to a TEXT or IMAGE part. The argument
8988 EXPERIMENTAL FEATURE. TO BE DOCUMENTED. 9013 to this field is the source code of a Lua program invoking various
9014 filter operations. For more information, please refer to the page
9015 "Evas filters reference".
9016 @see evasfiltersref
8989 @endproperty 9017 @endproperty
8990*/ 9018*/
8991static void 9019static void
8992st_collections_group_parts_part_description_text_filter(void) 9020st_collections_group_parts_part_description_text_filter(void)
8993{ 9021{
8994 Edje_Part_Description_Text *ed; 9022 Edje_Part_Description_Text *ed;
8995 Eina_List *sources = NULL;
8996 Eina_Stringshare *name;
8997 char *token, *code;
8998 Eina_Bool valid = EINA_TRUE;
8999 Edje_Part_Collection *pc;
9000 9023
9001 static int part_key = 0; 9024 check_arg_count(1);
9025
9026 if (current_part->type != EDJE_PART_TYPE_TEXT)
9027 {
9028 ERR("parse error %s:%i. text attributes in non-TEXT part.",
9029 file_in, line - 1);
9030 exit(-1);
9031 }
9032
9033 ed = (Edje_Part_Description_Text*) current_desc;
9034
9035 free((void*) ed->text.filter.code);
9036 ed->text.filter.code = parse_str(0);
9037}
9038
9039/**
9040 @page edcref
9041
9042 @property
9043 filter.source
9044 @parameters
9045 [another part's name] [(optional) buffer name for filter program]
9046 @effect
9047 Binds another part as an image source (like a proxy source) for a
9048 text or image filter operation. Optionally, a buffer name may be
9049 specified, so the same filter code can be used with different sources.
9050 For more information, please refer to the page "Evas filters reference".
9051 @see evasfiltersref
9052 @endproperty
9053*/
9054static void
9055st_collections_group_parts_part_description_text_filter_source(void)
9056{
9057 Edje_Part_Description_Text *ed;
9058 Edje_Part_Collection *pc;
9059 char *name = NULL, *part, *str;
9060 size_t sn = 0, sp;
9061 int *part_key;
9002 9062
9003 static const char *allowed_name_chars = 9063 static const char *allowed_name_chars =
9004 "abcdefghijklmnopqrstuvwxyzABCDEFGHJIKLMNOPQRSTUVWXYZ0123456789_"; 9064 "abcdefghijklmnopqrstuvwxyzABCDEFGHJIKLMNOPQRSTUVWXYZ0123456789_";
9005 9065
9006 check_arg_count(1); 9066 /* 1 or 2 args only */
9067 check_min_arg_count(1);
9068 if (get_arg_count() > 1)
9069 check_arg_count(2);
9007 9070
9008 if (current_part->type != EDJE_PART_TYPE_TEXT) 9071 if (current_part->type != EDJE_PART_TYPE_TEXT)
9009 { 9072 {
@@ -9014,72 +9077,55 @@ st_collections_group_parts_part_description_text_filter(void)
9014 9077
9015 ed = (Edje_Part_Description_Text*) current_desc; 9078 ed = (Edje_Part_Description_Text*) current_desc;
9016 pc = eina_list_data_get(eina_list_last(edje_collections)); 9079 pc = eina_list_data_get(eina_list_last(edje_collections));
9017 if (ed->text.filter.code) 9080
9081 part = parse_str(0);
9082 sp = strlen(part);
9083
9084 if (get_arg_count() > 1)
9018 { 9085 {
9019 EINA_LIST_FREE(ed->text.filter.sources, name) 9086 name = parse_str(1);
9087 if (name) sn = strlen(name);
9088 if (!name || (strspn(name, allowed_name_chars) != sn))
9020 { 9089 {
9021 part_lookup_delete(pc, name, &part_key, NULL); 9090 ERR("parse error %s:%i. invalid name for a filter buffer: %s",
9022 eina_stringshare_del(name); 9091 file_in, line - 1, name);
9092 exit(-1);
9023 } 9093 }
9024 free((void*)ed->text.filter.code);
9025 } 9094 }
9026 ed->text.filter.sources = NULL;
9027
9028 ed->text.filter.code = parse_str(0);
9029 if (!ed->text.filter.code) return;
9030 9095
9031 // Parse list of buffers that have a source 9096 if (!name && (strspn(part, allowed_name_chars) == sp))
9032 // note: does not support comments 9097 str = strdup(part);
9033 code = strdup(ed->text.filter.code); 9098 else
9034 for (token = strtok(code, ";"); token; token = strtok(NULL, ";"))
9035 { 9099 {
9036 size_t len; 9100 if (!name)
9037
9038 len = strspn(token, " \n\t");
9039 token += len;
9040
9041 if (!strncasecmp("buffer", token, 6))
9042 { 9101 {
9043 // note: a valid string won't necessary compile at runtime 9102 // name = part so we replace all invalid chars by '_'
9044 9103 size_t k;
9045 token = strchr(token, ':'); 9104 name = strdup(part);
9046 if (!token) 9105 sn = strlen(name);
9047 { 9106 for (k = 0; k < sn; k++)
9048 valid = EINA_FALSE;
9049 break;
9050 }
9051 token = strchr(token, '(');
9052 if (!token)
9053 {
9054 valid = EINA_FALSE;
9055 break;
9056 }
9057 token = strcasestr(token, "src");
9058 if (!token) continue;
9059 token += 3;
9060 len = strspn(token, " =\n\t");
9061 if (!len || !token[len])
9062 { 9107 {
9063 valid = EINA_FALSE; 9108 if (!index(allowed_name_chars, name[k]))
9064 break; 9109 name[k] = '_';
9065 }
9066 token += len;
9067 len = strspn(token, allowed_name_chars);
9068 if (!len || !token[len])
9069 {
9070 valid = EINA_FALSE;
9071 break;
9072 } 9110 }
9073 token[len] = '\0';
9074 name = eina_stringshare_add(token);
9075
9076 sources = eina_list_append(sources, name);
9077 data_queue_part_lookup(pc, name, &part_key);
9078 } 9111 }
9079 } 9112 sn += sp + 1;
9080 free(code); 9113 str = malloc(sn + 1);
9081 9114 if (!str) exit(-1);
9082 if (valid) ed->text.filter.sources = sources; 9115 strncpy(str, name, sn);
9116 strncat(str, ":", sn);
9117 strncat(str, part, sn);
9118 str[sn] = '\0';
9119 }
9120 ed->text.filter.sources = eina_list_append(ed->text.filter.sources, str);
9121
9122 // note: this is leaked. not a big deal.
9123 part_key = malloc(sizeof(int));
9124 *part_key = -1;
9125 data_queue_part_lookup(pc, part, part_key);
9126
9127 free(part);
9128 free(name);
9083} 9129}
9084 9130
9085 9131