From: Jean-Philippe Bruyère Date: Tue, 21 Feb 2017 07:46:24 +0000 (+0100) Subject: move lastPaintedSlot affectation to end of Paint X-Git-Tag: v0.5.1~10 X-Git-Url: https://git.osiis.dedyn.io/?a=commitdiff_plain;h=f17432714c7215c2a0705d53f8e53c51b539f4a1;p=jp%2Fcrow.git move lastPaintedSlot affectation to end of Paint --- diff --git a/src/GraphicObjects/GraphicObject.cs b/src/GraphicObjects/GraphicObject.cs index 287edd50..22bfdea2 100644 --- a/src/GraphicObjects/GraphicObject.cs +++ b/src/GraphicObjects/GraphicObject.cs @@ -516,13 +516,15 @@ namespace Crow if (isVisible) RegisterForLayouting (LayoutingType.Sizing); else { - Slot.Width = 0; - LayoutChanged.Raise (this, new LayoutingEventArgs (LayoutingType.Width)); - Slot.Height = 0; - LayoutChanged.Raise (this, new LayoutingEventArgs (LayoutingType.Height)); - if (this.parent != null) - CurrentInterface.EnqueueForRepaint (this); - LastSlots.Width = LastSlots.Height = 0; + lock (CurrentInterface.UpdateMutex) { + Slot.Width = 0; + LayoutChanged.Raise (this, new LayoutingEventArgs (LayoutingType.Width)); + Slot.Height = 0; + LayoutChanged.Raise (this, new LayoutingEventArgs (LayoutingType.Height)); + if (this.parent != null) + CurrentInterface.EnqueueForRepaint (this); + LastSlots.Width = LastSlots.Height = 0; + } } //trigger a mouse to handle possible hover changes @@ -594,7 +596,7 @@ namespace Crow NotifyValueChanged ("DataSource", DataSource); } get { - return dataSource == null ? + return dataSource == null ? LogicalParent == null ? null : LogicalParent is GraphicObject ? (LogicalParent as GraphicObject).DataSource : null : dataSource; @@ -811,6 +813,20 @@ namespace Crow } #region Queuing + /// + /// Register old and new slot for clipping + /// + public virtual void ClippingRegistration(){ + IsQueueForRedraw = false; + if (Parent == null) + return; + Parent.RegisterClip (LastPaintedSlot); + Parent.RegisterClip (Slot); + } + /// + /// Add clip rectangle to this.clipping and propagate up to root + /// + /// Clip rectangle public virtual void RegisterClip(Rectangle clip){ if (CacheEnabled && !IsDirty) Clipping.AddRectangle (clip + ClientRectangle.Position); @@ -1097,7 +1113,7 @@ namespace Crow } protected virtual void UpdateCache(Context ctx){ Rectangle rb = Slot + Parent.ClientRectangle.Position; - using (ImageSurface cache = new ImageSurface (bmp, Format.Argb32, Slot.Width, Slot.Height, 4 * Slot.Width)) { + using (ImageSurface cache = new ImageSurface (bmp, Format.Argb32, Slot.Width, Slot.Height, 4 * Slot.Width)) { if (clearBackground) { ctx.Save (); ctx.Operator = Operator.Clear; @@ -1119,8 +1135,6 @@ namespace Crow if (Slot.Height < 0 || Slot.Width < 0 || parent == null) return; lock (this) { - LastPaintedSlot = Slot; - if (cacheEnabled) { if (Slot.Width > Interface.MaxCacheSize || Slot.Height > Interface.MaxCacheSize) cacheEnabled = false; @@ -1145,6 +1159,7 @@ namespace Crow ctx.Restore (); } + LastPaintedSlot = Slot; } } void paintDisabled(Context gr, Rectangle rb){ @@ -1212,7 +1227,7 @@ namespace Crow else currentInterface.clickTimer.Restart(); CurrentInterface.eligibleForDoubleClick = null; - + if (CurrentInterface.ActiveWidget == null) CurrentInterface.ActiveWidget = this; if (this.Focusable && !Interface.FocusOnHover) { diff --git a/src/Interface.cs b/src/Interface.cs index e90ae42c..c5b6013d 100644 --- a/src/Interface.cs +++ b/src/Interface.cs @@ -471,13 +471,8 @@ namespace Crow while (DrawingQueue.Count > 0) { lock (DrawingQueue) g = DrawingQueue.Dequeue (); - g.IsQueueForRedraw = false; - if (g.Parent == null) - continue; - lock (g) { - g.Parent.RegisterClip (g.LastPaintedSlot); - g.Parent.RegisterClip (g.getSlot ()); - } + lock (g) + g.ClippingRegistration (); } #if MEASURE_TIME