From: jpbruyere Date: Thu, 4 Aug 2016 17:48:05 +0000 (+0200) Subject: Layouting DiscardQueue with MaxDiscardCount X-Git-Tag: v0.4~18^2~9 X-Git-Url: https://git.osiis.dedyn.io/?a=commitdiff_plain;h=b58c6b328c06784d31765b29b574bed17082be27;p=jp%2Fcrow.git Layouting DiscardQueue with MaxDiscardCount modifié : src/Interface.cs modifié : src/LayoutingQueueItem.cs modifié : src/GraphicObjects/ListBox.cs --- diff --git a/src/GraphicObjects/ListBox.cs b/src/GraphicObjects/ListBox.cs index 826eb388..fdb3960f 100644 --- a/src/GraphicObjects/ListBox.cs +++ b/src/GraphicObjects/ListBox.cs @@ -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 diff --git a/src/Interface.cs b/src/Interface.cs index 6d532164..ca5cb28f 100644 --- a/src/Interface.cs +++ b/src/Interface.cs @@ -81,7 +81,8 @@ namespace Crow public const int MaxCacheSize = 2048; /// Above this count, the layouting is discard for the widget and it /// will not be rendered on screen - public const int MaxLayoutingTries = 50; + public const int MaxLayoutingTries = 5; + public const int MaxDiscardCount = 10; /// Global font rendering settings for Cairo public static FontOptions FontRenderingOptions; #endregion @@ -89,6 +90,7 @@ namespace Crow internal bool XmlLoading = false; public Queue LayoutingQueue = new Queue (); + public Queue DiscardQueue; public Queue ProcessedLayoutingQueue; public Queue DrawingQueue = new Queue(); 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 (); 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 (); diff --git a/src/LayoutingQueueItem.cs b/src/LayoutingQueueItem.cs index 8ffb7dbf..f35eb78d 100644 --- a/src/LayoutingQueueItem.cs +++ b/src/LayoutingQueueItem.cs @@ -46,7 +46,7 @@ namespace Crow /// Bitfield containing the element of the layout to performs (x|y|width|height) public LayoutingType LayoutType; /// Unsuccessfull UpdateLayout and requeueing count - 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)