[Spice-devel] [PATCH 2/8] Make glz_decoder non-optional canvas_base in canvas constructors

alexl at redhat.com alexl at redhat.com
Mon Mar 8 09:33:53 PST 2010


From: Alexander Larsson <alexl at redhat.com>

It can still be NULL, but we simplify the headers by always including it.
There is no practical performance difference here.
---
 common/cairo_canvas.c |    7 +------
 common/cairo_canvas.h |    2 --
 common/canvas_base.c  |   13 ++++++++-----
 common/gdi_canvas.c   |    8 +-------
 common/gl_canvas.c    |    7 +------
 common/gl_canvas.h    |    2 --
 server/red_worker.c   |    4 ++--
 7 files changed, 13 insertions(+), 30 deletions(-)

diff --git a/common/cairo_canvas.c b/common/cairo_canvas.c
index ed815d1..a3211de 100644
--- a/common/cairo_canvas.c
+++ b/common/cairo_canvas.c
@@ -2155,9 +2155,7 @@ CairoCanvas *canvas_create(pixman_image_t *image, int bits,
 #else
 CairoCanvas *canvas_create(pixman_image_t *image, int bits
 #endif
-#ifdef USE_GLZ
                             , SpiceGlzDecoder *glz_decoder
-#endif
 #ifndef CAIRO_CANVAS_NO_CHUNKS
                            , void *get_virt_opaque, get_virt_fn_t get_virt,
                            void *validate_virt_opaque, validate_virt_fn_t validate_virt
@@ -2181,10 +2179,7 @@ CairoCanvas *canvas_create(pixman_image_t *image, int bits
 #else
     init_ok = canvas_base_init(&canvas->base, bits
 #endif
-#ifdef USE_GLZ
-                               ,
-                               glz_decoder
-#endif
+                               , glz_decoder
 #ifndef CAIRO_CANVAS_NO_CHUNKS
                                ,
                                get_virt_opaque,
diff --git a/common/cairo_canvas.h b/common/cairo_canvas.h
index 390c61c..3800903 100644
--- a/common/cairo_canvas.h
+++ b/common/cairo_canvas.h
@@ -69,9 +69,7 @@ CairoCanvas *canvas_create(pixman_image_t *image, int bits,
 #else
 CairoCanvas *canvas_create(pixman_image_t *image, int bits
 #endif
-#ifdef USE_GLZ
                            , SpiceGlzDecoder *glz_decoder
-#endif
 #ifndef CAIRO_CANVAS_NO_CHUNKS
                            , void *get_virt_opaque, get_virt_fn_t get_virt,
                            void *validate_virt_opaque, validate_virt_fn_t validate_virt
diff --git a/common/canvas_base.c b/common/canvas_base.c
index 8bac592..aeb1cb5 100644
--- a/common/canvas_base.c
+++ b/common/canvas_base.c
@@ -622,6 +622,11 @@ static pixman_image_t *canvas_get_glz(CanvasBase *canvas, LZImage *image)
 #ifdef WIN32
     canvas->glz_data.decode_data.dc = canvas->dc;
 #endif
+
+    if (canvas->glz_data.decoder == NULL) {
+        CANVAS_ERROR("glz not supported");
+    }
+
     canvas->glz_data.decoder->ops->decode(canvas->glz_data.decoder,
                                           image->lz_rgb.data, NULL,
                                           &canvas->glz_data.decode_data);
@@ -816,7 +821,8 @@ static pixman_image_t *canvas_get_image_internal(CanvasBase *canvas, SPICE_ADDRE
         break;
     }
 #endif
-#ifdef USE_GLZ
+
+#if defined(CAIRO_CANVAS_CACHE)
     case SPICE_IMAGE_TYPE_GLZ_RGB: {
         access_test(canvas, descriptor, sizeof(SpiceLZRGBImage));
         LZImage *image = (LZImage *)descriptor;
@@ -824,6 +830,7 @@ static pixman_image_t *canvas_get_image_internal(CanvasBase *canvas, SPICE_ADDRE
         break;
     }
 #endif
+
     case SPICE_IMAGE_TYPE_FROM_CACHE:
         return canvas->bits_cache->ops->get(canvas->bits_cache, descriptor->id);
     case SPICE_IMAGE_TYPE_BITMAP: {
@@ -1546,9 +1553,7 @@ static int canvas_base_init(CanvasBase *canvas, int depth,
 #else
 static int canvas_base_init(CanvasBase *canvas, int depth
 #endif
-#ifdef USE_GLZ
                             , SpiceGlzDecoder *glz_decoder
-#endif
 #ifndef CAIRO_CANVAS_NO_CHUNKS
                            , void *get_virt_opaque, get_virt_fn_t get_virt,
                            void *validate_virt_opaque, validate_virt_fn_t validate_virt
@@ -1583,9 +1588,7 @@ static int canvas_base_init(CanvasBase *canvas, int depth
             return 0;
     }
 #endif
-#ifdef USE_GLZ
     canvas->glz_data.decoder = glz_decoder;
-#endif
 
     if (depth == 16) {
         canvas->color_shift = 5;
diff --git a/common/gdi_canvas.c b/common/gdi_canvas.c
index c4750a8..40305df 100644
--- a/common/gdi_canvas.c
+++ b/common/gdi_canvas.c
@@ -1707,9 +1707,7 @@ GdiCanvas *gdi_canvas_create(HDC dc, int bits,
 #else
 GdiCanvas *gdi_canvas_create(HDC dc, int bits
 #endif
-#ifdef USE_GLZ
                             , SpiceGlzDecoder *glz_decoder
-#endif
                             )
 {
     GdiCanvas *canvas;
@@ -1729,11 +1727,7 @@ GdiCanvas *gdi_canvas_create(HDC dc, int bits
 #else
     init_ok = gdi_canvas_base_init(&canvas->base, bits
 #endif
-#ifdef USE_GLZ
-                               ,
-                               glz_decoder
-#endif
-                               );
+                               , glz_decoder);
     canvas->dc = dc;
     canvas->lock = lock;
     return canvas;
diff --git a/common/gl_canvas.c b/common/gl_canvas.c
index 6b5eda9..f173194 100644
--- a/common/gl_canvas.c
+++ b/common/gl_canvas.c
@@ -811,9 +811,7 @@ GLCanvas *gl_canvas_create(void *usr_data, int width, int height, int depth,
 #else
 GLCanvas *gl_canvas_create(void *usr_data, int width, int height, int depth
 #endif
-#ifdef USE_GLZ
                            , SpiceGlzDecoder *glz_decoder
-#endif
 #ifndef CAIRO_CANVAS_NO_CHUNKS
                            , void *get_virt_opaque, get_virt_fn_t get_virt,
                            void *validate_virt_opaque, validate_virt_fn_t validate_virt
@@ -843,10 +841,7 @@ GLCanvas *gl_canvas_create(void *usr_data, int width, int height, int depth
 #else
     init_ok = canvas_base_init(&canvas->base, depth
 #endif
-#ifdef USE_GLZ
-                               ,
-                               glz_decoder
-#endif
+                               , glz_decoder
 #ifndef CAIRO_CANVAS_NO_CHUNKS
                                ,
                                get_virt_opaque,
diff --git a/common/gl_canvas.h b/common/gl_canvas.h
index 1c57340..ec0cbdb 100644
--- a/common/gl_canvas.h
+++ b/common/gl_canvas.h
@@ -64,9 +64,7 @@ GLCanvas *gl_canvas_create(void *usr_data, int width, int height, int depth,
 #else
 GLCanvas *gl_canvas_create(void *usr_data, int width, int height, int depth
 #endif
-#ifdef USE_GLZ
                            , SpiceGlzDecoder *glz_decoder
-#endif
 #ifndef CAIRO_CANVAS_NO_CHUNKS
                            , void *get_virt_opaque, get_virt_fn_t get_virt,
                            void *validate_virt_opaque, validate_virt_fn_t validate_virt
diff --git a/server/red_worker.c b/server/red_worker.c
index 100f309..52d8451 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -7490,7 +7490,7 @@ static CairoCanvas *create_cairo_context(RedWorker *worker, uint32_t width, uint
     if (surface == NULL) {
         red_error("create cairo surface failed");
     }
-    canvas = canvas_create(surface, depth, &worker->image_cache.base,
+    canvas = canvas_create(surface, depth, &worker->image_cache.base, NULL,
                            worker, cb_get_virt_preload_group, worker,
                            cb_validate_virt_preload_group);
     pixman_image_unref (surface);
@@ -7554,7 +7554,7 @@ static GLCanvas *create_ogl_context_common(RedWorker *worker, OGLCtx *ctx, uint3
     GLCanvas *canvas;
 
     oglctx_make_current(ctx);
-    if (!(canvas = gl_canvas_create(ctx, width, height, depth, &worker->image_cache.base,
+    if (!(canvas = gl_canvas_create(ctx, width, height, depth, &worker->image_cache.base, NULL,
                                     worker, cb_get_virt_preload_group,
                                     worker, cb_validate_virt_preload_group))) {
         return NULL;
-- 
1.6.6



More information about the Spice-devel mailing list