summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@gmail.com>2013-09-13 18:11:16 +0200
committerFrediano Ziglio <fziglio@redhat.com>2015-11-06 10:10:40 +0000
commite76f40295209103cc7a0cf7003f8422c7e02577d (patch)
tree2f7942facb13d189acabe5f52fa14f0a9ab9c042
parentc9bb089869bd7bed1abaf37bb6233356ef61a242 (diff)
downloadspice-e76f40295209103cc7a0cf7003f8422c7e02577d.tar.gz
spice-e76f40295209103cc7a0cf7003f8422c7e02577d.tar.xz
spice-e76f40295209103cc7a0cf7003f8422c7e02577d.zip
worker: move shadow_new() and container_new()
Acked-by: Fabiano Fidêncio <fidencio@redhat.com>
-rw-r--r--server/red_worker.c50
-rw-r--r--server/tree.c39
-rw-r--r--server/tree.h9
3 files changed, 56 insertions, 42 deletions
diff --git a/server/red_worker.c b/server/red_worker.c
index 81666b68..c29b042a 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -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);
}
}
diff --git a/server/tree.c b/server/tree.c
index ed7d39ad..64fa6db9 100644
--- a/server/tree.c
+++ b/server/tree.c
@@ -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;
+}
diff --git a/server/tree.h b/server/tree.h
index 82f9ce3b..6e83f7a8 100644
--- a/server/tree.h
+++ b/server/tree.h
@@ -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_ */