internal void NotifyTileCacheIsRendering(DocumentCanvasTileCache tileCache)
        {
            long num2;
            long num3;

            base.VerifyAccess();
            int mipLevel = tileCache.MipLevel;

            if ((mipLevel < 0) || (mipLevel > 0x3f))
            {
                ExceptionUtil.ThrowInternalErrorException();
            }
            if (tileCache.IsHighQuality)
            {
                long tileCacheHQIsRenderingMask = this.tileCacheHQIsRenderingMask;
                this.tileCacheHQIsRenderingMask |= ((long)1L) << mipLevel;
                num2 = tileCacheHQIsRenderingMask;
                num3 = this.tileCacheHQIsRenderingMask;
            }
            else
            {
                long tileCacheIsRenderingMask = this.tileCacheIsRenderingMask;
                this.tileCacheIsRenderingMask |= ((long)1L) << mipLevel;
                num2 = tileCacheIsRenderingMask;
                num3 = this.tileCacheIsRenderingMask;
            }
            if ((num2 == 0) && (num3 != 0))
            {
                Interlocked.Increment(ref tileCacheIsRenderingCount);
            }
        }
        internal void NotifyTileCacheIsActiveChanged(DocumentCanvasTileCache tileCache, bool isActive)
        {
            int mipLevel = tileCache.MipLevel;

            foreach (DocumentCanvasLayerView view in this.documentCanvasLayerViews.Values)
            {
                if ((mipLevel == 0) || (tileCache.IsHighQuality == GetIsHighQualityScalingEnabled(view.CanvasView)))
                {
                    view.NotifyTileCacheIsActiveChanged(tileCache, isActive);
                }
            }
        }
        internal void NotifyTileCacheFinishedRendering <TEnumerable>(DocumentCanvasTileCache tileCache, TEnumerable tileOffsets) where TEnumerable : IEnumerable <PointInt32>
        {
            base.VerifyAccess();
            int mipLevel = tileCache.MipLevel;

            foreach (DocumentCanvasLayerView view in this.documentCanvasLayerViews.Values)
            {
                if ((mipLevel == 0) || (tileCache.IsHighQuality == GetIsHighQualityScalingEnabled(view.CanvasView)))
                {
                    view.NotifyTileCacheFinishedRendering <TEnumerable>(tileCache, tileOffsets);
                }
            }
        }
 public void PreRenderSync()
 {
     base.VerifyAccess();
     foreach (DocumentCanvasTileCache cache in this.tileCaches)
     {
         cache.ProcessTileRenderQueue();
         cache.ProcessTileRenderedQueue();
     }
     foreach (DocumentCanvasLayerViewMipLayer layer in this.mipLayers)
     {
         DocumentCanvasTileCache tileCache = layer.TileCache;
         layer.NotifyTileCacheFinishedRendering <IEnumerable <PointInt32> >(tileCache.TileMathHelper.EnumerateTileOffsets());
     }
 }
        internal void NotifyTileCacheInvalidated(DocumentCanvasTileCache tileCache, RectInt32 sourceRect)
        {
            int mipLevel = tileCache.MipLevel;

            this.mipLayers[mipLevel].NotifyTileCacheInvalidated(sourceRect);
            if (this.mipLayers[mipLevel].IsActive)
            {
                RectInt32 num4 = RectInt32.Intersect(this.canvasView.GetVisibleCanvasBounds().Int32Bound, sourceRect);
                if (num4.HasPositiveArea)
                {
                    this.tileCaches[mipLevel].QueueInvalidTilesForRendering(num4, true);
                }
            }
        }
 public DocumentCanvasLayerViewMipLayer(DocumentCanvasLayerView owner, int canvasTileEdgeLog2, int mipLevel, DocumentCanvasTileCache tileCache)
 {
     Validate.Begin().IsNotNull <DocumentCanvasLayerView>(owner, "owner").IsNotNull <DocumentCanvasTileCache>(tileCache, "tileCache").Check().IsGreaterThanOrEqualTo(canvasTileEdgeLog2, 1, "canvasTileEdgeLog2").Check();
     owner.VerifyAccess();
     this.owner      = owner;
     this.tileCache  = tileCache;
     this.canvasView = this.owner.CanvasView;
     this.canvasView.ViewportCanvasBoundsChanged += new ValueChangedEventHandler <RectDouble>(this.OnCanvasViewViewportCanvasBoundsChanged);
     this.mipLevel              = mipLevel;
     this.tileMathHelper        = this.tileCache.TileMathHelper;
     this.deviceBitmapTickets   = ArrayUtil.Create2D <ObjectPoolTicket <IDeviceBitmap> >(this.tileMathHelper.TileRows, this.tileMathHelper.TileColumns);
     this.deviceBitmaps         = ArrayUtil.Create2D <IDeviceBitmap>(this.tileMathHelper.TileRows, this.tileMathHelper.TileColumns);
     this.tileBuffers           = ArrayUtil.Create2D <IBitmap <ColorPbgra32> >(this.tileMathHelper.TileRows, this.tileMathHelper.TileColumns);
     this.isDeviceBitmapCurrent = ArrayUtil.Create2D <bool>(this.tileMathHelper.TileRows, this.tileMathHelper.TileColumns);
 }
        internal void NotifyTileCacheInvalidated(DocumentCanvasTileCache tileCache, RectInt32 sourceRect)
        {
            base.VerifyAccess();
            int mipLevel = tileCache.MipLevel;

            foreach (DocumentCanvasLayerView view in this.documentCanvasLayerViews.Values)
            {
                if ((mipLevel == 0) || (tileCache.IsHighQuality == GetIsHighQualityScalingEnabled(view.CanvasView)))
                {
                    view.NotifyTileCacheInvalidated(tileCache, sourceRect);
                }
            }
            if (tileCache.IsActive)
            {
                tileCache.ProcessTileRenderQueue();
            }
        }
 private void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (this.tileCache != null)
         {
             this.IsActive  = false;
             this.IsVisible = false;
             this.tileCache = null;
         }
         if (((this.deviceBitmaps != null) && (this.deviceBitmapTickets != null)) && (this.tileBuffers != null))
         {
             Work.QueueFreeStream <IDisposable[]>(ref (from to in this.tileMathHelper.EnumerateTileOffsets() select this.EnumerateTileResources(to)).SelectMany <IDisposable>().ToArrayEx <IDisposable>());
             this.deviceBitmaps       = null;
             this.deviceBitmapTickets = null;
             this.tileBuffers         = null;
         }
         if (this.canvasView != null)
         {
             this.canvasView.ViewportCanvasBoundsChanged -= new ValueChangedEventHandler <RectDouble>(this.OnCanvasViewViewportCanvasBoundsChanged);
             this.canvasView = null;
         }
     }
 }
        internal void NotifyTileCacheIsActiveChanged(DocumentCanvasTileCache tileCache, bool isActive)
        {
            int mipLevel = tileCache.MipLevel;

            this.mipLayers[mipLevel].NotifyTileCacheIsActiveChanged(isActive);
        }
        internal void NotifyTileCacheFinishedRendering <TEnumerable>(DocumentCanvasTileCache tileCache, TEnumerable finishedTileOffsets) where TEnumerable : IEnumerable <PointInt32>
        {
            int mipLevel = tileCache.MipLevel;

            this.mipLayers[mipLevel].NotifyTileCacheFinishedRendering <TEnumerable>(finishedTileOffsets);
        }