mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-25 23:55:38 +00:00
Added a manualUnloadAll function to TextureResource.
Also converted some variables to static inline and cleand up some code.
This commit is contained in:
parent
b69706fc35
commit
899ace3eb6
|
@ -11,11 +11,6 @@
|
||||||
#include "utils/FileSystemUtil.h"
|
#include "utils/FileSystemUtil.h"
|
||||||
#include "utils/StringUtil.h"
|
#include "utils/StringUtil.h"
|
||||||
|
|
||||||
TextureDataManager TextureResource::sTextureDataManager;
|
|
||||||
std::map<TextureResource::TextureKeyType, std::weak_ptr<TextureResource>>
|
|
||||||
TextureResource::sTextureMap;
|
|
||||||
std::set<TextureResource*> TextureResource::sAllTextures;
|
|
||||||
|
|
||||||
TextureResource::TextureResource(
|
TextureResource::TextureResource(
|
||||||
const std::string& path, bool tile, bool dynamic, bool linearMagnify, bool forceRasterization)
|
const std::string& path, bool tile, bool dynamic, bool linearMagnify, bool forceRasterization)
|
||||||
: mTextureData {nullptr}
|
: mTextureData {nullptr}
|
||||||
|
@ -157,7 +152,7 @@ std::shared_ptr<TextureResource> TextureResource::get(const std::string& path,
|
||||||
return tex;
|
return tex;
|
||||||
}
|
}
|
||||||
|
|
||||||
TextureKeyType key(canonicalPath, tile);
|
TextureKeyType key {canonicalPath, tile};
|
||||||
auto foundTexture = sTextureMap.find(key);
|
auto foundTexture = sTextureMap.find(key);
|
||||||
|
|
||||||
if (foundTexture != sTextureMap.cend()) {
|
if (foundTexture != sTextureMap.cend()) {
|
||||||
|
|
|
@ -35,6 +35,7 @@ public:
|
||||||
void initFromPixels(const unsigned char* dataRGBA, size_t width, size_t height);
|
void initFromPixels(const unsigned char* dataRGBA, size_t width, size_t height);
|
||||||
virtual void initFromMemory(const char* data, size_t length);
|
virtual void initFromMemory(const char* data, size_t length);
|
||||||
static void manualUnload(std::string path, bool tile);
|
static void manualUnload(std::string path, bool tile);
|
||||||
|
static void manualUnloadAll() { sTextureMap.clear(); }
|
||||||
|
|
||||||
// Returns the raw pixel values.
|
// Returns the raw pixel values.
|
||||||
std::vector<unsigned char> getRawRGBAData();
|
std::vector<unsigned char> getRawRGBAData();
|
||||||
|
@ -79,7 +80,7 @@ private:
|
||||||
std::shared_ptr<TextureData> mTextureData;
|
std::shared_ptr<TextureData> mTextureData;
|
||||||
|
|
||||||
// The texture data manager manages loading and unloading of filesystem based textures.
|
// The texture data manager manages loading and unloading of filesystem based textures.
|
||||||
static TextureDataManager sTextureDataManager;
|
static inline TextureDataManager sTextureDataManager;
|
||||||
|
|
||||||
glm::ivec2 mSize;
|
glm::ivec2 mSize;
|
||||||
glm::vec2 mSourceSize;
|
glm::vec2 mSourceSize;
|
||||||
|
@ -87,9 +88,9 @@ private:
|
||||||
|
|
||||||
using TextureKeyType = std::pair<std::string, bool>;
|
using TextureKeyType = std::pair<std::string, bool>;
|
||||||
// Map of textures, used to prevent duplicate textures.
|
// Map of textures, used to prevent duplicate textures.
|
||||||
static std::map<TextureKeyType, std::weak_ptr<TextureResource>> sTextureMap;
|
static inline std::map<TextureKeyType, std::weak_ptr<TextureResource>> sTextureMap;
|
||||||
// Set of all textures, used for memory management.
|
// Set of all textures, used for memory management.
|
||||||
static std::set<TextureResource*> sAllTextures;
|
static inline std::set<TextureResource*> sAllTextures;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ES_CORE_RESOURCES_TEXTURE_RESOURCE_H
|
#endif // ES_CORE_RESOURCES_TEXTURE_RESOURCE_H
|
||||||
|
|
Loading…
Reference in a new issue