diff options
author | Alexander Larsson <alexl@redhat.com> | 2010-02-08 15:38:24 +0100 |
---|---|---|
committer | Marc-André Lureau <marcandre.lureau@gmail.com> | 2012-03-20 15:25:37 +0100 |
commit | f9e187c619dea25079c6b4499aedf1ce65d4511a (patch) | |
tree | ee0c0e166616bc43d83a07500590adf8c6e4b46c /common/canvas_base.h | |
parent | 517e38ad0fcfdd2063c74f1d4958045a1fbd0b5d (diff) | |
download | spice-common-f9e187c619dea25079c6b4499aedf1ce65d4511a.tar.gz spice-common-f9e187c619dea25079c6b4499aedf1ce65d4511a.tar.xz spice-common-f9e187c619dea25079c6b4499aedf1ce65d4511a.zip |
Turn image and palette cache into c style dynamic interface
Instead of passing a bunch of function pointer and an opaque
pointer we make a real type and add a vtable pointer to it.
This means we can simplify all the canvas constructors, etc.
Diffstat (limited to 'common/canvas_base.h')
-rw-r--r-- | common/canvas_base.h | 36 |
1 files changed, 27 insertions, 9 deletions
diff --git a/common/canvas_base.h b/common/canvas_base.h index 15cf869..cc75087 100644 --- a/common/canvas_base.h +++ b/common/canvas_base.h @@ -24,15 +24,33 @@ #include "lz.h" #include <spice/draw.h> -#if defined(CAIRO_CANVAS_CACHE) || defined(CAIRO_CANVAS_IMAGE_CACHE) -typedef void (*bits_cache_put_fn_t)(void *bits_cache_opaque, uint64_t id, cairo_surface_t *surface); -typedef cairo_surface_t *(*bits_cache_get_fn_t)(void *bits_cache_opaque, uint64_t id); -#endif -#ifdef CAIRO_CANVAS_CACHE -typedef void (*palette_cache_put_fn_t)(void *palette_cache_opaque, SpicePalette *palette); -typedef SpicePalette *(*palette_cache_get_fn_t)(void *palette_cache_opaque, uint64_t id); -typedef void (*palette_cache_release_fn_t)(SpicePalette *palette); -#endif +typedef struct _SpiceImageCache SpiceImageCache; +typedef struct _SpicePaletteCache SpicePaletteCache; + +typedef struct { + void (*put)(SpiceImageCache *cache, + uint64_t id, + cairo_surface_t *surface); + cairo_surface_t *(*get)(SpiceImageCache *cache, + uint64_t id); +} SpiceImageCacheOps; + +struct _SpiceImageCache { + SpiceImageCacheOps *ops; +}; + +typedef struct { + void (*put)(SpicePaletteCache *cache, + SpicePalette *palette); + SpicePalette *(*get)(SpicePaletteCache *cache, + uint64_t id); + void (*release)(SpicePaletteCache *cache, + SpicePalette *palette); +} SpicePaletteCacheOps; + +struct _SpicePaletteCache { + SpicePaletteCacheOps *ops; +}; typedef void (*glz_decode_fn_t)(void *glz_decoder_opaque, uint8_t *data, SpicePalette *plt, void *usr_data); |