vdr-plugin-skindesigner/extensions/imagecache.c

604 lines
22 KiB
C
Raw Normal View History

2014-09-27 09:25:14 +02:00
#include <string>
#include <sstream>
#include <map>
#include <fstream>
2015-06-13 10:46:11 +02:00
#include <iostream>
2014-09-27 09:25:14 +02:00
#include <sys/stat.h>
#include "imagecache.h"
2015-03-12 17:28:35 +01:00
#include "cairoimage.h"
2014-09-27 09:25:14 +02:00
#include "../config.h"
#include "helpers.h"
cMutex cImageCache::mutex;
string cImageCache::items[16] = { "Schedule", "Channels", "Timers", "Recordings", "Setup", "Commands",
"OSD", "EPG", "DVB", "LNB", "CAM", "Recording", "Replay", "Miscellaneous", "Plugins", "Restart"};
cImageCache::cImageCache() {
2014-09-27 09:25:14 +02:00
tempStaticLogo = NULL;
}
cImageCache::~cImageCache() {
Clear();
if (tempStaticLogo) {
delete tempStaticLogo;
tempStaticLogo = NULL;
}
}
void cImageCache::SetPathes(void) {
2015-05-30 16:43:59 +02:00
cString skinPath = config.GetSkinPath(Setup.OSDSkin);
string logoPathSkin = *cString::sprintf("%s%s/themes/%s/logos/", *skinPath, Setup.OSDSkin, Setup.OSDTheme);
if (FolderExists(logoPathSkin)) {
logoPath = logoPathSkin;
} else {
logoPath = *config.logoPath;
}
2015-05-30 16:43:59 +02:00
iconPathSkin = *cString::sprintf("%s%s/", *skinPath, Setup.OSDSkin);
skinPartsPathSkin = *cString::sprintf("%s%s/skinparts/", *skinPath, Setup.OSDSkin);
2015-05-30 16:43:59 +02:00
iconPathTheme = *cString::sprintf("%s%s/themes/%s/", *skinPath, Setup.OSDSkin, Setup.OSDTheme);
skinPartsPathTheme = *cString::sprintf("%s%s/themes/%s/skinparts/", *skinPath, Setup.OSDSkin, Setup.OSDTheme);
2015-06-13 10:46:11 +02:00
svgTemplatePath = *cString::sprintf("%s%s/svgtemplates/", *skinPath, Setup.OSDSkin);
dsyslog("skindesigner: using channel logo path %s", logoPath.c_str());
dsyslog("skindesigner: using icon path %s", iconPathTheme.c_str());
dsyslog("skindesigner: using skinparts path %s", skinPartsPathTheme.c_str());
2015-06-13 10:46:11 +02:00
dsyslog("skindesigner: using svgtemplate path %s", svgTemplatePath.c_str());
}
2014-09-27 09:25:14 +02:00
void cImageCache::CacheLogo(int width, int height) {
if (config.numLogosPerSizeInitial == 0)
return;
if (width == 0 || height == 0)
return;
2016-03-13 16:02:26 +01:00
#if defined (APIVERSNUM) && (APIVERSNUM >= 20301)
LOCK_CHANNELS_READ;
const cChannels* channels = Channels;
#else
const cChannels* channels = &Channels;
#endif
2014-11-25 14:33:59 +01:00
int logosCached = 0;
2016-01-26 18:32:38 +01:00
if (config.numLogosMax && config.numLogosMax < (int)channelLogoCache.size())
return;
2016-03-13 16:02:26 +01:00
for (const cChannel *channel = channels->First(); channel; channel = channels->Next(channel)) {
2014-11-25 14:33:59 +01:00
if (logosCached >= config.numLogosPerSizeInitial)
2014-09-27 09:25:14 +02:00
break;
if (channel->GroupSep()) {
continue;
}
2014-11-25 14:33:59 +01:00
stringstream logoName;
logoName << *channel->GetChannelID().ToString() << "_" << width << "x" << height;
map<string, cImage*>::iterator hit = channelLogoCache.find(logoName.str());
if (hit != channelLogoCache.end()) {
continue;
}
2014-09-27 09:25:14 +02:00
bool success = LoadLogo(channel);
if (success) {
2014-11-25 14:33:59 +01:00
logosCached++;
2014-09-27 09:25:14 +02:00
cImage *image = CreateImage(width, height);
channelLogoCache.insert(pair<string, cImage*>(logoName.str(), image));
}
2016-01-26 18:32:38 +01:00
if (config.numLogosMax && config.numLogosMax < (int)channelLogoCache.size())
return;
2014-09-27 09:25:14 +02:00
}
}
cImage *cImageCache::GetLogo(string channelID, int width, int height) {
cMutexLock MutexLock(&mutex);
stringstream logoName;
logoName << channelID << "_" << width << "x" << height;
std::map<std::string, cImage*>::iterator hit = channelLogoCache.find(logoName.str());
if (hit != channelLogoCache.end()) {
return (cImage*)hit->second;
} else {
tChannelID chanID = tChannelID::FromString(channelID.c_str());
2016-03-13 16:02:26 +01:00
#if defined (APIVERSNUM) && (APIVERSNUM >= 20301)
LOCK_CHANNELS_READ;
const cChannels* channels = Channels;
#else
cChannels* channels = &Channels;
#endif
const cChannel *channel = channels->GetByChannelID(chanID);
2014-09-27 09:25:14 +02:00
if (!channel)
return NULL;
bool success = LoadLogo(channel);
if (success) {
2015-04-02 11:57:19 +02:00
if (config.limitLogoCache && ((int)channelLogoCache.size() >= config.numLogosMax)) {
2014-09-27 09:25:14 +02:00
//logo cache is full, don't cache anymore
if (tempStaticLogo) {
delete tempStaticLogo;
tempStaticLogo = NULL;
}
tempStaticLogo = CreateImage(width, height);
return tempStaticLogo;
} else {
//add requested logo to cache
cImage *image = CreateImage(width, height);
channelLogoCache.insert(pair<string, cImage*>(logoName.str(), image));
hit = channelLogoCache.find(logoName.str());
if (hit != channelLogoCache.end()) {
return (cImage*)hit->second;
}
}
}
}
return NULL;
}
cImage *cImageCache::GetSeparatorLogo(string name, int width, int height) {
cMutexLock MutexLock(&mutex);
stringstream logoName;
logoName << name << "_" << width << "x" << height;
std::map<std::string, cImage*>::iterator hit = channelLogoCache.find(logoName.str());
if (hit != channelLogoCache.end()) {
return (cImage*)hit->second;
} else {
bool success = LoadSeparatorLogo(name);
if (success) {
//add requested logo to cache
cImage *image = CreateImage(width, height);
channelLogoCache.insert(pair<string, cImage*>(logoName.str(), image));
hit = channelLogoCache.find(logoName.str());
if (hit != channelLogoCache.end()) {
return (cImage*)hit->second;
}
}
}
return NULL;
}
bool cImageCache::LogoExists(string channelID) {
tChannelID chanID = tChannelID::FromString(channelID.c_str());
2016-03-13 16:02:26 +01:00
#if defined (APIVERSNUM) && (APIVERSNUM >= 20301)
LOCK_CHANNELS_READ;
const cChannels* channels = Channels;
#else
cChannels* channels = &Channels;
#endif
const cChannel *channel = channels->GetByChannelID(chanID);
2014-09-27 09:25:14 +02:00
if (!channel)
return false;
string logoLower = StrToLowerCase(channel->Name());
string channelIDLower = StrToLowerCase(channelID.c_str());
2014-11-11 20:50:00 +01:00
return (FileExists(logoPath.c_str(), logoLower, "svg") ||
FileExists(logoPath.c_str(), logoLower, "png") ||
FileExists(logoPath.c_str(), channelIDLower, "svg") ||
FileExists(logoPath.c_str(), channelIDLower, "png"));
2014-09-27 09:25:14 +02:00
}
bool cImageCache::SeparatorLogoExists(string name) {
2014-10-13 17:39:14 +02:00
string separatorPath = *cString::sprintf("%sseparatorlogos/", logoPath.c_str());
2014-09-27 09:25:14 +02:00
string nameLower = StrToLowerCase(name.c_str());
2014-11-11 20:50:00 +01:00
2014-11-12 17:05:36 +01:00
return (FileExists(separatorPath, nameLower, "svg") ||
FileExists(separatorPath, nameLower, "png"));
2014-09-27 09:25:14 +02:00
}
void cImageCache::CacheIcon(eImageType type, string name, int width, int height) {
if (width < 1 || width > 1920 || height < 1 || height > 1080)
return;
2014-11-25 14:33:59 +01:00
GetIcon(type, name, width, height);
2014-09-27 09:25:14 +02:00
}
2016-01-26 18:32:38 +01:00
cCachedImage *cImageCache::GetIcon(eImageType type, string name, int width, int height) {
2014-09-27 09:25:14 +02:00
if (width < 1 || width > 1920 || height < 1 || height > 1080)
return NULL;
cMutexLock MutexLock(&mutex);
stringstream iconName;
iconName << name << "_" << width << "x" << height;
2016-01-26 18:32:38 +01:00
map<string, cCachedImage*>::iterator hit = iconCache.find(iconName.str());
2014-09-27 09:25:14 +02:00
if (hit != iconCache.end()) {
2016-01-26 18:32:38 +01:00
return (cCachedImage*)hit->second;
2014-09-27 09:25:14 +02:00
} else {
bool success = LoadIcon(type, name);
if (!success)
return NULL;
cImage *image = CreateImage(width, height, true);
2016-01-26 18:32:38 +01:00
cCachedImage *cachedImg = new cCachedImage();
cachedImg->size = image->Width() * image->Height() * sizeof(tColor);
int handle = cOsdProvider::StoreImage(*image);
if (handle) {
cachedImg->handle = handle;
delete image;
} else {
cachedImg->image = image;
}
iconCache.insert(pair<string, cCachedImage*>(iconName.str(), cachedImg));
2014-09-27 09:25:14 +02:00
hit = iconCache.find(iconName.str());
if (hit != iconCache.end()) {
2016-01-26 18:32:38 +01:00
return (cCachedImage*)hit->second;
2014-09-27 09:25:14 +02:00
}
}
return NULL;
}
string cImageCache::GetIconName(string label, eMenuCategory cat, string plugName) {
2014-10-26 08:26:44 +01:00
//if cat is set, use standard menu entries
switch (cat) {
case mcSchedule:
case mcScheduleNow:
case mcScheduleNext:
case mcEvent:
return "standardicons/Schedule";
case mcChannel:
case mcChannelEdit:
return "standardicons/Channels";
case mcTimer:
case mcTimerEdit:
return "standardicons/Timers";
case mcRecording:
case mcRecordingInfo:
case mcSetupRecord:
case mcSetupReplay:
return "standardicons/Recordings";
2015-02-12 18:56:41 +01:00
case mcPlugin: {
//check for Plugins
for (int i = 0; ; i++) {
cPlugin *p = cPluginManager::GetPlugin(i);
if (p) {
const char *mainMenuEntry = p->MainMenuEntry();
if (mainMenuEntry) {
string plugMainEntry = mainMenuEntry;
try {
if (label.substr(0, plugMainEntry.size()) == plugMainEntry) {
return *cString::sprintf("pluginicons/%s", p->Name());
}
} catch (...) {}
}
} else
break;
}
return "standardicons/Plugins";
}
2014-10-26 08:26:44 +01:00
case mcPluginSetup:
case mcSetupPlugins:
return "standardicons/Plugins";
case mcSetup:
return "standardicons/Setup";
case mcSetupOsd:
return "standardicons/OSD";
case mcSetupEpg:
return "standardicons/EPG";
case mcSetupDvb:
return "standardicons/DVB";
case mcSetupLnb:
return "standardicons/LNB";
case mcSetupCam:
return "standardicons/CAM";
case mcSetupMisc:
return "standardicons/Miscellaneous";
case mcCommand:
return "standardicons/Commands";
2015-04-02 11:57:19 +02:00
default:
break;
2014-10-26 08:26:44 +01:00
}
2014-09-27 09:25:14 +02:00
//check for standard menu entries
for (int i=0; i<16; i++) {
string s = trVDR(items[i].c_str());
if (s == label) {
return *cString::sprintf("standardicons/%s", items[i].c_str());
}
}
//check for special main menu entries "stop recording", "stop replay"
string stopRecording = skipspace(trVDR(" Stop recording "));
string stopReplay = skipspace(trVDR(" Stop replaying"));
try {
if (label.substr(0, stopRecording.size()) == stopRecording) {
return "standardicons/StopRecording";
}
if (label.substr(0, stopReplay.size()) == stopReplay) {
return "standardicons/StopReplay";
}
} catch (...) {}
//check for Plugins
if (plugName.size() > 0) {
return *cString::sprintf("pluginicons/%s", plugName.c_str());
}
2014-09-27 09:25:14 +02:00
for (int i = 0; ; i++) {
cPlugin *p = cPluginManager::GetPlugin(i);
if (p) {
const char *mainMenuEntry = p->MainMenuEntry();
if (mainMenuEntry) {
string plugMainEntry = mainMenuEntry;
try {
if (label.substr(0, plugMainEntry.size()) == plugMainEntry) {
return *cString::sprintf("pluginicons/%s", p->Name());
}
} catch (...) {}
}
} else
break;
}
return *cString::sprintf("customicons/%s", label.c_str());
}
bool cImageCache::MenuIconExists(string name) {
//first check in theme specific icon folder
cString iconThemePath = cString::sprintf("%smenuicons/", iconPathTheme.c_str());
if (FileExists(*iconThemePath, name, "svg")) {
return true;
}
if (FileExists(*iconThemePath, name, "png")) {
return true;
}
//then check skin icon folder
cString iconSkinPath = cString::sprintf("%smenuicons/", iconPathSkin.c_str());
if (FileExists(*iconSkinPath, name, "svg")) {
return true;
}
if (FileExists(*iconSkinPath, name, "png")) {
return true;
}
2016-04-19 16:54:30 +02:00
//finally check svg templates
cString iconTemplatePath = cString::sprintf("%smenuicons/", svgTemplatePath.c_str());
if (FileExists(*iconTemplatePath, name, "svg")) {
return true;
}
return false;
}
2014-09-27 09:25:14 +02:00
void cImageCache::CacheSkinpart(string name, int width, int height) {
if (width < 1 || width > 1920 || height < 1 || height > 1080)
return;
2014-11-25 14:33:59 +01:00
GetSkinpart(name, width, height);
2014-09-27 09:25:14 +02:00
}
2016-01-26 18:32:38 +01:00
cCachedImage *cImageCache::GetSkinpart(string name, int width, int height) {
2014-09-27 09:25:14 +02:00
if (width < 1 || width > 1920 || height < 1 || height > 1080)
return NULL;
cMutexLock MutexLock(&mutex);
stringstream iconName;
iconName << name << "_" << width << "x" << height;
2016-01-26 18:32:38 +01:00
map<string, cCachedImage*>::iterator hit = skinPartsCache.find(iconName.str());
2014-09-27 09:25:14 +02:00
if (hit != skinPartsCache.end()) {
2016-01-26 18:32:38 +01:00
return (cCachedImage*)hit->second;
2014-09-27 09:25:14 +02:00
} else {
bool success = LoadSkinpart(name);
if (!success)
return NULL;
cImage *image = CreateImage(width, height, false);
2016-01-26 18:32:38 +01:00
cCachedImage *cachedImg = new cCachedImage();
cachedImg->size = image->Width() * image->Height() * sizeof(tColor);
int handle = cOsdProvider::StoreImage(*image);
if (handle) {
cachedImg->handle = handle;
delete image;
} else {
cachedImg->image = image;
}
skinPartsCache.insert(pair<string, cCachedImage*>(iconName.str(), cachedImg));
2014-09-27 09:25:14 +02:00
hit = skinPartsCache.find(iconName.str());
if (hit != skinPartsCache.end()) {
2016-01-26 18:32:38 +01:00
return (cCachedImage*)hit->second;
2014-09-27 09:25:14 +02:00
}
}
return NULL;
}
cImage *cImageCache::GetVerticalText(string text, tColor color, string font, int size, int direction) {
2015-03-12 17:28:35 +01:00
cMutexLock MutexLock(&mutex);
stringstream buf;
buf << text << "_" << size << "_" << direction;
2015-03-12 17:28:35 +01:00
string imgName = buf.str();
map<string, cImage*>::iterator hit = cairoImageCache.find(imgName);
if (hit != cairoImageCache.end()) {
return (cImage*)hit->second;
} else {
cCairoImage c;
c.DrawTextVertical(text, color, font, size, direction);
2015-03-12 17:28:35 +01:00
cImage *image = c.GetImage();
cairoImageCache.insert(pair<string, cImage*>(imgName, image));
hit = cairoImageCache.find(imgName);
if (hit != cairoImageCache.end()) {
return (cImage*)hit->second;
}
}
return NULL;
}
2014-09-27 09:25:14 +02:00
bool cImageCache::LoadIcon(eImageType type, string name) {
cString subdir("");
2016-01-26 18:32:38 +01:00
if (type == eImageType::menuicon)
2014-09-27 09:25:14 +02:00
subdir = "menuicons";
2016-01-26 18:32:38 +01:00
else if (type == eImageType::icon)
2014-09-27 09:25:14 +02:00
subdir = "icons";
2014-10-30 21:07:26 +01:00
//first check in theme specific icon path
cString subIconThemePath = cString::sprintf("%s%s/", iconPathTheme.c_str(), *subdir);
if (FileExists(*subIconThemePath, name, "svg"))
return LoadImage(*subIconThemePath, name, "svg");
else if (FileExists(*subIconThemePath, name, "png"))
return LoadImage(*subIconThemePath, name, "png");
//then check in skin icon path
cString subIconSkinPath = cString::sprintf("%s%s/", iconPathSkin.c_str(), *subdir);
if (FileExists(*subIconSkinPath, name, "svg"))
return LoadImage(*subIconSkinPath, name, "svg");
2015-06-13 10:46:11 +02:00
else if (FileExists(*subIconSkinPath, name, "png"))
return LoadImage(*subIconSkinPath, name, "png");
2015-06-13 10:46:11 +02:00
//and finally check if a svg template exists
cSVGTemplate svgTemplate(name, *subdir, svgTemplatePath);
2015-06-13 10:46:11 +02:00
if (!svgTemplate.Exists())
return false;
svgTemplate.ReadTemplate();
if (!svgTemplate.ParseTemplate())
return false;
string tmpImageName = svgTemplate.WriteImage();
return LoadImage(tmpImageName.c_str());
2014-09-27 09:25:14 +02:00
}
bool cImageCache::LoadLogo(const cChannel *channel) {
if (!channel)
return false;
string channelID = StrToLowerCase(*(channel->GetChannelID().ToString()));
string logoLower = StrToLowerCase(channel->Name());
2014-10-30 21:07:26 +01:00
2014-11-11 20:50:00 +01:00
if (FileExists(logoPath.c_str(), channelID.c_str(), "svg"))
return LoadImage(logoPath.c_str(), channelID.c_str(), "svg");
if (FileExists(logoPath.c_str(), channelID.c_str(), "png"))
return LoadImage(logoPath.c_str(), channelID.c_str(), "png");
if (FileExists(logoPath.c_str(), logoLower.c_str(), "svg"))
return LoadImage(logoPath.c_str(), logoLower.c_str(), "svg");
if (FileExists(logoPath.c_str(), logoLower.c_str(), "png"))
return LoadImage(logoPath.c_str(), logoLower.c_str(), "png");
2014-10-30 21:07:26 +01:00
2014-09-27 09:25:14 +02:00
return false;
}
bool cImageCache::LoadSeparatorLogo(string name) {
2014-11-11 20:50:00 +01:00
string separatorPath = *cString::sprintf("%sseparatorlogos/", logoPath.c_str());
2014-09-27 09:25:14 +02:00
string nameLower = StrToLowerCase(name.c_str());
2014-11-12 17:05:36 +01:00
if (FileExists(separatorPath, nameLower.c_str(), "svg"))
return LoadImage(separatorPath, nameLower.c_str(), "svg");
else
return LoadImage(separatorPath, nameLower.c_str(), "png");
2014-09-27 09:25:14 +02:00
}
bool cImageCache::LoadSkinpart(string name) {
if (FileExists(skinPartsPathTheme.c_str(), name, "svg"))
return LoadImage(skinPartsPathTheme.c_str(), name, "svg");
else if (FileExists(skinPartsPathTheme.c_str(), name, "png"))
return LoadImage(skinPartsPathTheme.c_str(), name, "png");
else if (FileExists(skinPartsPathSkin.c_str(), name, "svg"))
return LoadImage(skinPartsPathSkin.c_str(), name, "svg");
2015-06-13 10:46:11 +02:00
else if (FileExists(skinPartsPathSkin.c_str(), name, "png"))
return LoadImage(skinPartsPathSkin.c_str(), name, "png");
2015-06-13 10:46:11 +02:00
//check if a svg template exists
cSVGTemplate svgTemplate(name, "skinparts", svgTemplatePath);
2015-06-13 10:46:11 +02:00
if (!svgTemplate.Exists())
return false;
svgTemplate.ReadTemplate();
if (!svgTemplate.ParseTemplate())
return false;
string tmpImageName = svgTemplate.WriteImage();
return LoadImage(tmpImageName.c_str());
2014-09-27 09:25:14 +02:00
}
void cImageCache::Clear(void) {
2016-01-26 18:32:38 +01:00
for(map<string, cCachedImage*>::const_iterator it = iconCache.begin(); it != iconCache.end(); it++) {
cCachedImage *img = (cCachedImage*)it->second;
2014-09-27 09:25:14 +02:00
delete img;
}
iconCache.clear();
for(map<string, cImage*>::const_iterator it = channelLogoCache.begin(); it != channelLogoCache.end(); it++) {
cImage *img = (cImage*)it->second;
delete img;
}
channelLogoCache.clear();
2016-01-26 18:32:38 +01:00
for(map<string, cCachedImage*>::const_iterator it = skinPartsCache.begin(); it != skinPartsCache.end(); it++) {
cCachedImage *img = (cCachedImage*)it->second;
2014-09-27 09:25:14 +02:00
delete img;
}
skinPartsCache.clear();
2015-03-12 17:28:35 +01:00
for(map<string, cImage*>::const_iterator it = cairoImageCache.begin(); it != cairoImageCache.end(); it++) {
cImage *img = (cImage*)it->second;
delete img;
}
cairoImageCache.clear();
2014-09-27 09:25:14 +02:00
}
void cImageCache::Debug(bool full) {
2016-01-26 18:32:38 +01:00
float sizeIconCacheInternal = 0;
float sizeIconCacheExternal = 0;
2014-09-27 09:25:14 +02:00
int numIcons = 0;
2016-01-26 18:32:38 +01:00
GetIconCacheSize(numIcons, sizeIconCacheInternal, sizeIconCacheExternal);
dsyslog("skindesigner: cached %d icons - size internal mem %.2fMB, high level mem %.2fMB", numIcons, sizeIconCacheInternal, sizeIconCacheExternal);
2014-09-27 09:25:14 +02:00
if (full) {
2016-01-26 18:32:38 +01:00
for(std::map<std::string, cCachedImage*>::const_iterator it = iconCache.begin(); it != iconCache.end(); it++) {
2014-09-27 09:25:14 +02:00
string name = it->first;
2016-01-26 18:32:38 +01:00
cCachedImage *img = (cCachedImage*)it->second;
dsyslog("skindesigner: cached icon %s, handle %d", name.c_str(), img->handle);
2014-09-27 09:25:14 +02:00
}
}
2016-01-26 18:32:38 +01:00
float sizeLogoCache = 0;
2014-09-27 09:25:14 +02:00
int numLogos = 0;
GetLogoCacheSize(numLogos, sizeLogoCache);
2016-01-26 18:32:38 +01:00
dsyslog("skindesigner: cached %d logos - size %.2fMB internal mem", numLogos, sizeLogoCache);
2014-09-27 09:25:14 +02:00
if (full) {
for(std::map<std::string, cImage*>::const_iterator it = channelLogoCache.begin(); it != channelLogoCache.end(); it++) {
string name = it->first;
dsyslog("skindesigner: cached logo %s", name.c_str());
}
}
2016-01-26 18:32:38 +01:00
float sizeSkinpartCacheInternal = 0;
float sizeSkinpartCacheExternal = 0;
2014-09-27 09:25:14 +02:00
int numSkinparts = 0;
2016-01-26 18:32:38 +01:00
GetSkinpartsCacheSize(numSkinparts, sizeSkinpartCacheInternal, sizeSkinpartCacheExternal);
dsyslog("skindesigner: cached %d skinparts - size internal mem %.2fMB, high level mem %.2fMB", numSkinparts, sizeSkinpartCacheInternal, sizeSkinpartCacheExternal);
2014-09-27 09:25:14 +02:00
if (full) {
2016-01-26 18:32:38 +01:00
for(std::map<std::string, cCachedImage*>::const_iterator it = skinPartsCache.begin(); it != skinPartsCache.end(); it++) {
2014-09-27 09:25:14 +02:00
string name = it->first;
dsyslog("skindesigner: cached skinpart %s", name.c_str());
}
}
}
2016-01-26 18:32:38 +01:00
void cImageCache::GetIconCacheSize(int &num, float &sizeInternal, float &sizeExternal) {
2014-09-27 09:25:14 +02:00
num = iconCache.size();
2016-01-26 18:32:38 +01:00
int sizeByteInternal = 0;
int sizeByteExternal = 0;
for (map<string, cCachedImage*>::iterator icon = iconCache.begin(); icon != iconCache.end(); icon++) {
cCachedImage* img = icon->second;
if (img->image)
sizeByteInternal += img->size;
else
sizeByteExternal += img->size;
2014-09-27 09:25:14 +02:00
}
2016-01-26 18:32:38 +01:00
sizeInternal = sizeByteInternal / 1024.0f / 1024.0f;
sizeExternal = sizeByteExternal / 1024.0f / 1024.0f;
2014-09-27 09:25:14 +02:00
}
2016-01-26 18:32:38 +01:00
void cImageCache::GetLogoCacheSize(int &num, float &size) {
2014-09-27 09:25:14 +02:00
num = channelLogoCache.size();
2016-01-26 18:32:38 +01:00
int sizeByte = 0;
2014-09-27 09:25:14 +02:00
for (map<string, cImage*>::iterator logo = channelLogoCache.begin(); logo != channelLogoCache.end(); logo++) {
cImage* img = logo->second;
2016-01-26 18:32:38 +01:00
sizeByte += img->Width() * img->Height() * sizeof(tColor);
2014-09-27 09:25:14 +02:00
}
2016-01-26 18:32:38 +01:00
size = sizeByte / 1024.0f;
2014-09-27 09:25:14 +02:00
}
2016-01-26 18:32:38 +01:00
void cImageCache::GetSkinpartsCacheSize(int &num, float &sizeInternal, float &sizeExternal) {
2014-09-27 09:25:14 +02:00
num = skinPartsCache.size();
2016-01-26 18:32:38 +01:00
int sizeByteInternal = 0;
int sizeByteExternal = 0;
for (map<string, cCachedImage*>::iterator skinpart = skinPartsCache.begin(); skinpart != skinPartsCache.end(); skinpart++) {
cCachedImage* img = skinpart->second;
if (img->image)
sizeByteInternal += img->size;
else
sizeByteExternal += img->size;
}
sizeInternal = sizeByteInternal / 1024.0f / 1024.0f;
sizeExternal = sizeByteExternal / 1024.0f / 1024.0f;
2014-09-27 09:25:14 +02:00
}