mirror of
https://gitlab.uni-freiburg.de/opensourcevdi/spice
synced 2025-12-26 14:41:25 +00:00
Make canvas Glz decoder integration nicer
We use a dynamic interface similar to e.g. SpiceImageCache instead of passing both function and opaque
This commit is contained in:
parent
04b35fe7ff
commit
c0fdcd1a10
@ -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);
|
||||
}
|
||||
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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()
|
||||
|
||||
@ -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();
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
@ -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
|
||||
,
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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);
|
||||
|
||||
|
||||
@ -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
|
||||
,
|
||||
|
||||
@ -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,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user