[Spice-commits] server/red-worker.c

Frediano Ziglio fziglio at kemper.freedesktop.org
Tue Jan 24 15:57:31 UTC 2017


 server/red-worker.c |   39 +++++++++++++++++++--------------------
 1 file changed, 19 insertions(+), 20 deletions(-)

New commits:
commit 0959305ecf1769d6a7387f14a3ba18739588ab2f
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Tue Jan 24 15:56:50 2017 +0000

    red-worker: Reuse code to process display command
    
    Code to read and process display commands were the same
    so use a common function for better reuse.
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Christophe Fergeau <cfergeau at redhat.com>

diff --git a/server/red-worker.c b/server/red-worker.c
index 394a935..475acc4 100644
--- a/server/red-worker.c
+++ b/server/red-worker.c
@@ -169,6 +169,20 @@ static RedDrawable *red_drawable_new(QXLInstance *qxl)
     return red;
 }
 
+static gboolean red_process_surface_cmd(RedWorker *worker, QXLCommandExt *ext, gboolean loadvm)
+{
+    RedSurfaceCmd surface_cmd;
+
+    if (red_get_surface_cmd(&worker->mem_slots, ext->group_id, &surface_cmd, ext->cmd.data)) {
+        return FALSE;
+    }
+    display_channel_process_surface_cmd(worker->display_channel, &surface_cmd, loadvm);
+    // display_channel_process_surface_cmd() takes ownership of 'release_info_ext',
+    // we don't need to release it ourselves
+    red_put_surface_cmd(&surface_cmd);
+    return TRUE;
+}
+
 static int red_process_display(RedWorker *worker, int *ring_is_empty)
 {
     QXLCommandExt ext_cmd;
@@ -245,18 +259,10 @@ static int red_process_display(RedWorker *worker, int *ring_is_empty)
             red_put_message(&message);
             break;
         }
-        case QXL_CMD_SURFACE: {
-            RedSurfaceCmd surface;
-
-            if (red_get_surface_cmd(&worker->mem_slots, ext_cmd.group_id,
-                                    &surface, ext_cmd.cmd.data)) {
-                break;
-            }
-            display_channel_process_surface_cmd(worker->display_channel, &surface, FALSE);
-            // do not release resource as is released inside display_channel_process_surface_cmd
-            red_put_surface_cmd(&surface);
+        case QXL_CMD_SURFACE:
+            red_process_surface_cmd(worker, &ext_cmd, FALSE);
             break;
-        }
+
         default:
             spice_error("bad command type");
         }
@@ -984,20 +990,13 @@ static void handle_dev_close(void *opaque, void *payload)
 
 static int loadvm_command(RedWorker *worker, QXLCommandExt *ext)
 {
-    RedSurfaceCmd surface_cmd;
-
     switch (ext->cmd.type) {
     case QXL_CMD_CURSOR:
         return red_process_cursor_cmd(worker, ext);
 
     case QXL_CMD_SURFACE:
-        if (red_get_surface_cmd(&worker->mem_slots, ext->group_id, &surface_cmd, ext->cmd.data)) {
-            return FALSE;
-        }
-        display_channel_process_surface_cmd(worker->display_channel, &surface_cmd, TRUE);
-        // do not release resource as is released inside display_channel_process_surface_cmd
-        red_put_surface_cmd(&surface_cmd);
-        break;
+        return red_process_surface_cmd(worker, ext, TRUE);
+
     default:
         spice_warning("unhandled loadvm command type (%d)", ext->cmd.type);
     }


More information about the Spice-commits mailing list