mirror of
https://gitlab.uni-freiburg.de/opensourcevdi/spice
synced 2026-01-08 21:14:11 +00:00
worker: move some tree container functions
Acked-by: Fabiano Fidêncio <fidencio@redhat.com>
This commit is contained in:
parent
cc8107c830
commit
120c9ae38b
@ -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);
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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_ */
|
||||
|
||||
Loading…
Reference in New Issue
Block a user