예제 #1
0
 public bool ProcessTileRenderQueue()
 {
     base.VerifyAccess();
     using (this.processTileRenderQueueRegion.UseEnterScope())
     {
         if (this.IsDisposed)
         {
             this.tilesRenderQueue.Clear();
             return(false);
         }
         int count = this.tilesRenderQueue.Count;
         IList <PointInt32> workItemQueueAccumulator = null;
         for (int i = 0; i < count; i++)
         {
             PointInt32 tileOffset = this.tilesRenderQueue.Dequeue();
             if (this.IsTileRenderingCancelled(tileOffset))
             {
                 if (!this.tilesRenderingSet.Contains(tileOffset))
                 {
                     ExceptionUtil.ThrowInternalErrorException();
                 }
                 this.tilesRenderQueue.TryEnqueue(tileOffset);
             }
             else
             {
                 if (!this.tilesRenderingSet.Add(tileOffset))
                 {
                     ExceptionUtil.ThrowInternalErrorException();
                 }
                 if (this.tilesRenderingSet.Count == 1)
                 {
                     this.owner.NotifyTileCacheIsRendering(this);
                 }
                 if (workItemQueueAccumulator == null)
                 {
                     workItemQueueAccumulator = new List <PointInt32>();
                 }
                 workItemQueueAccumulator.Add(tileOffset);
             }
         }
         if (workItemQueueAccumulator != null)
         {
             PointInt32 sourcePt  = PointDouble.Round(this.owner.MouseLocation, MidpointRounding.AwayFromZero);
             PointInt32 comparand = this.tileMathHelper.ConvertSourcePointToTileOffset(sourcePt);
             CompareTileOffsetsByDistance comparer = new CompareTileOffsetsByDistance(comparand);
             this.workItemQueue.Edit(delegate {
                 this.workItemQueue.EnqueueRange <IList <PointInt32> >(workItemQueueAccumulator);
                 this.workItemQueue.Sort <CompareTileOffsetsByDistance>(comparer);
             });
             return(true);
         }
         return(false);
     }
 }
        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;
                                }
                            }
                        }
                    }
                }
            }
        }