[Spice-devel] [PATCH v6 6/7] Remove dependency from dcc-encoders to Drawable
Jonathon Jongsma
jjongsma at redhat.com
Thu Jun 16 20:04:06 UTC 2016
Acked-by: Jonathon Jongsma <jjongsma at redhat.com>
On Thu, 2016-06-16 at 10:41 +0100, Frediano Ziglio wrote:
> 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 | 19 ++++++++++++-------
> server/dcc-encoders.h | 4 +++-
> server/dcc.c | 4 +++-
> 3 files changed, 18 insertions(+), 9 deletions(-)
>
> diff --git a/server/dcc-encoders.c b/server/dcc-encoders.c
> index 42affd5..984f2d4 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
>
> @@ -1151,7 +1153,8 @@ int image_encoders_compress_lz4(ImageEncoders *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(ImageEncoders *enc, Drawable
> *drawable)
> +static RedGlzDrawable *get_glz_drawable(ImageEncoders *enc, RedDrawable
> *red_drawable,
> + GlzImageRetention *glz_retention)
> {
> RedGlzDrawable *ret;
> RingItem *item, *next;
> @@ -1159,7 +1162,7 @@ static RedGlzDrawable *get_glz_drawable(ImageEncoders
> *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, &glz_retention->ring, ret,
> LINK_TO_GLZ(item)) {
> if (ret->encoders == enc) {
> return ret;
> }
> @@ -1168,7 +1171,7 @@ static RedGlzDrawable *get_glz_drawable(ImageEncoders
> *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);
> @@ -1176,7 +1179,7 @@ static RedGlzDrawable *get_glz_drawable(ImageEncoders
> *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_retention.ring, &ret->drawable_link);
> + ring_add(&glz_retention->ring, &ret->drawable_link);
> enc->shared_data->glz_drawable_count++;
> return ret;
> }
> @@ -1202,7 +1205,9 @@ static GlzDrawableInstanceItem
> *add_glz_drawable_instance(RedGlzDrawable *glz_dr
> #define MIN_GLZ_SIZE_FOR_ZLIB 100
>
> int image_encoders_compress_glz(ImageEncoders *enc,
> - SpiceImage *dest, SpiceBitmap *src, Drawable
> *drawable,
> + SpiceImage *dest, SpiceBitmap *src,
> + RedDrawable *red_drawable,
> + GlzImageRetention *glz_retention,
> compress_send_data_t* o_comp_data,
> gboolean enable_zlib_glz_wrap)
> {
> @@ -1234,7 +1239,7 @@ int image_encoders_compress_glz(ImageEncoders *enc,
>
> encoder_data_init(&glz_data->data);
>
> - glz_drawable = get_glz_drawable(enc, drawable);
> + glz_drawable = get_glz_drawable(enc, red_drawable, glz_retention);
> 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 38e6c5a..ed8bdea 100644
> --- a/server/dcc-encoders.h
> +++ b/server/dcc-encoders.h
> @@ -204,7 +204,9 @@ int image_encoders_compress_jpeg(ImageEncoders *enc,
> SpiceImage *dest,
> int image_encoders_compress_lz4(ImageEncoders *enc, SpiceImage *dest,
> SpiceBitmap *src, compress_send_data_t*
> o_comp_data);
> int image_encoders_compress_glz(ImageEncoders *enc,
> - SpiceImage *dest, SpiceBitmap *src, struct
> Drawable *drawable,
> + SpiceImage *dest, SpiceBitmap *src,
> + RedDrawable *red_drawable,
> + GlzImageRetention *glz_retention,
> compress_send_data_t* o_comp_data,
> gboolean enable_zlib_glz_wrap);
>
> diff --git a/server/dcc.c b/server/dcc.c
> index e5c80ad..45c3ca8 100644
> --- a/server/dcc.c
> +++ b/server/dcc.c
> @@ -735,7 +735,9 @@ int dcc_compress_image(DisplayChannelClient *dcc,
> success = image_encoders_compress_quic(&dcc->encoders, dest, src,
> o_comp_data);
> break;
> case SPICE_IMAGE_COMPRESSION_GLZ:
> - success = image_encoders_compress_glz(&dcc->encoders, dest, src,
> drawable, o_comp_data,
> + success = image_encoders_compress_glz(&dcc->encoders, dest, src,
> + drawable->red_drawable,
> &drawable->glz_retention,
> + o_comp_data,
> display_channel-
> >enable_zlib_glz_wrap);
> if (success) {
> break;
More information about the Spice-devel
mailing list