perf: optimize texture caching

This commit is contained in:
2026-01-16 17:56:41 +08:00
parent 562599b8b4
commit 94502e6104
3 changed files with 44 additions and 21 deletions

View File

@@ -10,13 +10,13 @@ public:
~TextureManager();
SDL_Texture* createTextureFromRect(int x, int y, SDL_FRect& rect, SDL_Color& coler);
SDL_Texture* createTextureFromRect(SDL_FRect& rect, SDL_Color& coler);
void cleanupAllTexture();
SDL_Texture* getTexture(int x, int y);
SDL_Texture* getTexture(SDL_FRect& rect, SDL_Color& color);
bool destoryTexture(int x, int y);
bool destoryTexture(SDL_FRect& rect, SDL_Color& color);
private:
@@ -24,6 +24,6 @@ private:
std::unordered_map<size_t, SDL_Texture*> m_cacheTexture;
size_t makeHash(int x, int y);
size_t makeHash(SDL_FRect& rect, SDL_Color& color);
};