From 1d6f6a764e1e8b4f66476668828295418448eb7e Mon Sep 17 00:00:00 2001 From: kamel5 Date: Fri, 5 Mar 2021 14:16:08 +0100 Subject: Simplify cImageCache - Merge CreateCache(void) and CreateCacheDelayed(void) and move CreateCache() to cImageCache::cImageCache(). This allows a new instance of imgCache to be created after configuration changes. - Eliminate cImageCache::Reload() cImageCache::Reload() is no longer required. --- imagecache.c | 10 +--------- imagecache.h | 4 +--- nopacity.c | 11 +++-------- nopacity.h | 1 - setup.c | 3 ++- 5 files changed, 7 insertions(+), 22 deletions(-) diff --git a/imagecache.c b/imagecache.c index dc9968d..dedc038 100644 --- a/imagecache.c +++ b/imagecache.c @@ -12,6 +12,7 @@ cImageCache *imgCache; cImageCache::cImageCache() : cImageMagickWrapper() { tempStaticLogo = NULL; osdTheme = Setup.OSDTheme; + CreateCache(); } cImageCache::~cImageCache() { @@ -60,9 +61,6 @@ void cImageCache::CreateCache(void) { } } -} - -void cImageCache::CreateCacheDelayed(void) { if (config.GetValue("displayType") == dtBlending) CreateSkinElementsBlended(); else if (config.GetValue("displayType") == dtGraphical) @@ -77,12 +75,6 @@ bool cImageCache::ThemeChanged(void) { return false; } -void cImageCache::Reload(void) { - Clear(); - CreateCache(); - CreateCacheDelayed(); -} - cImage *cImageCache::GetMenuIcon(std::string name) { std::map::iterator hit = menuIconCache.find(name); if (hit != menuIconCache.end()) { diff --git a/imagecache.h b/imagecache.h index a46b63d..cbecffe 100644 --- a/imagecache.h +++ b/imagecache.h @@ -74,9 +74,6 @@ class cImageCache : public cImageMagickWrapper { public: cImageCache(); ~cImageCache(); - void CreateCache(void); - void CreateCacheDelayed(void); - void Reload(void); bool ThemeChanged(void); cImage *GetMenuIcon(std::string name); cImage *GetSkinIcon(std::string name, int width=0, int height=0, bool preserveAspect = true); @@ -95,6 +92,7 @@ private: std::map logoTimerCache; std::vector > GetMenuIcons(void); std::vector > GetSkinIcons(void); + void CreateCache(void); bool LoadIcon(eCacheType type, std::string name); void InsertIntoIconCache(eCacheType type, std::string name, int width, int height, bool preserveAspect = true); bool LoadLogo(const cChannel *channel); diff --git a/nopacity.c b/nopacity.c index 073eb9b..cbe2841 100644 --- a/nopacity.c +++ b/nopacity.c @@ -12,7 +12,6 @@ #include "displaymessage.h" cNopacity::cNopacity(void) : cSkin("nOpacity", &::Theme) { - init = true; config.LoadThemeSpecificConfigs(); config.SetThemeSpecificDefaults(); config.SetThemeSetup(); @@ -21,8 +20,7 @@ cNopacity::cNopacity(void) : cSkin("nOpacity", &::Theme) { geoManager = new cGeometryManager(); geoManager->SetGeometry(); fontManager = NULL; - imgCache = new cImageCache(); - imgCache->CreateCache(); + imgCache = NULL; } cNopacity::~cNopacity() { @@ -37,10 +35,6 @@ const char *cNopacity::Description(void) { cSkinDisplayChannel *cNopacity::DisplayChannel(bool WithInfo) { ReloadCaches(); - if (init) { - imgCache->CreateCacheDelayed(); - init = false; - } return new cNopacityDisplayChannel(WithInfo); } @@ -79,7 +73,8 @@ void cNopacity::ReloadCaches(void) { geoManager->SetGeometry(); delete fontManager; fontManager = new cFontManager(); - imgCache->Reload(); + delete imgCache; + imgCache = new cImageCache(); dsyslog("nopacity: Cache reloaded in %d ms", int(cTimeMs::Now()-start)); } } diff --git a/nopacity.h b/nopacity.h index fc36af9..7652f7b 100644 --- a/nopacity.h +++ b/nopacity.h @@ -9,7 +9,6 @@ class cNopacityDisplayMenu; class cNopacity : public cSkin { private: - bool init; void ReloadCaches(void); public: cNopacity(void); diff --git a/setup.c b/setup.c index 01eb97f..d87088d 100644 --- a/setup.c +++ b/setup.c @@ -13,7 +13,8 @@ cNopacitySetup::~cNopacitySetup() { geoManager->SetGeometry(); delete fontManager; fontManager = new cFontManager(); - imgCache->Reload(); + delete imgCache; + imgCache = new cImageCache(); dsyslog("nopacity: Cache reloaded in %d ms", int(cTimeMs::Now()-start)); } -- cgit v1.2.3