[Spice-devel] [PATCH 29/30] Remove dependency from dcc-encoders to Drawable

Frediano Ziglio fziglio at redhat.com
Tue Jun 7 10:18:07 UTC 2016


Encoding image requires a RedDrawable (where the data is stored) and
a Ring where to store information to free Glz structures.

Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
---
 server/dcc-encoders.c | 17 ++++++++++-------
 server/dcc-encoders.h |  3 ++-
 server/dcc.c          |  4 +++-
 3 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/server/dcc-encoders.c b/server/dcc-encoders.c
index 06132ed..57051ac 100644
--- a/server/dcc-encoders.c
+++ b/server/dcc-encoders.c
@@ -22,7 +22,9 @@
 #include <glib.h>
 
 #include "dcc-encoders.h"
-#include "display-channel.h"
+#include "spice-bitmap-utils.h"
+#include "red-worker.h" // red_drawable_unref
+#include "pixmap-cache.h" // MAX_CACHE_CLIENTS
 
 #define ZLIB_DEFAULT_COMPRESSION_LEVEL 3
 
@@ -1147,7 +1149,7 @@ int dcc_compress_image_lz4(EncodersData *enc, SpiceImage *dest,
 
 /* if already exists, returns it. Otherwise allocates and adds it (1) to the ring tail
    in the channel (2) to the Drawable*/
-static RedGlzDrawable *get_glz_drawable(EncodersData *enc, Drawable *drawable)
+static RedGlzDrawable *get_glz_drawable(EncodersData *enc, RedDrawable *red_drawable, Ring *drawable_ring)
 {
     RedGlzDrawable *ret;
     RingItem *item, *next;
@@ -1155,7 +1157,7 @@ static RedGlzDrawable *get_glz_drawable(EncodersData *enc, Drawable *drawable)
     // TODO - I don't really understand what's going on here, so doing the technical equivalent
     // now that we have multiple glz_dicts, so the only way to go from dcc to drawable glz is to go
     // over the glz_ring (unless adding some better data structure then a ring)
-    DRAWABLE_FOREACH_GLZ_SAFE(drawable, item, next, ret) {
+    SAFE_FOREACH(item, next, TRUE, drawable_ring, ret, LINK_TO_GLZ(item)) {
         if (ret->encoders == enc) {
             return ret;
         }
@@ -1164,7 +1166,7 @@ static RedGlzDrawable *get_glz_drawable(EncodersData *enc, Drawable *drawable)
     ret = spice_new(RedGlzDrawable, 1);
 
     ret->encoders = enc;
-    ret->red_drawable = red_drawable_ref(drawable->red_drawable);
+    ret->red_drawable = red_drawable_ref(red_drawable);
     ret->has_drawable = TRUE;
     ret->instances_count = 0;
     ring_init(&ret->instances);
@@ -1172,7 +1174,7 @@ static RedGlzDrawable *get_glz_drawable(EncodersData *enc, Drawable *drawable)
     ring_item_init(&ret->link);
     ring_item_init(&ret->drawable_link);
     ring_add_before(&ret->link, &enc->glz_drawables);
-    ring_add(&drawable->glz_ring, &ret->drawable_link);
+    ring_add(drawable_ring, &ret->drawable_link);
     return ret;
 }
 
@@ -1197,7 +1199,8 @@ static GlzDrawableInstanceItem *add_glz_drawable_instance(RedGlzDrawable *glz_dr
 #define MIN_GLZ_SIZE_FOR_ZLIB 100
 
 int dcc_compress_image_glz(EncodersData *enc,
-                           SpiceImage *dest, SpiceBitmap *src, Drawable *drawable,
+                           SpiceImage *dest, SpiceBitmap *src,
+                           RedDrawable *red_drawable, Ring *drawable_ring,
                            compress_send_data_t* o_comp_data,
                            gboolean enable_zlib_glz_wrap,
                            stat_info_t *glz_stats,
@@ -1231,7 +1234,7 @@ int dcc_compress_image_glz(EncodersData *enc,
 
     encoder_data_init(&glz_data->data);
 
-    glz_drawable = get_glz_drawable(enc, drawable);
+    glz_drawable = get_glz_drawable(enc, red_drawable, drawable_ring);
     glz_drawable_instance = add_glz_drawable_instance(glz_drawable);
 
     glz_data->data.u.lines_data.chunks = src->data;
diff --git a/server/dcc-encoders.h b/server/dcc-encoders.h
index f41c49a..1decd33 100644
--- a/server/dcc-encoders.h
+++ b/server/dcc-encoders.h
@@ -180,7 +180,8 @@ int dcc_compress_image_lz4(EncodersData *enc, SpiceImage *dest,
                            SpiceBitmap *src, compress_send_data_t* o_comp_data,
                            stat_info_t *stats);
 int dcc_compress_image_glz(EncodersData *enc,
-                           SpiceImage *dest, SpiceBitmap *src, struct Drawable *drawable,
+                           SpiceImage *dest, SpiceBitmap *src,
+                           RedDrawable *red_drawable, Ring *drawable_ring,
                            compress_send_data_t* o_comp_data,
                            gboolean enable_zlib_glz_wrap,
                            stat_info_t *glz_stats,
diff --git a/server/dcc.c b/server/dcc.c
index 6d74cd7..5829eb9 100644
--- a/server/dcc.c
+++ b/server/dcc.c
@@ -742,7 +742,9 @@ int dcc_compress_image(DisplayChannelClient *dcc,
         success = dcc_compress_image_quic(&dcc->encoders, dest, src, o_comp_data, &display_channel->quic_stat);
         break;
     case SPICE_IMAGE_COMPRESSION_GLZ:
-        success = dcc_compress_image_glz(&dcc->encoders, dest, src, drawable, o_comp_data,
+        success = dcc_compress_image_glz(&dcc->encoders, dest, src,
+                                         drawable->red_drawable, &drawable->glz_ring,
+                                         o_comp_data,
                                          display_channel->enable_zlib_glz_wrap,
                                          &display_channel->glz_stat,
                                          &display_channel->zlib_glz_stat);
-- 
2.7.4



More information about the Spice-devel mailing list