[Spice-devel] [PATCH RFC 04/14] Pass surface directly to display_channel_surface_unref
Frediano Ziglio
fziglio at redhat.com
Thu Sep 29 08:44:03 UTC 2016
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
---
server/display-channel.c | 23 ++++++++++++++---------
server/display-channel.h | 2 +-
server/red-worker.c | 2 +-
3 files changed, 16 insertions(+), 11 deletions(-)
diff --git a/server/display-channel.c b/server/display-channel.c
index 5e9bc7d..5cdd0cb 100644
--- a/server/display-channel.c
+++ b/server/display-channel.c
@@ -169,9 +169,8 @@ static void stop_streams(DisplayChannel *display)
memset(display->priv->items_trace, 0, sizeof(display->priv->items_trace));
}
-void display_channel_surface_unref(DisplayChannel *display, uint32_t surface_id)
+static void display_channel_surface_unref(DisplayChannel *display, RedSurface *surface)
{
- RedSurface *surface = &display->priv->surfaces[surface_id];
QXLInstance *qxl = display->common.qxl;
DisplayChannelClient *dcc;
GListIter iter;
@@ -182,7 +181,7 @@ void display_channel_surface_unref(DisplayChannel *display, uint32_t surface_id)
}
// only primary surface streams are supported
- if (is_primary_surface(display, surface_id)) {
+ if (is_primary_surface(display, surface->id)) {
stop_streams(display);
}
spice_assert(surface->context.canvas);
@@ -198,7 +197,7 @@ void display_channel_surface_unref(DisplayChannel *display, uint32_t surface_id)
region_destroy(&surface->draw_dirty_region);
surface->context.canvas = NULL;
FOREACH_DCC(display, iter, dcc) {
- dcc_destroy_surface(dcc, surface_id);
+ dcc_destroy_surface(dcc, surface->id);
}
spice_warn_if_fail(ring_is_empty(&surface->depend_on_me));
@@ -211,6 +210,11 @@ gboolean display_channel_surface_has_canvas(DisplayChannel *display,
return display->priv->surfaces[surface_id].context.canvas != NULL;
}
+void display_channel_surface_id_unref(DisplayChannel *display, uint32_t surface_id)
+{
+ display_channel_surface_unref(display, &display->priv->surfaces[surface_id]);
+}
+
static void streams_update_visible_region(DisplayChannel *display, Drawable *drawable)
{
Ring *ring;
@@ -1333,7 +1337,7 @@ static void drawable_unref_surface_deps(DisplayChannel *display, Drawable *drawa
if (surface == NULL) {
continue;
}
- display_channel_surface_unref(display, surface->id);
+ display_channel_surface_unref(display, surface);
}
}
@@ -1354,7 +1358,7 @@ void drawable_unref(Drawable *drawable)
drawable_remove_dependencies(display, drawable);
drawable_unref_surface_deps(display, drawable);
- display_channel_surface_unref(display, drawable->surface->id);
+ display_channel_surface_unref(display, drawable->surface);
glz_retention_detach_drawables(&drawable->glz_retention);
@@ -1709,13 +1713,14 @@ static void clear_surface_drawables_from_pipes(DisplayChannel *display, int surf
/* TODO: cleanup/refactor destroy functions */
static void display_channel_destroy_surface(DisplayChannel *display, uint32_t surface_id)
{
+ RedSurface *surface = &display->priv->surfaces[surface_id];
draw_depend_on_me(display, surface_id);
/* note that draw_depend_on_me must be called before current_remove_all.
otherwise "current" will hold items that other drawables may depend on, and then
current_remove_all will remove them from the pipe. */
- current_remove_all(display, &display->priv->surfaces[surface_id]);
+ current_remove_all(display, surface);
clear_surface_drawables_from_pipes(display, surface_id, FALSE);
- display_channel_surface_unref(display, surface_id);
+ display_channel_surface_unref(display, surface);
}
void display_channel_destroy_surface_wait(DisplayChannel *display, uint32_t surface_id)
@@ -1745,7 +1750,7 @@ void display_channel_destroy_surfaces(DisplayChannel *display)
if (display->priv->surfaces[i].context.canvas) {
display_channel_destroy_surface_wait(display, i);
if (display->priv->surfaces[i].context.canvas) {
- display_channel_surface_unref(display, i);
+ display_channel_surface_unref(display, &display->priv->surfaces[i]);
}
spice_assert(!display->priv->surfaces[i].context.canvas);
}
diff --git a/server/display-channel.h b/server/display-channel.h
index 8918ccb..a425364 100644
--- a/server/display-channel.h
+++ b/server/display-channel.h
@@ -266,7 +266,7 @@ void display_channel_set_video_codecs (DisplayCha
int display_channel_get_streams_timeout (DisplayChannel *display);
void display_channel_compress_stats_print (const DisplayChannel *display);
void display_channel_compress_stats_reset (DisplayChannel *display);
-void display_channel_surface_unref (DisplayChannel *display,
+void display_channel_surface_id_unref (DisplayChannel *display,
uint32_t surface_id);
void display_channel_current_flush (DisplayChannel *display,
int surface_id);
diff --git a/server/red-worker.c b/server/red-worker.c
index b3f6c12..7252487 100644
--- a/server/red-worker.c
+++ b/server/red-worker.c
@@ -670,7 +670,7 @@ static void destroy_primary_surface(RedWorker *worker, uint32_t surface_id)
flush_all_qxl_commands(worker);
display_channel_destroy_surface_wait(display, 0);
- display_channel_surface_unref(display, 0);
+ display_channel_surface_id_unref(display, 0);
/* FIXME: accessing private data only for warning purposes...
spice_warn_if_fail(ring_is_empty(&display->streams));
--
2.7.4
More information about the Spice-devel
mailing list