#ifndef RAGNAROK_SOURCE_RENDER_TEXTURES_TEXTURECACHE_H #define RAGNAROK_SOURCE_RENDER_TEXTURES_TEXTURECACHE_H #include "Resource/EZeffectResource.h" #include class ResourceMgr; class CRenderSystemBase; class TextureSources { public: virtual const char* Resolve(const char* name) = 0; virtual bool MovieSize(const char* name, int& width, int& height) = 0; virtual void CleanupTextures() = 0; protected: ~TextureSources() = default; }; struct TextureNameLess { bool operator()(const char* left, const char* right) const; }; class TextureCache : public EffectTextures { public: TextureCache(ResourceMgr& resources, CRenderSystemBase*& system, TextureSources& sources, const int& reduction, const unsigned& reuseDelay); ~TextureCache(); CTexture* Load(const char* name, int option, bool fullSize, bool dynamic, bool renderTarget) override; CTexture* Default() override; CTexture* Create(const char* name, int option, bool fullSize, bool dynamic, bool renderTarget); CTexture* Upload(int width, int height, const std::uint32_t* pixels, int format, int option, bool fullSize, bool dynamic, bool renderTarget); void Remove(CTexture* texture); void Clear(); void ClearUnused(); void Reload(); private: ResourceMgr& m_resources; CRenderSystemBase*& m_system; TextureSources& m_sources; const int& m_reduction; const unsigned& m_reuseDelay; std::map m_textures; }; CTexture* CreateTexture(std::uint32_t width, std::uint32_t height, std::int32_t format, bool dynamic, bool renderTarget); #endif