internal void InvalidateSelectionArea() { base.VerifyAccess(); SelectionSnapshot selectionSnapshot = base.Owner.SelectionSnapshot; RectDouble fastMaxBounds = selectionSnapshot.FastMaxBounds; if (!selectionSnapshot.IsEmpty && !fastMaxBounds.IsEmpty) { double canvasHairWidth = base.CanvasView.CanvasHairWidth; double dx = this.outlineStrokeWidthPx * canvasHairWidth; RectDouble canvasRect = RectDouble.Inflate(fastMaxBounds, dx, dx); base.CanvasView.Invalidate(canvasRect); } }
private void RedrawOnBackgroundThread() { if (base.CheckAccess()) { ExceptionUtil.ThrowInvalidOperationException(); } if (this.redrawThreadFactory == null) { this.redrawThreadFactory = new Direct2DFactory(Direct2DFactoryType.MultiThreaded, DebugLevel.None); } if ((this.redrawThreadGeometryCache == null) || (this.redrawThreadGeometryCache.SelectionSnapshot != this.redrawRenderParams.SelectionSnapshot)) { DisposableUtil.Free <SelectionGeometryCache>(ref this.redrawThreadGeometryCache); this.redrawThreadGeometryCache = new SelectionGeometryCache(this.redrawThreadFactory, this.redrawRenderParams.SelectionSnapshot); } double scaleRatio = this.redrawRenderParams.ScaleRatio; PointDouble location = this.redrawRenderParams.ViewportCanvasBounds.Location; SizeDouble viewportSize = this.redrawRenderParams.ViewportSize; SizeInt32 num5 = SizeDouble.Ceiling(viewportSize); RectDouble b = RectDouble.Inflate(CanvasCoordinateConversions.ConvertExtentToViewport(CanvasCoordinateConversions.ConvertCanvasToExtent(this.redrawRenderParams.SelectionSnapshot.GeometryList.Value.Bounds, scaleRatio), scaleRatio, location), (double)this.outlineStrokeWidthPx, (double)this.outlineStrokeWidthPx); RectDouble a = new RectDouble(PointDouble.Zero, viewportSize); RectDouble renderViewportBounds = RectDouble.Intersect(a, b); RectInt32 viewportRect = renderViewportBounds.Int32Bound; RectDouble extentRect = CanvasCoordinateConversions.ConvertViewportToExtent(viewportRect, scaleRatio, location); RectDouble renderCanvasBounds = CanvasCoordinateConversions.ConvertExtentToCanvas(extentRect, scaleRatio); if (!viewportRect.HasPositiveArea) { base.SyncContext.Post((SendOrPostCallback)(_ => this.EndRedraw(renderViewportBounds, RectFloat.Zero, null, null))); } else { IBitmap <ColorAlpha8> interiorMask; float scale; PointFloat offset; Result <IGeometry> lazyGeometry; IBitmap <ColorAlpha8>[] dashedOutlineMasks; RectFloat maskSourceRect; SelectionSnapshot selectionSnapshot = this.redrawRenderParams.SelectionSnapshot; SelectionGeometryCache redrawThreadGeometryCache = this.redrawThreadGeometryCache; bool flag = this.redrawRenderParams.SelectionRenderingQuality == SelectionRenderingQuality.Aliased; if (!flag) { lazyGeometry = redrawThreadGeometryCache.Geometry; } else { bool flag3 = selectionSnapshot.IsRectilinear.Value; bool flag4 = selectionSnapshot.IsPixelated.Value; if (flag3 & flag4) { lazyGeometry = redrawThreadGeometryCache.Geometry; } else { lazyGeometry = redrawThreadGeometryCache.PixelatedGeometry; } } bool flag2 = !flag && this.redrawRenderParams.IsOutlineAntialiased; AntialiasMode antialiasMode = ((flag || !flag2) || selectionSnapshot.IsRectilinear.Value) ? AntialiasMode.Aliased : AntialiasMode.PerPrimitive; if (this.CanContinueRedrawing(null, null)) { scale = (float)this.redrawRenderParams.ScaleRatio; float x = -((float)renderCanvasBounds.X); float y = -((float)renderCanvasBounds.Y); offset = new PointFloat(x, y); interiorMask = BitmapAllocator.Alpha8.Allocate(viewportRect.Size, AllocationOptions.ZeroFillNotRequired); try { RetryManager.RunMemorySensitiveOperation(delegate { using (IDrawingContext context = DrawingContext.FromBitmap(this.redrawThreadFactory, interiorMask)) { context.Clear(null); IBrush interiorBrush = context.GetCachedOrCreateResource <IBrush>(whiteBrush); this.RenderSelection(context, scale, offset, this.redrawRenderParams, lazyGeometry, interiorBrush, null, null, antialiasMode); } }); } catch (OutOfMemoryException) { } if (this.CanContinueRedrawing(interiorMask, null)) { int num15; dashedOutlineMasks = new IBitmap <ColorAlpha8> [SelectionCanvasLayer.DashLength]; for (int i = 0; i < dashedOutlineMasks.Length; i = num15) { if ((!this.redrawRenderParams.IsOutlineAnimated && (i != 0)) && (i != (SelectionCanvasLayer.DashLength / 2))) { dashedOutlineMasks[i] = null; } else { dashedOutlineMasks[i] = BitmapAllocator.Alpha8.Allocate(viewportRect.Size, AllocationOptions.ZeroFillNotRequired); try { RetryManager.RunMemorySensitiveOperation(delegate { using (IDrawingContext context = DrawingContext.FromBitmap(this.redrawThreadFactory, dashedOutlineMasks[i])) { context.Clear(null); StrokeStyle resourceSource = SelectionCanvasLayer.GetDashedStrokeStyle(i); IStrokeStyle outlineStrokeStyle = context.GetCachedOrCreateResource <IStrokeStyle>(resourceSource); IBrush cachedOrCreateResource = context.GetCachedOrCreateResource <IBrush>(whiteBrush); this.RenderSelection(context, scale, offset, this.redrawRenderParams, lazyGeometry, null, cachedOrCreateResource, outlineStrokeStyle, antialiasMode); } }); } catch (OutOfMemoryException) { } if (!this.CanContinueRedrawing(interiorMask, dashedOutlineMasks)) { return; } } num15 = i + 1; } maskSourceRect = new RectFloat(PointFloat.Zero, interiorMask.Size); base.SyncContext.Post(_ => this.EndRedraw(renderCanvasBounds, maskSourceRect, interiorMask, dashedOutlineMasks), null); } } } }