mirror of
https://gitlab.uni-freiburg.de/opensourcevdi/spice
synced 2025-12-30 17:49:02 +00:00
worker: move shadow_new() and container_new()
Acked-by: Fabiano Fidêncio <fidencio@redhat.com>
This commit is contained in:
parent
c9bb089869
commit
e76f402952
@ -1457,24 +1457,6 @@ static void exclude_region(RedWorker *worker, Ring *ring, RingItem *ring_item, Q
|
||||
}
|
||||
}
|
||||
|
||||
static inline Container *__new_container(RedWorker *worker, DrawItem *item)
|
||||
{
|
||||
Container *container = spice_new(Container, 1);
|
||||
worker->containers_count++;
|
||||
container->base.type = TREE_ITEM_TYPE_CONTAINER;
|
||||
container->base.container = item->base.container;
|
||||
item->base.container = container;
|
||||
item->container_root = TRUE;
|
||||
region_clone(&container->base.rgn, &item->base.rgn);
|
||||
ring_item_init(&container->base.siblings_link);
|
||||
ring_add_after(&container->base.siblings_link, &item->base.siblings_link);
|
||||
ring_remove(&item->base.siblings_link);
|
||||
ring_init(&container->items);
|
||||
ring_add(&container->items, &item->base.siblings_link);
|
||||
|
||||
return container;
|
||||
}
|
||||
|
||||
static inline int is_opaque_item(TreeItem *item)
|
||||
{
|
||||
return item->type == TREE_ITEM_TYPE_CONTAINER ||
|
||||
@ -2782,13 +2764,14 @@ static inline int red_current_add(RedWorker *worker, Ring *ring, Drawable *drawa
|
||||
continue;
|
||||
}
|
||||
spice_assert(IS_DRAW_ITEM(sibling));
|
||||
if (!((DrawItem *)sibling)->container_root) {
|
||||
container = __new_container(worker, (DrawItem *)sibling);
|
||||
if (!DRAW_ITEM(sibling)->container_root) {
|
||||
container = container_new(DRAW_ITEM(sibling));
|
||||
if (!container) {
|
||||
spice_warning("create new container failed");
|
||||
region_destroy(&exclude_rgn);
|
||||
return FALSE;
|
||||
}
|
||||
worker->containers_count++;
|
||||
item->base.container = container;
|
||||
ring = &container->items;
|
||||
}
|
||||
@ -2817,7 +2800,7 @@ static inline int red_current_add(RedWorker *worker, Ring *ring, Drawable *drawa
|
||||
* before calling red_detach_streams_behind
|
||||
*/
|
||||
__current_add_drawable(worker, drawable, ring);
|
||||
if (drawable->surface_id == 0) {
|
||||
if (is_primary_surface(worker, drawable->surface_id)) {
|
||||
red_detach_streams_behind(worker, &drawable->tree_item.base.rgn, drawable);
|
||||
}
|
||||
}
|
||||
@ -2835,25 +2818,6 @@ static void add_clip_rects(QRegion *rgn, SpiceClipRects *data)
|
||||
}
|
||||
}
|
||||
|
||||
static inline Shadow *__new_shadow(RedWorker *worker, Drawable *item, SpicePoint *delta)
|
||||
{
|
||||
if (!delta->x && !delta->y) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Shadow *shadow = spice_new(Shadow, 1);
|
||||
worker->shadows_count++;
|
||||
shadow->base.type = TREE_ITEM_TYPE_SHADOW;
|
||||
shadow->base.container = NULL;
|
||||
shadow->owner = &item->tree_item;
|
||||
region_clone(&shadow->base.rgn, &item->tree_item.base.rgn);
|
||||
region_offset(&shadow->base.rgn, delta->x, delta->y);
|
||||
ring_item_init(&shadow->base.siblings_link);
|
||||
region_init(&shadow->on_hold);
|
||||
item->tree_item.shadow = shadow;
|
||||
return shadow;
|
||||
}
|
||||
|
||||
static inline int red_current_add_with_shadow(RedWorker *worker, Ring *ring, Drawable *item)
|
||||
{
|
||||
#ifdef RED_WORKER_STAT
|
||||
@ -2867,11 +2831,12 @@ static inline int red_current_add_with_shadow(RedWorker *worker, Ring *ring, Dra
|
||||
.y = red_drawable->u.copy_bits.src_pos.y - red_drawable->bbox.top
|
||||
};
|
||||
|
||||
Shadow *shadow = __new_shadow(worker, item, &delta);
|
||||
Shadow *shadow = shadow_new(&item->tree_item, &delta);
|
||||
if (!shadow) {
|
||||
stat_add(&worker->add_stat, start_time);
|
||||
return FALSE;
|
||||
}
|
||||
worker->shadows_count++;
|
||||
// item and his shadow must initially be placed in the same container.
|
||||
// for now putting them on root.
|
||||
|
||||
@ -2879,6 +2844,7 @@ static inline int red_current_add_with_shadow(RedWorker *worker, Ring *ring, Dra
|
||||
if (is_primary_surface(worker, item->surface_id)) {
|
||||
red_detach_streams_behind(worker, &shadow->base.rgn, NULL);
|
||||
}
|
||||
|
||||
ring_add(ring, &shadow->base.siblings_link);
|
||||
__current_add_drawable(worker, item, ring);
|
||||
if (item->tree_item.effect == QXL_EFFECT_OPAQUE) {
|
||||
@ -2888,7 +2854,7 @@ static inline int red_current_add_with_shadow(RedWorker *worker, Ring *ring, Dra
|
||||
region_destroy(&exclude_rgn);
|
||||
red_streams_update_visible_region(worker, item);
|
||||
} else {
|
||||
if (item->surface_id == 0) {
|
||||
if (is_primary_surface(worker, item->surface_id)) {
|
||||
red_detach_streams_behind(worker, &item->tree_item.base.rgn, item);
|
||||
}
|
||||
}
|
||||
|
||||
@ -180,3 +180,42 @@ void tree_item_dump(TreeItem *item)
|
||||
spice_return_if_fail(item != NULL);
|
||||
tree_foreach(item, dump_item, &di);
|
||||
}
|
||||
|
||||
Shadow* shadow_new(DrawItem *item, const SpicePoint *delta)
|
||||
{
|
||||
spice_return_val_if_fail(item->shadow == NULL, NULL);
|
||||
if (!delta->x && !delta->y) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Shadow *shadow = spice_new(Shadow, 1);
|
||||
|
||||
shadow->base.type = TREE_ITEM_TYPE_SHADOW;
|
||||
shadow->base.container = NULL;
|
||||
shadow->owner = item;
|
||||
region_clone(&shadow->base.rgn, &item->base.rgn);
|
||||
region_offset(&shadow->base.rgn, delta->x, delta->y);
|
||||
ring_item_init(&shadow->base.siblings_link);
|
||||
region_init(&shadow->on_hold);
|
||||
item->shadow = shadow;
|
||||
|
||||
return shadow;
|
||||
}
|
||||
|
||||
Container* container_new(DrawItem *item)
|
||||
{
|
||||
Container *container = spice_new(Container, 1);
|
||||
|
||||
container->base.type = TREE_ITEM_TYPE_CONTAINER;
|
||||
container->base.container = item->base.container;
|
||||
item->base.container = container;
|
||||
item->container_root = TRUE;
|
||||
region_clone(&container->base.rgn, &item->base.rgn);
|
||||
ring_item_init(&container->base.siblings_link);
|
||||
ring_add_after(&container->base.siblings_link, &item->base.siblings_link);
|
||||
ring_remove(&item->base.siblings_link);
|
||||
ring_init(&container->items);
|
||||
ring_add(&container->items, &item->base.siblings_link);
|
||||
|
||||
return container;
|
||||
}
|
||||
|
||||
@ -52,11 +52,17 @@ struct Shadow {
|
||||
DrawItem* owner;
|
||||
};
|
||||
|
||||
#define IS_SHADOW(item) ((item)->type == TREE_ITEM_TYPE_SHADOW)
|
||||
#define SHADOW(item) ((Shadow*)(item))
|
||||
|
||||
struct Container {
|
||||
TreeItem base;
|
||||
Ring items;
|
||||
};
|
||||
|
||||
#define IS_CONTAINER(item) ((item)->type == TREE_ITEM_TYPE_CONTAINER)
|
||||
#define CONTAINER(item) ((Container*)(item))
|
||||
|
||||
struct DrawItem {
|
||||
TreeItem base;
|
||||
uint8_t effect;
|
||||
@ -65,7 +71,10 @@ struct DrawItem {
|
||||
};
|
||||
|
||||
#define IS_DRAW_ITEM(item) ((item)->type == TREE_ITEM_TYPE_DRAWABLE)
|
||||
#define DRAW_ITEM(item) ((DrawItem*)(item))
|
||||
|
||||
void tree_item_dump (TreeItem *item);
|
||||
Shadow* shadow_new (DrawItem *item, const SpicePoint *delta);
|
||||
Container* container_new (DrawItem *item);
|
||||
|
||||
#endif /* TREE_H_ */
|
||||
|
||||
Loading…
Reference in New Issue
Block a user