support animated guild icon

This commit is contained in:
ouwou
2020-12-21 19:08:44 -05:00
parent 486d184c83
commit d8ff05ddf8
8 changed files with 77 additions and 11 deletions

View File

@@ -10,16 +10,21 @@ class ImageManager {
public:
ImageManager();
using callback_anim_type = sigc::slot<void(Glib::RefPtr<Gdk::PixbufAnimation>)>;
using callback_type = sigc::slot<void(Glib::RefPtr<Gdk::Pixbuf>)>;
Cache &GetCache();
void LoadFromURL(std::string url, callback_type cb);
// animations need dimensions before loading since there is no (easy) way to scale a PixbufAnimation
void LoadAnimationFromURL(std::string url, int w, int h, callback_anim_type cb);
void Prefetch(std::string url);
Glib::RefPtr<Gdk::Pixbuf> GetFromURLIfCached(std::string url);
Glib::RefPtr<Gdk::PixbufAnimation> GetAnimationFromURLIfCached(std::string url, int w, int h);
Glib::RefPtr<Gdk::Pixbuf> GetPlaceholder(int size);
private:
Glib::RefPtr<Gdk::Pixbuf> ReadFileToPixbuf(std::string path);
Glib::RefPtr<Gdk::PixbufAnimation> ReadFileToPixbufAnimation(std::string path, int w, int h);
mutable std::mutex m_load_mutex;
void RunCallbacks();