[Spice-commits] common/canvas_base.c

Yonit Halperin yhalperi at kemper.freedesktop.org
Thu Jan 31 13:44:44 PST 2013


 common/canvas_base.c |   19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

New commits:
commit df09927c3bb921f51a3a1f6ca09063bf44f1ee5b
Author: Yonit Halperin <yhalperi at redhat.com>
Date:   Thu Jan 31 11:47:47 2013 -0500

    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.

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)) {


More information about the Spice-commits mailing list