From c8106f51b4f2f77e7ce9e65ecd9b75acf1696a79 Mon Sep 17 00:00:00 2001 From: Bryce Harrington Date: Tue, 20 Feb 2007 08:08:25 +0000 Subject: Moving cache management code from .h to .cpp. Making the marker dropdowns static so they can be updated. (bzr r2403) --- src/ui/cache/svg_preview_cache.cpp | 47 ++++++++++++++++++++++++++++++++++++++ src/ui/cache/svg_preview_cache.h | 40 +++++--------------------------- 2 files changed, 53 insertions(+), 34 deletions(-) (limited to 'src/ui/cache') diff --git a/src/ui/cache/svg_preview_cache.cpp b/src/ui/cache/svg_preview_cache.cpp index 6b3bc3930..4aa46af2b 100644 --- a/src/ui/cache/svg_preview_cache.cpp +++ b/src/ui/cache/svg_preview_cache.cpp @@ -97,4 +97,51 @@ GdkPixbuf* render_pixbuf(NRArenaItem* root, double scale_factor, const NR::Rect& return pixbuf; } +namespace Inkscape { +namespace UI { +namespace Cache { +SvgPreview::SvgPreview() +{ +} + +SvgPreview::~SvgPreview() +{ +} + +Glib::ustring SvgPreview::cache_key(gchar const *name, unsigned psize) const { + Glib::ustring key = name; + key += ":"; + key += psize; + return key; +} + +GdkPixbuf* SvgPreview::get_preview_from_cache(const Glib::ustring& key) { + std::map::iterator found = _pixmap_cache.find(key); + if ( found != _pixmap_cache.end() ) { + return found->second; + } + return NULL; +} + +void SvgPreview::set_preview_in_cache(const Glib::ustring& key, GdkPixbuf* px) { + _pixmap_cache[key] = px; +} + +GdkPixbuf* SvgPreview::get_preview(const gchar* id, NRArenaItem *root, + double scale_factor, unsigned int psize) { + // First try looking up the cached preview in the cache map + Glib::ustring key = cache_key(id, psize); + GdkPixbuf* px = get_preview_from_cache(key); + + if (px == NULL) { + /* + px = render_pixbuf(root, scale_factor, dbox, psize); + set_preview_in_cache(key, px); + */ + } +} + +}; +}; +}; diff --git a/src/ui/cache/svg_preview_cache.h b/src/ui/cache/svg_preview_cache.h index 2d84b7273..14e05d2f8 100644 --- a/src/ui/cache/svg_preview_cache.h +++ b/src/ui/cache/svg_preview_cache.h @@ -22,41 +22,13 @@ class SvgPreview { std::map _pixmap_cache; public: - SvgPreview() {} - ~SvgPreview() {} + SvgPreview(); + ~SvgPreview(); - Glib::ustring cache_key(gchar const *name, unsigned psize) const { - Glib::ustring key = name; - key += ":"; - key += psize; - return key; - } - - GdkPixbuf* get_preview_from_cache(const Glib::ustring& key) { - std::map::iterator found = _pixmap_cache.find(key); - if ( found != _pixmap_cache.end() ) { - return found->second; - } - return NULL; - } - - void set_preview_in_cache(const Glib::ustring& key, GdkPixbuf* px) { - _pixmap_cache[key] = px; - } - - GdkPixbuf* get_preview(const gchar* id, NRArenaItem *root, double scale_factor, unsigned int psize) { - // First try looking up the cached preview in the cache map - Glib::ustring key = cache_key(id, psize); - GdkPixbuf* px = get_preview_from_cache(key); - - if (px == NULL) { -/* - px = render_pixbuf(root, scale_factor, dbox, psize); - set_preview_in_cache(key, px); -*/ - } - - } + Glib::ustring cache_key(gchar const *name, unsigned psize) const; + GdkPixbuf* get_preview_from_cache(const Glib::ustring& key); + void set_preview_in_cache(const Glib::ustring& key, GdkPixbuf* px); + GdkPixbuf* get_preview(const gchar* id, NRArenaItem *root, double scale_factor, unsigned int psize); }; }; // namespace Cache -- cgit v1.2.3