summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUcan, Emre (ADITG/SW1) <eucan@de.adit-jv.com>2015-08-20 14:13:29 +0000
committerPekka Paalanen <pekka.paalanen@collabora.co.uk>2015-08-21 11:46:23 +0300
commit38fcf381be99d6c53711909001ef3e52073d0324 (patch)
treedc084e011eeafcbc514f6a899043471cec6b8455
parentc2be6388d274fa243472c844f0698e9634dec972 (diff)
ivi-shell: clear order.surface_list before reordering it
It is only possible to remove a surface from the order.surface_list of a layer, when ivi_layout_layer_set_render_order is called with an empty array. Therefore, list of surfaces are cumulated if the API is called many times with different list of surfaces. 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_layer_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: wrapped the commit message] Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> [Earlier version Reviewed-by: Nobuhiko Tanibata <NOBUHIKO_TANIBATA@xddp.denso.co.jp>]
-rw-r--r--ivi-shell/ivi-layout-private.h1
-rw-r--r--ivi-shell/ivi-layout.c66
2 files changed, 21 insertions, 46 deletions
diff --git a/ivi-shell/ivi-layout-private.h b/ivi-shell/ivi-layout-private.h
index 9c04c304..074d5986 100644
--- a/ivi-shell/ivi-layout-private.h
+++ b/ivi-shell/ivi-layout-private.h
@@ -81,6 +81,7 @@ struct ivi_layout_layer {
} pending;
struct {
+ int dirty;
struct wl_list surface_list;
struct wl_list link;
} order;
diff --git a/ivi-shell/ivi-layout.c b/ivi-shell/ivi-layout.c
index d412069c..34bb2210 100644
--- a/ivi-shell/ivi-layout.c
+++ b/ivi-shell/ivi-layout.c
@@ -58,6 +58,7 @@
#include "config.h"
#include <string.h>
+#include <assert.h>
#include "compositor.h"
#include "ivi-layout-export.h"
@@ -809,53 +810,30 @@ commit_layer_list(struct ivi_layout *layout)
ivilayer->prop = ivilayer->pending.prop;
- if (!(ivilayer->event_mask &
- (IVI_NOTIFICATION_ADD | IVI_NOTIFICATION_REMOVE)) ) {
+ if (!ivilayer->order.dirty) {
continue;
}
- if (ivilayer->event_mask & IVI_NOTIFICATION_REMOVE) {
- wl_list_for_each_safe(ivisurf, next,
- &ivilayer->order.surface_list, order.link) {
- remove_ordersurface_from_layer(ivisurf);
-
- if (!wl_list_empty(&ivisurf->order.link)) {
- wl_list_remove(&ivisurf->order.link);
- }
-
- wl_list_init(&ivisurf->order.link);
- ivisurf->event_mask |= IVI_NOTIFICATION_REMOVE;
- }
-
- wl_list_init(&ivilayer->order.surface_list);
+ wl_list_for_each_safe(ivisurf, next, &ivilayer->order.surface_list,
+ order.link) {
+ remove_ordersurface_from_layer(ivisurf);
+ wl_list_remove(&ivisurf->order.link);
+ wl_list_init(&ivisurf->order.link);
+ ivisurf->event_mask |= IVI_NOTIFICATION_REMOVE;
}
- if (ivilayer->event_mask & IVI_NOTIFICATION_ADD) {
- wl_list_for_each_safe(ivisurf, next,
- &ivilayer->order.surface_list, order.link) {
- remove_ordersurface_from_layer(ivisurf);
-
- if (!wl_list_empty(&ivisurf->order.link)) {
- wl_list_remove(&ivisurf->order.link);
- }
+ assert(wl_list_empty(&ivilayer->order.surface_list));
- wl_list_init(&ivisurf->order.link);
- }
-
- wl_list_init(&ivilayer->order.surface_list);
- wl_list_for_each(ivisurf, &ivilayer->pending.surface_list,
+ wl_list_for_each(ivisurf, &ivilayer->pending.surface_list,
pending.link) {
- if (!wl_list_empty(&ivisurf->order.link)) {
- wl_list_remove(&ivisurf->order.link);
- wl_list_init(&ivisurf->order.link);
- }
-
- wl_list_insert(&ivilayer->order.surface_list,
- &ivisurf->order.link);
- add_ordersurface_to_layer(ivisurf, ivilayer);
- ivisurf->event_mask |= IVI_NOTIFICATION_ADD;
- }
+ wl_list_remove(&ivisurf->order.link);
+ wl_list_insert(&ivilayer->order.surface_list,
+ &ivisurf->order.link);
+ add_ordersurface_to_layer(ivisurf, ivilayer);
+ ivisurf->event_mask |= IVI_NOTIFICATION_ADD;
}
+
+ ivilayer->order.dirty = 0;
}
}
@@ -997,8 +975,6 @@ clear_surface_pending_list(struct ivi_layout_layer *ivilayer)
wl_list_init(&surface_link->pending.link);
}
-
- ivilayer->event_mask |= IVI_NOTIFICATION_REMOVE;
}
static void
@@ -1015,8 +991,6 @@ clear_surface_order_list(struct ivi_layout_layer *ivilayer)
wl_list_init(&surface_link->order.link);
}
-
- ivilayer->event_mask |= IVI_NOTIFICATION_REMOVE;
}
static void
@@ -2102,7 +2076,7 @@ ivi_layout_layer_set_render_order(struct ivi_layout_layer *ivilayer,
}
}
- ivilayer->event_mask |= IVI_NOTIFICATION_ADD;
+ ivilayer->order.dirty = 1;
return IVI_SUCCEEDED;
}
@@ -2526,7 +2500,7 @@ ivi_layout_layer_add_surface(struct ivi_layout_layer *ivilayer,
}
}
- ivilayer->event_mask |= IVI_NOTIFICATION_ADD;
+ ivilayer->order.dirty = 1;
return IVI_SUCCEEDED;
}
@@ -2554,7 +2528,7 @@ ivi_layout_layer_remove_surface(struct ivi_layout_layer *ivilayer,
}
}
- remsurf->event_mask |= IVI_NOTIFICATION_REMOVE;
+ ivilayer->order.dirty = 1;
}
static int32_t