summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathon Jongsma <jjongsma@redhat.com>2016-04-21 10:45:15 -0500
committerJonathon Jongsma <jjongsma@redhat.com>2016-04-27 09:40:43 -0500
commit50a2c2fce213e97a6d91a48737a3698946e972a5 (patch)
tree0fbda33f82d5f45ec383e5c00980c5f6740b8aa5
parentc6b1fc3551aac646a9cb3d09aec2247bdcc882e2 (diff)
Store display in Drawable struct
If the Drawable keeps a pointer to the Display channel that it is associated with, we can unref it directly and not need to pass the 'display' parameter separately to the unref function Acked-by: Frediano Ziglio <fziglio@redhat.com>
-rw-r--r--server/dcc.c18
-rw-r--r--server/display-channel.c17
-rw-r--r--server/display-channel.h4
3 files changed, 21 insertions, 18 deletions
diff --git a/server/dcc.c b/server/dcc.c
index 91c3f82c..d52d2e48 100644
--- a/server/dcc.c
+++ b/server/dcc.c
@@ -277,13 +277,11 @@ static void add_drawable_surface_images(DisplayChannelClient *dcc, Drawable *dra
void drawable_pipe_item_free(PipeItem *item)
{
DrawablePipeItem *dpi = SPICE_CONTAINEROF(item, DrawablePipeItem, dpi_pipe_item);
- DisplayChannel *display = DCC_TO_DC(dpi->dcc);
-
spice_assert(item->refcount == 0);
spice_warn_if_fail(!ring_item_is_linked(&item->link));
spice_warn_if_fail(!ring_item_is_linked(&dpi->base));
- display_channel_drawable_unref(display, dpi->drawable);
+ drawable_unref(dpi->drawable);
free(dpi);
}
@@ -1591,20 +1589,18 @@ int dcc_handle_migrate_data(DisplayChannelClient *dcc, uint32_t size, void *mess
return TRUE;
}
-static void upgrade_item_unref(DisplayChannel *display, UpgradeItem *item)
+static void upgrade_item_unref(UpgradeItem *item)
{
if (--item->refs != 0)
return;
- display_channel_drawable_unref(display, item->drawable);
+ drawable_unref(item->drawable);
free(item->rects);
free(item);
}
-static void release_item_after_push(DisplayChannelClient *dcc, PipeItem *item)
+static void release_item_after_push(PipeItem *item)
{
- DisplayChannel *display = DCC_TO_DC(dcc);
-
switch (item->type) {
case PIPE_ITEM_TYPE_DRAW:
case PIPE_ITEM_TYPE_IMAGE:
@@ -1613,7 +1609,7 @@ static void release_item_after_push(DisplayChannelClient *dcc, PipeItem *item)
pipe_item_unref(item);
break;
case PIPE_ITEM_TYPE_UPGRADE:
- upgrade_item_unref(display, (UpgradeItem *)item);
+ upgrade_item_unref((UpgradeItem *)item);
break;
case PIPE_ITEM_TYPE_GL_SCANOUT:
case PIPE_ITEM_TYPE_GL_DRAW:
@@ -1651,7 +1647,7 @@ static void release_item_before_push(DisplayChannelClient *dcc, PipeItem *item)
}
case PIPE_ITEM_TYPE_STREAM_CLIP:
case PIPE_ITEM_TYPE_UPGRADE:
- upgrade_item_unref(display, (UpgradeItem *)item);
+ upgrade_item_unref((UpgradeItem *)item);
break;
case PIPE_ITEM_TYPE_IMAGE:
case PIPE_ITEM_TYPE_MONITORS_CONFIG:
@@ -1688,7 +1684,7 @@ static void release_item_before_push(DisplayChannelClient *dcc, PipeItem *item)
void dcc_release_item(DisplayChannelClient *dcc, PipeItem *item, int item_pushed)
{
if (item_pushed)
- release_item_after_push(dcc, item);
+ release_item_after_push(item);
else
release_item_before_push(dcc, item);
}
diff --git a/server/display-channel.c b/server/display-channel.c
index abc94d59..c53c095e 100644
--- a/server/display-channel.c
+++ b/server/display-channel.c
@@ -390,7 +390,7 @@ static void current_remove_drawable(DisplayChannel *display, Drawable *item)
ring_remove(&item->tree_item.base.siblings_link);
ring_remove(&item->list_link);
ring_remove(&item->surface_list_link);
- display_channel_drawable_unref(display, item);
+ drawable_unref(item);
display->current_size--;
}
@@ -488,7 +488,7 @@ static int current_add_equal(DisplayChannel *display, DrawItem *item, TreeItem *
pipes_add_drawable(display, drawable);
}
drawable_remove_from_pipes(other_drawable);
- display_channel_drawable_unref(display, other_drawable);
+ drawable_unref(other_drawable);
return TRUE;
}
@@ -531,7 +531,7 @@ static int current_add_equal(DisplayChannel *display, DrawItem *item, TreeItem *
/* not sending other_drawable where possible */
drawable_remove_from_pipes(other_drawable);
- display_channel_drawable_unref(display, other_drawable);
+ drawable_unref(other_drawable);
return TRUE;
}
break;
@@ -1185,7 +1185,7 @@ void display_channel_process_draw(DisplayChannel *display, RedDrawable *red_draw
display_channel_add_drawable(display, drawable);
- display_channel_drawable_unref(display, drawable);
+ drawable_unref(drawable);
}
int display_channel_wait_for_migrate_data(DisplayChannel *display)
@@ -1373,6 +1373,10 @@ Drawable *display_channel_drawable_try_new(DisplayChannel *display,
}
bzero(drawable, sizeof(Drawable));
+ /* Pointer to the display from which the drawable is allocated. This
+ * pointer is safe to be retained as DisplayChannel lifespan is bigger than
+ * all drawables. */
+ drawable->display = display;
drawable->refs = 1;
drawable->creation_time = drawable->first_frame_time = spice_get_monotonic_time_ns();
ring_item_init(&drawable->list_link);
@@ -1423,8 +1427,9 @@ static void drawable_unref_surface_deps(DisplayChannel *display, Drawable *drawa
}
}
-void display_channel_drawable_unref(DisplayChannel *display, Drawable *drawable)
+void drawable_unref(Drawable *drawable)
{
+ DisplayChannel *display = drawable->display;
RingItem *item, *next;
if (--drawable->refs != 0)
@@ -1646,7 +1651,7 @@ static void draw_until(DisplayChannel *display, RedSurface *surface, Drawable *l
that display_channel_draw is called for, Otherwise, 'now' would have already been rendered.
See the call for red_handle_depends_on_target_surface in red_process_draw */
drawable_draw(display, now);
- display_channel_drawable_unref(display, now);
+ drawable_unref(now);
} while (now != last);
}
diff --git a/server/display-channel.h b/server/display-channel.h
index d5356fc2..3752c62f 100644
--- a/server/display-channel.h
+++ b/server/display-channel.h
@@ -79,8 +79,11 @@ struct Drawable {
int surface_deps[3];
uint32_t process_commands_generation;
+ DisplayChannel *display;
};
+void drawable_unref (Drawable *drawable);
+
#define LINK_TO_DPI(ptr) SPICE_CONTAINEROF((ptr), DrawablePipeItem, base)
#define DRAWABLE_FOREACH_DPI_SAFE(drawable, link, next, dpi) \
SAFE_FOREACH(link, next, drawable, &(drawable)->pipes, dpi, LINK_TO_DPI(link))
@@ -280,7 +283,6 @@ void display_channel_compress_stats_print (const Disp
void display_channel_compress_stats_reset (DisplayChannel *display);
Drawable * display_channel_drawable_try_new (DisplayChannel *display,
int process_commands_generation);
-void display_channel_drawable_unref (DisplayChannel *display, Drawable *drawable);
void display_channel_surface_unref (DisplayChannel *display,
uint32_t surface_id);
void display_channel_current_flush (DisplayChannel *display,