From 085ca1d99f159d696dda8d49aa1deec34d57bad4 Mon Sep 17 00:00:00 2001 From: Jerome St-Louis Date: Sat, 2 Jun 2012 03:58:24 -0400 Subject: [PATCH] eda/Id type's OnDisplay: Performance improvement: cache string in DataBox (requires more testing) --- ecere/src/com/dataTypes.ec | 1 + ecere/src/gui/controls/DataBox.ec | 29 +++++++++++++++++++++++------ ecere/src/gui/drivers/XInterface.ec | 2 +- 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/ecere/src/com/dataTypes.ec b/ecere/src/com/dataTypes.ec index 4b2cb51..4d7e4b7 100644 --- a/ecere/src/com/dataTypes.ec +++ b/ecere/src/com/dataTypes.ec @@ -1078,6 +1078,7 @@ static void OnUnserialize(Class _class, void ** data, IOChannel channel) Class lastClass = null; if(_class.type == normalClass || _class.type == noHeadClass) { + // TOFIX: Seriously!?!?? Fix me! data = *data = eInstance_New(_class); if(_class.type == normalClass) ((Instance)data)._refCount++; diff --git a/ecere/src/gui/controls/DataBox.ec b/ecere/src/gui/controls/DataBox.ec index 3b2f1b4..702c4dd 100644 --- a/ecere/src/gui/controls/DataBox.ec +++ b/ecere/src/gui/controls/DataBox.ec @@ -25,11 +25,19 @@ public: bool readOnly; bool keepEditor; bool autoSize; + bool needUpdate; + String stringValue; + needUpdate = true; + + ~DataBox() + { + delete stringValue; + } virtual void SetData(any_object newData, bool closingDropDown) { //type._vTbl[__ecereVMethodID_class_OnCopy](type, data, newData); - + needUpdate = true; if(type) { if(type.type == normalClass || type.type == noHeadClass) @@ -69,6 +77,7 @@ public: void Refresh() { + needUpdate = true; if(created) { if(!keepEditor) @@ -115,11 +124,19 @@ private: { if(type) { - //type._vTbl[__ecereVMethodID_class_OnDisplay](type, this.data, surface, 3, 2, clientSize.w, null, type.defaultAlignment, 0); - if(type.type == noHeadClass || type.type == normalClass) - type._vTbl[__ecereVMethodID_class_OnDisplay](type, *(void **)this.data, surface, 3, 1, clientSize.w, fieldData, type.defaultAlignment, 0); - else - type._vTbl[__ecereVMethodID_class_OnDisplay](type, this.data, surface, 3, 1, clientSize.w, fieldData, type.defaultAlignment, 0); + char tempString[1024]; + if(needUpdate) + { + String s; + if(type.type == noHeadClass || type.type == normalClass) + s = type._vTbl[__ecereVMethodID_class_OnGetString](type, *(void **)this.data, tempString, fieldData, null); + else + s = type._vTbl[__ecereVMethodID_class_OnGetString](type, this.data, tempString, fieldData, null); + delete stringValue; + stringValue = CopyString(s); + needUpdate = false; + } + type._vTbl[__ecereVMethodID_class_OnDisplay](class(String), stringValue, surface, 3, 1, clientSize.w, fieldData, type.defaultAlignment, 0); } } diff --git a/ecere/src/gui/drivers/XInterface.ec b/ecere/src/gui/drivers/XInterface.ec index 7ff05c9..0683181 100644 --- a/ecere/src/gui/drivers/XInterface.ec +++ b/ecere/src/gui/drivers/XInterface.ec @@ -2057,7 +2057,7 @@ class XInterface : Interface #endif depth = visualInfo ? visualInfo->depth : (window.alphaBlend ? 32 : xSystemDepth); visual = visualInfo ? visualInfo->visual : (window.alphaBlend ? FindFullColorVisual (xGlobalDisplay, &depth) : xSystemVisual); - // printf("visual: %x, depth: %d\n", visualInfo ? visualInfo->visualid : 0, depth); + // printf("visual: %d, depth: %d\n", visual, depth); if(visual) { -- 1.8.3.1