From 63e3afd99db6ec60e28c12c49c8d0ae9b5d7bd7b Mon Sep 17 00:00:00 2001 From: jpbruyere Date: Sat, 5 Mar 2016 20:41:26 +0100 Subject: [PATCH] remove double buffered LayoutingQueue,use dirtyBmp for gl rendering --- OTKCrow/OpenTKGameWindow.cs | 10 +-- src/GraphicObjects/GenericStack.cs | 24 +++---- src/GraphicObjects/GraphicObject.cs | 90 ++++++++++++-------------- src/GraphicObjects/Grid.cs | 4 +- src/GraphicObjects/Group.cs | 16 ++--- src/GraphicObjects/ILayoutable.cs | 4 +- src/GraphicObjects/PrivateContainer.cs | 12 ++-- src/GraphicObjects/TabView.cs | 8 +-- src/Interface.cs | 55 +++++++--------- src/LayoutingQueueItem.cs | 4 +- 10 files changed, 106 insertions(+), 121 deletions(-) diff --git a/OTKCrow/OpenTKGameWindow.cs b/OTKCrow/OpenTKGameWindow.cs index 992019a8..f9043c05 100644 --- a/OTKCrow/OpenTKGameWindow.cs +++ b/OTKCrow/OpenTKGameWindow.cs @@ -120,7 +120,7 @@ namespace Crow while (true) { CrowInterface.Update (); - Thread.Sleep (1); + Thread.Sleep (10); } } @@ -194,16 +194,10 @@ namespace Crow shader.Enable (); lock (CrowInterface.RenderMutex) { if (CrowInterface.IsDirty) { - byte[] tmp = new byte[4 * CrowInterface.DirtyRect.Width * CrowInterface.DirtyRect.Height]; - for (int y = 0; y < CrowInterface.DirtyRect.Height; y++) { - Array.Copy (CrowInterface.bmp, - ((CrowInterface.DirtyRect.Top + y) * ClientRectangle.Width * 4) + CrowInterface.DirtyRect.Left * 4, - tmp, y * CrowInterface.DirtyRect.Width * 4, CrowInterface.DirtyRect.Width * 4); - } GL.TexSubImage2D (TextureTarget.Texture2D, 0, CrowInterface.DirtyRect.Left, CrowInterface.DirtyRect.Top, CrowInterface.DirtyRect.Width, CrowInterface.DirtyRect.Height, - OpenTK.Graphics.OpenGL.PixelFormat.Bgra, PixelType.UnsignedByte, tmp); + OpenTK.Graphics.OpenGL.PixelFormat.Bgra, PixelType.UnsignedByte, CrowInterface.dirtyBmp); CrowInterface.IsDirty = false; } } diff --git a/src/GraphicObjects/GenericStack.cs b/src/GraphicObjects/GenericStack.cs index 897343b3..6dec8453 100644 --- a/src/GraphicObjects/GenericStack.cs +++ b/src/GraphicObjects/GenericStack.cs @@ -62,7 +62,7 @@ namespace Crow foreach (GraphicObject c in Children) { if (!c.Visible) continue; - if (c.QueuedLayoutings.HasFlag (LayoutingType.Width)) + if (c.RegisteredLayoutings.HasFlag (LayoutingType.Width)) return -1; tmp += c.Slot.Width + Spacing; } @@ -77,7 +77,7 @@ namespace Crow foreach (GraphicObject c in Children) { if (!c.Visible) continue; - if (c.QueuedLayoutings.HasFlag (LayoutingType.Height)) + if (c.RegisteredLayoutings.HasFlag (LayoutingType.Height)) return -1; tmp += c.Slot.Height + Spacing; } @@ -99,7 +99,7 @@ namespace Crow continue; c.Slot.X = d; d += c.Slot.Width + Spacing; - c.EnqueueForLayouting (LayoutingType.Y); + c.RegisterForLayouting (LayoutingType.Y); } } else { foreach (GraphicObject c in Children) { @@ -107,7 +107,7 @@ namespace Crow continue; c.Slot.Y = d; d += c.Slot.Height + Spacing; - c.EnqueueForLayouting (LayoutingType.X); + c.RegisterForLayouting (LayoutingType.X); } } bmp = null; @@ -115,7 +115,7 @@ namespace Crow public override bool UpdateLayout (LayoutingType layoutType) { - QueuedLayoutings &= (~layoutType); + RegisteredLayoutings &= (~layoutType); if (layoutType == LayoutingType.ArrangeChildren) { //allow 1 child to have size to 0 if stack has fixed or streched size policy, @@ -130,7 +130,7 @@ namespace Crow if (!Children [i].Visible) continue; //requeue Positionning if child is not layouted - if (Children [i].QueuedLayoutings.HasFlag (LayoutingType.Width)) + if (Children [i].RegisteredLayoutings.HasFlag (LayoutingType.Width)) return false; cptChildren++; if (Children [i].Width == 0) { @@ -169,7 +169,7 @@ namespace Crow for (int i = 0; i < Children.Count; i++) { if (!Children [i].Visible) continue; - if (Children [i].QueuedLayoutings.HasFlag (LayoutingType.Height)) + if (Children [i].RegisteredLayoutings.HasFlag (LayoutingType.Height)) return false; cptChildren++; if (Children [i].Height == 0) { @@ -205,7 +205,7 @@ namespace Crow ComputeChildrenPositions (); //if no layouting remains in queue for item, registre for redraw - if (QueuedLayoutings == LayoutingType.None && bmp==null) + if (RegisteredLayoutings == LayoutingType.None && bmp==null) this.AddToRedrawList (); return true; @@ -223,15 +223,15 @@ namespace Crow case LayoutingType.Width: if (Orientation == Orientation.Horizontal) { if (this.Bounds.Width < 0) - this.EnqueueForLayouting (LayoutingType.Width); - this.EnqueueForLayouting (LayoutingType.ArrangeChildren); + this.RegisterForLayouting (LayoutingType.Width); + this.RegisterForLayouting (LayoutingType.ArrangeChildren); } break; case LayoutingType.Height: if (Orientation == Orientation.Vertical) { if (this.Bounds.Height < 0) - this.EnqueueForLayouting (LayoutingType.Height); - this.EnqueueForLayouting (LayoutingType.ArrangeChildren); + this.RegisterForLayouting (LayoutingType.Height); + this.RegisterForLayouting (LayoutingType.ArrangeChildren); } break; } diff --git a/src/GraphicObjects/GraphicObject.cs b/src/GraphicObjects/GraphicObject.cs index 1909b07d..dd83c948 100644 --- a/src/GraphicObjects/GraphicObject.cs +++ b/src/GraphicObjects/GraphicObject.cs @@ -57,7 +57,7 @@ namespace Crow #endregion #region private fields - LayoutingType queuedLayoutings = LayoutingType.None; + LayoutingType registeredLayoutings = LayoutingType.None; ILayoutable logicalParent; ILayoutable _parent; string _name = "unamed"; @@ -101,13 +101,12 @@ namespace Crow /// IDEA is to add a ScreenCoordinates function that use only lastPaintedSlots /// public Rectangle LastPaintedSlot; - public LayoutingType RegisteredLayoutings = LayoutingType.None; public object Tag; public byte[] bmp; #endregion #region ILayoutable - [XmlIgnore]public LayoutingType QueuedLayoutings { get { return queuedLayoutings; } set { queuedLayoutings = value; } } + [XmlIgnore]public LayoutingType RegisteredLayoutings { get { return registeredLayoutings; } set { registeredLayoutings = value; } } //TODO: it would save the recurent cost of a cast in event bubbling if parent type was GraphicObject // or we could add to the interface the mouse events /// @@ -637,10 +636,6 @@ namespace Crow { Interface.RegisterForGraphicUpdate (this); } - public void RegisterForLayouting(LayoutingType lt) - { - Interface.RegisterForLayouting (this, lt); - } internal bool IsInRedrawList = false; /// /// Add clipping region in redraw list of interface, dont update cached object content @@ -664,43 +659,44 @@ namespace Crow } public virtual bool ArrangeChildren { get { return false; } } - public virtual void EnqueueForLayouting(LayoutingType layoutType){ + public virtual void RegisterForLayouting(LayoutingType layoutType){ if (Parent == null) return; - //dont set position for stretched item - if (Width == 0) - layoutType &= (~LayoutingType.X); - if (Height == 0) - layoutType &= (~LayoutingType.Y); - - if (!ArrangeChildren) - layoutType &= (~LayoutingType.ArrangeChildren); + lock (Interface.CurrentInterface.LayoutingQueue) { + //dont set position for stretched item + if (Width == 0) + layoutType &= (~LayoutingType.X); + if (Height == 0) + layoutType &= (~LayoutingType.Y); - //apply constraints depending on parent type - if (Parent is GraphicObject) - (Parent as GraphicObject).ChildrenLayoutingConstraints (ref layoutType); + if (!ArrangeChildren) + layoutType &= (~LayoutingType.ArrangeChildren); - //prevent queueing same LayoutingType for this - layoutType &= (~QueuedLayoutings); + //apply constraints depending on parent type + if (Parent is GraphicObject) + (Parent as GraphicObject).ChildrenLayoutingConstraints (ref layoutType); - if (layoutType == LayoutingType.None) - return; + //prevent queueing same LayoutingType for this + layoutType &= (~RegisteredLayoutings); - #if DEBUG_LAYOUTING - Debug.WriteLine ("REGLayout => {1}->{0}", layoutType, this.ToString()); - #endif + if (layoutType == LayoutingType.None) + return; - //enqueue LQI LayoutingTypes separately - if (layoutType.HasFlag (LayoutingType.Width)) - Interface.CurrentInterface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.Width, this)); - if (layoutType.HasFlag (LayoutingType.Height)) - Interface.CurrentInterface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.Height, this)); - if (layoutType.HasFlag (LayoutingType.X)) - Interface.CurrentInterface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.X, this)); - if (layoutType.HasFlag (LayoutingType.Y)) - Interface.CurrentInterface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.Y, this)); - if (layoutType.HasFlag (LayoutingType.ArrangeChildren)) - Interface.CurrentInterface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.ArrangeChildren, this)); + #if DEBUG_LAYOUTING + Debug.WriteLine ("REGLayout => {1}->{0}", layoutType, this.ToString()); + #endif + //enqueue LQI LayoutingTypes separately + if (layoutType.HasFlag (LayoutingType.Width)) + Interface.CurrentInterface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.Width, this)); + if (layoutType.HasFlag (LayoutingType.Height)) + Interface.CurrentInterface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.Height, this)); + if (layoutType.HasFlag (LayoutingType.X)) + Interface.CurrentInterface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.X, this)); + if (layoutType.HasFlag (LayoutingType.Y)) + Interface.CurrentInterface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.Y, this)); + if (layoutType.HasFlag (LayoutingType.ArrangeChildren)) + Interface.CurrentInterface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.ArrangeChildren, this)); + } } /// trigger dependant sizing component update @@ -712,10 +708,10 @@ namespace Crow switch (layoutType) { case LayoutingType.Width: - EnqueueForLayouting (LayoutingType.X); + RegisterForLayouting (LayoutingType.X); break; case LayoutingType.Height: - EnqueueForLayouting (LayoutingType.Y); + RegisterForLayouting (LayoutingType.Y); break; } LayoutChanged.Raise (this, new LayoutingEventArgs (layoutType)); @@ -728,14 +724,14 @@ namespace Crow public virtual bool UpdateLayout (LayoutingType layoutType) { //unset bit, it would be reset if LQI is re-queued - queuedLayoutings &= (~layoutType); + registeredLayoutings &= (~layoutType); switch (layoutType) { case LayoutingType.X: if (Bounds.X == 0) { - if (Parent.QueuedLayoutings.HasFlag (LayoutingType.Width) || - QueuedLayoutings.HasFlag (LayoutingType.Width)) + if (Parent.RegisteredLayoutings.HasFlag (LayoutingType.Width) || + RegisteredLayoutings.HasFlag (LayoutingType.Width)) return false; switch (HorizontalAlignment) { @@ -764,8 +760,8 @@ namespace Crow case LayoutingType.Y: if (Bounds.Y == 0) { - if (Parent.QueuedLayoutings.HasFlag (LayoutingType.Height) || - QueuedLayoutings.HasFlag (LayoutingType.Height)) + if (Parent.RegisteredLayoutings.HasFlag (LayoutingType.Height) || + RegisteredLayoutings.HasFlag (LayoutingType.Height)) return false; switch (VerticalAlignment) { @@ -796,7 +792,7 @@ namespace Crow Slot.Width = Width; else if (Width < 0) { Slot.Width = measureRawSize (LayoutingType.Width); - }else if (Parent.QueuedLayoutings.HasFlag (LayoutingType.Width)) + }else if (Parent.RegisteredLayoutings.HasFlag (LayoutingType.Width)) return false; else Slot.Width = Parent.ClientRectangle.Width; @@ -821,7 +817,7 @@ namespace Crow Slot.Height = Height; else if (Height < 0){ Slot.Height = measureRawSize (LayoutingType.Height); - }else if (Parent.QueuedLayoutings.HasFlag (LayoutingType.Height)) + }else if (Parent.RegisteredLayoutings.HasFlag (LayoutingType.Height)) return false; else Slot.Height = Parent.ClientRectangle.Height; @@ -844,7 +840,7 @@ namespace Crow } //if no layouting remains in queue for item, registre for redraw - if (this.queuedLayoutings == LayoutingType.None && bmp == null) + if (this.registeredLayoutings == LayoutingType.None && bmp == null) this.AddToRedrawList (); return true; diff --git a/src/GraphicObjects/Grid.cs b/src/GraphicObjects/Grid.cs index e13690a7..a16deb8c 100644 --- a/src/GraphicObjects/Grid.cs +++ b/src/GraphicObjects/Grid.cs @@ -128,14 +128,14 @@ namespace Crow public override bool UpdateLayout (LayoutingType layoutType) { - QueuedLayoutings &= (~layoutType); + RegisteredLayoutings &= (~layoutType); if (layoutType == LayoutingType.ArrangeChildren) { ComputeChildrenPositions (); //if no layouting remains in queue for item, registre for redraw - if (QueuedLayoutings == LayoutingType.None && bmp==null) + if (RegisteredLayoutings == LayoutingType.None && bmp==null) this.AddToRedrawList (); return true; diff --git a/src/GraphicObjects/Group.cs b/src/GraphicObjects/Group.cs index 3b2c1380..869ec113 100644 --- a/src/GraphicObjects/Group.cs +++ b/src/GraphicObjects/Group.cs @@ -162,14 +162,14 @@ namespace Crow foreach (GraphicObject c in Children) { if (!c.Visible) continue; - c.EnqueueForLayouting (LayoutingType.X | LayoutingType.Width); + c.RegisterForLayouting (LayoutingType.X | LayoutingType.Width); } break; case LayoutingType.Height: foreach (GraphicObject c in Children) { if (!c.Visible) continue; - c.EnqueueForLayouting (LayoutingType.Y | LayoutingType.Height); } + c.RegisterForLayouting (LayoutingType.Y | LayoutingType.Height); } break; } } @@ -182,14 +182,14 @@ namespace Crow maxChildrenWidth = g.Slot.Width; largestChild = g; if (this.Bounds.Width < 0) - this.EnqueueForLayouting (LayoutingType.Width); + this.RegisterForLayouting (LayoutingType.Width); } else if (g == largestChild) { largestChild = null; maxChildrenWidth = 0; if (this.Bounds.Width < 0) - this.EnqueueForLayouting (LayoutingType.Width); + this.RegisterForLayouting (LayoutingType.Width); } break; case LayoutingType.Height: @@ -197,14 +197,14 @@ namespace Crow maxChildrenHeight = g.Slot.Height; tallestChild = g; if (this.Bounds.Height < 0) - this.EnqueueForLayouting (LayoutingType.Height); + this.RegisterForLayouting (LayoutingType.Height); } else if (g == tallestChild) { tallestChild = null; maxChildrenHeight = 0; if (this.Bounds.Height < 0) - this.EnqueueForLayouting (LayoutingType.Height); + this.RegisterForLayouting (LayoutingType.Height); } break; } @@ -226,7 +226,7 @@ namespace Crow for (int i = 0; i < Children.Count; i++) { if (!Children [i].Visible) continue; - if (children [i].QueuedLayoutings.HasFlag (LayoutingType.Width)) + if (children [i].RegisteredLayoutings.HasFlag (LayoutingType.Width)) continue; if (Children [i].Slot.Width > maxChildrenWidth) { maxChildrenWidth = Children [i].Slot.Width; @@ -243,7 +243,7 @@ namespace Crow for (int i = 0; i < Children.Count; i++) { if (!Children [i].Visible) continue; - if (children [i].QueuedLayoutings.HasFlag (LayoutingType.Height)) + if (children [i].RegisteredLayoutings.HasFlag (LayoutingType.Height)) continue; if (Children [i].Slot.Height > maxChildrenHeight) { maxChildrenHeight = Children [i].Slot.Height; diff --git a/src/GraphicObjects/ILayoutable.cs b/src/GraphicObjects/ILayoutable.cs index 77f9409b..a8df3ae0 100644 --- a/src/GraphicObjects/ILayoutable.cs +++ b/src/GraphicObjects/ILayoutable.cs @@ -18,8 +18,8 @@ namespace Crow Rectangle getBounds(); bool ArrangeChildren { get; } - LayoutingType QueuedLayoutings { get; set; } - void EnqueueForLayouting(LayoutingType layoutType); + LayoutingType RegisteredLayoutings { get; set; } + void RegisterForLayouting(LayoutingType layoutType); void RegisterClip(Rectangle clip); bool UpdateLayout(LayoutingType layoutType); diff --git a/src/GraphicObjects/PrivateContainer.cs b/src/GraphicObjects/PrivateContainer.cs index 1aa39633..3a3d9067 100644 --- a/src/GraphicObjects/PrivateContainer.cs +++ b/src/GraphicObjects/PrivateContainer.cs @@ -95,10 +95,10 @@ namespace Crow if (child == null) return base.measureRawSize (lt); if (lt == LayoutingType.Width) - return child.QueuedLayoutings.HasFlag(LayoutingType.Width) ? + return child.RegisteredLayoutings.HasFlag(LayoutingType.Width) ? -1 : child.Slot.Size.Width + 2 * Margin; else - return child.QueuedLayoutings.HasFlag(LayoutingType.Height) ? + return child.RegisteredLayoutings.HasFlag(LayoutingType.Height) ? -1 : child.Slot.Size.Height + 2 * Margin; } public override bool UpdateLayout (LayoutingType layoutType) @@ -127,13 +127,13 @@ namespace Crow case LayoutingType.Width: if (child != null) { if (child.Visible) - child.EnqueueForLayouting (LayoutingType.X | LayoutingType.Width); + child.RegisterForLayouting (LayoutingType.X | LayoutingType.Width); } break; case LayoutingType.Height: if (child != null) { if (child.Visible) - child.EnqueueForLayouting (LayoutingType.Y | LayoutingType.Height); + child.RegisterForLayouting (LayoutingType.Y | LayoutingType.Height); } break; } @@ -148,11 +148,11 @@ namespace Crow break; case LayoutingType.Width: if (this.Bounds.Width < 0) - this.EnqueueForLayouting (LayoutingType.Width); + this.RegisterForLayouting (LayoutingType.Width); break; case LayoutingType.Height: if (this.Bounds.Height < 0) - this.EnqueueForLayouting (LayoutingType.Height); + this.RegisterForLayouting (LayoutingType.Height); break; } } diff --git a/src/GraphicObjects/TabView.cs b/src/GraphicObjects/TabView.cs index 7ae5e3d3..2700043a 100644 --- a/src/GraphicObjects/TabView.cs +++ b/src/GraphicObjects/TabView.cs @@ -126,7 +126,7 @@ namespace Crow public override bool ArrangeChildren { get { return true; } } public override bool UpdateLayout (LayoutingType layoutType) { - QueuedLayoutings &= (~layoutType); + RegisteredLayoutings &= (~layoutType); if (layoutType == LayoutingType.ArrangeChildren) { int curOffset = Spacing; @@ -136,18 +136,18 @@ namespace Crow TabItem ti = Children [i] as TabItem; ti.TabOffset = curOffset; if (Orientation == Orientation.Horizontal) { - if (ti.TabTitle.QueuedLayoutings.HasFlag (LayoutingType.Width)) + if (ti.TabTitle.RegisteredLayoutings.HasFlag (LayoutingType.Width)) return false; curOffset += ti.TabTitle.Slot.Width + Spacing; } else { - if (ti.TabTitle.QueuedLayoutings.HasFlag (LayoutingType.Height)) + if (ti.TabTitle.RegisteredLayoutings.HasFlag (LayoutingType.Height)) return false; curOffset += ti.TabTitle.Slot.Height + Spacing; } } //if no layouting remains in queue for item, registre for redraw - if (QueuedLayoutings == LayoutingType.None && bmp==null) + if (RegisteredLayoutings == LayoutingType.None && bmp==null) this.AddToRedrawList (); return true; diff --git a/src/Interface.cs b/src/Interface.cs index f1b01fd0..8224f86f 100644 --- a/src/Interface.cs +++ b/src/Interface.cs @@ -79,23 +79,12 @@ namespace Crow public Queue LayoutingQueue = new Queue(); public Queue GraphicUpdateQueue = new Queue(); - public Queue UpdateLayoutQueue = new Queue(); - public static void RegisterForLayouting(GraphicObject g, LayoutingType lt){ - - lock (CurrentInterface.UpdateLayoutQueue) { - if (CurrentInterface == null) - return; - if (g.RegisteredLayoutings == LayoutingType.None) - CurrentInterface.UpdateLayoutQueue.Enqueue (g); - g.RegisteredLayoutings |= lt; - } - } public static void RegisterForGraphicUpdate(GraphicObject g) { lock (CurrentInterface.GraphicUpdateQueue) { if (g.IsQueueForGraphicUpdate) - return; + return; if (CurrentInterface == null) return; CurrentInterface.GraphicUpdateQueue.Enqueue (g); @@ -109,7 +98,7 @@ namespace Crow if (Interface.CurrentInterface == null) return; Interface.CurrentInterface.RedrawList.Add (g); - g.IsInRedrawList = true; + g.IsInRedrawList = true; } #region default values loading helpers @@ -238,12 +227,12 @@ namespace Crow } public GraphicObject LoadInterface (string path) - { - lock (this) { + { + lock (this) { GraphicObject tmp = Interface.Load (path, this); AddWidget (tmp); return tmp; - } + } } #endregion @@ -266,10 +255,12 @@ namespace Crow Context ctx; Surface surf; - volatile public byte[] bmp; + public byte[] bmp; + public byte[] dirtyBmp; public bool IsDirty = false; public Rectangle DirtyRect; public object RenderMutex = new object(); + public object UpdateMutex = new object(); #region focus GraphicObject _activeWidget; //button is pressed on widget @@ -337,6 +328,7 @@ namespace Crow processDrawing (); } + #if MEASURE_TIME updateTime.Stop (); #endif @@ -362,18 +354,13 @@ namespace Crow #if MEASURE_TIME layoutTime.Restart(); #endif - lock (Interface.CurrentInterface.UpdateLayoutQueue) { - while(Interface.CurrentInterface.UpdateLayoutQueue.Count>0){ - GraphicObject g = Interface.CurrentInterface.UpdateLayoutQueue.Dequeue(); - g.EnqueueForLayouting (g.RegisteredLayoutings); - g.RegisteredLayoutings = LayoutingType.None; - } - } - //Debug.WriteLine ("======= Layouting queue start ======="); - LayoutingQueueItem lqi = null; - while (Interface.CurrentInterface.LayoutingQueue.Count > 0) { + lock (Interface.CurrentInterface.LayoutingQueue) { + //Debug.WriteLine ("======= Layouting queue start ======="); + LayoutingQueueItem lqi = null; + while (Interface.CurrentInterface.LayoutingQueue.Count > 0) { lqi = Interface.CurrentInterface.LayoutingQueue.Dequeue (); lqi.ProcessLayouting (); + } } #if MEASURE_TIME layoutTime.Stop (); @@ -443,6 +430,13 @@ namespace Crow DirtyRect.Height = Math.Min (ClientRectangle.Height - DirtyRect.Top, DirtyRect.Height); DirtyRect.Width = Math.Max (0, DirtyRect.Width); DirtyRect.Height = Math.Max (0, DirtyRect.Height); + + dirtyBmp = new byte[4 * DirtyRect.Width * DirtyRect.Height]; + for (int y = 0; y < DirtyRect.Height; y++) { + Array.Copy (bmp, + ((DirtyRect.Top + y) * ClientRectangle.Width * 4) + DirtyRect.Left * 4, + dirtyBmp, y * DirtyRect.Width * 4, DirtyRect.Width * 4); + } } clipping.Reset (); } @@ -510,7 +504,7 @@ namespace Crow public void ProcessResize(Rectangle bounds){ - lock (RenderMutex) { + lock (CurrentInterface) { clientRectangle = bounds; int stride = 4 * ClientRectangle.Width; @@ -519,6 +513,7 @@ namespace Crow foreach (GraphicObject g in GraphicObjects) g.RegisterForLayouting (LayoutingType.All); + clipping.AddRectangle (clientRectangle); } } @@ -682,11 +677,11 @@ namespace Crow get { throw new NotImplementedException (); } set { throw new NotImplementedException (); } } - public LayoutingType QueuedLayoutings { + public LayoutingType RegisteredLayoutings { get { return LayoutingType.None; } set { throw new NotImplementedException (); } } - public void EnqueueForLayouting (LayoutingType layoutType) { throw new NotImplementedException (); } + public void RegisterForLayouting (LayoutingType layoutType) { throw new NotImplementedException (); } public bool UpdateLayout (LayoutingType layoutType) { throw new NotImplementedException (); } public Rectangle ContextCoordinates (Rectangle r) => r; public Rectangle ScreenCoordinates (Rectangle r) => r; diff --git a/src/LayoutingQueueItem.cs b/src/LayoutingQueueItem.cs index b9a25677..5fbde097 100644 --- a/src/LayoutingQueueItem.cs +++ b/src/LayoutingQueueItem.cs @@ -45,7 +45,7 @@ namespace Crow { LayoutType = _layoutType; GraphicObject = _graphicObject; - GraphicObject.QueuedLayoutings |= LayoutType; + GraphicObject.RegisteredLayoutings |= LayoutType; } public void ProcessLayouting() @@ -65,7 +65,7 @@ namespace Crow #endif GraphicObject.LayoutingTries ++; if (GraphicObject.LayoutingTries < Interface.MaxLayoutingTries) { - GraphicObject.QueuedLayoutings |= LayoutType; + GraphicObject.RegisteredLayoutings |= LayoutType; Interface.CurrentInterface.LayoutingQueue.Enqueue (this); } } else { -- 2.47.3