eda/Id type's OnDisplay: Performance improvement: cache string in DataBox (requires...
authorJerome St-Louis <jerome@ecere.com>
Sat, 2 Jun 2012 07:58:24 +0000 (03:58 -0400)
committerJerome St-Louis <jerome@ecere.com>
Sat, 2 Jun 2012 07:58:24 +0000 (03:58 -0400)
ecere/src/com/dataTypes.ec
ecere/src/gui/controls/DataBox.ec
ecere/src/gui/drivers/XInterface.ec

index 4b2cb51..4d7e4b7 100644 (file)
@@ -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++;
index 3b2f1b4..702c4dd 100644 (file)
@@ -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);
       }
    }
 
index 7ff05c9..0683181 100644 (file)
@@ -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)
       {