[Spice-devel] [PATCH spice-server 1/2] image compression: Handle NULL drawable

Pavel Grunt pgrunt at redhat.com
Fri Jun 26 08:18:18 PDT 2015


---
 server/red_worker.c | 23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)

diff --git a/server/red_worker.c b/server/red_worker.c
index 515262d..3a305d8 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -6560,6 +6560,13 @@ static inline int red_compress_image(DisplayChannelClient *dcc,
     spice_image_compression_t image_compression =
         display_channel->common.worker->image_compression;
     int quic_compress = FALSE;
+    uint32_t group_id;
+
+    if (drawable != NULL) {
+        group_id = drawable->group_id;
+    } else {
+        group_id = display_channel->common.worker->mem_slots.internal_groupslot_id;
+    }
 
     if ((image_compression == SPICE_IMAGE_COMPRESS_OFF) ||
         ((src->y * src->stride) < MIN_SIZE_TO_COMPRESS)) { // TODO: change the size cond
@@ -6590,10 +6597,11 @@ static inline int red_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) &&
                             (_get_bitmap_graduality_level(display_channel->common.worker, src,
-                                                          drawable->group_id) ==
+                                                          group_id) ==
                              BITMAP_GRADUAL_HIGH);
                     } else {
                         quic_compress = (drawable->copy_bitmap_graduality == BITMAP_GRADUAL_HIGH);
@@ -6616,17 +6624,18 @@ static inline int red_compress_image(DisplayChannelClient *dcc,
             // if we use lz for alpha, the stride can't be extra
             if (src->format != SPICE_BITMAP_FMT_RGBA || !_stride_is_extra(src)) {
                 return red_jpeg_compress_image(dcc, dest,
-                                               src, o_comp_data, drawable->group_id);
+                                               src, o_comp_data, group_id);
             }
         }
         return red_quic_compress_image(dcc, dest,
-                                       src, o_comp_data, drawable->group_id);
+                                       src, o_comp_data, group_id);
     } else {
         int glz;
         int ret;
         if ((image_compression == SPICE_IMAGE_COMPRESS_AUTO_GLZ) ||
             (image_compression == SPICE_IMAGE_COMPRESS_GLZ)) {
-            glz = BITMAP_FMT_HAS_GRADUALITY(src->format) && (
+            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_COMPRESS_AUTO_LZ) ||
@@ -6658,11 +6667,11 @@ static inline int red_compress_image(DisplayChannelClient *dcc,
                 red_channel_client_test_remote_cap(&dcc->common.base,
                         SPICE_DISPLAY_CAP_LZ4_COMPRESSION)) {
                 ret = red_lz4_compress_image(dcc, dest, src, o_comp_data,
-                                             drawable->group_id);
+                                             group_id);
             } else
 #endif
                 ret = red_lz_compress_image(dcc, dest, src, o_comp_data,
-                                            drawable->group_id);
+                                            group_id);
 #ifdef COMPRESS_DEBUG
             spice_info("LZ LOCAL compress");
 #endif
-- 
2.4.4



More information about the Spice-devel mailing list