diff options
author | Alexander Larsson <alexl@redhat.com> | 2010-03-02 15:41:08 +0100 |
---|---|---|
committer | Alexander Larsson <alexl@redhat.com> | 2010-03-08 19:45:27 +0100 |
commit | c0fdcd1a10d0eae92fec9e00382b445d669c7428 (patch) | |
tree | 590429cdba9b115c90e5beaec90f1981ed513121 | |
parent | 04b35fe7ff6b09885a2af9ef8627b45b892e3fb0 (diff) | |
download | spice-c0fdcd1a10d0eae92fec9e00382b445d669c7428.tar.gz spice-c0fdcd1a10d0eae92fec9e00382b445d669c7428.tar.xz spice-c0fdcd1a10d0eae92fec9e00382b445d669c7428.zip |
Make canvas Glz decoder integration nicer
We use a dynamic interface similar to e.g. SpiceImageCache instead
of passing both function and opaque
-rw-r--r-- | client/canvas.cpp | 7 | ||||
-rw-r--r-- | client/canvas.h | 1 | ||||
-rw-r--r-- | client/glz_decoder.cpp | 14 | ||||
-rw-r--r-- | client/glz_decoder.h | 6 | ||||
-rw-r--r-- | client/red_cairo_canvas.cpp | 3 | ||||
-rw-r--r-- | client/red_gdi_canvas.cpp | 3 | ||||
-rw-r--r-- | client/red_gl_canvas.cpp | 3 | ||||
-rw-r--r-- | common/cairo_canvas.c | 5 | ||||
-rw-r--r-- | common/cairo_canvas.h | 2 | ||||
-rw-r--r-- | common/canvas_base.c | 13 | ||||
-rw-r--r-- | common/canvas_base.h | 14 | ||||
-rw-r--r-- | common/gdi_canvas.c | 5 | ||||
-rw-r--r-- | common/gdi_canvas.h | 3 | ||||
-rw-r--r-- | common/gl_canvas.c | 5 | ||||
-rw-r--r-- | common/gl_canvas.h | 2 |
15 files changed, 48 insertions, 38 deletions
diff --git a/client/canvas.cpp b/client/canvas.cpp index 24ebd01b..516a874c 100644 --- a/client/canvas.cpp +++ b/client/canvas.cpp @@ -212,10 +212,3 @@ void Canvas::draw_stroke(SpiceMsgDisplayDrawStroke& stroke, int size) localalize_attr(stroke.data.attr); draw_stroke(&stroke.base.box, &stroke.base.clip, &stroke.data); } - -void Canvas::glz_decode(void *opaque, uint8_t *data, SpicePalette *plt, void *usr_data) -{ - GlzDecoder* decoder = static_cast<GlzDecoder*>(opaque); - decoder->decode(data, plt, usr_data); -} - diff --git a/client/canvas.h b/client/canvas.h index 79400cc3..2f122638 100644 --- a/client/canvas.h +++ b/client/canvas.h @@ -295,7 +295,6 @@ protected: PaletteCache& palette_cache() { return _palette_cache;} GlzDecoder& glz_decoder() {return _glz_decoder;} - static void glz_decode(void *opaque, uint8_t *data, SpicePalette *plt, void *usr_data); private: void access_test(void* ptr, size_t size); diff --git a/client/glz_decoder.cpp b/client/glz_decoder.cpp index 0453aaae..30eecc14 100644 --- a/client/glz_decoder.cpp +++ b/client/glz_decoder.cpp @@ -1,3 +1,4 @@ +/* -*- Mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */ /* Copyright (C) 2009 Red Hat, Inc. @@ -19,12 +20,25 @@ #include "glz_decoder_config.h" #include "glz_decoder.h" +static void op_decode (SpiceGlzDecoder *decoder, + uint8_t *data, + SpicePalette *plt, + void *usr_data) +{ + GlzDecoder* _decoder = static_cast<GlzDecoder*>(decoder); + _decoder->decode(data, plt, usr_data); +} + GlzDecoder::GlzDecoder(GlzDecoderWindow &images_window, GlzDecodeHandler &usr_handler, GlzDecoderDebug &debug_calls) : _images_window (images_window) , _usr_handler (usr_handler) , _debug_calls (debug_calls) { + static SpiceGlzDecoderOps decoder_ops = { + op_decode, + }; + ops = &decoder_ops; } GlzDecoder::~GlzDecoder() diff --git a/client/glz_decoder.h b/client/glz_decoder.h index c2afa54e..2b797d8c 100644 --- a/client/glz_decoder.h +++ b/client/glz_decoder.h @@ -1,3 +1,4 @@ +/* -*- Mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */ /* Copyright (C) 2009 Red Hat, Inc. @@ -21,6 +22,7 @@ #include "lz_common.h" #include "glz_decoder_config.h" #include "glz_decoder_window.h" +#include "canvas_base.h" #include <spice/draw.h> @@ -47,9 +49,9 @@ public: This class implements the lz decoding algorithm */ -class GlzDecoder { +class GlzDecoder : public SpiceGlzDecoder +{ public: - GlzDecoder(GlzDecoderWindow &images_window, GlzDecodeHandler &usr_handler, GlzDecoderDebug &debug_calls); virtual ~GlzDecoder(); diff --git a/client/red_cairo_canvas.cpp b/client/red_cairo_canvas.cpp index 87023e17..97277fb3 100644 --- a/client/red_cairo_canvas.cpp +++ b/client/red_cairo_canvas.cpp @@ -102,8 +102,7 @@ void CCanvas::set_mode(int width, int height, int depth, RedWindow *win) if (!(_canvas = canvas_create(surface, depth, &pixmap_cache().base, &palette_cache().base, - &glz_decoder(), - glz_decode))) { + &glz_decoder()))) { THROW("create canvas failed"); } pixman_image_unref (surface); diff --git a/client/red_gdi_canvas.cpp b/client/red_gdi_canvas.cpp index 671fe82f..efdf5d4d 100644 --- a/client/red_gdi_canvas.cpp +++ b/client/red_gdi_canvas.cpp @@ -92,8 +92,7 @@ void GDICanvas::set_mode(int width, int height, int depth) &_pixmap->get_mutex(), depth, &pixmap_cache().base, &palette_cache().base, - &glz_decoder(), - glz_decode))) { + &glz_decoder()))) { THROW("create canvas failed"); } } diff --git a/client/red_gl_canvas.cpp b/client/red_gl_canvas.cpp index 65984257..76dabc71 100644 --- a/client/red_gl_canvas.cpp +++ b/client/red_gl_canvas.cpp @@ -99,8 +99,7 @@ void GCanvas::set_mode(int width, int height, int depth, RedWindow *win, if (!(_canvas = gl_canvas_create(NULL, width, height, depth, &pixmap_cache().base, &palette_cache().base, - &glz_decoder(), - glz_decode))) { + &glz_decoder()))) { THROW("create canvas failed"); } } diff --git a/common/cairo_canvas.c b/common/cairo_canvas.c index addb3d47..ed815d19 100644 --- a/common/cairo_canvas.c +++ b/common/cairo_canvas.c @@ -2156,7 +2156,7 @@ CairoCanvas *canvas_create(pixman_image_t *image, int bits, CairoCanvas *canvas_create(pixman_image_t *image, int bits #endif #ifdef USE_GLZ - , void *glz_decoder_opaque, glz_decode_fn_t glz_decode + , SpiceGlzDecoder *glz_decoder #endif #ifndef CAIRO_CANVAS_NO_CHUNKS , void *get_virt_opaque, get_virt_fn_t get_virt, @@ -2183,8 +2183,7 @@ CairoCanvas *canvas_create(pixman_image_t *image, int bits #endif #ifdef USE_GLZ , - glz_decoder_opaque, - glz_decode + glz_decoder #endif #ifndef CAIRO_CANVAS_NO_CHUNKS , diff --git a/common/cairo_canvas.h b/common/cairo_canvas.h index 205c62cb..390c61cf 100644 --- a/common/cairo_canvas.h +++ b/common/cairo_canvas.h @@ -70,7 +70,7 @@ CairoCanvas *canvas_create(pixman_image_t *image, int bits, CairoCanvas *canvas_create(pixman_image_t *image, int bits #endif #ifdef USE_GLZ - , void *glz_decoder_opaque, glz_decode_fn_t glz_decode + , SpiceGlzDecoder *glz_decoder #endif #ifndef CAIRO_CANVAS_NO_CHUNKS , void *get_virt_opaque, get_virt_fn_t get_virt, diff --git a/common/canvas_base.c b/common/canvas_base.c index 23039eb3..8bac5923 100644 --- a/common/canvas_base.c +++ b/common/canvas_base.c @@ -154,8 +154,7 @@ typedef struct LzData { } LzData; typedef struct GlzData { - void *decoder_opaque; - glz_decode_fn_t decode; + SpiceGlzDecoder *decoder; LzDecodeUsrData decode_data; } GlzData; @@ -623,8 +622,9 @@ static pixman_image_t *canvas_get_glz(CanvasBase *canvas, LZImage *image) #ifdef WIN32 canvas->glz_data.decode_data.dc = canvas->dc; #endif - canvas->glz_data.decode(canvas->glz_data.decoder_opaque, image->lz_rgb.data, NULL, - &canvas->glz_data.decode_data); + canvas->glz_data.decoder->ops->decode(canvas->glz_data.decoder, + image->lz_rgb.data, NULL, + &canvas->glz_data.decode_data); /* global_decode calls alloc_lz_image, which sets canvas->glz_data.surface */ return (canvas->glz_data.decode_data.out_surface); } @@ -1547,7 +1547,7 @@ static int canvas_base_init(CanvasBase *canvas, int depth, static int canvas_base_init(CanvasBase *canvas, int depth #endif #ifdef USE_GLZ - , void *glz_decoder_opaque, glz_decode_fn_t glz_decode + , SpiceGlzDecoder *glz_decoder #endif #ifndef CAIRO_CANVAS_NO_CHUNKS , void *get_virt_opaque, get_virt_fn_t get_virt, @@ -1584,8 +1584,7 @@ static int canvas_base_init(CanvasBase *canvas, int depth } #endif #ifdef USE_GLZ - canvas->glz_data.decoder_opaque = glz_decoder_opaque; - canvas->glz_data.decode = glz_decode; + canvas->glz_data.decoder = glz_decoder; #endif if (depth == 16) { diff --git a/common/canvas_base.h b/common/canvas_base.h index 78ece624..7796245c 100644 --- a/common/canvas_base.h +++ b/common/canvas_base.h @@ -26,6 +26,7 @@ typedef struct _SpiceImageCache SpiceImageCache; typedef struct _SpicePaletteCache SpicePaletteCache; +typedef struct _SpiceGlzDecoder SpiceGlzDecoder; typedef struct { void (*put)(SpiceImageCache *cache, @@ -52,8 +53,17 @@ struct _SpicePaletteCache { SpicePaletteCacheOps *ops; }; -typedef void (*glz_decode_fn_t)(void *glz_decoder_opaque, uint8_t *data, - SpicePalette *plt, void *usr_data); +typedef struct { + void (*decode)(SpiceGlzDecoder *decoder, + uint8_t *data, + SpicePalette *plt, + void *usr_data); +} SpiceGlzDecoderOps; + +struct _SpiceGlzDecoder { + SpiceGlzDecoderOps *ops; +}; + #ifndef CAIRO_CANVAS_NO_CHUNKS typedef void *(*get_virt_fn_t)(void *get_virt_opaque, unsigned long addr, uint32_t add_size); typedef void (*validate_virt_fn_t)(void *validate_virt_opaque, unsigned long virt, diff --git a/common/gdi_canvas.c b/common/gdi_canvas.c index ae477db4..c4750a8e 100644 --- a/common/gdi_canvas.c +++ b/common/gdi_canvas.c @@ -1708,7 +1708,7 @@ GdiCanvas *gdi_canvas_create(HDC dc, int bits, GdiCanvas *gdi_canvas_create(HDC dc, int bits #endif #ifdef USE_GLZ - , void *glz_decoder_opaque, glz_decode_fn_t glz_decode + , SpiceGlzDecoder *glz_decoder #endif ) { @@ -1731,8 +1731,7 @@ GdiCanvas *gdi_canvas_create(HDC dc, int bits #endif #ifdef USE_GLZ , - glz_decoder_opaque, - glz_decode + glz_decoder #endif ); canvas->dc = dc; diff --git a/common/gdi_canvas.h b/common/gdi_canvas.h index d9b8d219..12082d83 100644 --- a/common/gdi_canvas.h +++ b/common/gdi_canvas.h @@ -62,8 +62,7 @@ void gdi_canvas_set_access_params(GdiCanvas *canvas, unsigned long base, unsigne GdiCanvas *gdi_canvas_create(HDC dc, class Mutex *lock, int bits, SpiceImageCache *bits_cache, SpicePaletteCache *palette_cache, - void *glz_decoder_opaque, - glz_decode_fn_t glz_decode); + SpiceGlzDecoder *glz_decoder); void gdi_canvas_destroy(GdiCanvas *canvas); diff --git a/common/gl_canvas.c b/common/gl_canvas.c index 076090e9..6b5eda97 100644 --- a/common/gl_canvas.c +++ b/common/gl_canvas.c @@ -812,7 +812,7 @@ GLCanvas *gl_canvas_create(void *usr_data, int width, int height, int depth, GLCanvas *gl_canvas_create(void *usr_data, int width, int height, int depth #endif #ifdef USE_GLZ - , void *glz_decoder_opaque, glz_decode_fn_t glz_decode + , SpiceGlzDecoder *glz_decoder #endif #ifndef CAIRO_CANVAS_NO_CHUNKS , void *get_virt_opaque, get_virt_fn_t get_virt, @@ -845,8 +845,7 @@ GLCanvas *gl_canvas_create(void *usr_data, int width, int height, int depth #endif #ifdef USE_GLZ , - glz_decoder_opaque, - glz_decode + glz_decoder #endif #ifndef CAIRO_CANVAS_NO_CHUNKS , diff --git a/common/gl_canvas.h b/common/gl_canvas.h index 39b27923..1c573407 100644 --- a/common/gl_canvas.h +++ b/common/gl_canvas.h @@ -65,7 +65,7 @@ GLCanvas *gl_canvas_create(void *usr_data, int width, int height, int depth, GLCanvas *gl_canvas_create(void *usr_data, int width, int height, int depth #endif #ifdef USE_GLZ - , void *glz_decoder_opaque, glz_decode_fn_t glz_decode + , SpiceGlzDecoder *glz_decoder #endif #ifndef CAIRO_CANVAS_NO_CHUNKS , void *get_virt_opaque, get_virt_fn_t get_virt, |