[Spice-devel] [PATCH 04/10] worker: s/destroy_surface/surface_unref

Frediano Ziglio fziglio at redhat.com
Fri Nov 6 03:02:00 PST 2015


From: Marc-André Lureau <marcandre.lureau at gmail.com>

---
 server/red_worker.c | 53 +++++++++++++++++++++++++++--------------------------
 1 file changed, 27 insertions(+), 26 deletions(-)

diff --git a/server/red_worker.c b/server/red_worker.c
index 7a4822a..93e0efb 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -853,7 +853,7 @@ static inline PipeItem *red_pipe_get_tail(DisplayChannelClient *dcc)
     return (PipeItem*)ring_get_tail(&RED_CHANNEL_CLIENT(dcc)->pipe);
 }
 
-static inline void red_destroy_surface(RedWorker *worker, uint32_t surface_id);
+static void red_surface_unref(RedWorker *worker, uint32_t surface_id);
 
 static inline void red_pipes_remove_drawable(Drawable *drawable)
 {
@@ -1016,36 +1016,37 @@ static void stop_streams(DisplayChannel *display)
     memset(display->items_trace, 0, sizeof(display->items_trace));
 }
 
-static inline void red_destroy_surface(RedWorker *worker, uint32_t surface_id)
+static void red_surface_unref(RedWorker *worker, uint32_t surface_id)
 {
     DisplayChannel *display = worker->display_channel;
     RedSurface *surface = &worker->surfaces[surface_id];
     DisplayChannelClient *dcc;
     RingItem *link, *next;
 
-    if (!--surface->refs) {
-        // only primary surface streams are supported
-        if (is_primary_surface(worker->display_channel, surface_id)) {
-            stop_streams(display);
-        }
-        spice_assert(surface->context.canvas);
+    if (--surface->refs != 0)
+        return;
 
-        surface->context.canvas->ops->destroy(surface->context.canvas);
-        if (surface->create.info) {
-            worker->qxl->st->qif->release_resource(worker->qxl, surface->create);
-        }
-        if (surface->destroy.info) {
-            worker->qxl->st->qif->release_resource(worker->qxl, surface->destroy);
-        }
+    // only primary surface streams are supported
+    if (is_primary_surface(worker->display_channel, surface_id)) {
+        stop_streams(display);
+    }
+    spice_assert(surface->context.canvas);
 
-        region_destroy(&surface->draw_dirty_region);
-        surface->context.canvas = NULL;
-        FOREACH_DCC(worker->display_channel, link, next, dcc) {
-            red_destroy_surface_item(worker, dcc, surface_id);
-        }
+    surface->context.canvas->ops->destroy(surface->context.canvas);
+    if (surface->create.info) {
+        worker->qxl->st->qif->release_resource(worker->qxl, surface->create);
+    }
+    if (surface->destroy.info) {
+        worker->qxl->st->qif->release_resource(worker->qxl, surface->destroy);
+    }
 
-        spice_warn_if(!ring_is_empty(&surface->depend_on_me));
+    region_destroy(&surface->draw_dirty_region);
+    surface->context.canvas = NULL;
+    FOREACH_DCC(worker->display_channel, link, next, dcc) {
+        red_destroy_surface_item(worker, dcc, surface_id);
     }
+
+    spice_warn_if(!ring_is_empty(&surface->depend_on_me));
 }
 
 static inline void set_surface_release_info(QXLReleaseInfoExt *release_info_ext,
@@ -1096,7 +1097,7 @@ static inline void red_dec_surfaces_drawable_dependencies(RedWorker *worker, Dra
         if (surface_id == -1) {
             continue;
         }
-        red_destroy_surface(worker, surface_id);
+        red_surface_unref(worker, surface_id);
     }
 }
 
@@ -1133,7 +1134,7 @@ static void red_worker_drawable_unref(RedWorker *worker, Drawable *drawable)
 
     remove_drawable_dependencies(worker, drawable);
     red_dec_surfaces_drawable_dependencies(worker, drawable);
-    red_destroy_surface(worker, drawable->surface_id);
+    red_surface_unref(worker, drawable->surface_id);
 
     RING_FOREACH_SAFE(item, next, &drawable->glz_ring) {
         SPICE_CONTAINEROF(item, RedGlzDrawable, drawable_link)->drawable = NULL;
@@ -3165,7 +3166,7 @@ static inline void red_process_surface(RedWorker *worker, RedSurfaceCmd *surface
            red_current_clear will remove them from the pipe. */
         red_current_clear(worker, surface_id);
         red_clear_surface_drawables_from_pipes(worker, surface_id, FALSE);
-        red_destroy_surface(worker, surface_id);
+        red_surface_unref(worker, surface_id);
         break;
     default:
             spice_error("unknown surface command");
@@ -9235,7 +9236,7 @@ static inline void dev_destroy_surfaces(RedWorker *worker)
         if (worker->surfaces[i].context.canvas) {
             destroy_surface_wait(worker, i);
             if (worker->surfaces[i].context.canvas) {
-                red_destroy_surface(worker, i);
+                red_surface_unref(worker, i);
             }
             spice_assert(!worker->surfaces[i].context.canvas);
         }
@@ -9367,7 +9368,7 @@ static void dev_destroy_primary_surface(RedWorker *worker, uint32_t surface_id)
 
     flush_all_qxl_commands(worker);
     dev_destroy_surface_wait(worker, 0);
-    red_destroy_surface(worker, 0);
+    red_surface_unref(worker, 0);
     spice_warn_if_fail(ring_is_empty(&display->streams));
 
     spice_assert(!worker->surfaces[surface_id].context.canvas);
-- 
2.4.3



More information about the Spice-devel mailing list