コード例 #1
0
        public void BeforeRender(RectFloat clipRect)
        {
            if ((!this.afterRenderCalled || this.beforeRenderCalled) || this.renderCalled)
            {
                throw new PaintDotNet.InternalErrorException();
            }
            this.afterRenderCalled  = false;
            this.beforeRenderCalled = true;
            bool flag = this.canvasView.RenderTarget.IsSupported(RenderTargetType.Software, null, null, null);

            if (flag || this.IsActive)
            {
                this.renderStopwatch.Restart();
                RectInt32 num2  = RectInt32.Intersect(clipRect.Int32Bound, this.owner.Document.Bounds());
                bool      flag2 = false;
                if (num2.HasPositiveArea)
                {
                    PointInt32   num7;
                    PointInt32[] array = this.nonCurrentTileOffsets.ToArrayEx <PointInt32>();
                    this.nonCurrentTileOffsets.Clear();
                    PointInt32 sourcePt  = PointDouble.Round(this.owner.Owner.MouseLocation, MidpointRounding.AwayFromZero);
                    PointInt32 comparand = this.tileMathHelper.ConvertSourcePointToTileOffset(sourcePt);
                    CompareTileOffsetsByDistance comparer = new CompareTileOffsetsByDistance(comparand);
                    ListUtil.Sort <PointInt32, ArrayStruct <PointInt32>, CompareTileOffsetsByDistance>(array.AsStruct <PointInt32>(), comparer);
                    DequeSet <PointInt32> set = new DequeSet <PointInt32>(array);
                    int count = set.Count;
                    while (set.TryDequeue(out num7))
                    {
                        if (!this.isDeviceBitmapCurrent[num7.Y][num7.X])
                        {
                            if (flag2)
                            {
                                this.nonCurrentTileOffsets.TryEnqueue(num7);
                            }
                            else
                            {
                                if (!this.TryUpdateDeviceBitmap(num7))
                                {
                                    this.nonCurrentTileOffsets.TryEnqueue(num7);
                                    flag2 = true;
                                }
                                if ((!flag2 && !flag) && (this.renderStopwatch.ElapsedMilliseconds > 0x7fffffffffffffffL))
                                {
                                    flag2 = true;
                                }
                            }
                        }
                    }
                }
            }
        }
コード例 #2
0
 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));
 }