]> O.S.I.I.S - jp/crow.git/commitdiff
remove double buffered LayoutingQueue,use dirtyBmp for gl rendering
authorjpbruyere <jp.bruyere@hotmail.com>
Sat, 5 Mar 2016 19:41:26 +0000 (20:41 +0100)
committerjpbruyere <jp.bruyere@hotmail.com>
Sat, 5 Mar 2016 19:41:26 +0000 (20:41 +0100)
OTKCrow/OpenTKGameWindow.cs
src/GraphicObjects/GenericStack.cs
src/GraphicObjects/GraphicObject.cs
src/GraphicObjects/Grid.cs
src/GraphicObjects/Group.cs
src/GraphicObjects/ILayoutable.cs
src/GraphicObjects/PrivateContainer.cs
src/GraphicObjects/TabView.cs
src/Interface.cs
src/LayoutingQueueItem.cs

index 992019a8f34627f940ce0733eea656c48afe0ed4..f9043c05a8331b327d1bf749c6462a1b5c678bd6 100644 (file)
@@ -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;
                                }
                        }
index 897343b3f1a650923dd492d278cc120223c7dd96..6dec845316d3e2f7548f9f9b963f5d102f443e5e 100644 (file)
@@ -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;
                        }
index 1909b07db43e5472255fbe710ca36c27497250a2..dd83c948dcfee99d377932af36b1fa7569ff6b97 100644 (file)
@@ -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
                /// </summary>
                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
                /// <summary>
@@ -637,10 +636,6 @@ namespace Crow
                {
                        Interface.RegisterForGraphicUpdate (this);
                }
-               public void RegisterForLayouting(LayoutingType lt)
-               {
-                       Interface.RegisterForLayouting (this, lt);
-               }
                internal bool IsInRedrawList = false;
                /// <summary>
                /// 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));
+                       }
                }
 
                /// <summary> trigger dependant sizing component update </summary>
@@ -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;
index e13690a7999d64f6b68b57a778b961847913accc..a16deb8cd04cb5e5833dd4781a1aabe0f677b5ae 100644 (file)
@@ -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;
index 3b2c138022569c1f901fcc59d8b301fb47c0ead6..869ec11378a65f7170fb88be6391f0e0ea67dad4 100644 (file)
@@ -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;
index 77f9409bea0d7db12fbffc137cbb15e7557487b7..a8df3ae0a453c320a361f54bc316b9970c0c3a75 100644 (file)
@@ -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);
 
index 1aa39633e7df87018a524854d2d56f8537d98820..3a3d90671c22a504bd5668c5d07ccd2e80211d9f 100644 (file)
@@ -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;
                        }
                }
index 7ae5e3d3e1c231e2f73b9ab794265005d89b4b91..2700043aa899287c89a031fb120f5a4e0550f771 100644 (file)
@@ -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;
index f1b01fd005b58a7bf1e0759ccb33804408ce995e..8224f86f31298e353d1348f8eb7bd2eb608fa8a3 100644 (file)
@@ -79,23 +79,12 @@ namespace Crow
 
                public Queue<LayoutingQueueItem> LayoutingQueue = new Queue<LayoutingQueueItem>();
                public Queue<GraphicObject> GraphicUpdateQueue = new Queue<GraphicObject>();
-               public Queue<GraphicObject> UpdateLayoutQueue = new Queue<GraphicObject>();
 
-               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;
index b9a256775d9189663931cff8d45ca70851ca45fc..5fbde09705c54903d05d7cfee5375b411c8ede7a 100644 (file)
@@ -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 {