[Spice-devel] [spice-common 1/2] Remove redundant #if defined(SW_CANVAS_CACHE) || defined(SW_CANVAS_IMAGE_CACHE)

Christophe Fergeau cfergeau at redhat.com
Thu Jan 22 08:43:26 PST 2015


SW_CANVAS_CACHE is always defined when building spice-gtk,
SW_CANVAS_IMAGE_CACHE is always defined when building spice-server, and
they are the only 2 users of spice-common. Moreover, build when none of
these is defined is broken.
---
 common/canvas_base.c | 38 +-------------------------------------
 1 file changed, 1 insertion(+), 37 deletions(-)

diff --git a/common/canvas_base.c b/common/canvas_base.c
index a1bfc27..c38e8ac 100644
--- a/common/canvas_base.c
+++ b/common/canvas_base.c
@@ -142,9 +142,7 @@ typedef struct CanvasBase {
     int height;
     pixman_region32_t canvas_region;
 
-#if defined(SW_CANVAS_CACHE) || defined(SW_CANVAS_IMAGE_CACHE)
     SpiceImageCache *bits_cache;
-#endif
 #ifdef SW_CANVAS_CACHE
     SpicePaletteCache *palette_cache;
 #endif
@@ -1116,7 +1114,6 @@ static int image_has_palette_to_cache(SpiceImage *image)
 }
 #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,
@@ -1310,36 +1307,6 @@ static pixman_image_t *canvas_get_image_internal(CanvasBase *canvas, SpiceImage
     return surface;
 }
 
-#else
-
-static pixman_image_t *canvas_get_image_internal(CanvasBase *canvas, SpiceImage *image,
-                                                 int want_original, int real_get)
-{
-    SpiceImageDescriptor *descriptor = &image->descriptor;
-    pixman_format_code_t format;
-
-    /* When touching, never load image. */
-    if (!real_get) {
-        return NULL;
-    }
-
-    switch (descriptor->type) {
-    case SPICE_IMAGE_TYPE_QUIC: {
-        return canvas_get_quic(canvas, image, 0);
-    }
-    case SPICE_IMAGE_TYPE_BITMAP: {
-        return canvas_get_bits(canvas, &image->u.bitmap, want_original, &format);
-    }
-    default:
-        spice_warn_if_reached();
-        return NULL;
-    }
-
-    return NULL;
-}
-
-#endif
-
 static SpiceCanvas *canvas_get_surface_mask(CanvasBase *canvas, SpiceImage *image)
 {
     return canvas_get_surface_mask_internal(canvas, image);
@@ -1639,7 +1606,6 @@ static pixman_image_t *canvas_get_mask(CanvasBase *canvas, SpiceQMask *mask, int
         return NULL;
     }
 
-#if defined(SW_CANVAS_CACHE) || defined(SW_CANVAS_IMAGE_CACHE)
     if (cache_me) {
         canvas->bits_cache->ops->put(canvas->bits_cache, image->descriptor.id, surface);
     }
@@ -1654,7 +1620,7 @@ static pixman_image_t *canvas_get_mask(CanvasBase *canvas, SpiceQMask *mask, int
             surface = inv_surf;
         }
     }
-#endif
+
     return surface;
 }
 
@@ -3638,9 +3604,7 @@ static int canvas_base_init(CanvasBase *canvas, SpiceCanvasOps *ops,
                               canvas->width,
                               canvas->height);
 
-#if defined(SW_CANVAS_CACHE) || defined(SW_CANVAS_IMAGE_CACHE)
     canvas->bits_cache = bits_cache;
-#endif
 #ifdef SW_CANVAS_CACHE
     canvas->palette_cache = palette_cache;
 #endif
-- 
2.1.0



More information about the Spice-devel mailing list