internal void AddAccumRect(InvalidateGfxArgs args) { #if DEBUG Rectangle previewAccum = _accumulateInvalidRect; if (!_hasAccumRect) { previewAccum = args.GlobalRect; } else { previewAccum = Rectangle.Union(previewAccum, args.GlobalRect); } //if (previewAccum.Height > 30 && previewAccum.Height < 100) //{ //} #endif _accumInvalidateQueue.Add(args); _hasRenderTreeInvalidateAccumRect = true;//*** if (!_hasAccumRect) { _accumulateInvalidRect = args.GlobalRect; _hasAccumRect = true; } else { #if DEBUG //if (_accumInvalidateQueue.Count > 50) //{ //} #endif //TODO: check if we should do union or separate this into another group if (!_accumulateInvalidRect.IntersectsWith(args.GlobalRect)) { _accumulateInvalidRect = Rectangle.Union(_accumulateInvalidRect, args.GlobalRect); } else { _accumulateInvalidRect = Rectangle.Union(_accumulateInvalidRect, args.GlobalRect); } } #if DEBUG if (dbugEnableGraphicInvalidateTrace && dbugGraphicInvalidateTracer != null) { string state_str = "ACC: "; if (dbugNeedContentArrangement || dbugNeedReCalculateContentSize) { state_str = "!!" + state_str; } dbugGraphicInvalidateTracer.WriteInfo("ACC: " + _accumulateInvalidRect.ToString()); dbugGraphicInvalidateTracer.WriteInfo("\r\n"); } #endif }
/// <summary> /// add to nearest update-rect-region, if not found create a new one /// </summary> /// <param name="a"></param> void AddToNearestRegion(InvalidateGfxArgs a) { int j = _updateList.Count; GfxUpdateRectRgn found = null; for (int i = j - 1; i >= 0; --i) { //search from latest rgn GfxUpdateRectRgn existing = _updateList[i]; if (existing.AccumRect.IntersectsWith(a.GlobalRect)) { found = existing; break; } } if (found == null) { GfxUpdateRectRgn updateJob = _updateRectRgnPool.Borrow(); updateJob.AddDetail(a); _updateList.Add(updateJob); } else { found.AddDetail(a); } }
public void AddDetail(InvalidateGfxArgs a) { #if DEBUG //if (a.GlobalRect.Height == 31) //{ //} #endif if (_invList.Count == 0) { AccumRect = a.GlobalRect; } else { if (AccumRect.Contains(a.GlobalRect)) { //new global is inside the current AccumRect if (RenderElement.IsInUpdateRgnQueue(a.StartOn)) { #if DEBUG System.Diagnostics.Debug.WriteLine("add_detail:skip"); #endif return; } } AccumRect = Rectangle.Union(AccumRect, a.GlobalRect); } RenderElement.MarkAsInUpdateRgnQueue(a.StartOn);//*** _invList.Add(a); }
public static InvalidateGfxArgs GetInvalidateGfxArgs() { #if DEBUG InvalidateGfxArgs invGfx = _invGfxPool.Borrow(); invGfx.dbugWaitingInPool = false; return(invGfx); #else return(_invGfxPool.Borrow()); #endif }
public static void InvalidateGraphicLocalArea(RenderElement re, Rectangle localArea) { //RELATIVE to re *** if (localArea.Height == 0 || localArea.Width == 0) { return; } InvalidateGfxArgs inv = GetInvalidateGfxArgs(); inv.SetReason_UpdateLocalArea(re, localArea); InternalBubbleUpInvalidateGraphicArea(inv); }
public override sealed void SetViewport(int viewportLeft, int viewportTop) { int diffLeft = viewportLeft - _viewportLeft; int diffTop = viewportTop - _viewportTop; if (diffLeft != 0 || diffTop != 0) { _viewportLeft = viewportLeft; _viewportTop = viewportTop; // if (!this.BlockGraphicUpdateBubble) { InvalidateGfxArgs args = BubbleInvalidater.GetInvalidateGfxArgs(); args.SetReason_ChangeViewport(this, diffLeft, diffTop); this.InvalidateGraphics(args); } } }
public static void ReleaseInvalidateGfxArgs(InvalidateGfxArgs args) { #if DEBUG if (args.dbugWaitingInPool) { // throw new NotSupportedException(); } args.dbugWaitingInPool = true; #endif if (args.FromMainPool) { _invGfxPool.ReleaseBack(args); } else { #if DEBUG System.Diagnostics.Debug.WriteLine("InvalidateGfxArgs=>not from pool:"); #endif } }
public void SetCurrentUpdate(int index) { //reset AccumUpdateArea = Rectangle.Empty; _bubbleGfxTracks.Clear(); _currentUpdateRgn = _updateList[index]; int detailCount = _currentUpdateRgn.DetailCount; for (int i = 0; i < detailCount; ++i) { InvalidateGfxArgs args = _currentUpdateRgn.GetDetail(i); //ensure RenderElement.MarkAsGfxUpdateTip(args.StartOn); //TODO: review here again BubbleUpGraphicsUpdateTrack(args.StartOn, _bubbleGfxTracks); } AccumUpdateArea = _currentUpdateRgn.AccumRect; RenderElement.WaitForStartRenderElement = true; }
public void SetUpdatePlanForFlushAccum() { //create accumulative plan //merge consecutive RenderElement.WaitForStartRenderElement = false; List <InvalidateGfxArgs> accumQueue = RootGraphic.GetAccumInvalidateGfxArgsQueue(_rootgfx); int j = accumQueue.Count; if (j == 0) { return; } else if (j > 10) //??? { //default (original) mode System.Diagnostics.Debug.WriteLine("traditional: " + j); for (int i = 0; i < j; ++i) { BubbleInvalidater.ReleaseInvalidateGfxArgs(accumQueue[i]); } } else { #if DEBUG if (j == 2) { } System.Diagnostics.Debug.WriteLine("flush accum:" + j); //-------------- //>>preview for debug if (RenderElement.dbugUpdateTrackingCount > 0) { throw new System.NotSupportedException(); } //for (int i = 0; i < j; ++i) //{ // InvalidateGfxArgs a = accumQueue[i]; // RenderElement srcE = a.SrcRenderElement; // if (srcE.NoClipOrBgIsNotOpaque) // { // srcE = FindFirstClipedOrOpaqueParent(srcE); // if (srcE == null) // { // throw new System.NotSupportedException(); // } // } // if (srcE.IsBubbleGfxUpdateTrackedTip) // { // } //} //<<preview for debug //-------------- #endif for (int i = 0; i < j; ++i) { InvalidateGfxArgs a = accumQueue[i]; RenderElement srcE = a.SrcRenderElement; if (srcE.NoClipOrBgIsNotOpaque) { srcE = FindFirstClipedOrOpaqueParent(srcE); } a.StartOn = srcE; AddToNearestRegion(a); } } accumQueue.Clear(); }
internal static void InternalBubbleUpInvalidateGraphicArea(InvalidateGfxArgs args)//RenderElement fromElement, ref Rectangle elemClientRect, bool passSourceElem) { //total bounds = total bounds at level if (IsInRenderPhase) { ReleaseInvalidateGfxArgs(args); return; } //-------------------------------------- bool hasviewportOffset = args.Reason == InvalidateReason.ViewportChanged; int viewport_diffLeft = args.LeftDiff; int viewport_diffTop = args.TopDiff; //bubble up ,find global rect coord //and then merge to accumulate rect RenderElement fromElement = args.SrcRenderElement; Rectangle elemClientRect = args.Rect; bool passSourceElem = args.PassSrcElement; //HasViewportOffset = false; int globalPoint_X = 0; int globalPoint_Y = 0; #if DEBUG //if (fromElement.dbug_ObjectNote == "panel") //{ //} int dbug_ncount = 0; //dbugWriteStopGfxBubbleUp(fromElement, ref dbug_ncount, dbug_ncount, ">> :" + elemClientRect.ToString()); #endif for (; ;) { if (!fromElement.Visible) { #if DEBUG //dbugWriteStopGfxBubbleUp(fromElement, ref dbug_ncount, 0, "EARLY-RET: "); #endif ReleaseInvalidateGfxArgs(args); return; } else if (fromElement.BlockGraphicUpdateBubble) { #if DEBUG //dbugWriteStopGfxBubbleUp(fromElement, ref dbug_ncount, 0, "BLOCKED2: "); #endif ReleaseInvalidateGfxArgs(args); return; } #if DEBUG //dbugWriteStopGfxBubbleUp(fromElement, ref dbug_ncount, dbug_ncount, ">> "); #endif globalPoint_X += fromElement.X; globalPoint_Y += fromElement.Y; if (fromElement.MayHasViewport && passSourceElem) { elemClientRect.Offset(globalPoint_X, globalPoint_Y); //**** #if DEBUG //TODO: review here if (fromElement.HasDoubleScrollableSurface) { //container.VisualScrollableSurface.WindowRootNotifyInvalidArea(elementClientRect); } #endif Rectangle elementRect = fromElement.RectBounds; elementRect.Offset(fromElement.ViewportLeft, fromElement.ViewportTop); if (fromElement.NeedClipArea) { elemClientRect.Intersect(elementRect); } globalPoint_X = -fromElement.ViewportLeft; //reset ? globalPoint_Y = -fromElement.ViewportTop; //reset ? } #if DEBUG //System.Diagnostics.Debug.WriteLine(elemClientRect.ToString()); #endif if (fromElement.IsTopWindow) { break; } else { #if DEBUG if (fromElement.dbugParentVisualElement == null) { //dbugWriteStopGfxBubbleUp(fromElement, ref dbug_ncount, 0, "BLOCKED3: "); } #endif if (RenderElement.RequestInvalidateGraphicsNoti(fromElement)) { RenderElement.InvokeInvalidateGraphicsNoti(fromElement, !passSourceElem, elemClientRect); } IParentLink parentLink = fromElement.MyParentLink; if (parentLink == null) { ReleaseInvalidateGfxArgs(args); return; } parentLink.AdjustLocation(ref globalPoint_X, ref globalPoint_Y); //move up if ((fromElement = parentLink.ParentRenderElement) == null) { ReleaseInvalidateGfxArgs(args); return; } } passSourceElem = true; } //---------- //now we are on the top of root RootGraphic root = fromElement.GetRoot(); #if DEBUG RootGraphic dbugMyroot = root; if (dbugMyroot.dbugEnableGraphicInvalidateTrace && dbugMyroot.dbugGraphicInvalidateTracer != null) { while (dbug_ncount > 0) { dbugMyroot.dbugGraphicInvalidateTracer.PopElement(); dbug_ncount--; } } #endif //---------------------------------------- elemClientRect.Offset(globalPoint_X, globalPoint_Y); if (elemClientRect.Top > root.Height || elemClientRect.Left > root.Width || elemClientRect.Bottom < 0 || elemClientRect.Right < 0) { #if DEBUG if (dbugMyroot.dbugEnableGraphicInvalidateTrace && dbugMyroot.dbugGraphicInvalidateTracer != null) { dbugMyroot.dbugGraphicInvalidateTracer.WriteInfo("ZERO-EEX"); dbugMyroot.dbugGraphicInvalidateTracer.WriteInfo("\r\n"); } #endif ReleaseInvalidateGfxArgs(args); return; } //-------------------------------------------------------------------------------------------------- args.GlobalRect = elemClientRect; //if (root.HasViewportOffset = hasviewportOffset) //{ // root.ViewportDiffLeft = viewport_diffLeft; // root.ViewportDiffTop = viewport_diffTop; //} root.AddAccumRect(args); }
protected static void InternalBubbleup(InvalidateGfxArgs args) => BubbleInvalidater.InternalBubbleUpInvalidateGraphicArea(args);
protected static void ReleaseInvalidateGfxArgs(InvalidateGfxArgs args) => BubbleInvalidater.ReleaseInvalidateGfxArgs(args);