[Spice-commits] 7 commits - server/red_parse_qxl.c server/red_parse_qxl.h server/red_worker.c

Gerd Hoffmann kraxel at kemper.freedesktop.org
Fri Aug 27 01:12:31 PDT 2010


 server/red_parse_qxl.c |   51 +++++++++++++++++++++-
 server/red_parse_qxl.h |    4 -
 server/red_worker.c    |  110 +++++++------------------------------------------
 3 files changed, 66 insertions(+), 99 deletions(-)

New commits:
commit 80bb4d95a028ae1ed5119d3c53af68a0d59bf8cb
Author: Gerd Hoffmann <kraxel at redhat.com>
Date:   Fri Aug 27 09:21:04 2010 +0200

    zap more unused bits.
    
    BufDescriptor isn't used at all.
    Two AddBufInfo fields (slot_id and group_id) are not used any more.

diff --git a/server/red_worker.c b/server/red_worker.c
index ec9f6bb..3efaa3e 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -224,14 +224,6 @@ enum {
     BUF_TYPE_RAW = 1,
 };
 
-typedef struct BufDescriptor {
-    uint32_t type;
-    uint32_t size;
-    uint8_t *data;
-    uint32_t slot_id;
-    uint32_t group_id;
-} BufDescriptor;
-
 enum {
     PIPE_ITEM_TYPE_DRAW,
     PIPE_ITEM_TYPE_INVAL_ONE,
@@ -4492,8 +4484,6 @@ typedef struct {
     uint32_t type;
     void *data;
     uint32_t size;
-    uint32_t slot_id;
-    uint32_t group_id;
 } AddBufInfo;
 
 static void marshaller_add_compressed(RedWorker *worker, SpiceMarshaller *m,
@@ -5994,8 +5984,6 @@ static void fill_cursor(CursorChannel *cursor_channel, SpiceCursor *red_cursor,
             addbuf->type = BUF_TYPE_RAW;
             addbuf->data = red_cursor->data;
             addbuf->size = red_cursor->data_size;
-            addbuf->slot_id = 0;
-            addbuf->group_id = 0;
         }
     } else {
         LocalCursor *local_cursor;
@@ -6005,8 +5993,6 @@ static void fill_cursor(CursorChannel *cursor_channel, SpiceCursor *red_cursor,
         addbuf->type = BUF_TYPE_RAW;
         addbuf->data = local_cursor->red_cursor.data;
         addbuf->size = local_cursor->data_size;
-        addbuf->slot_id = 0;
-        addbuf->group_id = 0;
     }
 }
 
commit 36a81133807e057e065c5f42383239e2f078312c
Author: Gerd Hoffmann <kraxel at redhat.com>
Date:   Fri Aug 27 08:43:44 2010 +0200

    red_get_cursor: avoid extra copy

diff --git a/server/red_parse_qxl.c b/server/red_parse_qxl.c
index 6fa6ac5..e6e700b 100644
--- a/server/red_parse_qxl.c
+++ b/server/red_parse_qxl.c
@@ -1009,11 +1009,11 @@ static void red_get_cursor(RedMemSlotInfo *slots, int group_id,
                                    &chunks, &qxl->chunk);
     data = red_linearize_chunk(&chunks, size, &free_data);
     red_put_data_chunks(&chunks);
-    red->data = spice_malloc(size);
-    memcpy(red->data, data, size);
-
     if (free_data) {
-        free(data);
+        red->data = data;
+    } else {
+        red->data = spice_malloc(size);
+        memcpy(red->data, data, size);
     }
 }
 
commit 81e14d76d1ef99c8e69f3cd7e30e9bf186df1a35
Author: Gerd Hoffmann <kraxel at redhat.com>
Date:   Thu Aug 26 23:59:29 2010 +0200

    fix red_cursur_flush segfault

