[Spice-commits] 10 commits - server/cursor-channel.c server/cursor-channel.h server/dcc.c server/dcc-encoders.c server/dcc-encoders.h server/dcc-send.c server/display-channel.c server/display-channel.h server/red-parse-qxl.c server/red-parse-qxl.h server/red-worker.c server/red-worker.h

Frediano Ziglio fziglio at kemper.freedesktop.org
Mon Feb 15 12:32:45 UTC 2016


 server/cursor-channel.c  |   15 ++++-----------
 server/cursor-channel.h  |    3 +--
 server/dcc-encoders.c    |    3 +--
 server/dcc-encoders.h    |    1 -
 server/dcc-send.c        |    4 ++--
 server/dcc.c             |    1 -
 server/display-channel.c |   34 +++++++++++++---------------------
 server/display-channel.h |    5 -----
 server/red-parse-qxl.c   |   21 ++++++++++++++-------
 server/red-parse-qxl.h   |   11 ++++++-----
 server/red-worker.c      |   47 ++++++++++++++++-------------------------------
 server/red-worker.h      |    4 +---
 12 files changed, 58 insertions(+), 91 deletions(-)

New commits:
commit 7870c27fcaf91277d7a9fc17f950b3ee788be720
Author: Christophe Fergeau <cfergeau at redhat.com>
Date:   Fri Feb 12 18:51:09 2016 +0100

    display-channel: Remove extra group_id arguments
    
    They are now carried in the appropriate command through
    QXLReleaseInfoExt, so we don't need to pass them around explicitly.
    
    Acked-by: Frediano Ziglio <fziglio at redhat.com>

