mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-25 23:55:38 +00:00
Reverted the SVG caching logic.
This commit is contained in:
parent
50f2af0077
commit
7321bf8f36
|
@ -72,11 +72,9 @@ protected:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void updateInfoPanel();
|
void updateInfoPanel();
|
||||||
|
|
||||||
const std::string getImagePath(FileData* file);
|
const std::string getImagePath(FileData* file);
|
||||||
|
|
||||||
void initMDLabels();
|
void initMDLabels();
|
||||||
|
|
||||||
void initMDValues();
|
void initMDValues();
|
||||||
|
|
||||||
ImageComponent mMarquee;
|
ImageComponent mMarquee;
|
||||||
|
|
|
@ -30,19 +30,19 @@ BadgesComponent::BadgesComponent(Window* window)
|
||||||
|
|
||||||
mImageComponents = std::map<std::string, ImageComponent>();
|
mImageComponents = std::map<std::string, ImageComponent>();
|
||||||
ImageComponent mImageFavorite = ImageComponent(window);
|
ImageComponent mImageFavorite = ImageComponent(window);
|
||||||
mImageFavorite.setImage(mBadgeIcons[SLOT_FAVORITE], false, true, true);
|
mImageFavorite.setImage(mBadgeIcons[SLOT_FAVORITE], false, true);
|
||||||
mImageComponents.insert({SLOT_FAVORITE, mImageFavorite});
|
mImageComponents.insert({SLOT_FAVORITE, mImageFavorite});
|
||||||
ImageComponent mImageCompleted = ImageComponent(window);
|
ImageComponent mImageCompleted = ImageComponent(window);
|
||||||
mImageCompleted.setImage(mBadgeIcons[SLOT_COMPLETED], false, true, true);
|
mImageCompleted.setImage(mBadgeIcons[SLOT_COMPLETED], false, true);
|
||||||
mImageComponents.insert({SLOT_COMPLETED, mImageCompleted});
|
mImageComponents.insert({SLOT_COMPLETED, mImageCompleted});
|
||||||
ImageComponent mImageKids = ImageComponent(window);
|
ImageComponent mImageKids = ImageComponent(window);
|
||||||
mImageKids.setImage(mBadgeIcons[SLOT_KIDS], false, true, true);
|
mImageKids.setImage(mBadgeIcons[SLOT_KIDS], false, true);
|
||||||
mImageComponents.insert({SLOT_KIDS, mImageKids});
|
mImageComponents.insert({SLOT_KIDS, mImageKids});
|
||||||
ImageComponent mImageBroken = ImageComponent(window);
|
ImageComponent mImageBroken = ImageComponent(window);
|
||||||
mImageBroken.setImage(mBadgeIcons[SLOT_BROKEN], false, true, true);
|
mImageBroken.setImage(mBadgeIcons[SLOT_BROKEN], false, true);
|
||||||
mImageComponents.insert({SLOT_BROKEN, mImageBroken});
|
mImageComponents.insert({SLOT_BROKEN, mImageBroken});
|
||||||
ImageComponent mImageAltEmu = ImageComponent(window);
|
ImageComponent mImageAltEmu = ImageComponent(window);
|
||||||
mImageAltEmu.setImage(mBadgeIcons[SLOT_ALTERNATIVE_EMULATOR], false, true, true);
|
mImageAltEmu.setImage(mBadgeIcons[SLOT_ALTERNATIVE_EMULATOR], false, true);
|
||||||
mImageComponents.insert({SLOT_ALTERNATIVE_EMULATOR, mImageAltEmu});
|
mImageComponents.insert({SLOT_ALTERNATIVE_EMULATOR, mImageAltEmu});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,7 +99,7 @@ void BadgesComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
|
||||||
if (properties & PATH && elem->has(slot) &&
|
if (properties & PATH && elem->has(slot) &&
|
||||||
mBadgeIcons[slot] != elem->get<std::string>(slot)) {
|
mBadgeIcons[slot] != elem->get<std::string>(slot)) {
|
||||||
mBadgeIcons[slot] = elem->get<std::string>(slot);
|
mBadgeIcons[slot] = elem->get<std::string>(slot);
|
||||||
mImageComponents.find(slot)->second.setImage(mBadgeIcons[slot], false, true, true);
|
mImageComponents.find(slot)->second.setImage(mBadgeIcons[slot], false, true);
|
||||||
imgChanged = true;
|
imgChanged = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -138,7 +138,7 @@ void ImageComponent::resize()
|
||||||
onSizeChanged();
|
onSizeChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImageComponent::setImage(std::string path, bool tile, bool linearMagnify, bool cacheImage)
|
void ImageComponent::setImage(std::string path, bool tile, bool linearMagnify)
|
||||||
{
|
{
|
||||||
// Always load bundled graphic resources statically, unless mForceLoad has been set.
|
// Always load bundled graphic resources statically, unless mForceLoad has been set.
|
||||||
// This eliminates annoying texture pop-in problems that would otherwise occur.
|
// This eliminates annoying texture pop-in problems that would otherwise occur.
|
||||||
|
@ -150,12 +150,11 @@ void ImageComponent::setImage(std::string path, bool tile, bool linearMagnify, b
|
||||||
if (mDefaultPath.empty() || !ResourceManager::getInstance()->fileExists(mDefaultPath))
|
if (mDefaultPath.empty() || !ResourceManager::getInstance()->fileExists(mDefaultPath))
|
||||||
mTexture.reset();
|
mTexture.reset();
|
||||||
else
|
else
|
||||||
mTexture = TextureResource::get(mDefaultPath, tile, mForceLoad, mDynamic, linearMagnify,
|
mTexture =
|
||||||
1.0f, cacheImage);
|
TextureResource::get(mDefaultPath, tile, mForceLoad, mDynamic, linearMagnify);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
mTexture =
|
mTexture = TextureResource::get(path, tile, mForceLoad, mDynamic, linearMagnify);
|
||||||
TextureResource::get(path, tile, mForceLoad, mDynamic, linearMagnify, 1.0f, cacheImage);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
resize();
|
resize();
|
||||||
|
|
|
@ -18,20 +18,15 @@ class ImageComponent : public GuiComponent
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ImageComponent(Window* window, bool forceLoad = false, bool dynamic = true);
|
ImageComponent(Window* window, bool forceLoad = false, bool dynamic = true);
|
||||||
virtual ~ImageComponent() {};
|
virtual ~ImageComponent() {}
|
||||||
|
|
||||||
void setDefaultImage(std::string path) { mDefaultPath = path; }
|
void setDefaultImage(std::string path) { mDefaultPath = path; }
|
||||||
|
|
||||||
// Loads the image at the given filepath. Will tile if tile is true (retrieves texture
|
// Loads the image at the given filepath. Will tile if tile is true (retrieves texture
|
||||||
// as tiling, creates vertices accordingly).
|
// as tiling, creates vertices accordingly).
|
||||||
void setImage(std::string path,
|
void setImage(std::string path, bool tile = false, bool linearMagnify = false);
|
||||||
bool tile = false,
|
|
||||||
bool linearMagnify = false,
|
|
||||||
bool cacheSVG = false);
|
|
||||||
|
|
||||||
// Loads an image from memory.
|
// Loads an image from memory.
|
||||||
void setImage(const char* data, size_t length, bool tile = false);
|
void setImage(const char* data, size_t length, bool tile = false);
|
||||||
|
|
||||||
// Use an already existing texture.
|
// Use an already existing texture.
|
||||||
void setImage(const std::shared_ptr<TextureResource>& texture, bool resizeTexture = true);
|
void setImage(const std::shared_ptr<TextureResource>& texture, bool resizeTexture = true);
|
||||||
|
|
||||||
|
|
|
@ -148,8 +148,7 @@ std::shared_ptr<TextureResource> TextureResource::get(const std::string& path,
|
||||||
bool forceLoad,
|
bool forceLoad,
|
||||||
bool dynamic,
|
bool dynamic,
|
||||||
bool linearMagnify,
|
bool linearMagnify,
|
||||||
float scaleDuringLoad,
|
float scaleDuringLoad)
|
||||||
bool cacheImage)
|
|
||||||
{
|
{
|
||||||
std::shared_ptr<ResourceManager>& rm = ResourceManager::getInstance();
|
std::shared_ptr<ResourceManager>& rm = ResourceManager::getInstance();
|
||||||
|
|
||||||
|
@ -177,7 +176,7 @@ std::shared_ptr<TextureResource> TextureResource::get(const std::string& path,
|
||||||
std::shared_ptr<TextureData> data = sTextureDataManager.get(tex.get());
|
std::shared_ptr<TextureData> data = sTextureDataManager.get(tex.get());
|
||||||
|
|
||||||
// Is it an SVG?
|
// Is it an SVG?
|
||||||
if (key.first.substr(key.first.size() - 4, std::string::npos) != ".svg" || cacheImage) {
|
if (key.first.substr(key.first.size() - 4, std::string::npos) != ".svg") {
|
||||||
// Probably not. Add it to our map. We don't add SVGs because 2 SVGs might be
|
// Probably not. Add it to our map. We don't add SVGs because 2 SVGs might be
|
||||||
// rasterized at different sizes.
|
// rasterized at different sizes.
|
||||||
sTextureMap[key] = std::weak_ptr<TextureResource>(tex);
|
sTextureMap[key] = std::weak_ptr<TextureResource>(tex);
|
||||||
|
|
|
@ -30,9 +30,7 @@ public:
|
||||||
bool forceLoad = false,
|
bool forceLoad = false,
|
||||||
bool dynamic = true,
|
bool dynamic = true,
|
||||||
bool linearMagnify = false,
|
bool linearMagnify = false,
|
||||||
float scaleDuringLoad = 1.0f,
|
float scaleDuringLoad = 1.0f);
|
||||||
bool cacheImage = false);
|
|
||||||
|
|
||||||
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);
|
||||||
|
|
Loading…
Reference in a new issue