mirror of
https://projects.vdr-developer.org/git/vdr-plugin-skindesigner.git
synced 2023-10-19 17:58:31 +02:00
optimized image caching code
This commit is contained in:
parent
0422c52c6e
commit
d684cec70e
@ -46,25 +46,24 @@ void cImageCache::CacheLogo(int width, int height) {
|
||||
if (width == 0 || height == 0)
|
||||
return;
|
||||
|
||||
int channelsCached = 0;
|
||||
int logosCached = 0;
|
||||
|
||||
for (const cChannel *channel = Channels.First(); channel; channel = Channels.Next(channel)) {
|
||||
if (channelsCached >= config.numLogosPerSizeInitial)
|
||||
if (logosCached >= config.numLogosPerSizeInitial)
|
||||
break;
|
||||
if (channel->GroupSep()) {
|
||||
continue;
|
||||
}
|
||||
bool success = LoadLogo(channel);
|
||||
if (success) {
|
||||
channelsCached++;
|
||||
cImage *image = CreateImage(width, height);
|
||||
stringstream logoName;
|
||||
logoName << *channel->GetChannelID().ToString() << "_" << width << "x" << height;
|
||||
std::map<std::string, cImage*>::iterator hit = channelLogoCache.find(logoName.str());
|
||||
map<string, cImage*>::iterator hit = channelLogoCache.find(logoName.str());
|
||||
if (hit != channelLogoCache.end()) {
|
||||
delete image;
|
||||
return;
|
||||
continue;
|
||||
}
|
||||
bool success = LoadLogo(channel);
|
||||
if (success) {
|
||||
logosCached++;
|
||||
cImage *image = CreateImage(width, height);
|
||||
channelLogoCache.insert(pair<string, cImage*>(logoName.str(), image));
|
||||
}
|
||||
}
|
||||
@ -158,13 +157,7 @@ bool cImageCache::SeparatorLogoExists(string name) {
|
||||
void cImageCache::CacheIcon(eImageType type, string name, int width, int height) {
|
||||
if (width < 1 || width > 1920 || height < 1 || height > 1080)
|
||||
return;
|
||||
bool success = LoadIcon(type, name);
|
||||
if (!success)
|
||||
return;
|
||||
stringstream iconName;
|
||||
iconName << name << "_" << width << "x" << height;
|
||||
cImage *image = CreateImage(width, height, true);
|
||||
iconCache.insert(pair<string, cImage*>(iconName.str(), image));
|
||||
GetIcon(type, name, width, height);
|
||||
}
|
||||
|
||||
cImage *cImageCache::GetIcon(eImageType type, string name, int width, int height) {
|
||||
@ -281,13 +274,7 @@ bool cImageCache::MenuIconExists(string name) {
|
||||
void cImageCache::CacheSkinpart(string name, int width, int height) {
|
||||
if (width < 1 || width > 1920 || height < 1 || height > 1080)
|
||||
return;
|
||||
bool success = LoadSkinpart(name);
|
||||
if (!success)
|
||||
return;
|
||||
stringstream iconName;
|
||||
iconName << name << "_" << width << "x" << height;
|
||||
cImage *image = CreateImage(width, height, false);
|
||||
skinPartsCache.insert(pair<string, cImage*>(iconName.str(), image));
|
||||
GetSkinpart(name, width, height);
|
||||
}
|
||||
|
||||
cImage *cImageCache::GetSkinpart(string name, int width, int height) {
|
||||
|
@ -104,7 +104,6 @@ vector< pair<string, int> > cTemplate::GetUsedFonts(void) {
|
||||
|
||||
void cTemplate::CacheImages(void) {
|
||||
CacheImages(rootView);
|
||||
|
||||
rootView->InitSubViewIterator();
|
||||
cTemplateView *subView = NULL;
|
||||
while(subView = rootView->GetNextSubView()) {
|
||||
@ -113,9 +112,7 @@ void cTemplate::CacheImages(void) {
|
||||
}
|
||||
|
||||
void cTemplate::Debug(void) {
|
||||
|
||||
rootView->Debug();
|
||||
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
@ -213,13 +210,7 @@ void cTemplate::CacheImages(cTemplateView *view) {
|
||||
viewElement->InitIterator();
|
||||
cTemplatePixmap *pix = NULL;
|
||||
while(pix = viewElement->GetNextPixmap()) {
|
||||
pix->InitIterator();
|
||||
cTemplateFunction *func = NULL;
|
||||
while(func = pix->GetNextFunction()) {
|
||||
if (func->GetType() == ftDrawImage) {
|
||||
CacheImage(func);
|
||||
}
|
||||
}
|
||||
CachePixmapImages(pix);
|
||||
}
|
||||
}
|
||||
//used images in viewLists pixmaps
|
||||
@ -229,17 +220,31 @@ void cTemplate::CacheImages(cTemplateView *view) {
|
||||
viewList->InitIterator();
|
||||
cTemplatePixmap *pix = NULL;
|
||||
while(pix = viewList->GetNextPixmap()) {
|
||||
pix->InitIterator();
|
||||
cTemplateFunction *func = NULL;
|
||||
while(func = pix->GetNextFunction()) {
|
||||
if (func->GetType() == ftDrawImage) {
|
||||
CacheImage(func);
|
||||
}
|
||||
}
|
||||
CachePixmapImages(pix);
|
||||
}
|
||||
cTemplateViewElement *listElement = viewList->GetListElement();
|
||||
listElement->InitIterator();
|
||||
while(pix = listElement->GetNextPixmap()) {
|
||||
CachePixmapImages(pix);
|
||||
}
|
||||
cTemplateViewElement *currentElement = viewList->GetListElementCurrent();
|
||||
if (!currentElement) {
|
||||
continue;
|
||||
}
|
||||
currentElement->InitIterator();
|
||||
while(pix = currentElement->GetNextPixmap()) {
|
||||
CachePixmapImages(pix);
|
||||
}
|
||||
}
|
||||
//used images in viewTabs
|
||||
view->InitViewTabIterator();
|
||||
cTemplateViewTab *viewTab = NULL;
|
||||
while(viewTab = view->GetNextViewTab()) {
|
||||
CachePixmapImages(viewTab);
|
||||
}
|
||||
}
|
||||
|
||||
void cTemplate::CachePixmapImages(cTemplatePixmap *pix) {
|
||||
pix->InitIterator();
|
||||
cTemplateFunction *func = NULL;
|
||||
while(func = pix->GetNextFunction()) {
|
||||
@ -247,20 +252,6 @@ void cTemplate::CacheImages(cTemplateView *view) {
|
||||
CacheImage(func);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//used logos in viewTabs
|
||||
view->InitViewTabIterator();
|
||||
cTemplateViewTab *viewTab = NULL;
|
||||
while(viewTab = view->GetNextViewTab()) {
|
||||
viewTab->InitIterator();
|
||||
cTemplateFunction *func = NULL;
|
||||
while(func = viewTab->GetNextFunction()) {
|
||||
if (func->GetType() == ftDrawImage) {
|
||||
CacheImage(func);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void cTemplate::CacheImage(cTemplateFunction *func) {
|
||||
|
@ -32,6 +32,7 @@ enum eViewType {
|
||||
class cTemplate {
|
||||
private:
|
||||
eViewType viewType;
|
||||
void CachePixmapImages(cTemplatePixmap *pix);
|
||||
void CacheImage(cTemplateFunction *func);
|
||||
protected:
|
||||
cGlobals *globals;
|
||||
|
@ -209,5 +209,5 @@
|
||||
</areascroll>
|
||||
</currentelement>
|
||||
</menuitems>
|
||||
|
||||
</menuschedules>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user