]> O.S.I.I.S - jp/crow.git/commitdiff
IsQueuedForRedraw boolean in each GO, to prevent searching in object list
authorjpbruyere <jp.bruyere@hotmail.com>
Thu, 11 Feb 2016 11:50:46 +0000 (12:50 +0100)
committerjpbruyere <jp.bruyere@hotmail.com>
Thu, 11 Feb 2016 11:50:46 +0000 (12:50 +0100)
Move lastPaintedSlot update to Paint instead of UpdateGraphic which is not called if GO isn't cached

UnitTest/NUnitCrowWindow.cs
src/GraphicObjects/GraphicObject.cs
src/OpenTKGameWindow.cs

index f0879dd955bc8bd0b7f484502dfeb645a09139b2..95a28f0173c23f660f95a27167aa6007eb6e5398 100644 (file)
@@ -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(){
index e3780845bcfd2ee0822d7c3338c0c21774847b7a..14516dba43606a5dfc240f8fe76ecbcbedd601c9 100644 (file)
@@ -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;
                /// <summary>
                /// Add clipping region in redraw list of interface, dont update cached object content
                /// </summary>
                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 </summary>
                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) {
index ac3cd75cd7826a43ca156599297de6e6e5693228..16362c6c195e4e804478c91bb861efec28a9ef8e 100644 (file)
@@ -281,6 +281,7 @@ namespace Crow
                                        gobjsToRedraw.CopyTo (gotr);
                                        gobjsToRedraw.Clear ();
                                        foreach (GraphicObject p in gotr) {
+                                               p.IsQueuedForRedraw = false;
                                                p.registerClipRect ();
                                        }