コード例 #1
0
 public bool ProcessTileRenderedQueue()
 {
     base.VerifyAccess();
     using (this.processTileRenderedQueueRegion.UseEnterScope())
     {
         if (this.IsDisposed)
         {
             bool flag = false;
             do
             {
                 KeyValuePair <PointInt32, RenderedTileInfo> pair;
                 while (this.tilesRenderedQueue.TryDequeue(out pair))
                 {
                     DisposableUtil.Free <IBitmap <ColorPbgra32> >(ref pair.Value.Buffer);
                     flag = true;
                 }
             }while (Interlocked.Exchange(ref this.isProcessTileRenderedQueueQueued, 0) == 1);
             return(flag);
         }
         if (Interlocked.Exchange(ref this.isProcessTileRenderedQueueQueued, 0) == 0)
         {
             return(false);
         }
         List <PointInt32> collection           = new List <PointInt32>();
         List <PointInt32> cancelledTileOffsets = null;
         bool flag3 = false;
         int  count = this.tilesRenderedQueue.Count;
         for (int i = 0; i < count; i++)
         {
             KeyValuePair <PointInt32, RenderedTileInfo> pair2;
             if (this.tilesRenderedQueue.TryDequeue(out pair2))
             {
                 PointInt32             key    = pair2.Key;
                 RenderedTileInfo       info2  = pair2.Value;
                 IBitmap <ColorPbgra32> buffer = info2.Buffer;
                 if (this.tilesRenderingCancelledSet.Remove(key) || !info2.Completed)
                 {
                     DisposableUtil.Free <IBitmap <ColorPbgra32> >(ref buffer);
                     if (this.tilesRenderQueue.Contains(key))
                     {
                         flag3 = true;
                     }
                     else if (info2.Error is OperationCanceledException)
                     {
                         if (cancelledTileOffsets == null)
                         {
                             cancelledTileOffsets = new List <PointInt32>();
                         }
                         cancelledTileOffsets.Add(key);
                     }
                 }
                 else
                 {
                     if ((buffer.IsNullReference <IBitmap <ColorPbgra32> >() || buffer.IsDisposed) || !pair2.Value.Completed)
                     {
                         throw new PaintDotNet.InternalErrorException();
                     }
                     IBitmap <ColorPbgra32> disposeMe = this.tileBuffers[key.Y][key.X];
                     DisposableUtil.Free <IBitmap <ColorPbgra32> >(ref disposeMe);
                     this.tileBuffers[key.Y][key.X] = buffer;
                     this.tileIsValid[key.Y][key.X] = true;
                     collection.Add(key);
                 }
                 if (!this.tilesRenderingSet.Remove(key))
                 {
                     throw new PaintDotNet.InternalErrorException();
                 }
             }
         }
         if (collection.Any <PointInt32>())
         {
             this.owner.NotifyTileCacheFinishedRendering <List <PointInt32> >(this, collection);
         }
         if (flag3)
         {
             this.ProcessTileRenderQueue();
         }
         if (!this.tilesRenderingSet.Any <PointInt32>())
         {
             this.owner.NotifyTileCacheIsIdle(this);
         }
         if (cancelledTileOffsets != null)
         {
             this.syncContext.Post(delegate(object _) {
                 this.InvalidateCancelledTiles(cancelledTileOffsets);
             });
         }
         return(collection.Any <PointInt32>());
     }
 }