summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@gmail.com>2013-09-17 01:45:01 +0200
committerFrediano Ziglio <fziglio@redhat.com>2015-11-12 12:26:47 +0000
commit120c9ae38bb26150f5d90d1817a99065dfa37133 (patch)
tree2c7019d4e674cc81dba8d820f44d76e551e7e974
parentcc8107c830d045a2deb9bffed6d32d1f563c9a35 (diff)
downloadspice-120c9ae38bb26150f5d90d1817a99065dfa37133.zip
spice-120c9ae38bb26150f5d90d1817a99065dfa37133.tar.gz
spice-120c9ae38bb26150f5d90d1817a99065dfa37133.tar.xz
worker: move some tree container functions
Acked-by: Fabiano Fidêncio <fidencio@redhat.com>
-rw-r--r--server/red_worker.c32
-rw-r--r--server/tree.c27
-rw-r--r--server/tree.h2
3 files changed, 33 insertions, 28 deletions
diff --git a/server/red_worker.c b/server/red_worker.c
index 11aa3f0..286bde4 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -974,30 +974,6 @@ static inline void remove_shadow(DrawItem *item)
free(shadow);
}
-static inline void current_remove_container(RedWorker *worker, Container *container)
-{
- spice_assert(ring_is_empty(&container->items));
- ring_remove(&container->base.siblings_link);
- region_destroy(&container->base.rgn);
- free(container);
-}
-
-static inline void container_cleanup(RedWorker *worker, Container *container)
-{
- while (container && container->items.next == container->items.prev) {
- Container *next = container->base.container;
- if (container->items.next != &container->items) {
- TreeItem *item = (TreeItem *)ring_get_head(&container->items);
- spice_assert(item);
- ring_remove(&item->siblings_link);
- ring_add_after(&item->siblings_link, &container->base.siblings_link);
- item->container = container->base.container;
- }
- current_remove_container(worker, container);
- container = next;
- }
-}
-
static void display_stream_trace_add_drawable(DisplayChannel *display, Drawable *item)
{
ItemTrace *trace;
@@ -1076,7 +1052,7 @@ static inline void current_remove(RedWorker *worker, TreeItem *item)
continue;
}
ring_item = now->siblings_link.prev;
- current_remove_container(worker, container);
+ container_free(container);
}
if (now == item) {
return;
@@ -2659,7 +2635,7 @@ static bool free_one_drawable(RedWorker *worker, int force_glz_free)
container = drawable->tree_item.base.container;
current_remove_drawable(worker, drawable);
- container_cleanup(worker, container);
+ container_cleanup(container);
return TRUE;
}
@@ -3157,7 +3133,7 @@ static void red_update_area_till(RedWorker *worker, const SpiceRect *area, int s
now->refs++;
container = now->tree_item.base.container;
current_remove_drawable(worker, now);
- container_cleanup(worker, container);
+ container_cleanup(container);
/* red_draw_drawable may call red_update_area for the surfaces 'now' depends on. Notice,
that it is valid to call red_update_area in this case and not red_update_area_till:
It is impossible that there was newer item then 'last' in one of the surfaces
@@ -3216,7 +3192,7 @@ static void red_update_area(RedWorker *worker, const SpiceRect *area, int surfac
now->refs++;
container = now->tree_item.base.container;
current_remove_drawable(worker, now);
- container_cleanup(worker, container);
+ container_cleanup(container);
red_draw_drawable(worker, now);
display_channel_drawable_unref(display, now);
} while (now != last);
diff --git a/server/tree.c b/server/tree.c
index bf50edf..ad31f09 100644
--- a/server/tree.c
+++ b/server/tree.c
@@ -223,3 +223,30 @@ Container* container_new(DrawItem *item)
return container;
}
+
+void container_free(Container *container)
+{
+ spice_return_if_fail(ring_is_empty(&container->items));
+
+ ring_remove(&container->base.siblings_link);
+ region_destroy(&container->base.rgn);
+ free(container);
+}
+
+void container_cleanup(Container *container)
+{
+ /* visit upward, removing containers */
+ /* non-empty container get its element moving up ?? */
+ while (container && container->items.next == container->items.prev) {
+ Container *next = container->base.container;
+ if (container->items.next != &container->items) {
+ TreeItem *item = (TreeItem *)ring_get_head(&container->items);
+ spice_assert(item);
+ ring_remove(&item->siblings_link);
+ ring_add_after(&item->siblings_link, &container->base.siblings_link);
+ item->container = container->base.container;
+ }
+ container_free(container);
+ container = next;
+ }
+}
diff --git a/server/tree.h b/server/tree.h
index 6249c28..01d4ff9 100644
--- a/server/tree.h
+++ b/server/tree.h
@@ -82,5 +82,7 @@ static inline int is_opaque_item(TreeItem *item)
void tree_item_dump (TreeItem *item);
Shadow* shadow_new (DrawItem *item, const SpicePoint *delta);
Container* container_new (DrawItem *item);
+void container_free (Container *container);
+void container_cleanup (Container *container);
#endif /* TREE_H_ */