From: jpbruyere Date: Thu, 11 Feb 2016 11:50:46 +0000 (+0100) Subject: IsQueuedForRedraw boolean in each GO, to prevent searching in object list X-Git-Tag: 0.3~8 X-Git-Url: https://git.osiis.dedyn.io/?a=commitdiff_plain;h=0f8a64797810a03d036d7c9fcfddc5e11733f719;p=jp%2Fcrow.git IsQueuedForRedraw boolean in each GO, to prevent searching in object list Move lastPaintedSlot update to Paint instead of UpdateGraphic which is not called if GO isn't cached --- diff --git a/UnitTest/NUnitCrowWindow.cs b/UnitTest/NUnitCrowWindow.cs index f0879dd9..95a28f01 100644 --- a/UnitTest/NUnitCrowWindow.cs +++ b/UnitTest/NUnitCrowWindow.cs @@ -165,6 +165,7 @@ namespace Crow gobjsToRedraw.CopyTo (gotr); gobjsToRedraw.Clear (); foreach (GraphicObject p in gotr) { + p.IsQueuedForRedraw = false; p.registerClipRect (); } @@ -206,11 +207,12 @@ namespace Crow updateTime.Stop (); ctx.Dispose (); - sw.WriteLine ("{3}\t{0,8}\t{1,8}\t{2,8}", + sw.WriteLine ("{0}\t{1,8}\t{2,8}\t{3,8}\t{4,8}", + testId, layoutTime.ElapsedTicks, guTime.ElapsedTicks, updateTime.ElapsedTicks, - testId); + loadTime.ElapsedTicks); sw.Flush (); // Console.WriteLine("{3} => layout:{0}ms\tdraw{1}ms\tupdate:{2}ms", @@ -224,10 +226,13 @@ namespace Crow #endregion #region loading + public Stopwatch loadTime = new Stopwatch (); public GraphicObject LoadTest (string id) { testId = id; + loadTime.Start (); GraphicObject tmp = Interface.Load ("Interfaces/" + testId + ".crow", this); + loadTime.Stop (); AddWidget (tmp); return tmp; } @@ -255,8 +260,8 @@ namespace Crow sw = new StreamWriter (path); - sw.WriteLine ("ID layout draw update"); - sw.WriteLine ("------------------------------------------------"); + sw.WriteLine ("ID layout draw update load"); + sw.WriteLine ("----------------------------------------------------------------"); sw.Flush (); } ~NUnitCrowWindow(){ diff --git a/src/GraphicObjects/GraphicObject.cs b/src/GraphicObjects/GraphicObject.cs index e3780845..14516dba 100644 --- a/src/GraphicObjects/GraphicObject.cs +++ b/src/GraphicObjects/GraphicObject.cs @@ -83,6 +83,7 @@ namespace Crow Size _maximumSize = "0;0"; Size _minimumSize = "0;0"; bool cacheEnabled = false; + object dataSource; #endregion #region public fields @@ -406,8 +407,6 @@ namespace Crow get { return _minimumSize; } set { _minimumSize = value; } } - object dataSource; - [XmlIgnore]public virtual object DataSource { set { if (dataSource == value) @@ -495,19 +494,24 @@ namespace Crow bmp = null; RegisterForRedraw (); } + public bool IsQueuedForRedraw = false; /// /// Add clipping region in redraw list of interface, dont update cached object content /// public virtual void RegisterForRedraw () { + if (IsQueuedForRedraw) + return; //test if this speed up a lot to cancel clipping for an uncached group Group p = Parent as Group; if (p != null) { if (p.bmp == null) return; } - if (HostContainer != null) - HostContainer.gobjsToRedraw.Add (this); + if (HostContainer == null) + return; + HostContainer.gobjsToRedraw.Add (this); + IsQueuedForRedraw = true; } #region Layouting @@ -734,8 +738,6 @@ namespace Crow /// this trigger the effective drawing routine protected virtual void UpdateGraphic () { - LastPaintedSlot = Slot; - int stride = 4 * Slot.Width; int bmpSize = Math.Abs (stride) * Slot.Height; @@ -757,6 +759,8 @@ namespace Crow if (!Visible) return; + LastPaintedSlot = Slot; + Rectangle rb = Parent.ContextCoordinates (Slot); if (cacheEnabled) { diff --git a/src/OpenTKGameWindow.cs b/src/OpenTKGameWindow.cs index ac3cd75c..16362c6c 100644 --- a/src/OpenTKGameWindow.cs +++ b/src/OpenTKGameWindow.cs @@ -281,6 +281,7 @@ namespace Crow gobjsToRedraw.CopyTo (gotr); gobjsToRedraw.Clear (); foreach (GraphicObject p in gotr) { + p.IsQueuedForRedraw = false; p.registerClipRect (); }