diff options
author | Jean-Philippe Andre <jp.andre@samsung.com> | 2017-04-10 16:01:28 +0900 |
---|---|---|
committer | Jean-Philippe Andre <jp.andre@samsung.com> | 2017-04-10 16:14:45 +0900 |
commit | c0db1f422502102f012fadfa17078a69d085c736 (patch) | |
tree | 85c6ef1da3c6c448ed054133e47e22ed6363baec | |
parent | 1ab87367d8f1c0f416a65c4a43d96bb2f3683052 (diff) |
edje: Add workaround for misuses of clip_set
An unfortunately very common misuse of clip is as follows:
- Layout A is created (edje object / elm_layout)
- Object B is swallowed inside A
- Clipper C is set to clip B
This is a invalid usage, as layout A takes control over the clip
property of B (just like it does for geometry, visibility, color...).
Since 75ec3a7338c9c2406d4 edje_recalc resets the clip at every calc
loop, as it can change between states.
In the past, edje_recalc did not reset the clip so anyone could
(wrongly) swallow an object and then change its clip from C to modify
its color, mask it, blend it, etc... Even though this was not proper
use of the API, this is not very clearly documented, and since it
worked, it has been (ab)used a lot already.
The result now is that a clipper set from C will become visible
as an opaque white rectangle covering the entire UI. Booh.
This patch is a workaround that should have no impact on well
written applications. As a bonus this avoids an extra call to
clip_set() from edje.
@fix
-rw-r--r-- | src/lib/edje/edje_calc.c | 40 | ||||
-rw-r--r-- | src/lib/edje/edje_load.c | 5 | ||||
-rw-r--r-- | src/lib/edje/edje_private.h | 1 |
3 files changed, 31 insertions, 15 deletions
diff --git a/src/lib/edje/edje_calc.c b/src/lib/edje/edje_calc.c index 6f5e08c17d..bf0d809c5a 100644 --- a/src/lib/edje/edje_calc.c +++ b/src/lib/edje/edje_calc.c | |||
@@ -4360,7 +4360,10 @@ _edje_part_recalc(Edje *ed, Edje_Real_Part *ep, int flags, Edje_Calc_Params *sta | |||
4360 | if (ep->param1.description->rel2.id_y >= 0) | 4360 | if (ep->param1.description->rel2.id_y >= 0) |
4361 | rp1[Rel2Y] = ed->table_parts[ep->param1.description->rel2.id_y]; | 4361 | rp1[Rel2Y] = ed->table_parts[ep->param1.description->rel2.id_y]; |
4362 | if (ep->param1.description->clip_to_id >= 0) | 4362 | if (ep->param1.description->clip_to_id >= 0) |
4363 | clip1 = ed->table_parts[ep->param1.description->clip_to_id % ed->table_parts_size]; | 4363 | { |
4364 | clip1 = ed->table_parts[ep->param1.description->clip_to_id % ed->table_parts_size]; | ||
4365 | ed->has_state_clip = EINA_TRUE; | ||
4366 | } | ||
4364 | } | 4367 | } |
4365 | if (ep->param2) | 4368 | if (ep->param2) |
4366 | { | 4369 | { |
@@ -4373,7 +4376,10 @@ _edje_part_recalc(Edje *ed, Edje_Real_Part *ep, int flags, Edje_Calc_Params *sta | |||
4373 | if (ep->param2->description->rel2.id_y >= 0) | 4376 | if (ep->param2->description->rel2.id_y >= 0) |
4374 | rp2[Rel2Y] = ed->table_parts[ep->param2->description->rel2.id_y]; | 4377 | rp2[Rel2Y] = ed->table_parts[ep->param2->description->rel2.id_y]; |
4375 | if (ep->param2->description->clip_to_id >= 0) | 4378 | if (ep->param2->description->clip_to_id >= 0) |
4376 | clip2 = ed->table_parts[ep->param2->description->clip_to_id % ed->table_parts_size]; | 4379 | { |
4380 | clip2 = ed->table_parts[ep->param2->description->clip_to_id % ed->table_parts_size]; | ||
4381 | ed->has_state_clip = EINA_TRUE; | ||
4382 | } | ||
4377 | } | 4383 | } |
4378 | 4384 | ||
4379 | if (flags & FLAG_X) | 4385 | if (flags & FLAG_X) |
@@ -5119,12 +5125,15 @@ _edje_part_recalc(Edje *ed, Edje_Real_Part *ep, int flags, Edje_Calc_Params *sta | |||
5119 | _edje_entry_real_part_configure(ed, ep); | 5125 | _edje_entry_real_part_configure(ed, ep); |
5120 | 5126 | ||
5121 | /* handle clip overrides */ | 5127 | /* handle clip overrides */ |
5122 | if ((pf->ext) && (pf->ext->clip_to) && (pf->ext->clip_to->object)) | 5128 | if (ed->has_state_clip) |
5123 | evas_object_clip_set(ep->object, pf->ext->clip_to->object); | 5129 | { |
5124 | else if (ep->part->clip_to_id >= 0) | 5130 | if ((pf->ext) && (pf->ext->clip_to) && (pf->ext->clip_to->object)) |
5125 | evas_object_clip_set(ep->object, ed->table_parts[ep->part->clip_to_id % ed->table_parts_size]->object); | 5131 | evas_object_clip_set(ep->object, pf->ext->clip_to->object); |
5126 | else | 5132 | else if (ep->part->clip_to_id >= 0) |
5127 | evas_object_clip_set(ep->object, ed->base->clipper); | 5133 | evas_object_clip_set(ep->object, ed->table_parts[ep->part->clip_to_id % ed->table_parts_size]->object); |
5134 | else | ||
5135 | evas_object_clip_set(ep->object, ed->base->clipper); | ||
5136 | } | ||
5128 | break; | 5137 | break; |
5129 | 5138 | ||
5130 | case EDJE_PART_TYPE_TEXT: | 5139 | case EDJE_PART_TYPE_TEXT: |
@@ -5384,12 +5393,15 @@ _edje_part_recalc(Edje *ed, Edje_Real_Part *ep, int flags, Edje_Calc_Params *sta | |||
5384 | (ep->typedata.swallow)) && | 5393 | (ep->typedata.swallow)) && |
5385 | (ep->typedata.swallow->swallowed_object)) | 5394 | (ep->typedata.swallow->swallowed_object)) |
5386 | { | 5395 | { |
5387 | if ((pf->ext) && (pf->ext->clip_to) && (pf->ext->clip_to->object)) | 5396 | if (ed->has_state_clip) |
5388 | evas_object_clip_set(ep->typedata.swallow->swallowed_object, pf->ext->clip_to->object); | 5397 | { |
5389 | else if (ep->part->clip_to_id >= 0) | 5398 | if ((pf->ext) && (pf->ext->clip_to) && (pf->ext->clip_to->object)) |
5390 | evas_object_clip_set(ep->typedata.swallow->swallowed_object, ed->table_parts[ep->part->clip_to_id % ed->table_parts_size]->object); | 5399 | evas_object_clip_set(ep->typedata.swallow->swallowed_object, pf->ext->clip_to->object); |
5391 | else | 5400 | else if (ep->part->clip_to_id >= 0) |
5392 | evas_object_clip_set(ep->typedata.swallow->swallowed_object, ed->base->clipper); | 5401 | evas_object_clip_set(ep->typedata.swallow->swallowed_object, ed->table_parts[ep->part->clip_to_id % ed->table_parts_size]->object); |
5402 | else | ||
5403 | evas_object_clip_set(ep->typedata.swallow->swallowed_object, ed->base->clipper); | ||
5404 | } | ||
5393 | 5405 | ||
5394 | if (pf->visible) | 5406 | if (pf->visible) |
5395 | { | 5407 | { |
diff --git a/src/lib/edje/edje_load.c b/src/lib/edje/edje_load.c index 3a0b8fd36a..630228e430 100644 --- a/src/lib/edje/edje_load.c +++ b/src/lib/edje/edje_load.c | |||
@@ -1248,7 +1248,10 @@ _edje_object_file_set_internal(Evas_Object *obj, const Eina_File *file, const ch | |||
1248 | } | 1248 | } |
1249 | 1249 | ||
1250 | if (rp->param1.description && (rp->param1.description->clip_to_id >= 0)) | 1250 | if (rp->param1.description && (rp->param1.description->clip_to_id >= 0)) |
1251 | clip_to = ed->table_parts[rp->param1.description->clip_to_id % ed->table_parts_size]; | 1251 | { |
1252 | clip_to = ed->table_parts[rp->param1.description->clip_to_id % ed->table_parts_size]; | ||
1253 | ed->has_state_clip = EINA_TRUE; | ||
1254 | } | ||
1252 | else if (rp->part->clip_to_id >= 0) | 1255 | else if (rp->part->clip_to_id >= 0) |
1253 | clip_to = ed->table_parts[rp->part->clip_to_id % ed->table_parts_size]; | 1256 | clip_to = ed->table_parts[rp->part->clip_to_id % ed->table_parts_size]; |
1254 | if (clip_to && clip_to->object && rp->object) | 1257 | if (clip_to && clip_to->object && rp->object) |
diff --git a/src/lib/edje/edje_private.h b/src/lib/edje/edje_private.h index a849f3034f..b5cd5543d3 100644 --- a/src/lib/edje/edje_private.h +++ b/src/lib/edje/edje_private.h | |||
@@ -1765,6 +1765,7 @@ struct _Edje | |||
1765 | Eina_Bool recalc_hints : 1; | 1765 | Eina_Bool recalc_hints : 1; |
1766 | Eina_Bool need_map_update : 1; | 1766 | Eina_Bool need_map_update : 1; |
1767 | Eina_Bool canvas_animator : 1; | 1767 | Eina_Bool canvas_animator : 1; |
1768 | Eina_Bool has_state_clip : 1; | ||
1768 | }; | 1769 | }; |
1769 | 1770 | ||
1770 | struct _Edje_Calc_Params_Map | 1771 | struct _Edje_Calc_Params_Map |