diff options
Diffstat (limited to 'imgmanager.hpp')
-rw-r--r-- | imgmanager.hpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/imgmanager.hpp b/imgmanager.hpp index 9001500..800d6a2 100644 --- a/imgmanager.hpp +++ b/imgmanager.hpp @@ -2,17 +2,30 @@ #include <string> #include <unordered_map> #include <functional> +#include <queue> #include <gtkmm.h> #include "filecache.hpp" class ImageManager { public: + ImageManager(); + + using callback_type = std::function<void(Glib::RefPtr<Gdk::Pixbuf>)>; + Cache &GetCache(); - void LoadFromURL(std::string url, std::function<void(Glib::RefPtr<Gdk::Pixbuf>)> cb); + void LoadFromURL(std::string url, callback_type cb); Glib::RefPtr<Gdk::Pixbuf> GetFromURLIfCached(std::string url); Glib::RefPtr<Gdk::Pixbuf> GetPlaceholder(int size); private: + Glib::RefPtr<Gdk::Pixbuf> ReadFileToPixbuf(std::string path); + + mutable std::mutex m_load_mutex; + void RunCallbacks(); + Glib::Dispatcher m_cb_dispatcher; + mutable std::mutex m_cb_mutex; + std::queue<std::pair<Glib::RefPtr<Gdk::Pixbuf>, callback_type>> m_cb_queue; + std::unordered_map<std::string, Glib::RefPtr<Gdk::Pixbuf>> m_pixs; Cache m_cache; }; |