[Spice-devel] [PATCH 3/6] server/red_worker: add destroy_all_surfaces_starting_from (reused next patch)

Alon Levy alevy at redhat.com
Mon Jun 20 04:18:06 PDT 2011


Cc: Yonit Halperin <yhalperi at redhat.com>
---
 server/red_worker.c |   23 +++++++++++++++++------
 1 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/server/red_worker.c b/server/red_worker.c
index 3ffb52c..38ccb90 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -9546,15 +9546,14 @@ static inline void handle_dev_destroy_surface_wait(RedWorker *worker)
     write_message(worker->channel, &message);
 }
 
-/* called upon device reset */
-static inline void handle_dev_destroy_surfaces(RedWorker *worker)
+static inline void destroy_all_surfaces_starting_from(RedWorker *worker, int first_surface_id)
 {
     int i;
-    RedWorkerMessage message;
+
     red_printf("");
     flush_all_qxl_commands(worker);
     //to handle better
-    for (i = 0; i < NUM_SURFACES; ++i) {
+    for (i = first_surface_id; i < NUM_SURFACES; ++i) {
         if (worker->surfaces[i].context.canvas) {
             destroy_surface_wait(worker, i);
             if (worker->surfaces[i].context.canvas) {
@@ -9563,7 +9562,10 @@ static inline void handle_dev_destroy_surfaces(RedWorker *worker)
             ASSERT(!worker->surfaces[i].context.canvas);
         }
     }
-    ASSERT(ring_is_empty(&worker->streams));
+    if (first_surface_id == 0) {
+        // There are streams only on the primary surface.
+        ASSERT(ring_is_empty(&worker->streams));
+    }
 
     red_wait_outgoing_item((RedChannel *)worker->cursor_channel);
     if (worker->cursor_channel) {
@@ -9576,7 +9578,9 @@ static inline void handle_dev_destroy_surfaces(RedWorker *worker)
 
     if (worker->display_channel) {
         red_channel_pipe_add_type(&worker->display_channel->common.base, PIPE_ITEM_TYPE_INVAL_PALLET_CACHE);
-        red_pipe_add_verb(&worker->display_channel->common.base, SPICE_MSG_DISPLAY_STREAM_DESTROY_ALL);
+        if (first_surface_id == 0) {
+            red_pipe_add_verb(&worker->display_channel->common.base, SPICE_MSG_DISPLAY_STREAM_DESTROY_ALL);
+        }
     }
 
     red_display_clear_glz_drawables(worker->display_channel);
@@ -9584,7 +9588,14 @@ static inline void handle_dev_destroy_surfaces(RedWorker *worker)
     worker->cursor_visible = TRUE;
     worker->cursor_position.x = worker->cursor_position.y = 0;
     worker->cursor_trail_length = worker->cursor_trail_frequency = 0;
+}
+
+/* called upon device reset */
+static inline void handle_dev_destroy_surfaces(RedWorker *worker)
+{
+    RedWorkerMessage message;
 
+    destroy_all_surfaces_starting_from(worker, 0);
     message = RED_WORKER_MESSAGE_READY;
     write_message(worker->channel, &message);
 }
-- 
1.7.5.2



More information about the Spice-devel mailing list