]> O.S.I.I.S - jp/crow.git/commitdiff
Layouting DiscardQueue with MaxDiscardCount
authorjpbruyere <jp.bruyere@hotmail.com>
Thu, 4 Aug 2016 17:48:05 +0000 (19:48 +0200)
committerjpbruyere <jp.bruyere@hotmail.com>
Thu, 4 Aug 2016 18:06:58 +0000 (20:06 +0200)
modifié :         src/Interface.cs
modifié :         src/LayoutingQueueItem.cs

modifié :         src/GraphicObjects/ListBox.cs

src/GraphicObjects/ListBox.cs
src/Interface.cs
src/LayoutingQueueItem.cs

index 826eb38876f8fad7873c1995bb74f559f7164c64..fdb3960f21c1326eb64b75c78a6b55a9e3c71456 100644 (file)
@@ -163,13 +163,12 @@ namespace Crow
                                IMLStream itemStream = null;
                                Type dataType = data [i].GetType ();
 
-                               if (itemTemplates.ContainsKey (dataType.FullName)) {
+                               if (itemTemplates.ContainsKey (dataType.FullName))
                                        itemStream = itemTemplates [dataType.FullName];
-                               } else {
+                               else
                                        itemStream = itemTemplates ["default"];
-                               }
 
-                               lock (Interface.CurrentInterface.UpdateMutex) {
+                               lock (Interface.CurrentInterface.LayoutMutex) {
                                        g = Interface.Load (itemStream);
                                        page.AddChild (g);
                                        g.DataSource = data [i];
@@ -181,7 +180,7 @@ namespace Crow
                                //g.LogicalParent = this;
                        }
 
-                       lock (Interface.CurrentInterface.UpdateMutex)
+                       lock (Interface.CurrentInterface.LayoutMutex)
                                _list.AddChild (page);
 
                        #if DEBUG_LOAD
index 6d532164cd0c7b88ad5689ea3e9c935172f3fcf6..ca5cb28f689dbffc10561549570cdda85c1a0064 100644 (file)
@@ -81,7 +81,8 @@ namespace Crow
                public const int MaxCacheSize = 2048;
                /// <summary> Above this count, the layouting is discard for the widget and it
                /// will not be rendered on screen </summary>
-               public const int MaxLayoutingTries = 50;
+               public const int MaxLayoutingTries = 5;
+               public const int MaxDiscardCount = 10;
                /// <summary> Global font rendering settings for Cairo </summary>
                public static FontOptions FontRenderingOptions;
                #endregion
@@ -89,6 +90,7 @@ namespace Crow
                internal bool XmlLoading = false;
 
                public Queue<LayoutingQueueItem> LayoutingQueue = new Queue<LayoutingQueueItem> ();
+               public Queue<LayoutingQueueItem> DiscardQueue;
                public Queue<LayoutingQueueItem> ProcessedLayoutingQueue;
                public Queue<GraphicObject> DrawingQueue = new Queue<GraphicObject>();
                public string Clipboard;//TODO:use object instead for complex copy paste
@@ -96,6 +98,12 @@ namespace Crow
                {
 //                     if (g.RegisteredLayoutings != LayoutingType.None)
 //                             return;
+                       ILayoutable l = g;
+                       while (l.Parent != null)
+                               l = l.Parent;
+                       if (!(l is Interface))
+                               return;
+
                        lock (DrawingQueue) {
                                if (g.IsQueueForRedraw)
                                        return;
@@ -400,14 +408,17 @@ namespace Crow
                        #if MEASURE_TIME
                        layoutTime.Restart();
                        #endif
+                       DiscardQueue = new Queue<LayoutingQueueItem> ();
                        lock (LayoutMutex) {
                                //Debug.WriteLine ("======= Layouting queue start =======");
                                LayoutingQueueItem lqi = null;
-                               while (Interface.CurrentInterface.LayoutingQueue.Count > 0) {
-                                       lqi = Interface.CurrentInterface.LayoutingQueue.Dequeue ();
+                               while (LayoutingQueue.Count > 0) {
+                                       lqi = LayoutingQueue.Dequeue ();
                                        lqi.ProcessLayouting ();
                                }
+                               LayoutingQueue = DiscardQueue;
                        }
+                       DiscardQueue = null;
 
                        #if MEASURE_TIME
                        layoutTime.Stop ();
index 8ffb7dbf74e93a96872fbabd841c9784ae7a07ab..f35eb78d5ad43d811e9b88910d57d41b1f379a69 100644 (file)
@@ -46,7 +46,7 @@ namespace Crow
                /// <summary> Bitfield containing the element of the layout to performs (x|y|width|height)</summary>
                public LayoutingType LayoutType;
                /// <summary> Unsuccessfull UpdateLayout and requeueing count </summary>
-               public int LayoutingTries;
+               public int LayoutingTries, DiscardCount;
 
                #region CTOR
                public LayoutingQueueItem (LayoutingType _layoutType, ILayoutable _graphicObject)
@@ -70,16 +70,30 @@ namespace Crow
                        Debug.WriteLine ("Layouting => " + this.ToString ());
                        #endif
                        if (!GraphicObject.UpdateLayout (LayoutType)) {
-                               #if DEBUG_LAYOUTING
-                               Debug.WriteLine ("\tRequeuing => " + this.ToString ());
-                               #endif
-                               LayoutingTries ++;
                                if (LayoutingTries < Interface.MaxLayoutingTries) {
+                                       #if DEBUG_LAYOUTING
+                                       Debug.WriteLine ("\tRequeuing  => " + this.ToString ());
+                                       #endif
+                                       LayoutingTries++;
                                        GraphicObject.RegisteredLayoutings |= LayoutType;
                                        Interface.CurrentInterface.LayoutingQueue.Enqueue (this);
+                               } else if (DiscardCount < Interface.MaxDiscardCount) {
+                                       #if DEBUG_LAYOUTING
+                                       Debug.WriteLine ("\tDiscarding => " + this.ToString ());
+                                       #endif
+                                       LayoutingTries = 0;
+                                       DiscardCount++;
+                                       GraphicObject.RegisteredLayoutings |= LayoutType;
+                                       Interface.CurrentInterface.DiscardQueue.Enqueue (this);
                                }
-                       } else
+                               //#if DEBUG_LAYOUTING
+                               else
+                                       Debug.WriteLine ("\tDELETED    => " + this.ToString ());
+                               //#endif
+                       } else {
+                               DiscardCount = 0;
                                LayoutingTries = 0;
+                       }
                }
 
                public static implicit operator GraphicObject(LayoutingQueueItem queueItem)