optimized performance when creating a menu list

This commit is contained in:
louis 2014-11-01 16:02:56 +01:00
parent f9f68cae8d
commit f478ad10bb
5 changed files with 39 additions and 3 deletions

View File

@ -50,5 +50,6 @@ Version 0.0.3
- added {channelname}, {channelid}, {channellogoexists} for all schedules list and current views - added {channelname}, {channelid}, {channellogoexists} for all schedules list and current views
- added printf function for <drawtext>, see Wiki for documentation - added printf function for <drawtext>, see Wiki for documentation
- removed code for displaying bitrates in displaychannel again because of incompatibility with dvbapi Plugin - removed code for displaying bitrates in displaychannel again because of incompatibility with dvbapi Plugin
- optimized performance when creating a menu list

View File

@ -272,6 +272,36 @@ bool cTemplateFunction::CalculateParameters(void) {
return paramsValid; return paramsValid;
} }
bool cTemplateFunction::ReCalculateParameters(void) {
bool paramValid = true;
bool paramsValid = true;
for (map< eParamType, string >::iterator param = nativeParameters.begin(); param != nativeParameters.end(); param++) {
paramValid = true;
eParamType type = param->first;
string value = param->second;
switch (type) {
case ptX:
case ptY:
case ptWidth:
case ptHeight:
case ptMenuItemWidth:
case ptFontSize:
case ptFloatWidth:
case ptFloatHeight:
case ptMaxLines:
case ptColumnWidth:
case ptRowHeight:
SetNumericParameter(type, value);
break;
}
if (!paramValid) {
paramsValid = false;
esyslog("skindesigner: %s: invalid parameter %d, value %s", GetFuncName().c_str(), type, value.c_str());
}
}
return paramsValid;
}
void cTemplateFunction::CompleteParameters(void) { void cTemplateFunction::CompleteParameters(void) {
switch (type) { switch (type) {
case ftDrawImage: { case ftDrawImage: {
@ -733,8 +763,11 @@ bool cTemplateFunction::SetNumericParameter(eParamType type, string value) {
if (this->type < ftLoop && type == ptY) { if (this->type < ftLoop && type == ptY) {
val += containerY; val += containerY;
} }
numericParameters.erase(type);
numericDynamicParameters.erase(type);
numericParameters.insert(pair<eParamType, int>(type, val)); numericParameters.insert(pair<eParamType, int>(type, val));
} else { } else {
numericDynamicParameters.erase(type);
numericDynamicParameters.insert(pair<eParamType, string>(type, parsedValue)); numericDynamicParameters.insert(pair<eParamType, string>(type, parsedValue));
} }
return param.Valid(); return param.Valid();

View File

@ -172,6 +172,8 @@ public:
void SetTranslatedText(string translation); void SetTranslatedText(string translation);
//PreCache Parameters //PreCache Parameters
bool CalculateParameters(void); bool CalculateParameters(void);
//Complete Parameters
bool ReCalculateParameters(void);
void CompleteParameters(void); void CompleteParameters(void);
//Set and Unset Dynamic Tokens from view //Set and Unset Dynamic Tokens from view
void SetStringTokens(map < string, string > *tok) { stringTokens = tok; }; void SetStringTokens(map < string, string > *tok) { stringTokens = tok; };

View File

@ -78,11 +78,12 @@ void cTemplatePixmap::ParseDynamicParameters(map <string,int> *intTokens, bool i
for (vector<cTemplateFunction*>::iterator func = functions.begin(); func != functions.end(); func++) { for (vector<cTemplateFunction*>::iterator func = functions.begin(); func != functions.end(); func++) {
(*func)->SetContainer(x, y, width, height); (*func)->SetContainer(x, y, width, height);
(*func)->CalculateParameters(); (*func)->ReCalculateParameters();
(*func)->CompleteParameters(); (*func)->CompleteParameters();
if ((*func)->GetType() == ftLoop) { if ((*func)->GetType() == ftLoop) {
cTemplateLoopFunction *loopFunc = dynamic_cast<cTemplateLoopFunction*>(*func); cTemplateLoopFunction *loopFunc = dynamic_cast<cTemplateLoopFunction*>(*func);
if (!loopFunc->Ready()) { if (!loopFunc->Ready()) {
loopFunc->CalculateParameters();
loopFunc->SetIntTokens(intTokens); loopFunc->SetIntTokens(intTokens);
loopFunc->ParseParameters(); loopFunc->ParseParameters();
loopFunc->UnsetIntTokens(); loopFunc->UnsetIntTokens();
@ -137,8 +138,6 @@ bool cTemplatePixmap::CalculateParameters(void) {
for (vector<cTemplateFunction*>::iterator func = functions.begin(); func != functions.end(); func++) { for (vector<cTemplateFunction*>::iterator func = functions.begin(); func != functions.end(); func++) {
(*func)->SetGlobals(globals); (*func)->SetGlobals(globals);
if (!Ready())
continue;
(*func)->SetContainer(0, 0, pixWidth, pixHeight); (*func)->SetContainer(0, 0, pixWidth, pixHeight);
paramsValid = (*func)->CalculateParameters(); paramsValid = (*func)->CalculateParameters();
(*func)->CompleteParameters(); (*func)->CompleteParameters();

View File

@ -362,6 +362,7 @@ void cTemplateView::PreCache(bool isSubview) {
pixOffset += viewElement->GetNumPixmaps(); pixOffset += viewElement->GetNumPixmaps();
} }
//Cache ViewLists //Cache ViewLists
for (map < eViewList, cTemplateViewList* >::iterator it = viewLists.begin(); it != viewLists.end(); it++) { for (map < eViewList, cTemplateViewList* >::iterator it = viewLists.begin(); it != viewLists.end(); it++) {
cTemplateViewList *viewList = it->second; cTemplateViewList *viewList = it->second;