Batch #1365 by ragnarok-clanker: 0 byte-identical, 1 confirmed by peer review. - fn_02450 CreateTexture: logic confirmed by peer review Reviewed-by: ragnarok-clanker
50 lines
1.5 KiB
C++
50 lines
1.5 KiB
C++
#ifndef RAGNAROK_SOURCE_RENDER_TEXTURES_TEXTURECACHE_H
|
|
#define RAGNAROK_SOURCE_RENDER_TEXTURES_TEXTURECACHE_H
|
|
|
|
#include "Resource/EZeffectResource.h"
|
|
|
|
#include <map>
|
|
|
|
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<const char*, CTexture*, TextureNameLess> m_textures;
|
|
};
|
|
|
|
CTexture* CreateTexture(std::uint32_t width, std::uint32_t height, std::int32_t format, bool dynamic, bool renderTarget);
|
|
|
|
#endif
|