From a58153f08dbaca771024c2b26373c7f1a6807cc4 Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Thu, 8 Sep 2022 19:04:56 +0200 Subject: [PATCH] The badge overlay images are now retained in the texture cache. --- es-core/src/components/BadgeComponent.cpp | 3 +++ es-core/src/components/BadgeComponent.h | 3 +++ es-core/src/components/FlexboxComponent.h | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/es-core/src/components/BadgeComponent.cpp b/es-core/src/components/BadgeComponent.cpp index 87d4c5753..658ed9922 100644 --- a/es-core/src/components/BadgeComponent.cpp +++ b/es-core/src/components/BadgeComponent.cpp @@ -137,6 +137,9 @@ void BadgeComponent::setBadges(const std::vector& badges) if (it2 != sGameControllers.cend()) { it->overlayImage.setImage((*it2).fileName); + // This is done to keep the texture cache entry from expiring. + mOverlayMap[it2->shortName] = + std::make_unique(it->overlayImage); } else if (badge.gameController != "") it->overlayImage.setImage(sGameControllers.back().fileName); diff --git a/es-core/src/components/BadgeComponent.h b/es-core/src/components/BadgeComponent.h index 83da48341..6b1c88475 100644 --- a/es-core/src/components/BadgeComponent.h +++ b/es-core/src/components/BadgeComponent.h @@ -54,6 +54,9 @@ public: private: static inline std::vector sGameControllers; + // Used to keep the overlay texture cache entries from expiring. + std::map> mOverlayMap; + std::vector mFlexboxItems; FlexboxComponent mFlexboxComponent; diff --git a/es-core/src/components/FlexboxComponent.h b/es-core/src/components/FlexboxComponent.h index 529eb01c6..e525808cc 100644 --- a/es-core/src/components/FlexboxComponent.h +++ b/es-core/src/components/FlexboxComponent.h @@ -23,7 +23,7 @@ public: ImageComponent baseImage; // Optional overlay image that can be sized and positioned relative to the base image. - ImageComponent overlayImage {false, false}; + ImageComponent overlayImage; glm::vec2 overlayPosition {0.5f, 0.5f}; float overlaySize {0.5f};