summaryrefslogtreecommitdiffstats
path: root/common/canvas_base.h
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2010-02-08 15:38:24 +0100
committerAlexander Larsson <alexl@redhat.com>2010-02-23 14:43:20 +0100
commit0b0342ee7ece8ea5a811cfb05c70f03ca4e3bde3 (patch)
tree7e4ce72080519d7d55df6f3dadc63b6784c0856b /common/canvas_base.h
parent7537acd630e8973c92bb769b56d78836372b30c2 (diff)
downloadspice-0b0342ee7ece8ea5a811cfb05c70f03ca4e3bde3.tar.gz
spice-0b0342ee7ece8ea5a811cfb05c70f03ca4e3bde3.tar.xz
spice-0b0342ee7ece8ea5a811cfb05c70f03ca4e3bde3.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.h36
1 files changed, 27 insertions, 9 deletions
diff --git a/common/canvas_base.h b/common/canvas_base.h
index 15cf869e..cc750875 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);