pref: remove global texture cache

This commit is contained in:
Nomango 2023-09-26 13:12:26 +08:00
parent 03439bb431
commit 524ddd055a
4 changed files with 5 additions and 10 deletions

View File

@ -54,13 +54,13 @@ GifSprite::GifSprite(GifImagePtr gif)
bool GifSprite::Load(const String& file_path) bool GifSprite::Load(const String& file_path)
{ {
GifImagePtr image = TextureCache::GetInstance().PreloadGif(file_path); GifImagePtr image = new GifImage(file_path);
return Load(image); return Load(image);
} }
bool GifSprite::Load(const Resource& res) bool GifSprite::Load(const Resource& res)
{ {
GifImagePtr image = TextureCache::GetInstance().PreloadGif(res); GifImagePtr image = new GifImage(res);
return Load(image); return Load(image);
} }

View File

@ -61,7 +61,7 @@ SpriteFrame::SpriteFrame(TexturePtr texture, const Rect& crop_rect)
bool SpriteFrame::Load(const String& file_path) bool SpriteFrame::Load(const String& file_path)
{ {
TexturePtr texture = TextureCache::GetInstance().Preload(file_path); TexturePtr texture = new Texture(file_path);
if (texture->IsValid()) if (texture->IsValid())
{ {
SetTexture(texture); SetTexture(texture);
@ -72,7 +72,7 @@ bool SpriteFrame::Load(const String& file_path)
bool SpriteFrame::Load(const Resource& res) bool SpriteFrame::Load(const Resource& res)
{ {
TexturePtr texture = TextureCache::GetInstance().Preload(res); TexturePtr texture = new Texture(res);
if (texture->IsValid()) if (texture->IsValid())
{ {
SetTexture(texture); SetTexture(texture);

View File

@ -19,7 +19,6 @@
// THE SOFTWARE. // THE SOFTWARE.
#include <kiwano/render/Renderer.h> #include <kiwano/render/Renderer.h>
#include <kiwano/render/TextureCache.h>
#include <kiwano/event/WindowEvent.h> #include <kiwano/event/WindowEvent.h>
namespace kiwano namespace kiwano
@ -49,7 +48,6 @@ void Renderer::ResetResolutionWhenWindowResized(bool enabled)
void Renderer::Destroy() void Renderer::Destroy()
{ {
TextureCache::GetInstance().Clear();
FontCache::GetInstance().Clear(); FontCache::GetInstance().Clear();
} }

View File

@ -21,7 +21,6 @@
#pragma once #pragma once
#include <kiwano/render/GifImage.h> #include <kiwano/render/GifImage.h>
#include <kiwano/render/Texture.h> #include <kiwano/render/Texture.h>
#include <kiwano/core/Singleton.h>
namespace kiwano namespace kiwano
{ {
@ -34,10 +33,8 @@ namespace kiwano
* \~chinese * \~chinese
* @brief * @brief
*/ */
class KGE_API TextureCache final : public Singleton<TextureCache> class KGE_API TextureCache final
{ {
friend Singleton<TextureCache>;
public: public:
/// \~chinese /// \~chinese
/// @brief 预加载本地图片 /// @brief 预加载本地图片