[Spice-commits] 3 commits - server/dcc.c server/dcc.h server/dcc-send.c
Frediano Ziglio
fziglio at kemper.freedesktop.org
Wed Jan 20 08:05:45 PST 2016
server/dcc-send.c | 44 +----------------------------------------
server/dcc.c | 57 ++++++++++++++++++++++++++++--------------------------
server/dcc.h | 15 --------------
3 files changed, 32 insertions(+), 84 deletions(-)
New commits:
commit 0bfad8a37fd2fff1dd2134b99316193d90bdbfb0
Author: Pavel Grunt <pgrunt at redhat.com>
Date: Wed Jan 20 14:15:25 2016 +0100
dcc: make dcc_compress_image_*() private
Reviewed-by: Victor Toso <victortoso at redhat.com>
Acked-by: Frediano Ziglio <fziglio at redhat.com>
diff --git a/server/dcc.c b/server/dcc.c
index 613d7af..bf692f8 100644
--- a/server/dcc.c
+++ b/server/dcc.c
@@ -646,9 +646,9 @@ static const LzImageType bitmap_fmt_to_lz_image_type[] = {
#define MIN_GLZ_SIZE_FOR_ZLIB 100
-int dcc_compress_image_glz(DisplayChannelClient *dcc,
- SpiceImage *dest, SpiceBitmap *src, Drawable *drawable,
- compress_send_data_t* o_comp_data)
+static int dcc_compress_image_glz(DisplayChannelClient *dcc,
+ SpiceImage *dest, SpiceBitmap *src, Drawable *drawable,
+ compress_send_data_t* o_comp_data)
{
DisplayChannel *display_channel = DCC_TO_DC(dcc);
stat_start_time_t start_time;
@@ -723,9 +723,9 @@ glz:
return TRUE;
}
-int dcc_compress_image_lz(DisplayChannelClient *dcc,
- SpiceImage *dest, SpiceBitmap *src,
- compress_send_data_t* o_comp_data, uint32_t group_id)
+static int dcc_compress_image_lz(DisplayChannelClient *dcc,
+ SpiceImage *dest, SpiceBitmap *src,
+ compress_send_data_t* o_comp_data, uint32_t group_id)
{
LzData *lz_data = &dcc->lz_data;
LzContext *lz = dcc->lz;
@@ -785,9 +785,9 @@ int dcc_compress_image_lz(DisplayChannelClient *dcc,
return TRUE;
}
-int dcc_compress_image_jpeg(DisplayChannelClient *dcc, SpiceImage *dest,
- SpiceBitmap *src, compress_send_data_t* o_comp_data,
- uint32_t group_id)
+static int dcc_compress_image_jpeg(DisplayChannelClient *dcc, SpiceImage *dest,
+ SpiceBitmap *src, compress_send_data_t* o_comp_data,
+ uint32_t group_id)
{
JpegData *jpeg_data = &dcc->jpeg_data;
LzData *lz_data = &dcc->lz_data;
@@ -910,9 +910,9 @@ int dcc_compress_image_jpeg(DisplayChannelClient *dcc, SpiceImage *dest,
}
#ifdef USE_LZ4
-int dcc_compress_image_lz4(DisplayChannelClient *dcc, SpiceImage *dest,
- SpiceBitmap *src, compress_send_data_t* o_comp_data,
- uint32_t group_id)
+static int dcc_compress_image_lz4(DisplayChannelClient *dcc, SpiceImage *dest,
+ SpiceBitmap *src, compress_send_data_t* o_comp_data,
+ uint32_t group_id)
{
Lz4Data *lz4_data = &dcc->lz4_data;
Lz4EncoderContext *lz4 = dcc->lz4;
@@ -957,9 +957,9 @@ int dcc_compress_image_lz4(DisplayChannelClient *dcc, SpiceImage *dest,
}
#endif
-int dcc_compress_image_quic(DisplayChannelClient *dcc, SpiceImage *dest,
- SpiceBitmap *src, compress_send_data_t* o_comp_data,
- uint32_t group_id)
+static int dcc_compress_image_quic(DisplayChannelClient *dcc, SpiceImage *dest,
+ SpiceBitmap *src, compress_send_data_t* o_comp_data,
+ uint32_t group_id)
{
QuicData *quic_data = &dcc->quic_data;
QuicContext *quic = dcc->quic;
diff --git a/server/dcc.h b/server/dcc.h
index 2a12226..f715792 100644
--- a/server/dcc.h
+++ b/server/dcc.h
@@ -219,20 +219,5 @@ int dcc_compress_image (DisplayCha
SpiceImage *dest, SpiceBitmap *src, Drawable *drawable,
int can_lossy,
compress_send_data_t* o_comp_data);
-int dcc_compress_image_glz (DisplayChannelClient *dcc,
- SpiceImage *dest, SpiceBitmap *src, Drawable *drawable,
- compress_send_data_t* o_comp_data);
-int dcc_compress_image_lz (DisplayChannelClient *dcc,
- SpiceImage *dest, SpiceBitmap *src,
- compress_send_data_t* o_comp_data, uint32_t group_id);
-int dcc_compress_image_jpeg (DisplayChannelClient *dcc, SpiceImage *dest,
- SpiceBitmap *src, compress_send_data_t* o_comp_data,
- uint32_t group_id);
-int dcc_compress_image_quic (DisplayChannelClient *dcc, SpiceImage *dest,
- SpiceBitmap *src, compress_send_data_t* o_comp_data,
- uint32_t group_id);
-int dcc_compress_image_lz4 (DisplayChannelClient *dcc, SpiceImage *dest,
- SpiceBitmap *src, compress_send_data_t* o_comp_data,
- uint32_t group_id);
#endif /* DCC_H_ */
commit a310ac8860924c44583d858c4c5f3c60e4052f41
Author: Pavel Grunt <pgrunt at redhat.com>
Date: Wed Jan 20 14:15:24 2016 +0100
dcc-send: Use dcc_compress_image to compress image
Acked-by: Frediano Ziglio <fziglio at redhat.com>
diff --git a/server/dcc-send.c b/server/dcc-send.c
index c3f79ef..3cb50ba 100644
--- a/server/dcc-send.c
+++ b/server/dcc-send.c
@@ -1920,20 +1920,14 @@ static void red_marshall_image(RedChannelClient *rcc, SpiceMarshaller *m, ImageI
DisplayChannelClient *dcc = RCC_TO_DCC(rcc);
DisplayChannel *display = DCC_TO_DC(dcc);
SpiceImage red_image;
- RedWorker *worker;
SpiceBitmap bitmap;
SpiceChunks *chunks;
QRegion *surface_lossy_region;
- int comp_succeeded = FALSE;
- int lossy_comp = FALSE;
- int quic_comp = FALSE;
- SpiceImageCompression comp_mode;
SpiceMsgDisplayDrawCopy copy;
SpiceMarshaller *src_bitmap_out, *mask_bitmap_out;
SpiceMarshaller *bitmap_palette_out, *lzplt_palette_out;
spice_assert(rcc && display && item);
- worker = display->common.worker;
QXL_SET_IMAGE_ID(&red_image, QXL_IMAGE_GROUP_RED, display_channel_generate_uid(display));
red_image.descriptor.type = SPICE_IMAGE_TYPE_BITMAP;
@@ -1981,41 +1975,7 @@ static void red_marshall_image(RedChannelClient *rcc, SpiceMarshaller *m, ImageI
compress_send_data_t comp_send_data = {0};
- comp_mode = dcc->image_compression;
-
- if (((comp_mode == SPICE_IMAGE_COMPRESSION_AUTO_LZ) ||
- (comp_mode == SPICE_IMAGE_COMPRESSION_AUTO_GLZ)) && !bitmap_has_extra_stride(&bitmap)) {
-
- if (bitmap_fmt_has_graduality(item->image_format)) {
- BitmapGradualType grad_level;
-
- grad_level = bitmap_get_graduality_level(&bitmap);
- if (grad_level == BITMAP_GRADUAL_HIGH) {
- // if we use lz for alpha, the stride can't be extra
- lossy_comp = display->enable_jpeg && item->can_lossy;
- quic_comp = TRUE;
- }
- }
- } else if (comp_mode == SPICE_IMAGE_COMPRESSION_QUIC) {
- quic_comp = TRUE;
- }
-
- uint32_t groupid = red_worker_get_memslot(worker)->internal_groupslot_id;
-
- if (lossy_comp) {
- comp_succeeded = dcc_compress_image_jpeg(dcc, &red_image, &bitmap, &comp_send_data, groupid);
- } else if (quic_comp) {
- comp_succeeded = dcc_compress_image_quic(dcc, &red_image, &bitmap, &comp_send_data, groupid);
-#ifdef USE_LZ4
- } else if (comp_mode == SPICE_IMAGE_COMPRESSION_LZ4 &&
- bitmap_fmt_is_rgb(bitmap.format) &&
- red_channel_client_test_remote_cap(&dcc->common.base,
- SPICE_DISPLAY_CAP_LZ4_COMPRESSION)) {
- comp_succeeded = dcc_compress_image_lz4(dcc, &red_image, &bitmap, &comp_send_data, groupid);
-#endif
- } else if (comp_mode != SPICE_IMAGE_COMPRESSION_OFF) {
- comp_succeeded = dcc_compress_image_lz(dcc, &red_image, &bitmap, &comp_send_data, groupid);
- }
+ int comp_succeeded = dcc_compress_image(dcc, &red_image, &bitmap, NULL, item->can_lossy, &comp_send_data);
surface_lossy_region = &dcc->surface_client_lossy_region[item->surface_id];
if (comp_succeeded) {
@@ -2029,7 +1989,7 @@ static void red_marshall_image(RedChannelClient *rcc, SpiceMarshaller *m, ImageI
spice_marshall_Palette(lzplt_palette_out, comp_send_data.lzplt_palette);
}
- if (lossy_comp) {
+ if (spice_image_descriptor_is_lossy(&red_image.descriptor)) {
region_add(surface_lossy_region, ©.base.box);
} else {
region_remove(surface_lossy_region, ©.base.box);
commit faa907e3c686ea0d003da3ddcb66818b803a2b81
Author: Pavel Grunt <pgrunt at redhat.com>
Date: Wed Jan 20 14:15:23 2016 +0100
dcc_compress_image: Handle NULL drawable
It will be used in the following commit.
The GLZ compression cannot be used when the drawable is NULL.
Acked-by: Frediano Ziglio <fziglio at redhat.com>
diff --git a/server/dcc.c b/server/dcc.c
index 2568e24..613d7af 100644
--- a/server/dcc.c
+++ b/server/dcc.c
@@ -1037,6 +1037,7 @@ int dcc_compress_image(DisplayChannelClient *dcc,
DisplayChannel *display_channel = DCC_TO_DC(dcc);
SpiceImageCompression image_compression = dcc->image_compression;
int quic_compress = FALSE;
+ uint32_t group_id;
if ((image_compression == SPICE_IMAGE_COMPRESSION_OFF) ||
((src->y * src->stride) < MIN_SIZE_TO_COMPRESS)) { // TODO: change the size cond
@@ -1067,7 +1068,8 @@ int dcc_compress_image(DisplayChannelClient *dcc,
if ((src->x < MIN_DIMENSION_TO_QUIC) || (src->y < MIN_DIMENSION_TO_QUIC)) {
quic_compress = FALSE;
} else {
- if (drawable->copy_bitmap_graduality == BITMAP_GRADUAL_INVALID) {
+ if (drawable == NULL ||
+ drawable->copy_bitmap_graduality == BITMAP_GRADUAL_INVALID) {
quic_compress = bitmap_fmt_has_graduality(src->format) &&
bitmap_get_graduality_level(src) == BITMAP_GRADUAL_HIGH;
} else {
@@ -1080,6 +1082,12 @@ int dcc_compress_image(DisplayChannelClient *dcc,
}
}
+ if (drawable != NULL) {
+ group_id = drawable->group_id;
+ } else {
+ group_id = red_worker_get_memslot(display_channel->common.worker)->internal_groupslot_id;
+ }
+
if (quic_compress) {
#ifdef COMPRESS_DEBUG
spice_info("QUIC compress");
@@ -1090,20 +1098,17 @@ int dcc_compress_image(DisplayChannelClient *dcc,
(image_compression == SPICE_IMAGE_COMPRESSION_AUTO_GLZ))) {
// if we use lz for alpha, the stride can't be extra
if (src->format != SPICE_BITMAP_FMT_RGBA || !bitmap_has_extra_stride(src)) {
- return dcc_compress_image_jpeg(dcc, dest,
- src, o_comp_data, drawable->group_id);
+ return dcc_compress_image_jpeg(dcc, dest, src, o_comp_data, group_id);
}
}
- return dcc_compress_image_quic(dcc, dest,
- src, o_comp_data, drawable->group_id);
+ return dcc_compress_image_quic(dcc, dest, src, o_comp_data, group_id);
} else {
int glz;
int ret;
if ((image_compression == SPICE_IMAGE_COMPRESSION_AUTO_GLZ) ||
(image_compression == SPICE_IMAGE_COMPRESSION_GLZ)) {
- glz = bitmap_fmt_has_graduality(src->format) && (
- (src->x * src->y) < glz_enc_dictionary_get_size(
- dcc->glz_dict->dict));
+ glz = drawable != NULL && bitmap_fmt_has_graduality(src->format) &&
+ ((src->x * src->y) < glz_enc_dictionary_get_size(dcc->glz_dict->dict));
} else if ((image_compression == SPICE_IMAGE_COMPRESSION_AUTO_LZ) ||
(image_compression == SPICE_IMAGE_COMPRESSION_LZ) ||
(image_compression == SPICE_IMAGE_COMPRESSION_LZ4)) {
@@ -1132,12 +1137,10 @@ int dcc_compress_image(DisplayChannelClient *dcc,
bitmap_fmt_is_rgb(src->format) &&
red_channel_client_test_remote_cap(&dcc->common.base,
SPICE_DISPLAY_CAP_LZ4_COMPRESSION)) {
- ret = dcc_compress_image_lz4(dcc, dest, src, o_comp_data,
- drawable->group_id);
+ ret = dcc_compress_image_lz4(dcc, dest, src, o_comp_data, group_id);
} else
#endif
- ret = dcc_compress_image_lz(dcc, dest, src, o_comp_data,
- drawable->group_id);
+ ret = dcc_compress_image_lz(dcc, dest, src, o_comp_data, group_id);
#ifdef COMPRESS_DEBUG
spice_info("LZ LOCAL compress");
#endif
More information about the Spice-commits
mailing list