#pragma once #include #include #include #include #include "TextureProvider.h" #include "WallpaperEngine/Render/Helpers/ContextAware.h" #include "WallpaperEngine/Render/RenderContext.h" using namespace WallpaperEngine::Render; namespace WallpaperEngine::Render { class AlbumTexture; namespace Helpers { class ContextAware; } class RenderContext; class TextureCache final : Helpers::ContextAware { public: explicit TextureCache (RenderContext& context); ~TextureCache () override; /** * Checks if the given texture was already loaded and returns it * If the texture was not loaded yet, it tries to load it from the container * * @param filename * @return */ std::shared_ptr resolve (const std::string& filename); /** * Registers a texture in the cache * * @param name * @param texture */ void store (const std::string& name, std::shared_ptr texture); private: /** The previous album thumbnail texture */ std::shared_ptr m_previousThumbnail = nullptr; /** The current album thumbnail texture */ std::shared_ptr m_currentThumbnail = nullptr; /** Cached textures */ std::map> m_textureCache = {}; /** The callback to de-register media events */ std::function m_mediaCallback; }; } // namespace WallpaperEngine::Render