summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2015-06-17 11:21:47 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2015-06-25 14:36:09 +0900
commit88b81d240a3d29aebbc1d9b05dcb4335a69d1e63 (patch)
tree81e5dd20b671650edb7933aa639dfdec8a9cc390 /src
parent707b979ffdd25d63990c2b9c740b7331e0f94a4a (diff)
Edje: Move filter desc to common desc
This will be shared between IMAGE and TEXT. In the future it can also be shared with PROXY and TEXTBLOCK.
Diffstat (limited to 'src')
-rw-r--r--src/bin/edje/edje_cc.h1
-rw-r--r--src/bin/edje/edje_cc_handlers.c316
-rw-r--r--src/bin/edje/edje_cc_parse.c23
-rw-r--r--src/lib/edje/edje_private.h1
4 files changed, 186 insertions, 155 deletions
diff --git a/src/bin/edje/edje_cc.h b/src/bin/edje/edje_cc.h
index 3e25e69..106ea17 100644
--- a/src/bin/edje/edje_cc.h
+++ b/src/bin/edje/edje_cc.h
@@ -216,6 +216,7 @@ double parse_float_range(int n, double f, double t);
216int get_arg_count(void); 216int get_arg_count(void);
217void check_arg_count(int n); 217void check_arg_count(int n);
218void check_min_arg_count(int n); 218void check_min_arg_count(int n);
219int check_range_arg_count(int n, int m);
219 220
220int object_handler_num(void); 221int object_handler_num(void);
221int object_handler_short_num(void); 222int object_handler_short_num(void);
diff --git a/src/bin/edje/edje_cc_handlers.c b/src/bin/edje/edje_cc_handlers.c
index 403b210..8954f08 100644
--- a/src/bin/edje/edje_cc_handlers.c
+++ b/src/bin/edje/edje_cc_handlers.c
@@ -361,8 +361,6 @@ static void st_collections_group_parts_part_description_text_align(void);
361static void st_collections_group_parts_part_description_text_source(void); 361static 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);
365static void st_collections_group_parts_part_description_text_filter_source(void);
366static void st_collections_group_parts_part_description_box_layout(void); 364static void st_collections_group_parts_part_description_box_layout(void);
367static void st_collections_group_parts_part_description_box_align(void); 365static void st_collections_group_parts_part_description_box_align(void);
368static void st_collections_group_parts_part_description_box_padding(void); 366static void st_collections_group_parts_part_description_box_padding(void);
@@ -396,6 +394,8 @@ static void st_collections_group_parts_part_description_texture_filter1(void);
396static void st_collections_group_parts_part_description_texture_filter2(void); 394static void st_collections_group_parts_part_description_texture_filter2(void);
397static void st_collections_group_parts_part_description_mesh_assembly(void); 395static void st_collections_group_parts_part_description_mesh_assembly(void);
398static void st_collections_group_parts_part_description_mesh_geometry(void); 396static void st_collections_group_parts_part_description_mesh_geometry(void);
397static void st_collections_group_parts_part_description_filter_code(void);
398static void st_collections_group_parts_part_description_filter_source(void);
399 399
400#ifdef HAVE_EPHYSICS 400#ifdef HAVE_EPHYSICS
401static void st_collections_group_parts_part_description_physics_mass(void); 401static void st_collections_group_parts_part_description_physics_mass(void);
@@ -814,9 +814,7 @@ New_Statement_Handler statement_handlers[] =
814 {"collections.group.parts.part.description.text.fonts.font", st_fonts_font}, /* dup */ 814 {"collections.group.parts.part.description.text.fonts.font", st_fonts_font}, /* dup */
815 {"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},
816 {"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},
817 {"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_filter_code}, /* dup */
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},
820 {"collections.group.parts.part.description.box.layout", st_collections_group_parts_part_description_box_layout}, 818 {"collections.group.parts.part.description.box.layout", st_collections_group_parts_part_description_box_layout},
821 {"collections.group.parts.part.description.box.align", st_collections_group_parts_part_description_box_align}, 819 {"collections.group.parts.part.description.box.align", st_collections_group_parts_part_description_box_align},
822 {"collections.group.parts.part.description.box.padding", st_collections_group_parts_part_description_box_padding}, 820 {"collections.group.parts.part.description.box.padding", st_collections_group_parts_part_description_box_padding},
@@ -849,6 +847,8 @@ New_Statement_Handler statement_handlers[] =
849 {"collections.group.parts.part.description.texture.filter2", st_collections_group_parts_part_description_texture_filter2}, 847 {"collections.group.parts.part.description.texture.filter2", st_collections_group_parts_part_description_texture_filter2},
850 {"collections.group.parts.part.description.mesh.assembly", st_collections_group_parts_part_description_mesh_assembly}, 848 {"collections.group.parts.part.description.mesh.assembly", st_collections_group_parts_part_description_mesh_assembly},
851 {"collections.group.parts.part.description.mesh.geometry", st_collections_group_parts_part_description_mesh_geometry}, 849 {"collections.group.parts.part.description.mesh.geometry", st_collections_group_parts_part_description_mesh_geometry},
850 {"collections.group.parts.part.description.filter.code", st_collections_group_parts_part_description_filter_code},
851 {"collections.group.parts.part.description.filter.source", st_collections_group_parts_part_description_filter_source},
852 852
853#ifdef HAVE_EPHYSICS 853#ifdef HAVE_EPHYSICS
854 {"collections.group.parts.part.description.physics.mass", st_collections_group_parts_part_description_physics_mass}, 854 {"collections.group.parts.part.description.physics.mass", st_collections_group_parts_part_description_physics_mass},
@@ -1195,6 +1195,7 @@ New_Object_Handler object_handlers[] =
1195 {"collections.group.parts.part.description.orientation", NULL}, 1195 {"collections.group.parts.part.description.orientation", NULL},
1196 {"collections.group.parts.part.description.texture", ob_collections_group_parts_part_description_texture}, 1196 {"collections.group.parts.part.description.texture", ob_collections_group_parts_part_description_texture},
1197 {"collections.group.parts.part.description.mesh", NULL}, 1197 {"collections.group.parts.part.description.mesh", NULL},
1198 {"collections.group.parts.part.description.filter", NULL},
1198#ifdef HAVE_EPHYSICS 1199#ifdef HAVE_EPHYSICS
1199 {"collections.group.parts.part.description.physics", NULL}, 1200 {"collections.group.parts.part.description.physics", NULL},
1200 {"collections.group.parts.part.description.physics.movement_freedom", NULL}, 1201 {"collections.group.parts.part.description.physics.movement_freedom", NULL},
@@ -8982,156 +8983,6 @@ st_collections_group_parts_part_description_text_ellipsis(void)
8982 ed->text.ellipsis = parse_float_range(0, -1.0, 1.0); 8983 ed->text.ellipsis = parse_float_range(0, -1.0, 1.0);
8983} 8984}
8984 8985
8985/**
8986 @page edcref
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 }
9007 @property
9008 filter.code
9009 @parameters
9010 [filter program] OR [data name]
9011 @effect
9012 Applies a series of image filters to a TEXT or IMAGE part. The argument
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 The parameter can also be a parameter name as specified in the
9017 data section (item or file property). This means external filter files
9018 can be easily embedded in an edje file.
9019 @see evasfiltersref
9020 @endproperty
9021*/
9022static void
9023st_collections_group_parts_part_description_text_filter(void)
9024{
9025 Edje_Part_Description_Text *ed;
9026
9027 check_arg_count(1);
9028
9029 if (current_part->type != EDJE_PART_TYPE_TEXT)
9030 {
9031 ERR("parse error %s:%i. text attributes in non-TEXT part.",
9032 file_in, line - 1);
9033 exit(-1);
9034 }
9035
9036 ed = (Edje_Part_Description_Text*) current_desc;
9037
9038 free((void*) ed->text.filter.code);
9039 ed->text.filter.code = parse_str(0);
9040}
9041
9042/**
9043 @page edcref
9044
9045 @property
9046 filter.source
9047 @parameters
9048 [another part's name] [(optional) buffer name for filter program]
9049 @effect
9050 Binds another part as an image source (like a proxy source) for a
9051 text or image filter operation. Optionally, a buffer name may be
9052 specified, so the same filter code can be used with different sources.
9053 For more information, please refer to the page "Evas filters reference".
9054 @see evasfiltersref
9055 @endproperty
9056*/
9057static void
9058st_collections_group_parts_part_description_text_filter_source(void)
9059{
9060 Edje_Part_Description_Text *ed;
9061 Edje_Part_Collection *pc;
9062 char *name = NULL, *part, *str;
9063 size_t sn = 0, sp;
9064 int *part_key;
9065
9066 static const char *allowed_name_chars =
9067 "abcdefghijklmnopqrstuvwxyzABCDEFGHJIKLMNOPQRSTUVWXYZ0123456789_";
9068
9069 /* 1 or 2 args only */
9070 check_min_arg_count(1);
9071 if (get_arg_count() > 1)
9072 check_arg_count(2);
9073
9074 if (current_part->type != EDJE_PART_TYPE_TEXT)
9075 {
9076 ERR("parse error %s:%i. text attributes in non-TEXT part.",
9077 file_in, line - 1);
9078 exit(-1);
9079 }
9080
9081 ed = (Edje_Part_Description_Text*) current_desc;
9082 pc = eina_list_data_get(eina_list_last(edje_collections));
9083
9084 part = parse_str(0);
9085 sp = strlen(part);
9086
9087 if (get_arg_count() > 1)
9088 {
9089 name = parse_str(1);
9090 if (name) sn = strlen(name);
9091 if (!name || (strspn(name, allowed_name_chars) != sn))
9092 {
9093 ERR("parse error %s:%i. invalid name for a filter buffer: %s",
9094 file_in, line - 1, name);
9095 exit(-1);
9096 }
9097 }
9098
9099 if (!name && (strspn(part, allowed_name_chars) == sp))
9100 str = strdup(part);
9101 else
9102 {
9103 if (!name)
9104 {
9105 // name = part so we replace all invalid chars by '_'
9106 size_t k;
9107 name = strdup(part);
9108 sn = strlen(name);
9109 for (k = 0; k < sn; k++)
9110 {
9111 if (!index(allowed_name_chars, name[k]))
9112 name[k] = '_';
9113 }
9114 }
9115 sn += sp + 1;
9116 str = malloc(sn + 1);
9117 if (!str) exit(-1);
9118 strncpy(str, name, sn);
9119 strncat(str, ":", sn);
9120 strncat(str, part, sn);
9121 str[sn] = '\0';
9122 }
9123 ed->text.filter.sources = eina_list_append(ed->text.filter.sources, str);
9124
9125 // note: this is leaked. not a big deal.
9126 part_key = malloc(sizeof(int));
9127 *part_key = -1;
9128 data_queue_part_lookup(pc, part, part_key);
9129
9130 free(part);
9131 free(name);
9132}
9133
9134
9135/** @edcsubsection{collections_group_parts_description_box, 8986/** @edcsubsection{collections_group_parts_description_box,
9136 * Group.Parts.Part.Description.Box} */ 8987 * Group.Parts.Part.Description.Box} */
9137 8988
@@ -11643,6 +11494,161 @@ st_collections_group_parts_part_description_perspective_focal(void)
11643 current_desc->persp.focal = parse_int_range(0, 1, 0x7fffffff); 11494 current_desc->persp.focal = parse_int_range(0, 1, 0x7fffffff);
11644} 11495}
11645 11496
11497/** @edcsubsection{collections_group_parts_description_filter,
11498 * Group.Parts.Part.Description.Filter} */
11499
11500/**
11501 @page edcref
11502
11503 @context
11504 part {
11505 type: [TEXT or IMAGE];
11506 description {
11507 ..
11508 filter {
11509 code: "blend {} -- ..."
11510 // or:
11511 code: "data name";
11512 source: "part1" "buf";
11513 source: "part2" "otherbuf";
11514 source: "part3";
11515 }
11516 // or, for TEXT only (legacy):
11517 text.filter: "blend {} -- ..."
11518 ..
11519 }
11520 }
11521 @property
11522 filter.code
11523 @parameters
11524 [filter program] OR [data name]
11525 @effect
11526 Applies a series of image filters to a TEXT or IMAGE part. The argument
11527 to this field is the source code of a Lua program invoking various
11528 filter operations. For more information, please refer to the page
11529 "Evas filters reference".
11530 The parameter can also be a parameter name as specified in the
11531 data section (item or file property). This means external filter files
11532 can be easily embedded in an edje file.
11533 @see evasfiltersref
11534 @endproperty
11535*/
11536static void
11537st_collections_group_parts_part_description_filter_code(void)
11538{
11539 Edje_Part_Description_Spec_Filter *filter;
11540
11541 check_arg_count(1);
11542
11543 if (current_part->type == EDJE_PART_TYPE_TEXT)
11544 filter = &(((Edje_Part_Description_Text *)current_desc)->text.filter);
11545 else if (current_part->type == EDJE_PART_TYPE_IMAGE)
11546 filter = &(((Edje_Part_Description_Image *)current_desc)->image.filter);
11547 else
11548 {
11549 ERR("parse error %s:%i. filter set for non-TEXT and non-IMAGE part.",
11550 file_in, line - 1);
11551 exit(-1);
11552 }
11553
11554 free((void*) filter->code);
11555 filter->code = parse_str(0);
11556}
11557
11558/**
11559 @page edcref
11560
11561 @property
11562 filter.source
11563 @parameters
11564 [another part's name] [(optional) buffer name for filter program]
11565 @effect
11566 Binds another part as an image source (like a proxy source) for a
11567 text or image filter operation. Optionally, a buffer name may be
11568 specified, so the same filter code can be used with different sources.
11569 For more information, please refer to the page "Evas filters reference".
11570 @see evasfiltersref
11571 @endproperty
11572*/
11573static void
11574st_collections_group_parts_part_description_filter_source(void)
11575{
11576 Edje_Part_Description_Spec_Filter *filter;
11577 Edje_Part_Collection *pc;
11578 char *name, *part, *str;
11579 size_t sn = 0, sp;
11580 int *part_key;
11581 int args;
11582
11583 static const char *allowed_name_chars =
11584 "abcdefghijklmnopqrstuvwxyzABCDEFGHJIKLMNOPQRSTUVWXYZ0123456789_";
11585
11586 if (current_part->type == EDJE_PART_TYPE_TEXT)
11587 filter = &(((Edje_Part_Description_Text *)current_desc)->text.filter);
11588 else if (current_part->type == EDJE_PART_TYPE_IMAGE)
11589 filter = &(((Edje_Part_Description_Image *)current_desc)->image.filter);
11590 else
11591 {
11592 ERR("parse error %s:%i. filter set for non-TEXT and non-IMAGE part.",
11593 file_in, line - 1);
11594 exit(-1);
11595 }
11596
11597 args = check_range_arg_count(1, 2);
11598 pc = eina_list_data_get(eina_list_last(edje_collections));
11599
11600 part = parse_str(0);
11601 sp = strlen(part);
11602
11603 if (args > 1)
11604 {
11605 name = parse_str(1);
11606 if (name) sn = strlen(name);
11607 if (!name || (strspn(name, allowed_name_chars) != sn))
11608 {
11609 ERR("parse error %s:%i. invalid name for a filter buffer: %s",
11610 file_in, line - 1, name);
11611 exit(-1);
11612 }
11613 }
11614 else
11615 name = NULL;
11616
11617 if (!name && (strspn(part, allowed_name_chars) == sp))
11618 str = strdup(part);
11619 else
11620 {
11621 if (!name)
11622 {
11623 // name = part so we replace all invalid chars by '_'
11624 size_t k;
11625 name = strdup(part);
11626 sn = strlen(name);
11627 for (k = 0; k < sn; k++)
11628 {
11629 if (!index(allowed_name_chars, name[k]))
11630 name[k] = '_';
11631 }
11632 }
11633 sn += sp + 1;
11634 str = malloc(sn + 1);
11635 if (!str) exit(-1);
11636 strncpy(str, name, sn);
11637 strncat(str, ":", sn);
11638 strncat(str, part, sn);
11639 str[sn] = '\0';
11640 }
11641 filter->sources = eina_list_append(filter->sources, str);
11642
11643 // note: this is leaked. not a big deal.
11644 part_key = malloc(sizeof(int));
11645 *part_key = -1;
11646 data_queue_part_lookup(pc, part, part_key);
11647
11648 free(part);
11649 free(name);
11650}
11651
11646 11652
11647/** @edcsubsection{collections_group_parts_descriptions_params, 11653/** @edcsubsection{collections_group_parts_descriptions_params,
11648 * Group.Parts.Part.Description.Params} */ 11654 * Group.Parts.Part.Description.Params} */
diff --git a/src/bin/edje/edje_cc_parse.c b/src/bin/edje/edje_cc_parse.c
index 6327e8e..49da476 100644
--- a/src/bin/edje/edje_cc_parse.c
+++ b/src/bin/edje/edje_cc_parse.c
@@ -1374,6 +1374,29 @@ check_min_arg_count(int min_required_args)
1374 } 1374 }
1375} 1375}
1376 1376
1377int
1378check_range_arg_count(int min_required_args, int max_required_args)
1379{
1380 int num_args = eina_array_count(&params);
1381
1382 if (num_args < min_required_args)
1383 {
1384 ERR("%s:%i got %i arguments, but expected at least %i",
1385 file_in, line - 1, num_args, min_required_args);
1386 err_show();
1387 exit(-1);
1388 }
1389 else if (num_args > max_required_args)
1390 {
1391 ERR("%s:%i got %i arguments, but expected at most %i",
1392 file_in, line - 1, num_args, max_required_args);
1393 err_show();
1394 exit(-1);
1395 }
1396
1397 return num_args;
1398}
1399
1377/* simple expression parsing stuff */ 1400/* simple expression parsing stuff */
1378 1401
1379/* 1402/*
diff --git a/src/lib/edje/edje_private.h b/src/lib/edje/edje_private.h
index 7744f08..6f209f8 100644
--- a/src/lib/edje/edje_private.h
+++ b/src/lib/edje/edje_private.h
@@ -1298,6 +1298,7 @@ struct _Edje_Part_Description_Spec_Image
1298 Eina_Bool set; /* if image condition it's content */ 1298 Eina_Bool set; /* if image condition it's content */
1299 1299
1300 Edje_Part_Description_Spec_Border border; 1300 Edje_Part_Description_Spec_Border border;
1301 Edje_Part_Description_Spec_Filter filter;
1301}; 1302};
1302 1303
1303struct _Edje_Part_Description_Spec_Proxy 1304struct _Edje_Part_Description_Spec_Proxy