ivi-shell: clear order.layer_list before reordering it

It is only possible to remove a layer from the order.layer_list of a
screen, when ivi_layout_screen_set_render_order is called with an empty
array.  Therefore, list of layers are cumulated if the API is called
many times with different list of layers.

Change how the flags are set:
    - Introduce the dirty parameter for triggering the render order change.
    - IVI_NOTIFICATION_REMOVE/ADD flags are set only at commit_screen_list.

Checking wl_list_empty() on a link offers no information: if it returns
true, wl_list_remove() is safe to do. If it returns false, you still do
not know if wl_list_remove() is safe; the link could be part of a list,
or the link could be "uninitialized" (e.g. just wl_list_remove()'d).
(From Pekka Paalanen's comment at
http://lists.freedesktop.org/archives/wayland-devel/2015-August/023987.html).

Calling wl_list_init just before wl_list_insert is redundant.  Because
the links of the list are not read before it is overwritten by
wl_list_insert.

Use assert to control if the ivilayer->order.surface_list is empty.

Signed-off-by: Emre Ucan <eucan@de.adit-jv.com>
[Pekka: line-wrapped commit message]
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
dev
Ucan, Emre (ADITG/SW1) 9 years ago committed by Pekka Paalanen
parent 38fcf381be
commit 174257bdf8
  1. 55
      ivi-shell/ivi-layout.c

@ -94,14 +94,13 @@ struct ivi_layout_screen {
struct ivi_layout *layout; struct ivi_layout *layout;
struct weston_output *output; struct weston_output *output;
uint32_t event_mask;
struct { struct {
struct wl_list layer_list; struct wl_list layer_list;
struct wl_list link; struct wl_list link;
} pending; } pending;
struct { struct {
int dirty;
struct wl_list layer_list; struct wl_list layer_list;
struct wl_list link; struct wl_list link;
} order; } order;
@ -432,7 +431,6 @@ create_screen(struct weston_compositor *ec)
count++; count++;
iviscrn->output = output; iviscrn->output = output;
iviscrn->event_mask = 0;
wl_list_init(&iviscrn->pending.layer_list); wl_list_init(&iviscrn->pending.layer_list);
wl_list_init(&iviscrn->pending.link); wl_list_init(&iviscrn->pending.link);
@ -846,33 +844,17 @@ commit_screen_list(struct ivi_layout *layout)
struct ivi_layout_surface *ivisurf = NULL; struct ivi_layout_surface *ivisurf = NULL;
wl_list_for_each(iviscrn, &layout->screen_list, link) { wl_list_for_each(iviscrn, &layout->screen_list, link) {
if (iviscrn->event_mask & IVI_NOTIFICATION_REMOVE) { if (iviscrn->order.dirty) {
wl_list_for_each_safe(ivilayer, next, wl_list_for_each_safe(ivilayer, next,
&iviscrn->order.layer_list, order.link) { &iviscrn->order.layer_list, order.link) {
remove_orderlayer_from_screen(ivilayer); remove_orderlayer_from_screen(ivilayer);
wl_list_remove(&ivilayer->order.link);
if (!wl_list_empty(&ivilayer->order.link)) {
wl_list_remove(&ivilayer->order.link);
}
wl_list_init(&ivilayer->order.link); wl_list_init(&ivilayer->order.link);
ivilayer->event_mask |= IVI_NOTIFICATION_REMOVE; ivilayer->event_mask |= IVI_NOTIFICATION_REMOVE;
} }
}
if (iviscrn->event_mask & IVI_NOTIFICATION_ADD) { assert(wl_list_empty(&iviscrn->order.layer_list));
wl_list_for_each_safe(ivilayer, next,
&iviscrn->order.layer_list, order.link) {
remove_orderlayer_from_screen(ivilayer);
if (!wl_list_empty(&ivilayer->order.link)) {
wl_list_remove(&ivilayer->order.link);
}
wl_list_init(&ivilayer->order.link);
}
wl_list_init(&iviscrn->order.layer_list);
wl_list_for_each(ivilayer, &iviscrn->pending.layer_list, wl_list_for_each(ivilayer, &iviscrn->pending.layer_list,
pending.link) { pending.link) {
wl_list_insert(&iviscrn->order.layer_list, wl_list_insert(&iviscrn->order.layer_list,
@ -880,9 +862,9 @@ commit_screen_list(struct ivi_layout *layout)
add_orderlayer_to_screen(ivilayer, iviscrn); add_orderlayer_to_screen(ivilayer, iviscrn);
ivilayer->event_mask |= IVI_NOTIFICATION_ADD; ivilayer->event_mask |= IVI_NOTIFICATION_ADD;
} }
}
iviscrn->event_mask = 0; iviscrn->order.dirty = 0;
}
/* Clear view list of layout ivi_layer */ /* Clear view list of layout ivi_layer */
wl_list_init(&layout->layout_layer.view_list.link); wl_list_init(&layout->layout_layer.view_list.link);
@ -2323,7 +2305,7 @@ ivi_layout_screen_add_layer(struct ivi_layout_screen *iviscrn,
} }
} }
iviscrn->event_mask |= IVI_NOTIFICATION_ADD; iviscrn->order.dirty = 1;
return IVI_SUCCEEDED; return IVI_SUCCEEDED;
} }
@ -2346,23 +2328,11 @@ ivi_layout_screen_set_render_order(struct ivi_layout_screen *iviscrn,
wl_list_for_each_safe(ivilayer, next, wl_list_for_each_safe(ivilayer, next,
&iviscrn->pending.layer_list, pending.link) { &iviscrn->pending.layer_list, pending.link) {
wl_list_remove(&ivilayer->pending.link);
wl_list_init(&ivilayer->pending.link); wl_list_init(&ivilayer->pending.link);
} }
wl_list_init(&iviscrn->pending.layer_list); assert(wl_list_empty(&iviscrn->pending.layer_list));
if (pLayer == NULL) {
wl_list_for_each_safe(ivilayer, next, &iviscrn->pending.layer_list, pending.link) {
if (!wl_list_empty(&ivilayer->pending.link)) {
wl_list_remove(&ivilayer->pending.link);
}
wl_list_init(&ivilayer->pending.link);
}
iviscrn->event_mask |= IVI_NOTIFICATION_REMOVE;
return IVI_SUCCEEDED;
}
for (i = 0; i < number; i++) { for (i = 0; i < number; i++) {
id_layer = &pLayer[i]->id_layer; id_layer = &pLayer[i]->id_layer;
@ -2371,17 +2341,14 @@ ivi_layout_screen_set_render_order(struct ivi_layout_screen *iviscrn,
continue; continue;
} }
if (!wl_list_empty(&ivilayer->pending.link)) { wl_list_remove(&ivilayer->pending.link);
wl_list_remove(&ivilayer->pending.link);
}
wl_list_init(&ivilayer->pending.link);
wl_list_insert(&iviscrn->pending.layer_list, wl_list_insert(&iviscrn->pending.layer_list,
&ivilayer->pending.link); &ivilayer->pending.link);
break; break;
} }
} }
iviscrn->event_mask |= IVI_NOTIFICATION_ADD; iviscrn->order.dirty = 1;
return IVI_SUCCEEDED; return IVI_SUCCEEDED;
} }

Loading…
Cancel
Save