diff options
author | Yonit Halperin <yhalperi@redhat.com> | 2013-10-09 16:56:38 -0400 |
---|---|---|
committer | Yonit Halperin <yhalperi@redhat.com> | 2013-10-23 15:44:11 -0400 |
commit | 74bfa828eb5b6182737ead6d55cf84ce62dbf441 (patch) | |
tree | ce2430bd3aed842308a011879c3ef14a1aa0af42 | |
parent | f60cf5bd72c762fb1c149463cf3a9e946f0d3469 (diff) |
red_worker/fill_bits: separate filling & encoding bitmap SpiceImage data from marshalling it
-rw-r--r-- | server/red_worker.c | 74 |
1 files changed, 41 insertions, 33 deletions
diff --git a/server/red_worker.c b/server/red_worker.c index b1d6528..b84dec0 100644 --- a/server/red_worker.c +++ b/server/red_worker.c @@ -6697,6 +6697,41 @@ static void spice_image_set_surface_info(DisplayChannelClient *dcc, dst_image->u.surface.surface_id = surface_id; } +static void spice_image_encode_bitmap(DisplayChannelClient *dcc, + SpiceImage *src_image, + Drawable *drawable, + SpiceImage *dst_image, + int can_lossy) +{ + SpiceBitmap *src_bitmap = &src_image->u.bitmap; + +#ifdef DUMP_BITMAP + dump_bitmap(src_bitmap); +#endif + /* + * Images must be added to the cache only after they are compressed + * in order to prevent starvation in the client between pixmap_cache and + * global dictionary (in cases of multiple monitors) + */ + if (!red_compress_image(dcc, dst_image, src_bitmap, + drawable, can_lossy)) { + SpiceBitmap *dst_bitmap = &dst_image->u.bitmap; + *dst_bitmap = *src_bitmap; + red_display_add_image_to_pixmap_cache(&dcc->common.base, src_image, dst_image, FALSE); + + dst_bitmap->flags = src_bitmap->flags & SPICE_BITMAP_FLAGS_TOP_DOWN; + + fill_palette(dcc, dst_bitmap->palette, &dst_bitmap->flags); + + } else { + spice_assert(!spice_image_is_lossy_compressed(dst_image) || can_lossy); + red_display_add_image_to_pixmap_cache(&dcc->common.base, + src_image, + dst_image, + spice_image_is_lossy_compressed(dst_image)); + } +} + typedef enum { FILL_BITS_TYPE_INVALID, FILL_BITS_TYPE_CACHE, @@ -6737,41 +6772,14 @@ static FillBitsType fill_bits(DisplayChannelClient *dcc, SpiceMarshaller *m, spice_image_set_surface_info(dcc, simage, &image); spice_image_marshall(&image, m, TRUE); return FILL_BITS_TYPE_SURFACE; - case SPICE_IMAGE_TYPE_BITMAP: { - SpiceBitmap *bitmap = &image.u.bitmap; -#ifdef DUMP_BITMAP - dump_bitmap(&simage->u.bitmap); -#endif - /* Images must be added to the cache only after they are compressed - in order to prevent starvation in the client between pixmap_cache and - global dictionary (in cases of multiple monitors) */ - if (!red_compress_image(dcc, &image, &simage->u.bitmap, - drawable, can_lossy)) { - SpicePalette *palette; - - red_display_add_image_to_pixmap_cache(rcc, simage, &image, FALSE); - - *bitmap = simage->u.bitmap; - bitmap->flags = bitmap->flags & SPICE_BITMAP_FLAGS_TOP_DOWN; - - palette = bitmap->palette; - fill_palette(dcc, palette, &bitmap->flags); - spice_image_marshall(&image, m, TRUE); - - return FILL_BITS_TYPE_BITMAP; - } else { - int is_lossy = spice_image_is_lossy_compressed(&image); - - red_display_add_image_to_pixmap_cache(rcc, simage, &image, - is_lossy); - spice_image_marshall(&image, m, TRUE); + case SPICE_IMAGE_TYPE_BITMAP: + spice_image_encode_bitmap(dcc, simage, drawable, &image, can_lossy); + spice_image_marshall(&image, m, TRUE); - spice_assert(!is_lossy || can_lossy); - return (is_lossy ? FILL_BITS_TYPE_COMPRESS_LOSSY : - FILL_BITS_TYPE_COMPRESS_LOSSLESS); - } + return spice_image_is_lossy_compressed(&image) ? + FILL_BITS_TYPE_COMPRESS_LOSSY : + FILL_BITS_TYPE_COMPRESS_LOSSLESS; break; - } case SPICE_IMAGE_TYPE_QUIC: red_display_add_image_to_pixmap_cache(rcc, simage, &image, FALSE); image.u.quic = simage->u.quic; |