Blame SOURCES/0013-red_worker-cleanup-red_clear_surface_drawables_from_.patch

20333d
From 8d90b811ea77f80db914ffd153ee1d8954bf1cbb Mon Sep 17 00:00:00 2001
20333d
From: Yonit Halperin <yhalperi@redhat.com>
20333d
Date: Wed, 11 Sep 2013 13:39:35 -0400
20333d
Subject: [PATCH] red_worker: cleanup red_clear_surface_drawables_from_pipes
20333d
20333d
(1) merge 'force' and 'wait_for_outgoing_item' to one parameter.
20333d
    'wait_for_outgoing_item' is a derivative of 'force'.
20333d
(2) move the call to red_wait_outgoing_item to red_clear_surface_drawables_from_pipe
20333d
20333d
https://bugzilla.redhat.com/show_bug.cgi?id=1016795
20333d
---
20333d
 server/red_worker.c | 30 ++++++++++++++++++------------
20333d
 1 file changed, 18 insertions(+), 12 deletions(-)
20333d
20333d
diff --git a/server/red_worker.c b/server/red_worker.c
20333d
index b93796c..f2c9220 100644
20333d
--- a/server/red_worker.c
20333d
+++ b/server/red_worker.c
20333d
@@ -2032,7 +2032,7 @@ static void red_current_clear(RedWorker *worker, int surface_id)
20333d
 }
20333d
 
20333d
 static void red_clear_surface_drawables_from_pipe(DisplayChannelClient *dcc, int surface_id,
20333d
-                                                  int force)
20333d
+                                                  int wait_if_used)
20333d
 {
20333d
     Ring *ring;
20333d
     PipeItem *item;
20333d
@@ -2082,7 +2082,7 @@ static void red_clear_surface_drawables_from_pipe(DisplayChannelClient *dcc, int
20333d
 
20333d
         if (depend_found) {
20333d
             spice_debug("surface %d dependent item found %p, %p", surface_id, drawable, item);
20333d
-            if (force) {
20333d
+            if (wait_if_used) {
20333d
                 break;
20333d
             } else {
20333d
                 return;
20333d
@@ -2090,24 +2090,30 @@ static void red_clear_surface_drawables_from_pipe(DisplayChannelClient *dcc, int
20333d
         }
20333d
     }
20333d
 
20333d
+    if (!wait_if_used) {
20333d
+        return;
20333d
+    }
20333d
+
20333d
     if (item) {
20333d
         red_channel_client_wait_pipe_item_sent(&dcc->common.base, item);
20333d
+    } else {
20333d
+        /*
20333d
+         * in case that the pipe didn't contain any item that is dependent on the surface, but
20333d
+         * there is one during sending.
20333d
+         */
20333d
+        red_wait_outgoing_item(&dcc->common.base);
20333d
     }
20333d
 }
20333d
 
20333d
-static void red_clear_surface_drawables_from_pipes(RedWorker *worker, int surface_id,
20333d
-    int force, int wait_for_outgoing_item)
20333d
+static void red_clear_surface_drawables_from_pipes(RedWorker *worker,
20333d
+                                                   int surface_id,
20333d
+                                                   int wait_if_used)
20333d
 {
20333d
     RingItem *item, *next;
20333d
     DisplayChannelClient *dcc;
20333d
 
20333d
     WORKER_FOREACH_DCC_SAFE(worker, item, next, dcc) {
20333d
-        red_clear_surface_drawables_from_pipe(dcc, surface_id, force);
20333d
-        if (wait_for_outgoing_item) {
20333d
-            // in case that the pipe didn't contain any item that is dependent on the surface, but
20333d
-            // there is one during sending.
20333d
-            red_wait_outgoing_item(&dcc->common.base);
20333d
-        }
20333d
+        red_clear_surface_drawables_from_pipe(dcc, surface_id, wait_if_used);
20333d
     }
20333d
 }
20333d
 
20333d
@@ -4292,7 +4298,7 @@ static inline void red_process_surface(RedWorker *worker, RedSurfaceCmd *surface
20333d
            otherwise "current" will hold items that other drawables may depend on, and then
20333d
            red_current_clear will remove them from the pipe. */
20333d
         red_current_clear(worker, surface_id);
20333d
-        red_clear_surface_drawables_from_pipes(worker, surface_id, FALSE, FALSE);
20333d
+        red_clear_surface_drawables_from_pipes(worker, surface_id, FALSE);
20333d
         red_destroy_surface(worker, surface_id);
20333d
         break;
20333d
     default:
20333d
@@ -11099,7 +11105,7 @@ static inline void destroy_surface_wait(RedWorker *worker, int surface_id)
20333d
        otherwise "current" will hold items that other drawables may depend on, and then
20333d
        red_current_clear will remove them from the pipe. */
20333d
     red_current_clear(worker, surface_id);
20333d
-    red_clear_surface_drawables_from_pipes(worker, surface_id, TRUE, TRUE);
20333d
+    red_clear_surface_drawables_from_pipes(worker, surface_id, TRUE);
20333d
 }
20333d
 
20333d
 static void dev_destroy_surface_wait(RedWorker *worker, uint32_t surface_id)