]> git.proxmox.com Git - spiceterm.git/commitdiff
resize: discard pending commands
authorDietmar Maurer <dietmar@proxmox.com>
Wed, 9 Oct 2013 11:34:06 +0000 (13:34 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Wed, 9 Oct 2013 11:34:06 +0000 (13:34 +0200)
screen.c
spiceterm.h

index 451d119075c627b0ea96aad33afcb9e22656876b..53924e028d6b5b121f7cf92830f44c01a89721c0 100644 (file)
--- a/screen.c
+++ b/screen.c
@@ -91,6 +91,40 @@ spice_screen_destroy_update(SimpleSpiceUpdate *update)
     g_free(update);
 }
 
     g_free(update);
 }
 
+static void 
+release_qxl_command_ext(QXLCommandExt *ext)
+{
+    g_assert(ext != NULL);
+
+    switch (ext->cmd.type) {
+    case QXL_CMD_DRAW:
+        spice_screen_destroy_update((void*)ext);
+        break;
+    case QXL_CMD_SURFACE:
+        free(ext);
+        break;
+    case QXL_CMD_CURSOR: {
+        QXLCursorCmd *cmd = (QXLCursorCmd *)(unsigned long)ext->cmd.data;
+        if (cmd->type == QXL_CURSOR_SET) {
+            free(cmd);
+        }
+        free(ext);
+        break;
+    }
+    default:
+        abort();
+    }
+}
+
+static void 
+release_resource(QXLInstance *qin, struct QXLReleaseInfoExt release_info)
+{
+    QXLCommandExt *ext = (QXLCommandExt*)(unsigned long)release_info.info->id;
+
+    g_assert(release_info.group_id == MEM_SLOT_GROUP_ID);
+    release_qxl_command_ext(ext);
+}
+
 static int unique = 0x0ffff + 1;
 
 static void 
 static int unique = 0x0ffff + 1;
 
 static void 
@@ -375,24 +409,6 @@ create_primary_surface(SpiceScreen *spice_screen, uint32_t width,
     qxl_worker->create_primary_surface(qxl_worker, 0, &surface);
 }
 
     qxl_worker->create_primary_surface(qxl_worker, 0, &surface);
 }
 
-void 
-spice_screen_resize(SpiceScreen *spice_screen, uint32_t width,
-                    uint32_t height)
-{
-    QXLWorker *qxl_worker = spice_screen->qxl_worker;
-
-    if (spice_screen->width == width && spice_screen->height == height) {
-        return;
-    }
-
-    qxl_worker->destroy_primary_surface(qxl_worker, 0);
-
-    create_primary_surface(spice_screen, width, height);
-
-    spice_screen_clear(spice_screen, 0, 0, width, height);
-}
-                       
-
 QXLDevMemSlot slot = {
     .slot_group_id = MEM_SLOT_GROUP_ID,
     .slot_id = 0,
 QXLDevMemSlot slot = {
     .slot_group_id = MEM_SLOT_GROUP_ID,
     .slot_id = 0,
@@ -467,6 +483,19 @@ ret:
     return res;
 }
 
     return res;
 }
 
+void
+discard_pending_commands(SpiceScreen *spice_screen) 
+{
+    int pos;
+
+    g_mutex_lock(spice_screen->command_mutex);
+    for (pos = spice_screen->commands_start; pos < spice_screen->commands_end; pos++) {
+        release_qxl_command_ext(spice_screen->commands[pos % COMMANDS_SIZE]);
+    }
+    spice_screen->commands_start = spice_screen->commands_end;
+    g_mutex_unlock(spice_screen->command_mutex);
+}
+
 static int 
 req_cmd_notification(QXLInstance *qin)
 {
 static int 
 req_cmd_notification(QXLInstance *qin)
 {
@@ -476,32 +505,6 @@ req_cmd_notification(QXLInstance *qin)
     return TRUE;
 }
 
     return TRUE;
 }
 
-static void 
-release_resource(QXLInstance *qin, struct QXLReleaseInfoExt release_info)
-{
-    QXLCommandExt *ext = (QXLCommandExt*)(unsigned long)release_info.info->id;
-
-    g_assert(release_info.group_id == MEM_SLOT_GROUP_ID);
-    switch (ext->cmd.type) {
-        case QXL_CMD_DRAW:
-            spice_screen_destroy_update((void*)ext);
-            break;
-        case QXL_CMD_SURFACE:
-            free(ext);
-            break;
-        case QXL_CMD_CURSOR: {
-            QXLCursorCmd *cmd = (QXLCursorCmd *)(unsigned long)ext->cmd.data;
-            if (cmd->type == QXL_CURSOR_SET) {
-                free(cmd);
-            }
-            free(ext);
-            break;
-        }
-        default:
-            abort();
-    }
-}
-
 #define CURSOR_WIDTH 8
 #define CURSOR_HEIGHT 16
 
 #define CURSOR_WIDTH 8
 #define CURSOR_HEIGHT 16
 
@@ -643,6 +646,7 @@ do_conn_timeout(void *opaque)
     }
 }
 
     }
 }
 
+
 QXLInterface display_sif = {
     .base = {
         .type = SPICE_INTERFACE_QXL,
 QXLInterface display_sif = {
     .base = {
         .type = SPICE_INTERFACE_QXL,
@@ -743,3 +747,22 @@ spice_screen_new(SpiceCoreInterface *core, uint32_t width, uint32_t height, guin
 
     return spice_screen;
 }
 
     return spice_screen;
 }
+
+void 
+spice_screen_resize(SpiceScreen *spice_screen, uint32_t width,
+                    uint32_t height)
+{
+    QXLWorker *qxl_worker = spice_screen->qxl_worker;
+
+    if (spice_screen->width == width && spice_screen->height == height) {
+        return;
+    }
+
+    discard_pending_commands(spice_screen);
+
+    qxl_worker->destroy_primary_surface(qxl_worker, 0);
+
+    create_primary_surface(spice_screen, width, height);
+
+    spice_screen_clear(spice_screen, 0, 0, width, height);
+}
index b2c764c7922cb6b505a8d0d8b92a4980ec6f70f8..6657186717d27a31179ffae4dd4255a6a020fce7 100644 (file)
@@ -20,7 +20,7 @@ typedef struct TextCell {
     TextAttributes attrib;
 } TextCell;
 
     TextAttributes attrib;
 } TextCell;
 
-#define COMMANDS_SIZE (1024*10)
+#define COMMANDS_SIZE (1024)
 #define MAX_HEIGHT 1440
 #define MAX_WIDTH 2560
 
 #define MAX_HEIGHT 1440
 #define MAX_WIDTH 2560