diff --git a/server/display-channel.c b/server/display-channel.c
index 1ef7bad..82dbe03 100644
--- a/server/display-channel.c
+++ b/server/display-channel.c
@@ -1072,7 +1072,7 @@ static int validate_drawable_bbox(DisplayChannel *display, RedDrawable *drawable
  * @return initialized Drawable or NULL on failure
  */
 static Drawable *display_channel_get_drawable(DisplayChannel *display, uint8_t effect,
-                                              RedDrawable *red_drawable, uint32_t group_id,
+                                              RedDrawable *red_drawable,
                                               uint32_t process_commands_generation)
 {
     Drawable *drawable;
@@ -1091,7 +1091,7 @@ static Drawable *display_channel_get_drawable(DisplayChannel *display, uint8_t e
         }
     }
 
-    drawable = display_channel_drawable_try_new(display, group_id, process_commands_generation);
+    drawable = display_channel_drawable_try_new(display, process_commands_generation);
     if (!drawable) {
         return NULL;
     }
@@ -1169,10 +1169,10 @@ static void display_channel_add_drawable(DisplayChannel *display, Drawable *draw
 }
 
 void display_channel_process_draw(DisplayChannel *display, RedDrawable *red_drawable,
-                                  uint32_t group_id, int process_commands_generation)
+                                  int process_commands_generation)
 {
     Drawable *drawable =
-        display_channel_get_drawable(display, red_drawable->effect, red_drawable, group_id,
+        display_channel_get_drawable(display, red_drawable->effect, red_drawable,
                                      process_commands_generation);
 
     if (!drawable) {
@@ -1359,7 +1359,7 @@ static void drawables_init(DisplayChannel *display)
  * @return pointer to uninitialized Drawable or NULL on failure
  */
 Drawable *display_channel_drawable_try_new(DisplayChannel *display,
-                                           int group_id, int process_commands_generation)
+                                           int process_commands_generation)
 {
     Drawable *drawable;
 
@@ -2074,7 +2074,7 @@ DisplayChannel* display_channel_new(RedWorker *worker, int migrate, int stream_v
 }
 
 void display_channel_process_surface_cmd(DisplayChannel *display, RedSurfaceCmd *surface,
-                                         uint32_t group_id, int loadvm)
+                                         int loadvm)
 {
     uint32_t surface_id;
     RedSurface *red_surface;
diff --git a/server/display-channel.h b/server/display-channel.h
index 24d83a3..13b13b1 100644
--- a/server/display-channel.h
+++ b/server/display-channel.h
@@ -277,7 +277,6 @@ int                        display_channel_get_streams_timeout       (DisplayCha
 void                       display_channel_compress_stats_print      (const DisplayChannel *display);
 void                       display_channel_compress_stats_reset      (DisplayChannel *display);
 Drawable *                 display_channel_drawable_try_new          (DisplayChannel *display,
-                                                                      int group_id,
                                                                       int process_commands_generation);
 void                       display_channel_drawable_unref            (DisplayChannel *display, Drawable *drawable);
 void                       display_channel_surface_unref             (DisplayChannel *display,
@@ -298,11 +297,9 @@ void                       display_channel_destroy_surface           (DisplayCha
 uint32_t                   display_channel_generate_uid              (DisplayChannel *display);
 void                       display_channel_process_draw              (DisplayChannel *display,
                                                                       RedDrawable *red_drawable,
-                                                                      uint32_t group_id,
                                                                       int process_commands_generation);
 void                       display_channel_process_surface_cmd       (DisplayChannel *display,
                                                                       RedSurfaceCmd *surface,
-                                                                      uint32_t group_id,
                                                                       int loadvm);
 void                       display_channel_update_compression        (DisplayChannel *display,
                                                                       DisplayChannelClient *dcc);
diff --git a/server/red-worker.c b/server/red-worker.c
index b6fef79..6780d2b 100644
--- a/server/red-worker.c
+++ b/server/red-worker.c
@@ -234,7 +234,7 @@ static int red_process_display(RedWorker *worker, int *ring_is_empty)
 
             if (!red_get_drawable(&worker->mem_slots, ext_cmd.group_id,
                                  red_drawable, ext_cmd.cmd.data, ext_cmd.flags)) {
-                display_channel_process_draw(worker->display_channel, red_drawable, ext_cmd.group_id,
+                display_channel_process_draw(worker->display_channel, red_drawable,
                                              worker->process_display_generation);
             }
             // release the red_drawable
@@ -280,8 +280,7 @@ static int red_process_display(RedWorker *worker, int *ring_is_empty)
                                     &surface, ext_cmd.cmd.data)) {
                 break;
             }
-            display_channel_process_surface_cmd(worker->display_channel, &surface,
-                                                ext_cmd.group_id, FALSE);
+            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);
             break;
@@ -1169,8 +1168,7 @@ static int loadvm_command(RedWorker *worker, QXLCommandExt *ext)
             free(surface_cmd);
             return FALSE;
         }
-        display_channel_process_surface_cmd(worker->display_channel, surface_cmd,
-                                            ext->group_id, TRUE);
+        display_channel_process_surface_cmd(worker->display_channel, surface_cmd, TRUE);
         break;
     default:
         spice_warning("unhandled loadvm command type (%d)", ext->cmd.type);
commit 705be34b5e109011c5f6f4fc974b09ee8c28dd1d
Author: Christophe Fergeau <cfergeau at redhat.com>
Date:   Fri Feb 12 18:51:08 2016 +0100

    Remove CursorItem::group_id
    
    Now that the group_id is known to RedCursorCmd, we don't need to store
    it separately in CursorItem.
    
    Acked-by: Frediano Ziglio <fziglio at redhat.com>

diff --git a/server/cursor-channel.c b/server/cursor-channel.c
index d9b6faa..0ab0d80 100644
--- a/server/cursor-channel.c
+++ b/server/cursor-channel.c
@@ -38,7 +38,6 @@ enum {
 
 typedef struct CursorItem {
     QXLInstance *qxl;
-    uint32_t group_id;
     int refs;
     RedCursorCmd *red_cursor;
 } CursorItem;
@@ -82,7 +81,7 @@ struct CursorChannelClient {
 #include "cache-item.tmpl.c"
 #undef CLIENT_CURSOR_CACHE
 
-static CursorItem *cursor_item_new(QXLInstance *qxl, RedCursorCmd *cmd, uint32_t group_id)
+static CursorItem *cursor_item_new(QXLInstance *qxl, RedCursorCmd *cmd)
 {
     CursorItem *cursor_item;
 
@@ -91,7 +90,6 @@ static CursorItem *cursor_item_new(QXLInstance *qxl, RedCursorCmd *cmd, uint32_t
     cursor_item = g_new0(CursorItem, 1);
     cursor_item->qxl = qxl;
     cursor_item->refs = 1;
-    cursor_item->group_id = group_id;
     cursor_item->red_cursor = cmd;
 
     return cursor_item;
@@ -477,8 +475,7 @@ CursorChannelClient* cursor_channel_client_new(CursorChannel *cursor, RedClient
     return ccc;
 }
 
-void cursor_channel_process_cmd(CursorChannel *cursor, RedCursorCmd *cursor_cmd,
-                                uint32_t group_id)
+void cursor_channel_process_cmd(CursorChannel *cursor, RedCursorCmd *cursor_cmd)
 {
     CursorItem *cursor_item;
     int cursor_show = FALSE;
@@ -486,8 +483,7 @@ void cursor_channel_process_cmd(CursorChannel *cursor, RedCursorCmd *cursor_cmd,
     spice_return_if_fail(cursor);
     spice_return_if_fail(cursor_cmd);
 
-    cursor_item = cursor_item_new(cursor->common.qxl,
-                                  cursor_cmd, group_id);
+    cursor_item = cursor_item_new(cursor->common.qxl, cursor_cmd);
 
     switch (cursor_cmd->type) {
     case QXL_CURSOR_SET:
diff --git a/server/cursor-channel.h b/server/cursor-channel.h
index 104af20..967a117 100644
--- a/server/cursor-channel.h
+++ b/server/cursor-channel.h
@@ -34,8 +34,7 @@ CursorChannel*       cursor_channel_new         (RedWorker *worker);
 void                 cursor_channel_disconnect  (CursorChannel *cursor_channel);
 void                 cursor_channel_reset       (CursorChannel *cursor);
 void                 cursor_channel_init        (CursorChannel *cursor, CursorChannelClient* client);
-void                 cursor_channel_process_cmd (CursorChannel *cursor, RedCursorCmd *cursor_cmd,
-                                                 uint32_t group_id);
+void                 cursor_channel_process_cmd (CursorChannel *cursor, RedCursorCmd *cursor_cmd);
 void                 cursor_channel_set_mouse_mode(CursorChannel *cursor, uint32_t mode);
 
 CursorChannelClient* cursor_channel_client_new(CursorChannel *cursor,
diff --git a/server/red-worker.c b/server/red-worker.c
index 859ac3e..b6fef79 100644
--- a/server/red-worker.c
+++ b/server/red-worker.c
@@ -174,7 +174,7 @@ static int red_process_cursor(RedWorker *worker, int *ring_is_empty)
                 break;
             }
 
-            cursor_channel_process_cmd(worker->cursor_channel, cursor, ext_cmd.group_id);
+            cursor_channel_process_cmd(worker->cursor_channel, cursor);
             break;
         }
         default:
@@ -1161,7 +1161,7 @@ static int loadvm_command(RedWorker *worker, QXLCommandExt *ext)
             free(cursor_cmd);
             return FALSE;
         }
-        cursor_channel_process_cmd(worker->cursor_channel, cursor_cmd, ext->group_id);
+        cursor_channel_process_cmd(worker->cursor_channel, cursor_cmd);
         break;
     case QXL_CMD_SURFACE:
         surface_cmd = spice_new0(RedSurfaceCmd, 1);
commit 8091df87b3af2f88c7f58c76bc2c99ff891264b3
Author: Christophe Fergeau <cfergeau at redhat.com>
Date:   Fri Feb 12 18:51:07 2016 +0100

    red-parse-qxl: Use QXLReleaseInfoExt instead of QXLReleaseInfo
    
    This should allow to avoid moving the group_id separately from the QXL
    commands all over the code.
    
    Acked-by: Frediano Ziglio <fziglio at redhat.com>

diff --git a/server/cursor-channel.c b/server/cursor-channel.c
index 197376a..d9b6faa 100644
--- a/server/cursor-channel.c
+++ b/server/cursor-channel.c
@@ -109,7 +109,6 @@ static CursorItem *cursor_item_ref(CursorItem *item)
 
 static void cursor_item_unref(CursorItem *item)
 {
-    QXLReleaseInfoExt release_info_ext;
     RedCursorCmd *cursor_cmd;
 
     spice_return_if_fail(item != NULL);
@@ -118,9 +117,7 @@ static void cursor_item_unref(CursorItem *item)
         return;
 
     cursor_cmd = item->red_cursor;
-    release_info_ext.group_id = item->group_id;
-    release_info_ext.info = cursor_cmd->release_info;
-    item->qxl->st->qif->release_resource(item->qxl, release_info_ext);
+    item->qxl->st->qif->release_resource(item->qxl, cursor_cmd->release_info_ext);
     red_put_cursor_cmd(cursor_cmd);
     free(cursor_cmd);
 
diff --git a/server/display-channel.c b/server/display-channel.c
index 134d131..1ef7bad 100644
--- a/server/display-channel.c
+++ b/server/display-channel.c
@@ -2073,13 +2073,6 @@ DisplayChannel* display_channel_new(RedWorker *worker, int migrate, int stream_v
     return display;
 }
 
-static inline void set_surface_release_info(QXLReleaseInfoExt *release_info_ext,
-                                            QXLReleaseInfo *release_info, uint32_t group_id)
-{
-    release_info_ext->info = release_info;
-    release_info_ext->group_id = group_id;
-}
-
 void display_channel_process_surface_cmd(DisplayChannel *display, RedSurfaceCmd *surface,
                                          uint32_t group_id, int loadvm)
 {
@@ -2113,7 +2106,7 @@ void display_channel_process_surface_cmd(DisplayChannel *display, RedSurfaceCmd
                                        reloaded_surface,
                                        // reloaded surfaces will be sent on demand
                                        !reloaded_surface);
-        set_surface_release_info(&red_surface->create, surface->release_info, group_id);
+        red_surface->create = surface->release_info_ext;
         break;
     }
     case QXL_SURFACE_CMD_DESTROY:
@@ -2121,7 +2114,7 @@ void display_channel_process_surface_cmd(DisplayChannel *display, RedSurfaceCmd
             spice_warning("avoiding destroying a surface twice");
             break;
         }
-        set_surface_release_info(&red_surface->destroy, surface->release_info, group_id);
+        red_surface->destroy = surface->release_info_ext;
         display_channel_destroy_surface(display, surface_id);
         break;
     default:
diff --git a/server/red-parse-qxl.c b/server/red-parse-qxl.c
index 0270ae5..4d2cc72 100644
--- a/server/red-parse-qxl.c
+++ b/server/red-parse-qxl.c
@@ -1260,7 +1260,9 @@ int red_get_update_cmd(RedMemSlotInfo *slots, int group_id,
     if (error) {
         return 1;
     }
-    red->release_info     = &qxl->release_info;
+    red->release_info_ext.info     = &qxl->release_info;
+    red->release_info_ext.group_id = group_id;
+
 
     red_get_rect_ptr(&red->area, &qxl->area);
     red->update_id  = qxl->update_id;
@@ -1289,8 +1291,9 @@ int red_get_message(RedMemSlotInfo *slots, int group_id,
     if (error) {
         return 1;
     }
-    red->release_info  = &qxl->release_info;
-    red->data          = qxl->data;
+    red->release_info_ext.info      = &qxl->release_info;
+    red->release_info_ext.group_id  = group_id;
+    red->data                       = qxl->data;
     return 0;
 }
 
@@ -1329,7 +1332,8 @@ int red_get_surface_cmd(RedMemSlotInfo *slots, int group_id,
     if (error) {
         return 1;
     }
-    red->release_info     = &qxl->release_info;
+    red->release_info_ext.info      = &qxl->release_info;
+    red->release_info_ext.group_id  = group_id;
 
     red->surface_id = qxl->surface_id;
     red->type       = qxl->type;
@@ -1433,7 +1437,8 @@ int red_get_cursor_cmd(RedMemSlotInfo *slots, int group_id,
     if (error) {
         return error;
     }
-    red->release_info     = &qxl->release_info;
+    red->release_info_ext.info      = &qxl->release_info;
+    red->release_info_ext.group_id  = group_id;
 
     red->type = qxl->type;
     switch (red->type) {
diff --git a/server/red-parse-qxl.h b/server/red-parse-qxl.h
index 6bb0d4e..b5f95e6 100644
--- a/server/red-parse-qxl.h
+++ b/server/red-parse-qxl.h
@@ -65,14 +65,14 @@ static inline RedDrawable *red_drawable_ref(RedDrawable *drawable)
 }
 
 typedef struct RedUpdateCmd {
-    QXLReleaseInfo *release_info;
+    QXLReleaseInfoExt release_info_ext;
     SpiceRect area;
     uint32_t update_id;
     uint32_t surface_id;
 } RedUpdateCmd;
 
 typedef struct RedMessage {
-    QXLReleaseInfo *release_info;
+    QXLReleaseInfoExt release_info_ext;
     uint8_t *data;
 } RedMessage;
 
@@ -93,7 +93,7 @@ typedef struct RedSurfaceCreate {
 } RedSurfaceCreate;
 
 typedef struct RedSurfaceCmd {
-    QXLReleaseInfo *release_info;
+    QXLReleaseInfoExt release_info_ext;
     uint32_t surface_id;
     uint8_t type;
     uint32_t flags;
@@ -103,7 +103,7 @@ typedef struct RedSurfaceCmd {
 } RedSurfaceCmd;
 
 typedef struct RedCursorCmd {
-    QXLReleaseInfo *release_info;
+    QXLReleaseInfoExt release_info_ext;
     uint8_t type;
     union {
         struct {
diff --git a/server/red-worker.c b/server/red-worker.c
index 6daae5d..859ac3e 100644
--- a/server/red-worker.c
+++ b/server/red-worker.c
@@ -243,7 +243,6 @@ static int red_process_display(RedWorker *worker, int *ring_is_empty)
         }
         case QXL_CMD_UPDATE: {
             RedUpdateCmd update;
-            QXLReleaseInfoExt release_info_ext;
 
             if (red_get_update_cmd(&worker->mem_slots, ext_cmd.group_id,
                                    &update, ext_cmd.cmd.data)) {
@@ -255,15 +254,12 @@ static int red_process_display(RedWorker *worker, int *ring_is_empty)
                 display_channel_draw(worker->display_channel, &update.area, update.surface_id);
                 worker->qxl->st->qif->notify_update(worker->qxl, update.update_id);
             }
-            release_info_ext.group_id = ext_cmd.group_id;
-            release_info_ext.info = update.release_info;
-            worker->qxl->st->qif->release_resource(worker->qxl, release_info_ext);
+            worker->qxl->st->qif->release_resource(worker->qxl, update.release_info_ext);
             red_put_update_cmd(&update);
             break;
         }
         case QXL_CMD_MESSAGE: {
             RedMessage message;
-            QXLReleaseInfoExt release_info_ext;
 
             if (red_get_message(&worker->mem_slots, ext_cmd.group_id,
                                 &message, ext_cmd.cmd.data)) {
@@ -273,9 +269,7 @@ static int red_process_display(RedWorker *worker, int *ring_is_empty)
             /* alert: accessing message.data is insecure */
             spice_warning("MESSAGE: %s", message.data);
 #endif
-            release_info_ext.group_id = ext_cmd.group_id;
-            release_info_ext.info = message.release_info;
-            worker->qxl->st->qif->release_resource(worker->qxl, release_info_ext);
+            worker->qxl->st->qif->release_resource(worker->qxl, message.release_info_ext);
             red_put_message(&message);
             break;
         }
commit 4049481882629f9a725a07752f2719ec24bcfb62
Author: Christophe Fergeau <cfergeau at redhat.com>
Date:   Fri Feb 12 18:51:06 2016 +0100

    Remove RedGlzDrawable::group_id
    
    It's unused.
    
    Acked-by: Frediano Ziglio <fziglio at redhat.com>

diff --git a/server/dcc-encoders.h b/server/dcc-encoders.h
index a244c94..1cfc4f7 100644
--- a/server/dcc-encoders.h
+++ b/server/dcc-encoders.h
@@ -156,7 +156,6 @@ struct RedGlzDrawable {
     RingItem drawable_link;
     RedDrawable *red_drawable;
     Drawable    *drawable;
-    uint32_t     group_id;
     GlzDrawableInstanceItem instances_pool[MAX_GLZ_DRAWABLE_INSTANCES];
     Ring instances;
     uint8_t instances_count;
diff --git a/server/dcc.c b/server/dcc.c
index abf3c0d..9a4e90c 100644
--- a/server/dcc.c
+++ b/server/dcc.c
@@ -657,7 +657,6 @@ static RedGlzDrawable *get_glz_drawable(DisplayChannelClient *dcc, Drawable *dra
     ret->dcc = dcc;
     ret->red_drawable = red_drawable_ref(drawable->red_drawable);
     ret->drawable = drawable;
-    ret->group_id = drawable->red_drawable->release_info_ext.group_id;
     ret->instances_count = 0;
     ring_init(&ret->instances);
 
commit 9500c32a308a8593cc9abd6f0b869e05f92072b5
Author: Christophe Fergeau <cfergeau at redhat.com>
Date:   Fri Feb 12 18:51:05 2016 +0100

    Remove Drawable::group_id
    
    We can now directly get it from RedDrawable.
    
    Acked-by: Frediano Ziglio <fziglio at redhat.com>

diff --git a/server/dcc.c b/server/dcc.c
index bd25069..abf3c0d 100644
--- a/server/dcc.c
+++ b/server/dcc.c
@@ -657,7 +657,7 @@ static RedGlzDrawable *get_glz_drawable(DisplayChannelClient *dcc, Drawable *dra
     ret->dcc = dcc;
     ret->red_drawable = red_drawable_ref(drawable->red_drawable);
     ret->drawable = drawable;
-    ret->group_id = drawable->group_id;
+    ret->group_id = drawable->red_drawable->release_info_ext.group_id;
     ret->instances_count = 0;
     ring_init(&ret->instances);
 
diff --git a/server/display-channel.c b/server/display-channel.c
index 168d403..134d131 100644
--- a/server/display-channel.c
+++ b/server/display-channel.c
@@ -1379,7 +1379,6 @@ Drawable *display_channel_drawable_try_new(DisplayChannel *display,
     ring_init(&drawable->pipes);
     ring_init(&drawable->glz_ring);
     drawable->process_commands_generation = process_commands_generation;
-    drawable->group_id = group_id;
 
     return drawable;
 }
diff --git a/server/display-channel.h b/server/display-channel.h
index 49f1a4f..24d83a3 100644
--- a/server/display-channel.h
+++ b/server/display-channel.h
@@ -73,7 +73,6 @@ struct Drawable {
     Stream *sized_stream;
     int streamable;
     BitmapGradualType copy_bitmap_graduality;
-    uint32_t group_id;
     DependItem depend_items[3];
 
     int surface_id;
commit e213f09c38023f85cdbf38549bf8d15234df8acc
Author: Christophe Fergeau <cfergeau at redhat.com>
Date:   Fri Feb 12 18:51:04 2016 +0100

    Simplify red_drawable_unref()
    
    Now it no longer needs external state in order to destroy the
    RedDrawable instance when needed, so we can remove this from the
    prototype.
    
    Acked-by: Frediano Ziglio <fziglio at redhat.com>

diff --git a/server/dcc-encoders.c b/server/dcc-encoders.c
index c810b8e..f1dd1bb 100644
--- a/server/dcc-encoders.c
+++ b/server/dcc-encoders.c
@@ -483,8 +483,7 @@ void dcc_free_glz_drawable_instance(DisplayChannelClient *dcc,
         if (drawable) {
             ring_remove(&glz_drawable->drawable_link);
         }
-        red_drawable_unref(display_channel, glz_drawable->red_drawable,
-                           glz_drawable->group_id);
+        red_drawable_unref(glz_drawable->red_drawable);
         display_channel->glz_drawable_count--;
         if (ring_item_is_linked(&glz_drawable->link)) {
             ring_remove(&glz_drawable->link);
diff --git a/server/display-channel.c b/server/display-channel.c
index 6a26152..168d403 100644
--- a/server/display-channel.c
+++ b/server/display-channel.c
@@ -1444,7 +1444,7 @@ void display_channel_drawable_unref(DisplayChannel *display, Drawable *drawable)
         ring_remove(item);
     }
     if (drawable->red_drawable) {
-        red_drawable_unref(display, drawable->red_drawable, drawable->group_id);
+        red_drawable_unref(drawable->red_drawable);
     }
     drawable_free(display, drawable);
     display->drawable_count--;
diff --git a/server/red-worker.c b/server/red-worker.c
index cec9cf3..6daae5d 100644
--- a/server/red-worker.c
+++ b/server/red-worker.c
@@ -129,8 +129,7 @@ static void common_release_recv_buf(RedChannelClient *rcc, uint16_t type, uint32
     }
 }
 
-void red_drawable_unref(DisplayChannel *display, RedDrawable *red_drawable,
-                        uint32_t group_id)
+void red_drawable_unref(RedDrawable *red_drawable)
 {
     if (--red_drawable->refs) {
         return;
@@ -239,7 +238,7 @@ static int red_process_display(RedWorker *worker, int *ring_is_empty)
                                              worker->process_display_generation);
             }
             // release the red_drawable
-            red_drawable_unref(worker->display_channel, red_drawable, ext_cmd.group_id);
+            red_drawable_unref(red_drawable);
             break;
         }
         case QXL_CMD_UPDATE: {
diff --git a/server/red-worker.h b/server/red-worker.h
index 1285942..94974b7 100644
--- a/server/red-worker.h
+++ b/server/red-worker.h
@@ -97,9 +97,7 @@ QXLInstance* red_worker_get_qxl(RedWorker *worker);
 RedChannel* red_worker_get_cursor_channel(RedWorker *worker);
 RedChannel* red_worker_get_display_channel(RedWorker *worker);
 
-struct DisplayChannel;
-void red_drawable_unref(struct DisplayChannel *display, RedDrawable *red_drawable,
-                        uint32_t group_id);
+void red_drawable_unref(RedDrawable *red_drawable);
 
 CommonChannel *red_worker_new_channel(RedWorker *worker, int size,
                                    const char *name,
commit 650ef63782b82e63d7ef7931606dadfee4a4621a
Author: Christophe Fergeau <cfergeau at redhat.com>
Date:   Fri Feb 12 18:51:03 2016 +0100

    Add group_id to RedDrawable
    
    Storing a QXLReleaseInfoExt rather than a QXLReleaseInfo in RedDrawable
    gives us a place to store group_id for free. Since we are building a
    QXLReleaseInfoExt from QXLReleaseInfo and group_id when destroying a
    RedDrawable instance, this is a move in the right direction.
    
    Acked-by: Frediano Ziglio <fziglio at redhat.com>

diff --git a/server/red-parse-qxl.c b/server/red-parse-qxl.c
index dd1a09c..0270ae5 100644
--- a/server/red-parse-qxl.c
+++ b/server/red-parse-qxl.c
@@ -1027,7 +1027,8 @@ static int red_get_native_drawable(RedMemSlotInfo *slots, int group_id,
     if (error) {
         return error;
     }
-    red->release_info     = &qxl->release_info;
+    red->release_info_ext.info     = &qxl->release_info;
+    red->release_info_ext.group_id = group_id;
 
     red_get_rect_ptr(&red->bbox, &qxl->bbox);
     red_get_clip_ptr(slots, group_id, &red->clip, &qxl->clip);
@@ -1110,7 +1111,8 @@ static int red_get_compat_drawable(RedMemSlotInfo *slots, int group_id,
     if (error) {
         return error;
     }
-    red->release_info     = &qxl->release_info;
+    red->release_info_ext.info     = &qxl->release_info;
+    red->release_info_ext.group_id = group_id;
 
     red_get_rect_ptr(&red->bbox, &qxl->bbox);
     red_get_clip_ptr(slots, group_id, &red->clip, &qxl->clip);
diff --git a/server/red-parse-qxl.h b/server/red-parse-qxl.h
index 179d45c..6bb0d4e 100644
--- a/server/red-parse-qxl.h
+++ b/server/red-parse-qxl.h
@@ -26,7 +26,7 @@
 typedef struct RedDrawable {
     int refs;
     QXLInstance *qxl;
-    QXLReleaseInfo *release_info;
+    QXLReleaseInfoExt release_info_ext;
     uint32_t surface_id;
     uint8_t effect;
     uint8_t type;
diff --git a/server/red-worker.c b/server/red-worker.c
index 7e95509..cec9cf3 100644
--- a/server/red-worker.c
+++ b/server/red-worker.c
@@ -132,14 +132,11 @@ static void common_release_recv_buf(RedChannelClient *rcc, uint16_t type, uint32
 void red_drawable_unref(DisplayChannel *display, RedDrawable *red_drawable,
                         uint32_t group_id)
 {
-    QXLReleaseInfoExt release_info_ext;
-
     if (--red_drawable->refs) {
         return;
     }
-    release_info_ext.group_id = group_id;
-    release_info_ext.info = red_drawable->release_info;
-    red_drawable->qxl->st->qif->release_resource(red_drawable->qxl, release_info_ext);
+    red_drawable->qxl->st->qif->release_resource(red_drawable->qxl,
+                                                 red_drawable->release_info_ext);
     red_put_drawable(red_drawable);
     free(red_drawable);
 }
commit 7b3bdbfdda004d6aca055034e1f77cda1c93e993
Author: Christophe Fergeau <cfergeau at redhat.com>
Date:   Fri Feb 12 18:51:02 2016 +0100

    Add QXLInstance member to RedDrawable
    
    This allows to get rid of the DisplayChannel parameter to
    red_drawable_unref()
    
    Acked-by: Frediano Ziglio <fziglio at redhat.com>

diff --git a/server/red-parse-qxl.h b/server/red-parse-qxl.h
index 8f8d459..179d45c 100644
--- a/server/red-parse-qxl.h
+++ b/server/red-parse-qxl.h
@@ -25,6 +25,7 @@
 
 typedef struct RedDrawable {
     int refs;
+    QXLInstance *qxl;
     QXLReleaseInfo *release_info;
     uint32_t surface_id;
     uint8_t effect;
diff --git a/server/red-worker.c b/server/red-worker.c
index eebc193..7e95509 100644
--- a/server/red-worker.c
+++ b/server/red-worker.c
@@ -139,7 +139,7 @@ void red_drawable_unref(DisplayChannel *display, RedDrawable *red_drawable,
     }
     release_info_ext.group_id = group_id;
     release_info_ext.info = red_drawable->release_info;
-    display->common.qxl->st->qif->release_resource(display->common.qxl, release_info_ext);
+    red_drawable->qxl->st->qif->release_resource(red_drawable->qxl, release_info_ext);
     red_put_drawable(red_drawable);
     free(red_drawable);
 }
@@ -190,11 +190,12 @@ static int red_process_cursor(RedWorker *worker, int *ring_is_empty)
     return n;
 }
 
-static RedDrawable *red_drawable_new(RedWorker *worker)
+static RedDrawable *red_drawable_new(QXLInstance *qxl)
 {
     RedDrawable * red = spice_new0(RedDrawable, 1);
 
     red->refs = 1;
+    red->qxl = qxl;
 
     return red;
 }
@@ -233,7 +234,7 @@ static int red_process_display(RedWorker *worker, int *ring_is_empty)
         worker->display_poll_tries = 0;
         switch (ext_cmd.cmd.type) {
         case QXL_CMD_DRAW: {
-            RedDrawable *red_drawable = red_drawable_new(worker); // returns with 1 ref
+            RedDrawable *red_drawable = red_drawable_new(worker->qxl); // returns with 1 ref
 
             if (!red_get_drawable(&worker->mem_slots, ext_cmd.group_id,
                                  red_drawable, ext_cmd.cmd.data, ext_cmd.flags)) {
commit f8617db67a00a99494816a1bf7952a45d30e7317
Author: Christophe Fergeau <cfergeau at redhat.com>
Date:   Fri Feb 12 18:51:01 2016 +0100

    Remove DisplayChannel::red_drawable_count
    
    It's only used in a few debug printfs. If we want these stats, we'll
    have to find a better way than forcing a dependency on a high-level
    class in a lower-level _unref method just to maintain the stats.
    
    Acked-by: Frediano Ziglio <fziglio at redhat.com>

diff --git a/server/display-channel.c b/server/display-channel.c
index b586c54..6a26152 100644
--- a/server/display-channel.c
+++ b/server/display-channel.c
@@ -1297,8 +1297,8 @@ void display_channel_free_some(DisplayChannel *display)
     DisplayChannelClient *dcc;
     RingItem *item, *next;
 
-    spice_debug("#draw=%d, #red_draw=%d, #glz_draw=%d", display->drawable_count,
-                display->red_drawable_count, display->glz_drawable_count);
+    spice_debug("#draw=%d, #glz_draw=%d", display->drawable_count,
+                display->glz_drawable_count);
     FOREACH_DCC(display, item, next, dcc) {
         GlzSharedDictionary *glz_dict = dcc ? dcc->glz_dict : NULL;
 
@@ -1943,8 +1943,8 @@ static void on_disconnect(RedChannelClient *rcc)
     display_channel_compress_stats_print(display);
 
     // this was the last channel client
-    spice_debug("#draw=%d, #red_draw=%d, #glz_draw=%d",
-                display->drawable_count, display->red_drawable_count,
+    spice_debug("#draw=%d, #glz_draw=%d",
+                display->drawable_count,
                 display->glz_drawable_count);
 }
 
diff --git a/server/display-channel.h b/server/display-channel.h
index e0b18ca..49f1a4f 100644
--- a/server/display-channel.h
+++ b/server/display-channel.h
@@ -181,7 +181,6 @@ struct DisplayChannel {
     _Drawable drawables[NUM_DRAWABLES];
     _Drawable *free_drawables;
 
-    uint32_t red_drawable_count;
     uint32_t glz_drawable_count;
 
     int stream_video;
diff --git a/server/red-worker.c b/server/red-worker.c
index b7ef537..eebc193 100644
--- a/server/red-worker.c
+++ b/server/red-worker.c
@@ -137,7 +137,6 @@ void red_drawable_unref(DisplayChannel *display, RedDrawable *red_drawable,
     if (--red_drawable->refs) {
         return;
     }
-    display->red_drawable_count--;
     release_info_ext.group_id = group_id;
     release_info_ext.info = red_drawable->release_info;
     display->common.qxl->st->qif->release_resource(display->common.qxl, release_info_ext);
@@ -196,7 +195,6 @@ static RedDrawable *red_drawable_new(RedWorker *worker)
     RedDrawable * red = spice_new0(RedDrawable, 1);
 
     red->refs = 1;
-    worker->display_channel->red_drawable_count++;
 
     return red;
 }
@@ -856,9 +854,8 @@ static void handle_dev_oom(void *opaque, void *payload)
 
     spice_return_if_fail(worker->running);
     // streams? but without streams also leak
-    spice_debug("OOM1 #draw=%u, #red_draw=%u, #glz_draw=%u current %u pipes %u",
+    spice_debug("OOM1 #draw=%u, #glz_draw=%u current %u pipes %u",
                 display->drawable_count,
-                display->red_drawable_count,
                 display->glz_drawable_count,
                 display->current_size,
                 red_channel_sum_pipes_size(display_red_channel));
@@ -869,9 +866,8 @@ static void handle_dev_oom(void *opaque, void *payload)
         display_channel_free_some(worker->display_channel);
         worker->qxl->st->qif->flush_resources(worker->qxl);
     }
-    spice_debug("OOM2 #draw=%u, #red_draw=%u, #glz_draw=%u current %u pipes %u",
+    spice_debug("OOM2 #draw=%u, #glz_draw=%u current %u pipes %u",
                 display->drawable_count,
-                display->red_drawable_count,
                 display->glz_drawable_count,
                 display->current_size,
                 red_channel_sum_pipes_size(display_red_channel));
commit 78b495e4677718ba4148a36c75c508bc1dcde8d0
Author: Christophe Fergeau <cfergeau at redhat.com>
Date:   Fri Feb 12 18:51:00 2016 +0100

    qxl: Remove unused group_id arg to fill_attr
    
    Acked-by: Frediano Ziglio <fziglio at redhat.com>

diff --git a/server/dcc-send.c b/server/dcc-send.c
index 8144ed2..14ce239 100644
--- a/server/dcc-send.c
+++ b/server/dcc-send.c
@@ -501,7 +501,7 @@ static void fill_mask(RedChannelClient *rcc, SpiceMarshaller *m,
     }
 }
 
-static void fill_attr(SpiceMarshaller *m, SpiceLineAttr *attr, uint32_t group_id)
+static void fill_attr(SpiceMarshaller *m, SpiceLineAttr *attr)
 {
     int i;
 
@@ -1494,7 +1494,7 @@ static void red_marshall_qxl_draw_stroke(RedChannelClient *rcc,
                           &style_out,
                           &brush_pat_out);
 
-    fill_attr(style_out, &stroke.attr, item->group_id);
+    fill_attr(style_out, &stroke.attr);
     if (brush_pat_out) {
         fill_bits(dcc, brush_pat_out, stroke.brush.u.pattern.pat, item, FALSE);
     }


More information about the Spice-commits mailing list