diff options
author | Yonit Halperin <yhalperi@redhat.com> | 2013-01-31 11:47:47 -0500 |
---|---|---|
committer | Yonit Halperin <yhalperi@redhat.com> | 2013-01-31 11:55:37 -0500 |
commit | df09927c3bb921f51a3a1f6ca09063bf44f1ee5b (patch) | |
tree | 2d84d2aa3bd3be5933b2e718e20865274b4c3d4f | |
parent | c08e04b478376e9503ea62b5a09ea679dc16c220 (diff) |
canvas_base: fix not caching palettes that belong to images that are not rendered
Fixes: fedora 875348, 826036
When an image is not rendered, we still need to check if it contains
a palette that needs to be cached.
This bug caused the client to crash due to not finding palettes
in the cache.
-rw-r--r-- | common/canvas_base.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/common/canvas_base.c b/common/canvas_base.c index 0ec8526..38a8497 100644 --- a/common/canvas_base.c +++ b/common/canvas_base.c @@ -1037,8 +1037,24 @@ static SpiceCanvas *canvas_get_surface_mask_internal(CanvasBase *canvas, SpiceIm return NULL; } -#if defined(SW_CANVAS_CACHE) || defined(SW_CANVAS_IMAGE_CACHE) +#if defined(SW_CANVAS_CACHE) +static int image_has_palette_to_cache(SpiceImage *image) +{ + SpiceImageDescriptor *descriptor = &image->descriptor; + + if (descriptor->type == SPICE_IMAGE_TYPE_BITMAP) { + return image->u.bitmap.palette && + (image->u.bitmap.flags & SPICE_BITMAP_FLAGS_PAL_CACHE_ME); + } else if (descriptor->type == SPICE_IMAGE_TYPE_LZ_PLT) { + return image->u.lz_plt.palette && + (image->u.lz_plt.flags & SPICE_BITMAP_FLAGS_PAL_CACHE_ME); + } + return FALSE; +} +#endif + +#if defined(SW_CANVAS_CACHE) || defined(SW_CANVAS_IMAGE_CACHE) //#define DEBUG_LZ /* If real get is FALSE, then only do whatever is needed but don't return an image. For instance, @@ -1064,6 +1080,7 @@ static pixman_image_t *canvas_get_image_internal(CanvasBase *canvas, SpiceImage !(descriptor->flags & SPICE_IMAGE_FLAGS_CACHE_ME) && #ifdef SW_CANVAS_CACHE !(descriptor->flags & SPICE_IMAGE_FLAGS_CACHE_REPLACE_ME) && + !image_has_palette_to_cache(image) && #endif (descriptor->type != SPICE_IMAGE_TYPE_GLZ_RGB) && (descriptor->type != SPICE_IMAGE_TYPE_ZLIB_GLZ_RGB)) { |