From f22caf9aee2aa64313468b04efa615e2e1c7f8b3 Mon Sep 17 00:00:00 2001 From: Yonit Halperin Date: Sun, 18 Sep 2011 14:52:04 +0300 Subject: client: rewrite surfaces cache use std::map instead of a specific template (CHash). There is no need for special template. Moreover, using std::map will allow easy iteration over the surfaces. (cherry picked from commit fcb3b4ce5231218bcf949da4270bd85a2cfb3535 branch 0.8) Conflicts: client/display_channel.cpp --- client/canvas.cpp | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'client/canvas.cpp') diff --git a/client/canvas.cpp b/client/canvas.cpp index 3b5f4b69..139b663b 100644 --- a/client/canvas.cpp +++ b/client/canvas.cpp @@ -24,14 +24,35 @@ #include "utils.h" #include "debug.h" +static SpiceCanvas* surfaces_cache_op_get(SpiceImageSurfaces *surfaces, uint32_t surface_id) +{ + SurfacesCache* surfaces_cache = static_cast(surfaces); + if (!surfaces_cache->exist(surface_id)) { + return NULL; + } + return (*surfaces_cache)[surface_id]->get_internal_canvas(); +} + +SurfacesCache::SurfacesCache() +{ + static SpiceImageSurfacesOps surfaces_ops = { + surfaces_cache_op_get, + }; + ops = &surfaces_ops; +} + +bool SurfacesCache::exist(uint32_t surface_id) +{ + return (this->count(surface_id) != 0); +} Canvas::Canvas(PixmapCache& pixmap_cache, PaletteCache& palette_cache, - GlzDecoderWindow &glz_decoder_window, CSurfaces &csurfaces) + GlzDecoderWindow &glz_decoder_window, SurfacesCache &csurfaces) : _canvas (NULL) , _pixmap_cache (pixmap_cache) , _palette_cache (palette_cache) , _glz_decoder(glz_decoder_window, _glz_handler, _glz_debug) - , _csurfaces(csurfaces) + , _surfaces_cache(csurfaces) { } -- cgit