protected override void Dispose(bool disposing) { this.owner = null; this.document = null; this.overlays = null; base.Dispose(disposing); }
public DocumentRenderer(DocumentCanvasLayer owner) : base(owner.Document.Size()) { Validate.IsNotNull <DocumentCanvasLayer>(owner, "owner"); this.owner = owner; this.document = this.owner.Document; Validate.IsNotNull <Document>(this.document, "this.document"); this.overlays = new ConcurrentDictionary <Layer, DocumentLayerOverlay>(); }
public DocumentCanvasLayerView(DocumentCanvasLayer owner, PaintDotNet.Canvas.CanvasView canvasView, IList <DocumentCanvasTileCache> tileCaches) { Validate.Begin().IsNotNull <DocumentCanvasLayer>(owner, "owner").IsNotNull <PaintDotNet.Canvas.CanvasView>(canvasView, "canvasView").IsNotNull <IList <DocumentCanvasTileCache> >(tileCaches, "tileCaches").Check(); this.owner = owner; this.document = this.owner.Document; this.canvasView = canvasView; this.canvasView.IsVisibleChanged += new ValueChangedEventHandler <bool>(this.OnCanvasViewIsVisibleChanged); this.tileCaches = tileCaches; this.mipLayers = new DocumentCanvasLayerViewMipLayer[this.tileCaches.Count]; for (int i = 0; i < this.mipLayers.Length; i++) { this.mipLayers[i] = new DocumentCanvasLayerViewMipLayer(this, this.tileCaches[i].TileMathHelper.TileEdgeLog2, i, this.tileCaches[i]); } this.deviceBitmapPool = new ObjectPool <SizeInt32, IDeviceBitmap>(new Func <SizeInt32, IDeviceBitmap>(this.CreateDeviceBitmap), new Action <SizeInt32, IDeviceBitmap>(this.DisposeDeviceBitmap)); this.mipLayerZOrder = new List <DocumentCanvasLayerViewMipLayer>(); }
public void Render(IDrawingContext dc, RectFloat clipRect) { if ((!this.beforeRenderCalled || this.renderCalled) || this.afterRenderCalled) { throw new PaintDotNet.InternalErrorException(); } this.renderCalled = true; using (dc.UseAntialiasMode(AntialiasMode.Aliased)) { double scaleRatio = this.canvasView.ScaleRatio; double d = this.ConvertScaleRatioToMipLevel(scaleRatio); int num3 = (int)Math.Floor(d); bool flag = Math.Abs((double)(d - Math.Round(d, MidpointRounding.AwayFromZero))) < 0.01; bool isHighQualityScalingEnabled = DocumentCanvasLayer.GetIsHighQualityScalingEnabled(this.canvasView); for (int i = this.mipLayerZOrder.Count - 1; i >= 0; i--) { DocumentCanvasLayerViewMipLayer layer = this.mipLayerZOrder[i]; if (layer.MipLevel == 0) { if (flag) { layer.Render(dc, clipRect, 1f, BitmapInterpolationMode.NearestNeighbor); } else if (scaleRatio < 1.0) { layer.Render(dc, clipRect, 1f, isHighQualityScalingEnabled ? BitmapInterpolationMode.Linear : BitmapInterpolationMode.NearestNeighbor); } else { layer.Render(dc, clipRect, 1f, BitmapInterpolationMode.NearestNeighbor); if ((scaleRatio < 2.0) & isHighQualityScalingEnabled) { double num5 = d - num3; double num6 = 1.0 - (((1.0 - num5) * (1.0 - num5)) * (1.0 - num5)); double num7 = DoubleUtil.Clamp(num6, 0.0, 1.0); layer.Render(dc, clipRect, (float)num7, BitmapInterpolationMode.Linear); } } } else { layer.Render(dc, clipRect, 1f, isHighQualityScalingEnabled ? BitmapInterpolationMode.Linear : BitmapInterpolationMode.NearestNeighbor); } } } }
public DocumentCanvasTileCache(DocumentCanvasLayer owner, IBitmapSource <ColorBgra32> source, int sourceTileEdgeLog2, int mipLevel, bool highQuality) { Validate.Begin().IsNotNull <DocumentCanvasLayer>(owner, "owner").IsNotNull <IBitmapSource <ColorBgra32> >(source, "source").Check(); if (sourceTileEdgeLog2 < 0) { ExceptionUtil.ThrowArgumentOutOfRangeException("sourceTileEdgeLog2"); } if (mipLevel < 0) { ExceptionUtil.ThrowArgumentOutOfRangeException("mipLevel"); } this.syncContext = SynchronizationContext.Current; this.owner = owner; this.source = source; this.sourceSize = this.source.Size; this.sourceBounds = this.source.Bounds(); this.isHighQuality = highQuality; this.tileMathHelper = new PaintDotNet.Rendering.TileMathHelper(this.sourceSize.Width, this.sourceSize.Height, sourceTileEdgeLog2); this.mipLevel = mipLevel; this.tileIsValid = ArrayUtil.Create2D <bool>(this.tileMathHelper.TileRows, this.tileMathHelper.TileColumns); this.invalidTileOffsets = new DequeSet <PointInt32>(); this.tileBuffers = ArrayUtil.Create2D <IBitmap <ColorPbgra32> >(this.tileMathHelper.TileRows, this.tileMathHelper.TileColumns); for (int i = 0; i < this.tileMathHelper.TileRows; i++) { for (int j = 0; j < this.tileMathHelper.TileColumns; j++) { this.invalidTileOffsets.TryEnqueue(new PointInt32(j, i)); } } this.tilesRenderQueue = new DequeSet <PointInt32>(); this.tilesRenderingSet = new HashSet <PointInt32>(); this.tilesRenderingCancelledSet = new ConcurrentSet <PointInt32>(); this.tilesRenderedQueue = new ConcurrentDequeDictionary <PointInt32, RenderedTileInfo>(); this.processTileRenderQueueCallback = new SendOrPostCallback(this.ProcessTileRenderQueueCallback); this.processTileRenderedQueueCallback = new SendOrPostCallback(this.ProcessTileRenderedQueueCallback); this.workItemDispatcher = WorkItemDispatcher.Default; this.workItemQueue = new EditableDataWorkItemQueue <PointInt32>(this.workItemDispatcher, new Action <PointInt32>(this.RenderTileWorkItem)); }