summaryrefslogtreecommitdiff
path: root/src/bin/edje
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2015-04-28 18:56:02 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2015-06-15 16:59:41 +0900
commit75ec3a7338c9c2406d4765a4cc8247f72d6bec7b (patch)
tree2ce20dfa89b036f5d5326eadb4d9026da27f8309 /src/bin/edje
parent02d825f116e3b791c784791b10cfe613c5f18385 (diff)
Edje: Add clip as a property of a part description
Since masking, for performance and themeing reasons, it becomes interesting to be able to switch clippers on the fly. In particular, switching from an IMAGE mask to a standard RECT clipper can save a lot of power when masking is not required. This new flag "description.clip_to" will behave a bit like a mix of rel.to and visible: - It points to a part by name, just like part.clip_to. This will override the clipper set by the part, or override the default clipper. - Like "visible", it can not be interpolated between two values, so it will switch only at the end of a transition. - By default there is no clip override, which means Edje will fallback to the part's clipper, if any, or the base (group's) clipper. NOTE: - Since a clipper that does not clip anything becomes a standard object, it is visible and rendered. This will in 99.999% cases not be the intended behaviour. Currently we can simply use a transparent RECT in order to always have something clipped by the clipper, but this is a hack and this will trigger rendering of masks in their surfaces even when they are not actually used. Ideally, there should be a flag indicating to Edje & Evas that an object should be considered a clipper in all situations, and never be rendered on screen. TODO: - Support Edje Edit - Add Embryo & Lua functions - Add support in edje_convert - Add Edje/Evas flag to mark objects as "no_render" @feature
Diffstat (limited to 'src/bin/edje')
-rw-r--r--src/bin/edje/edje_cc_handlers.c33
-rwxr-xr-xsrc/bin/edje/edje_cc_out.c17
2 files changed, 44 insertions, 6 deletions
diff --git a/src/bin/edje/edje_cc_handlers.c b/src/bin/edje/edje_cc_handlers.c
index 1cb5b6ef10..b371aec5ca 100644
--- a/src/bin/edje/edje_cc_handlers.c
+++ b/src/bin/edje/edje_cc_handlers.c
@@ -326,6 +326,7 @@ static void st_collections_group_parts_part_description_rel2_to_set(const char *
326static void st_collections_group_parts_part_description_rel2_to(void); 326static void st_collections_group_parts_part_description_rel2_to(void);
327static void st_collections_group_parts_part_description_rel2_to_x(void); 327static void st_collections_group_parts_part_description_rel2_to_x(void);
328static void st_collections_group_parts_part_description_rel2_to_y(void); 328static void st_collections_group_parts_part_description_rel2_to_y(void);
329static void st_collections_group_parts_part_description_clip_to_id(void);
329static void st_collections_group_parts_part_description_image_normal(void); 330static void st_collections_group_parts_part_description_image_normal(void);
330static void st_collections_group_parts_part_description_image_tween(void); 331static void st_collections_group_parts_part_description_image_tween(void);
331static void st_collections_group_parts_part_description_image_border(void); 332static void st_collections_group_parts_part_description_image_border(void);
@@ -771,6 +772,7 @@ New_Statement_Handler statement_handlers[] =
771 {"collections.group.parts.part.description.rel2.to", st_collections_group_parts_part_description_rel2_to}, 772 {"collections.group.parts.part.description.rel2.to", st_collections_group_parts_part_description_rel2_to},
772 {"collections.group.parts.part.description.rel2.to_x", st_collections_group_parts_part_description_rel2_to_x}, 773 {"collections.group.parts.part.description.rel2.to_x", st_collections_group_parts_part_description_rel2_to_x},
773 {"collections.group.parts.part.description.rel2.to_y", st_collections_group_parts_part_description_rel2_to_y}, 774 {"collections.group.parts.part.description.rel2.to_y", st_collections_group_parts_part_description_rel2_to_y},
775 {"collections.group.parts.part.description.clip_to", st_collections_group_parts_part_description_clip_to_id},
774 {"collections.group.parts.part.description.image.normal", st_collections_group_parts_part_description_image_normal}, 776 {"collections.group.parts.part.description.image.normal", st_collections_group_parts_part_description_image_normal},
775 {"collections.group.parts.part.description.image.tween", st_collections_group_parts_part_description_image_tween}, 777 {"collections.group.parts.part.description.image.tween", st_collections_group_parts_part_description_image_tween},
776 IMAGE_SET_STATEMENTS("collections.group.parts.part.description.image") 778 IMAGE_SET_STATEMENTS("collections.group.parts.part.description.image")
@@ -1496,6 +1498,7 @@ _edje_part_description_alloc(unsigned char type, const char *collection, const c
1496 result->physics.depth = 30; 1498 result->physics.depth = 30;
1497#endif 1499#endif
1498 1500
1501 result->clip_to_id = -1;
1499 return result; 1502 return result;
1500} 1503}
1501 1504
@@ -4581,6 +4584,7 @@ _part_desc_free(Edje_Part_Collection *pc,
4581 part_lookup_del(pc, &(ed->rel1.id_y)); 4584 part_lookup_del(pc, &(ed->rel1.id_y));
4582 part_lookup_del(pc, &(ed->rel2.id_x)); 4585 part_lookup_del(pc, &(ed->rel2.id_x));
4583 part_lookup_del(pc, &(ed->rel2.id_y)); 4586 part_lookup_del(pc, &(ed->rel2.id_y));
4587 part_lookup_del(pc, &(ed->clip_to_id));
4584 part_lookup_del(pc, &(ed->map.id_persp)); 4588 part_lookup_del(pc, &(ed->map.id_persp));
4585 part_lookup_del(pc, &(ed->map.id_light)); 4589 part_lookup_del(pc, &(ed->map.id_light));
4586 part_lookup_del(pc, &(ed->map.rot.id_center)); 4590 part_lookup_del(pc, &(ed->map.rot.id_center));
@@ -5381,11 +5385,11 @@ st_collections_group_parts_part_clip_to_id(void)
5381 5385
5382 pc = eina_list_data_get(eina_list_last(edje_collections)); 5386 pc = eina_list_data_get(eina_list_last(edje_collections));
5383 { 5387 {
5384 char *name; 5388 char *name;
5385 5389
5386 name = parse_str(0); 5390 name = parse_str(0);
5387 data_queue_part_lookup(pc, name, &(current_part->clip_to_id)); 5391 data_queue_part_lookup(pc, name, &(current_part->clip_to_id));
5388 free(name); 5392 free(name);
5389 } 5393 }
5390} 5394}
5391 5395
@@ -6397,6 +6401,7 @@ _copied_map_colors_get(Edje_Part_Description_Common *parent)
6397 fixed: 0 0; 6401 fixed: 0 0;
6398 step: 0 0; 6402 step: 0 0;
6399 aspect: 1 1; 6403 aspect: 1 1;
6404 clip_to: "clip_override_part_name";
6400 6405
6401 rel1 { 6406 rel1 {
6402 .. 6407 ..
@@ -6428,6 +6433,7 @@ ob_collections_group_parts_part_description(void)
6428 ed->rel1.id_y = -1; 6433 ed->rel1.id_y = -1;
6429 ed->rel2.id_x = -1; 6434 ed->rel2.id_x = -1;
6430 ed->rel2.id_y = -1; 6435 ed->rel2.id_y = -1;
6436 ed->clip_to_id = -1;
6431 6437
6432 if (!ep->default_desc) 6438 if (!ep->default_desc)
6433 { 6439 {
@@ -6628,6 +6634,8 @@ st_collections_group_parts_part_description_inherit(void)
6628 data_queue_copied_part_lookup(pc, &parent->rel2.id_x, &ed->rel2.id_x); 6634 data_queue_copied_part_lookup(pc, &parent->rel2.id_x, &ed->rel2.id_x);
6629 data_queue_copied_part_lookup(pc, &parent->rel2.id_y, &ed->rel2.id_y); 6635 data_queue_copied_part_lookup(pc, &parent->rel2.id_y, &ed->rel2.id_y);
6630 6636
6637 data_queue_copied_part_lookup(pc, &parent->clip_to_id, &ed->clip_to_id);
6638
6631 data_queue_copied_part_lookup(pc, &parent->map.id_persp, &ed->map.id_persp); 6639 data_queue_copied_part_lookup(pc, &parent->map.id_persp, &ed->map.id_persp);
6632 data_queue_copied_part_lookup(pc, &parent->map.id_light, &ed->map.id_light); 6640 data_queue_copied_part_lookup(pc, &parent->map.id_light, &ed->map.id_light);
6633 data_queue_copied_part_lookup(pc, &parent->map.rot.id_center, &ed->map.rot.id_center); 6641 data_queue_copied_part_lookup(pc, &parent->map.rot.id_center, &ed->map.rot.id_center);
@@ -7625,6 +7633,23 @@ st_collections_group_parts_part_description_rel2_to_y(void)
7625 } 7633 }
7626} 7634}
7627 7635
7636static void
7637st_collections_group_parts_part_description_clip_to_id(void)
7638{
7639 Edje_Part_Collection *pc;
7640
7641 check_arg_count(1);
7642
7643 pc = eina_list_data_get(eina_list_last(edje_collections));
7644 {
7645 char *name;
7646
7647 name = parse_str(0);
7648 data_queue_part_lookup(pc, name, &(current_desc->clip_to_id));
7649 free(name);
7650 }
7651}
7652
7628/** @edcsubsection{collections_group_parts_description_image, 7653/** @edcsubsection{collections_group_parts_description_image,
7629 * Group.Parts.Part.Description.Image} */ 7654 * Group.Parts.Part.Description.Image} */
7630 7655
diff --git a/src/bin/edje/edje_cc_out.c b/src/bin/edje/edje_cc_out.c
index 485aa8c0dc..78d3fab431 100755
--- a/src/bin/edje/edje_cc_out.c
+++ b/src/bin/edje/edje_cc_out.c
@@ -465,6 +465,19 @@ check_nameless_state(Edje_Part_Collection *pc, Edje_Part *ep, Edje_Part_Descript
465} 465}
466 466
467static void 467static void
468check_state(Edje_Part_Collection *pc, Edje_Part *ep, Edje_Part_Description_Common *ed, Eet_File *ef)
469{
470 /* FIXME: When smart masks are supported, remove this check */
471 if (ed->clip_to_id != -1 &&
472 (pc->parts[ed->clip_to_id]->type != EDJE_PART_TYPE_RECTANGLE) &&
473 (pc->parts[ed->clip_to_id]->type != EDJE_PART_TYPE_IMAGE))
474 error_and_abort(ef, "Collection %i: description.clip_to point to a non RECT/IMAGE part '%s' !",
475 pc->id, pc->parts[ed->clip_to_id]->name);
476
477 check_nameless_state(pc, ep, ed, ef);
478}
479
480static void
468check_part(Edje_Part_Collection *pc, Edje_Part *ep, Eet_File *ef) 481check_part(Edje_Part_Collection *pc, Edje_Part *ep, Eet_File *ef)
469{ 482{
470 unsigned int i; 483 unsigned int i;
@@ -475,7 +488,7 @@ check_part(Edje_Part_Collection *pc, Edje_Part *ep, Eet_File *ef)
475 "for part \"%s\"", pc->id, ep->name); 488 "for part \"%s\"", pc->id, ep->name);
476 489
477 for (i = 0; i < ep->other.desc_count; ++i) 490 for (i = 0; i < ep->other.desc_count; ++i)
478 check_nameless_state(pc, ep, ep->other.desc[i], ef); 491 check_state(pc, ep, ep->other.desc[i], ef);
479 492
480 if (ep->type == EDJE_PART_TYPE_IMAGE) 493 if (ep->type == EDJE_PART_TYPE_IMAGE)
481 { 494 {
@@ -490,7 +503,7 @@ check_part(Edje_Part_Collection *pc, Edje_Part *ep, Eet_File *ef)
490 else if (ep->type == EDJE_PART_TYPE_GROUP) 503 else if (ep->type == EDJE_PART_TYPE_GROUP)
491 check_source_links(pc, ep, ef, group_path); 504 check_source_links(pc, ep, ef, group_path);
492 505
493 /* FIXME: When mask are supported remove this check */ 506 /* FIXME: When smart masks are supported, remove this check */
494 if (ep->clip_to_id != -1 && 507 if (ep->clip_to_id != -1 &&
495 (pc->parts[ep->clip_to_id]->type != EDJE_PART_TYPE_RECTANGLE) && 508 (pc->parts[ep->clip_to_id]->type != EDJE_PART_TYPE_RECTANGLE) &&
496 (pc->parts[ep->clip_to_id]->type != EDJE_PART_TYPE_IMAGE)) 509 (pc->parts[ep->clip_to_id]->type != EDJE_PART_TYPE_IMAGE))