Exemple #1
0
        private void RenderMask(ISurface <ColorAlpha8> dstMask, PointInt32 renderOffset)
        {
            int       width     = dstMask.Width;
            int       height    = dstMask.Height;
            bool      flag      = false;
            SizeInt32 size      = new SizeInt32(width, height);
            RectInt32 rectangle = new RectInt32(renderOffset, size);

            if (!flag && this.matrix.HasInverse)
            {
                Matrix3x2Double inverse           = this.matrix.Inverse;
                PointDouble     pt                = inverse.Transform(rectangle.TopLeft);
                PointDouble     num7              = inverse.Transform(rectangle.TopRight);
                PointDouble     num8              = inverse.Transform(rectangle.BottomLeft);
                PointDouble     num9              = inverse.Transform(rectangle.BottomRight);
                RectDouble      srcCoverageBounds = this.srcCoverageBounds;
                if ((srcCoverageBounds.Contains(pt) && srcCoverageBounds.Contains(num7)) && (srcCoverageBounds.Contains(num8) && srcCoverageBounds.Contains(num9)))
                {
                    dstMask.Clear(ColorAlpha8.Opaque);
                    flag = true;
                }
            }
            if (!flag)
            {
                GeometryRelation relation;
                IDirect2DFactory perThread = Direct2DFactory.PerThread;
                using (IRectangleGeometry geometry = perThread.CreateRectangleGeometry(rectangle))
                {
                    base.ThrowIfCancellationRequested();
                    using (IRectangleGeometry geometry2 = perThread.CreateRectangleGeometry(this.srcCoverageBounds))
                    {
                        base.ThrowIfCancellationRequested();
                        relation = geometry.CompareWithGeometry(geometry2, new Matrix3x2Float?((Matrix3x2Float)this.matrix), null);
                        base.ThrowIfCancellationRequested();
                    }
                }
                switch (relation)
                {
                case GeometryRelation.IsContained:
                    dstMask.Clear(ColorAlpha8.Opaque);
                    flag = true;
                    break;

                case GeometryRelation.Disjoint:
                    dstMask.Clear(ColorAlpha8.Transparent);
                    flag = true;
                    break;
                }
            }
            if (!flag)
            {
                using (IDrawingContext context = DrawingContext.FromSurface(dstMask, FactorySource.PerThread))
                {
                    base.ThrowIfCancellationRequested();
                    context.Clear(null);
                    context.AntialiasMode = AntialiasMode.PerPrimitive;
                    using (context.UseTranslateTransform((float)-renderOffset.X, (float)-renderOffset.Y, MatrixMultiplyOrder.Prepend))
                    {
                        using (context.UseTransformMultiply((Matrix3x2Float)this.matrix, MatrixMultiplyOrder.Prepend))
                        {
                            context.FillRectangle(this.srcCoverageBounds, whiteBrush);
                        }
                    }
                }
            }
        }
 public static IRectangleGeometry CreateRef(this IRectangleGeometry objectRef) =>
 ((IRectangleGeometry)objectRef.CreateRef(typeof(IRectangleGeometry)));