[Spice-commits] 2 commits - common/canvas_base.c
Christophe Fergau
teuf at kemper.freedesktop.org
Fri Jan 23 07:24:53 PST 2015
common/canvas_base.c | 116 +++++----------------------------------------------
1 file changed, 12 insertions(+), 104 deletions(-)
New commits:
commit ac26fd7acbe863964148b960a949ec87cbfb56c1
Author: Christophe Fergeau <cfergeau at redhat.com>
Date: Wed Jan 21 17:51:53 2015 +0100
Remove redundant #if defined(SW_CANVAS_CACHE) || defined(SW_CANVAS_IMAGE_CACHE)
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.
diff --git a/common/canvas_base.c b/common/canvas_base.c
index e6d5399..64d0aae 100644
--- a/common/canvas_base.c
+++ b/common/canvas_base.c
@@ -141,9 +141,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
@@ -1059,7 +1057,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,
@@ -1253,36 +1250,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);
@@ -1582,7 +1549,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);
}
@@ -1597,7 +1563,7 @@ static pixman_image_t *canvas_get_mask(CanvasBase *canvas, SpiceQMask *mask, int
surface = inv_surf;
}
}
-#endif
+
return surface;
}
@@ -3581,9 +3547,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
commit 062bf67442e80b138f4240b017b307e3915c4489
Author: Christophe Fergeau <cfergeau at redhat.com>
Date: Wed Jan 21 17:50:42 2015 +0100
Remove unused 'invers' arg from canvas_get_*
All canvas_get_{quic,jpeg,lz4,jpeg_alpha,lz} methods have an 'invers'
argument, but are always called with that argument being 0, so we can
drop it from the argument list, and remove the code triggerring when
it's true.
diff --git a/common/canvas_base.c b/common/canvas_base.c
index ddcbe32..e6d5399 100644
--- a/common/canvas_base.c
+++ b/common/canvas_base.c
@@ -375,7 +375,7 @@ static pixman_format_code_t canvas_get_target_format(CanvasBase *canvas,
}
static pixman_image_t *canvas_get_quic(CanvasBase *canvas, SpiceImage *image,
- int invers, int want_original)
+ int want_original)
{
pixman_image_t *surface = NULL;
QuicData *quic_data = &canvas->quic_data;
@@ -452,20 +452,6 @@ static pixman_image_t *canvas_get_quic(CanvasBase *canvas, SpiceImage *image,
return NULL;
}
- if (invers) {
- uint8_t *end = dest + height * stride;
- for (; dest != end; dest += stride) {
- uint32_t *pix;
- uint32_t *end_pix;
-
- pix = (uint32_t *)dest;
- end_pix = pix + width;
- for (; pix < end_pix; pix++) {
- *pix ^= 0xffffffff;
- }
- }
- }
-
#ifdef DEBUG_DUMP_COMPRESS
dump_surface(surface, 0);
#endif
@@ -497,7 +483,7 @@ static void dump_jpeg(uint8_t* data, int data_size)
}
#endif
-static pixman_image_t *canvas_get_jpeg(CanvasBase *canvas, SpiceImage *image, int invers)
+static pixman_image_t *canvas_get_jpeg(CanvasBase *canvas, SpiceImage *image)
{
pixman_image_t *surface = NULL;
int stride;
@@ -527,19 +513,6 @@ static pixman_image_t *canvas_get_jpeg(CanvasBase *canvas, SpiceImage *image, in
canvas->jpeg->ops->decode(canvas->jpeg, dest, stride, SPICE_BITMAP_FMT_32BIT);
- if (invers) {
- uint8_t *end = dest + height * stride;
- for (; dest != end; dest += stride) {
- uint32_t *pix;
- uint32_t *end_pix;
-
- pix = (uint32_t *)dest;
- end_pix = pix + width;
- for (; pix < end_pix; pix++) {
- *pix ^= 0x00ffffff;
- }
- }
- }
#ifdef DUMP_JPEG
dump_jpeg(image->u.jpeg.data, image->u.jpeg.data_size);
#endif
@@ -547,7 +520,7 @@ static pixman_image_t *canvas_get_jpeg(CanvasBase *canvas, SpiceImage *image, in
}
#ifdef USE_LZ4
-static pixman_image_t *canvas_get_lz4(CanvasBase *canvas, SpiceImage *image, int invers)
+static pixman_image_t *canvas_get_lz4(CanvasBase *canvas, SpiceImage *image)
{
pixman_image_t *surface = NULL;
int dec_size, enc_size;
@@ -604,8 +577,7 @@ static pixman_image_t *canvas_get_lz4(CanvasBase *canvas, SpiceImage *image, int
}
#endif
-static pixman_image_t *canvas_get_jpeg_alpha(CanvasBase *canvas,
- SpiceImage *image, int invers)
+static pixman_image_t *canvas_get_jpeg_alpha(CanvasBase *canvas, SpiceImage *image)
{
pixman_image_t *surface = NULL;
int stride;
@@ -667,19 +639,6 @@ static pixman_image_t *canvas_get_jpeg_alpha(CanvasBase *canvas,
}
lz_decode(lz_data->lz, LZ_IMAGE_TYPE_XXXA, decomp_alpha_buf);
- if (invers) {
- uint8_t *end = dest + height * stride;
- for (; dest != end; dest += stride) {
- uint32_t *pix;
- uint32_t *end_pix;
-
- pix = (uint32_t *)dest;
- end_pix = pix + width;
- for (; pix < end_pix; pix++) {
- *pix ^= 0x00ffffff;
- }
- }
- }
#ifdef DUMP_JPEG
dump_jpeg(image->u.jpeg_alpha.data, image->u.jpeg_alpha.jpeg_size);
#endif
@@ -779,7 +738,7 @@ static inline SpicePalette *canvas_get_localized_palette(CanvasBase *canvas, Spi
return copy;
}
-static pixman_image_t *canvas_get_lz(CanvasBase *canvas, SpiceImage *image, int invers,
+static pixman_image_t *canvas_get_lz(CanvasBase *canvas, SpiceImage *image,
int want_original)
{
LzData *lz_data = &canvas->lz_data;
@@ -881,21 +840,6 @@ static pixman_image_t *canvas_get_lz(CanvasBase *canvas, SpiceImage *image, int
lz_decode(lz_data->lz, as_type, decomp_buf);
- if (invers) {
- uint8_t *line = src;
- uint8_t *end = src + height * stride;
- for (; line != end; line += stride) {
- uint32_t *pix;
- uint32_t *end_pix;
-
- pix = (uint32_t *)line;
- end_pix = pix + width;
- for (; pix < end_pix; pix++) {
- *pix ^= 0xffffffff;
- }
- }
- }
-
if (free_palette) {
free(palette);
}
@@ -1159,30 +1103,30 @@ static pixman_image_t *canvas_get_image_internal(CanvasBase *canvas, SpiceImage
switch (descriptor->type) {
case SPICE_IMAGE_TYPE_QUIC: {
- surface = canvas_get_quic(canvas, image, 0, want_original);
+ surface = canvas_get_quic(canvas, image, want_original);
break;
}
#if defined(SW_CANVAS_CACHE)
case SPICE_IMAGE_TYPE_LZ_PLT: {
- surface = canvas_get_lz(canvas, image, 0, want_original);
+ surface = canvas_get_lz(canvas, image, want_original);
break;
}
case SPICE_IMAGE_TYPE_LZ_RGB: {
- surface = canvas_get_lz(canvas, image, 0, want_original);
+ surface = canvas_get_lz(canvas, image, want_original);
break;
}
#endif
case SPICE_IMAGE_TYPE_JPEG: {
- surface = canvas_get_jpeg(canvas, image, 0);
+ surface = canvas_get_jpeg(canvas, image);
break;
}
case SPICE_IMAGE_TYPE_JPEG_ALPHA: {
- surface = canvas_get_jpeg_alpha(canvas, image, 0);
+ surface = canvas_get_jpeg_alpha(canvas, image);
break;
}
case SPICE_IMAGE_TYPE_LZ4: {
#ifdef USE_LZ4
- surface = canvas_get_lz4(canvas, image, 0);
+ surface = canvas_get_lz4(canvas, image);
#else
spice_warning("Lz4 compression algorithm not supported.\n");
surface = NULL;
More information about the Spice-commits
mailing list