diff --git a/server/red_worker.c b/server/red_worker.c
index 1975597..ec9f6bb 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -9574,7 +9574,7 @@ static LocalCursor *_new_local_cursor(SpiceCursorHeader *header, int data_size,
 {
     LocalCursor *local;
 
-    local = (LocalCursor *)spice_malloc(sizeof(LocalCursor) + data_size);
+    local = (LocalCursor *)spice_malloc0(sizeof(LocalCursor) + data_size);
 
     red_pipe_item_init(&local->base.pipe_data, PIPE_ITEM_TYPE_LOCAL_CURSOR);
     local->base.refs = 1;
@@ -9584,6 +9584,8 @@ static LocalCursor *_new_local_cursor(SpiceCursorHeader *header, int data_size,
     local->red_cursor.header.unique = 0;
 
     local->red_cursor.flags = 0;
+    local->red_cursor.data = (uint8_t*)(local+1);
+
     local->position = position;
     local->data_size = data_size;
     return local;
commit b274fcf3f5e88c48fba910435dc122af04657153
Author: Gerd Hoffmann <kraxel at redhat.com>
Date:   Thu Aug 26 23:41:42 2010 +0200

    zap dead typedefs

diff --git a/server/red_worker.c b/server/red_worker.c
index 17bbf6f..1975597 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -522,11 +522,6 @@ typedef struct FreeList {
 
 typedef struct DisplayChannel DisplayChannel;
 
-typedef void *(*enc_get_virt_fn_t)(void *get_virt_opaque, unsigned long addr, uint32_t add_size,
-                                   uint32_t group_id);
-typedef void (*enc_validate_virt_fn_t)(void *validate_virt_opaque, unsigned long virt,
-                                       unsigned long from_addr, uint32_t add_size,
-                                       uint32_t group_id);
 typedef struct  {
     DisplayChannel *display_channel;
     RedCompressBuf *bufs_head;
commit 465ecbb818bd62fce26a7ad01c355dde7da22214
Author: Gerd Hoffmann <kraxel at redhat.com>
Date:   Thu Aug 26 23:39:14 2010 +0200

    zap dead qxl chunk code

diff --git a/server/red_worker.c b/server/red_worker.c
index f525f17..17bbf6f 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -222,7 +222,6 @@ struct EventListener {
 
 enum {
     BUF_TYPE_RAW = 1,
-    BUF_TYPE_CHUNK,
 };
 
 typedef struct BufDescriptor {
@@ -4517,41 +4516,13 @@ static void marshaller_add_compressed(RedWorker *worker, SpiceMarshaller *m,
 }
 
 
-static void marshaller_add_chunk(RedWorker *worker, SpiceMarshaller *m, QXLDataChunk *chunk, size_t size,
-                                 int memslot_id, uint32_t group_id)
-{
-    while (chunk != NULL && size > 0) {
-        int data_size = chunk->data_size;
-
-        if (data_size > size)
-            data_size = size;
-        size -= data_size;
-
-        if (data_size) {
-            validate_virt(&worker->mem_slots, (unsigned long)chunk->data, memslot_id, data_size, group_id);
-            spice_marshaller_add_ref(m, (uint8_t *)chunk->data, data_size);
-        }
-        chunk = chunk->next_chunk ?
-            (QXLDataChunk *)get_virt(&worker->mem_slots, chunk->next_chunk, sizeof(QXLDataChunk),
-                                     group_id) :
-            NULL;
-    }
-}
-
 static void add_buf_from_info(RedChannel *channel, SpiceMarshaller *m, AddBufInfo *info)
 {
-    QXLDataChunk *chunk;
-
     if (info->data) {
         switch (info->type) {
         case BUF_TYPE_RAW:
             spice_marshaller_add_ref(m, info->data, info->size);
             break;
-        case BUF_TYPE_CHUNK:
-            chunk = (QXLDataChunk *)info->data;
-            marshaller_add_chunk(channel->worker, m, chunk,
-                                 info->size, info->slot_id, info->group_id);
-            break;
         }
     }
 }
commit a05741ce1b9099c3a3df3865e4d0563eec46e2f8
Author: Gerd Hoffmann <kraxel at redhat.com>
Date:   Thu Aug 26 23:37:24 2010 +0200

    qxl parser: add cursor parsing

diff --git a/server/red_parse_qxl.c b/server/red_parse_qxl.c
index fb46bd8..6fa6ac5 100644
--- a/server/red_parse_qxl.c
+++ b/server/red_parse_qxl.c
@@ -984,6 +984,44 @@ void red_put_surface_cmd(RedSurfaceCmd *red)
     /* nothing yet */
 }
 
+static void red_get_cursor(RedMemSlotInfo *slots, int group_id,
+                           SpiceCursor *red, QXLPHYSICAL addr)
+{
+    QXLCursor *qxl;
+    RedDataChunk chunks;
+    size_t size;
+    uint8_t *data;
+    bool free_data;
+
+    qxl = (QXLCursor *)get_virt(slots, addr, sizeof(*qxl), group_id);
+
+    red->header.unique     = qxl->header.unique;
+    red->header.type       = qxl->header.type;
+    red->header.width      = qxl->header.width;
+    red->header.height     = qxl->header.height;
+    red->header.hot_spot_x = qxl->header.hot_spot_x;
+    red->header.hot_spot_y = qxl->header.hot_spot_y;
+
+    red->flags = 0;
+    red->data_size = qxl->data_size;
+    size = red_get_data_chunks_ptr(slots, group_id,
+                                   get_memslot_id(slots, addr),
+                                   &chunks, &qxl->chunk);
+    data = red_linearize_chunk(&chunks, size, &free_data);
+    red_put_data_chunks(&chunks);
+    red->data = spice_malloc(size);
+    memcpy(red->data, data, size);
+
+    if (free_data) {
+        free(data);
+    }
+}
+
+static void red_put_cursor(SpiceCursor *red)
+{
+    free(red->data);
+}
+
 void red_get_cursor_cmd(RedMemSlotInfo *slots, int group_id,
                         RedCursorCmd *red, QXLPHYSICAL addr)
 {
@@ -997,7 +1035,7 @@ void red_get_cursor_cmd(RedMemSlotInfo *slots, int group_id,
     case QXL_CURSOR_SET:
         red_get_point16_ptr(&red->u.set.position, &qxl->u.set.position);
         red->u.set.visible  = qxl->u.set.visible;
-        red->u.set.shape    = qxl->u.set.shape;
+        red_get_cursor(slots, group_id,  &red->u.set.shape, qxl->u.set.shape);
         break;
     case QXL_CURSOR_MOVE:
         red_get_point16_ptr(&red->u.position, &qxl->u.position);
@@ -1011,6 +1049,10 @@ void red_get_cursor_cmd(RedMemSlotInfo *slots, int group_id,
 
 void red_put_cursor_cmd(RedCursorCmd *red)
 {
-    /* nothing yet */
+    switch (red->type) {
+    case QXL_CURSOR_SET:
+        red_put_cursor(&red->u.set.shape);
+        break;
+    }
 }
 
diff --git a/server/red_parse_qxl.h b/server/red_parse_qxl.h
index 95408f7..1d97249 100644
--- a/server/red_parse_qxl.h
+++ b/server/red_parse_qxl.h
@@ -99,7 +99,7 @@ typedef struct RedCursorCmd {
         struct {
             SpicePoint16 position;
             uint8_t visible;
-            SPICE_ADDRESS shape;
+            SpiceCursor shape;
         } set;
         struct {
             uint16_t length;
diff --git a/server/red_worker.c b/server/red_worker.c
index 1ed7b83..f525f17 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -6001,8 +6001,6 @@ static void fill_attr(DisplayChannel *display_channel, SpiceMarshaller *m, Spice
 
 static void fill_cursor(CursorChannel *cursor_channel, SpiceCursor *red_cursor, CursorItem *cursor, AddBufInfo *addbuf)
 {
-    RedChannel *channel = &cursor_channel->base;
-
     addbuf->data = NULL;
 
     if (!cursor) {
@@ -6012,18 +6010,9 @@ static void fill_cursor(CursorChannel *cursor_channel, SpiceCursor *red_cursor,
 
     if (cursor->type == CURSOR_TYPE_DEV) {
         RedCursorCmd *cursor_cmd;
-        QXLCursor *qxl_cursor;
 
         cursor_cmd = cursor->red_cursor;
-        qxl_cursor = (QXLCursor *)get_virt(&channel->worker->mem_slots, cursor_cmd->u.set.shape,
-                                           sizeof(QXLCursor), cursor->group_id);
-        red_cursor->flags = 0;
-        red_cursor->header.unique = qxl_cursor->header.unique;
-        red_cursor->header.type = qxl_cursor->header.type;
-        red_cursor->header.width = qxl_cursor->header.width;
-        red_cursor->header.height = qxl_cursor->header.height;
-        red_cursor->header.hot_spot_x = qxl_cursor->header.hot_spot_x;
-        red_cursor->header.hot_spot_y = qxl_cursor->header.hot_spot_y;
+        *red_cursor = cursor_cmd->u.set.shape;
 
         if (red_cursor->header.unique) {
             if (red_cursor_cache_find(cursor_channel, red_cursor->header.unique)) {
@@ -6035,12 +6024,12 @@ static void fill_cursor(CursorChannel *cursor_channel, SpiceCursor *red_cursor,
             }
         }
 
-        if (qxl_cursor->data_size) {
-            addbuf->type = BUF_TYPE_CHUNK;
-            addbuf->data = &qxl_cursor->chunk;
-            addbuf->size = qxl_cursor->data_size;
-            addbuf->slot_id = get_memslot_id(&channel->worker->mem_slots, cursor_cmd->u.set.shape);
-            addbuf->group_id = cursor->group_id;
+        if (red_cursor->data_size) {
+            addbuf->type = BUF_TYPE_RAW;
+            addbuf->data = red_cursor->data;
+            addbuf->size = red_cursor->data_size;
+            addbuf->slot_id = 0;
+            addbuf->group_id = 0;
         }
     } else {
         LocalCursor *local_cursor;
@@ -9615,7 +9604,7 @@ typedef struct __attribute__ ((__packed__)) CursorData {
     SpiceCursor _cursor;
 } CursorData;
 
-static LocalCursor *_new_local_cursor(QXLCursorHeader *header, int data_size, SpicePoint16 position)
+static LocalCursor *_new_local_cursor(SpiceCursorHeader *header, int data_size, SpicePoint16 position)
 {
     LocalCursor *local;
 
@@ -9625,12 +9614,8 @@ static LocalCursor *_new_local_cursor(QXLCursorHeader *header, int data_size, Sp
     local->base.refs = 1;
     local->base.type = CURSOR_TYPE_LOCAL;
 
+    local->red_cursor.header = *header;
     local->red_cursor.header.unique = 0;
-    local->red_cursor.header.type = header->type;
-    local->red_cursor.header.width = header->width;
-    local->red_cursor.header.height = header->height;
-    local->red_cursor.header.hot_spot_x = header->hot_spot_x;
-    local->red_cursor.header.hot_spot_y = header->hot_spot_y;
 
     local->red_cursor.flags = 0;
     local->position = position;
@@ -9641,11 +9626,8 @@ static LocalCursor *_new_local_cursor(QXLCursorHeader *header, int data_size, Sp
 static void red_cursor_flush(RedWorker *worker)
 {
     RedCursorCmd *cursor_cmd;
-    QXLCursor *qxl_cursor;
+    SpiceCursor *cursor;
     LocalCursor *local;
-    uint32_t data_size;
-    QXLDataChunk *chunk;
-    uint8_t *dest;
 
     if (!worker->cursor || worker->cursor->type == CURSOR_TYPE_LOCAL) {
         return;
@@ -9655,26 +9637,13 @@ static void red_cursor_flush(RedWorker *worker)
 
     cursor_cmd = worker->cursor->red_cursor;
     ASSERT(cursor_cmd->type == QXL_CURSOR_SET);
-    qxl_cursor = (QXLCursor *)get_virt(&worker->mem_slots, cursor_cmd->u.set.shape, sizeof(QXLCursor),
-                                       worker->cursor->group_id);
+    cursor = &cursor_cmd->u.set.shape;
 
-    local = _new_local_cursor(&qxl_cursor->header, qxl_cursor->data_size,
+    local = _new_local_cursor(&cursor->header, cursor->data_size,
                               worker->cursor_position);
     ASSERT(local);
-    data_size = local->data_size;
-    dest = local->red_cursor.data;
-    chunk = &qxl_cursor->chunk;
-
-    while (data_size) {
-        ASSERT(chunk);
-        ASSERT(chunk->data_size <= data_size);
-        memcpy(dest, chunk->data, chunk->data_size);
-        data_size -= chunk->data_size;
-        dest += chunk->data_size;
-        chunk = chunk->next_chunk ?
-                (QXLDataChunk *)get_virt(&worker->mem_slots, chunk->next_chunk, sizeof(QXLDataChunk),
-                                         worker->mem_slots.internal_groupslot_id) : NULL;
-    }
+    memcpy(local->red_cursor.data, cursor->data, local->data_size);
+
     red_set_cursor(worker, &local->base);
     red_release_cursor(worker, &local->base);
 }
commit ea2f97a81015ecf2792e1906a6c0b156ec86cc5b
Author: Gerd Hoffmann <kraxel at redhat.com>
Date:   Thu Aug 26 22:29:12 2010 +0200

    qxl parser: complete QXL_SURFACE_CMD_CREATE parsing

diff --git a/server/red_parse_qxl.c b/server/red_parse_qxl.c
index 127141c..fb46bd8 100644
--- a/server/red_parse_qxl.c
+++ b/server/red_parse_qxl.c
@@ -957,6 +957,7 @@ void red_get_surface_cmd(RedMemSlotInfo *slots, int group_id,
                          RedSurfaceCmd *red, QXLPHYSICAL addr)
 {
     QXLSurfaceCmd *qxl;
+    size_t size;
 
     qxl = (QXLSurfaceCmd *)get_virt(slots, addr, sizeof(*qxl), group_id);
     red->release_info     = &qxl->release_info;
@@ -971,7 +972,9 @@ void red_get_surface_cmd(RedMemSlotInfo *slots, int group_id,
         red->u.surface_create.width  = qxl->u.surface_create.width;
         red->u.surface_create.height = qxl->u.surface_create.height;
         red->u.surface_create.stride = qxl->u.surface_create.stride;
-        red->u.surface_create.data   = qxl->u.surface_create.data;
+        size = red->u.surface_create.height * abs(red->u.surface_create.stride);
+        red->u.surface_create.data =
+            (uint8_t*)get_virt(slots, qxl->u.surface_create.data, size, group_id);
         break;
     }
 }
diff --git a/server/red_parse_qxl.h b/server/red_parse_qxl.h
index e80da8a..95408f7 100644
--- a/server/red_parse_qxl.h
+++ b/server/red_parse_qxl.h
@@ -79,7 +79,7 @@ typedef struct RedSurfaceCreate {
     uint32_t width;
     uint32_t height;
     int32_t stride;
-    SPICE_ADDRESS data;
+    uint8_t *data;
 } RedSurfaceCreate;
 
 typedef struct RedSurfaceCmd {
diff --git a/server/red_worker.c b/server/red_worker.c
index 27d9491..1ed7b83 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -3500,11 +3500,10 @@ static inline void red_process_surface(RedWorker *worker, RedSurfaceCmd *surface
 
     switch (surface->type) {
     case QXL_SURFACE_CMD_CREATE: {
-        unsigned long saved_data = (unsigned long)surface->u.surface_create.data;
         uint32_t height = surface->u.surface_create.height;
         int32_t stride = surface->u.surface_create.stride;
 
-        data = (uint8_t *)get_virt(&worker->mem_slots, saved_data, height * abs(stride), group_id);
+        data = surface->u.surface_create.data;
         if (stride < 0) {
             data -= (int32_t)(stride * (height - 1));
         }


More information about the Spice-commits mailing list