diff options
author | louis <louis.braun@gmx.de> | 2014-11-01 16:02:56 +0100 |
---|---|---|
committer | louis <louis.braun@gmx.de> | 2014-11-01 16:02:56 +0100 |
commit | f478ad10bbac192819c98a2edab464fb6347d5e9 (patch) | |
tree | a43030718608e5c21541ce8667f66c3e4c25ac86 | |
parent | f9f68cae8d64f5c60ffaa34118b66f5ebab28506 (diff) | |
download | vdr-plugin-skindesigner-f478ad10bbac192819c98a2edab464fb6347d5e9.tar.gz vdr-plugin-skindesigner-f478ad10bbac192819c98a2edab464fb6347d5e9.tar.bz2 |
optimized performance when creating a menu list
-rw-r--r-- | HISTORY | 1 | ||||
-rw-r--r-- | libtemplate/templatefunction.c | 33 | ||||
-rw-r--r-- | libtemplate/templatefunction.h | 2 | ||||
-rw-r--r-- | libtemplate/templatepixmap.c | 5 | ||||
-rw-r--r-- | libtemplate/templateview.c | 1 |
5 files changed, 39 insertions, 3 deletions
@@ -50,5 +50,6 @@ Version 0.0.3 - added {channelname}, {channelid}, {channellogoexists} for all schedules list and current views - added printf function for <drawtext>, see Wiki for documentation - removed code for displaying bitrates in displaychannel again because of incompatibility with dvbapi Plugin +- optimized performance when creating a menu list diff --git a/libtemplate/templatefunction.c b/libtemplate/templatefunction.c index df3e653..699e872 100644 --- a/libtemplate/templatefunction.c +++ b/libtemplate/templatefunction.c @@ -272,6 +272,36 @@ bool cTemplateFunction::CalculateParameters(void) { 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) {
switch (type) {
case ftDrawImage: {
@@ -733,8 +763,11 @@ bool cTemplateFunction::SetNumericParameter(eParamType type, string value) { if (this->type < ftLoop && type == ptY) {
val += containerY;
}
+ numericParameters.erase(type);
+ numericDynamicParameters.erase(type);
numericParameters.insert(pair<eParamType, int>(type, val));
} else {
+ numericDynamicParameters.erase(type);
numericDynamicParameters.insert(pair<eParamType, string>(type, parsedValue));
}
return param.Valid();
diff --git a/libtemplate/templatefunction.h b/libtemplate/templatefunction.h index 2af95dd..f7af25c 100644 --- a/libtemplate/templatefunction.h +++ b/libtemplate/templatefunction.h @@ -172,6 +172,8 @@ public: void SetTranslatedText(string translation); //PreCache Parameters bool CalculateParameters(void); + //Complete Parameters + bool ReCalculateParameters(void); void CompleteParameters(void); //Set and Unset Dynamic Tokens from view void SetStringTokens(map < string, string > *tok) { stringTokens = tok; }; diff --git a/libtemplate/templatepixmap.c b/libtemplate/templatepixmap.c index 4fbd513..a1d032b 100644 --- a/libtemplate/templatepixmap.c +++ b/libtemplate/templatepixmap.c @@ -78,11 +78,12 @@ void cTemplatePixmap::ParseDynamicParameters(map <string,int> *intTokens, bool i for (vector<cTemplateFunction*>::iterator func = functions.begin(); func != functions.end(); func++) {
(*func)->SetContainer(x, y, width, height);
- (*func)->CalculateParameters();
+ (*func)->ReCalculateParameters();
(*func)->CompleteParameters();
if ((*func)->GetType() == ftLoop) {
cTemplateLoopFunction *loopFunc = dynamic_cast<cTemplateLoopFunction*>(*func);
if (!loopFunc->Ready()) {
+ loopFunc->CalculateParameters();
loopFunc->SetIntTokens(intTokens);
loopFunc->ParseParameters();
loopFunc->UnsetIntTokens();
@@ -137,8 +138,6 @@ bool cTemplatePixmap::CalculateParameters(void) { for (vector<cTemplateFunction*>::iterator func = functions.begin(); func != functions.end(); func++) {
(*func)->SetGlobals(globals);
- if (!Ready())
- continue;
(*func)->SetContainer(0, 0, pixWidth, pixHeight);
paramsValid = (*func)->CalculateParameters();
(*func)->CompleteParameters();
diff --git a/libtemplate/templateview.c b/libtemplate/templateview.c index f122732..1dabe8c 100644 --- a/libtemplate/templateview.c +++ b/libtemplate/templateview.c @@ -362,6 +362,7 @@ void cTemplateView::PreCache(bool isSubview) { pixOffset += viewElement->GetNumPixmaps(); } + //Cache ViewLists for (map < eViewList, cTemplateViewList* >::iterator it = viewLists.begin(); it != viewLists.end(); it++) { cTemplateViewList *viewList = it->second; |