示例#1
0
        private void UpdateTileWhileLocked(TileData tileData, ICancellationToken cancelToken)
        {
            RectInt32  tileSourceRect = this.tileMathHelper.GetTileSourceRect(tileData.Offset);
            RectDouble num2           = tileSourceRect;

            cancelToken.ThrowIfCancellationRequested <ICancellationToken>();
            object newCurrencyToken = this.renderData.CreateCurrencyToken();

            cancelToken.ThrowIfCancellationRequested <ICancellationToken>();
            IList <int?> list  = this.renderData.GetStrokeSampleIndicesInRect(tileSourceRect, tileData.CurrencyToken, newCurrencyToken);
            int          count = list.Count;

            if (count > 0)
            {
                SizeDouble      size = this.stamp.Size;
                RectDouble      num5 = new RectDouble(PointDouble.Zero, size);
                IDrawingContext dc   = null;
                try
                {
                    for (int i = 0; i < count; i++)
                    {
                        int?nullable = list[i];
                        if (nullable.HasValue)
                        {
                            if (tileData.Mask == null)
                            {
                                cancelToken.ThrowIfCancellationRequested <ICancellationToken>();
                                tileData.Mask = new SurfaceAlpha8(tileSourceRect.Size);
                            }
                            if (tileData.MaskRenderTarget == null)
                            {
                                cancelToken.ThrowIfCancellationRequested <ICancellationToken>();
                                tileData.MaskRenderTarget = RenderTarget.FromSurface(tileData.Mask, FactorySource.PerThread);
                            }
                            if (dc == null)
                            {
                                cancelToken.ThrowIfCancellationRequested <ICancellationToken>();
                                dc = DrawingContext.FromRenderTarget(tileData.MaskRenderTarget);
                                dc.UseTranslateTransform((float)-tileSourceRect.X, (float)-tileSourceRect.Y, MatrixMultiplyOrder.Prepend);
                                dc.AntialiasMode = AntialiasMode.Aliased;
                            }
                            int        valueOrDefault = nullable.GetValueOrDefault();
                            RectDouble bounds         = this.renderData.StrokeSamples[valueOrDefault].GetBounds(size);
                            RectDouble num9           = this.stamp.Antialiased ? bounds : RectDouble.Round(bounds, MidpointRounding.AwayFromZero);
                            cancelToken.ThrowIfCancellationRequested <ICancellationToken>();
                            RectDouble?srcRect = null;
                            dc.FillOpacityMask(this.lazyStampMaskDevBitmap.CancelableValue <DeviceBitmap>(), whiteBrush, OpacityMaskContent.Graphics, new RectDouble?(num9), srcRect);
                        }
                    }
                }
                finally
                {
                    DisposableUtil.Free <IDrawingContext>(ref dc);
                }
            }
            tileData.CurrencyToken = newCurrencyToken;
        }