Exemple #1
0
        public VGStencilMasks AddClipping(ushort clipDepth)
        {
            for (int i = 0, m = (int)VGStencilMasks.Mask1; i < _clipLayers.Length; i++, m <<= 1)
                if (_clipLayers[i] == null)
                {
                    _clipLayers[i] = new ClipLayer((VGStencilMasks)m, clipDepth);
                    _clippingMask |= (VGStencilMasks)m;
                    return _clipLayers[i].Layer;
                }

            throw new NotSupportedException("Too much nested clipping characters!");
        }
Exemple #2
0
        public VGStencilMasks ReleaseClippings(ushort currentDepth)
        {
            VGStencilMasks mask = VGStencilMasks.None;
            if (_clippingMask == VGStencilMasks.None)
                return mask;

            for (int i = 0; i < _clipLayers.Length; i++)
            {
                if (_clipLayers[i] == null)
                    continue;

                if (_clipLayers[i].ClipDepth == currentDepth)
                {
                    _clipLayers[i] = null;
                    continue;
                }

                mask |= _clipLayers[i].Layer;
            }

            _clippingMask = mask;
            return mask;
        }
Exemple #3
0
 public ClipLayer(VGStencilMasks layer, ushort clipDepth)
 {
     Layer = layer;
     ClipDepth = clipDepth;
 }
Exemple #4
0
        public void ResetDefaultValues()
        {
            PathToSurface.Clear();
            ImageToSurface.Clear();
            GlyphToSurface.Clear();
            PathToFillPaint.Clear();
            PathToTextPaint.Clear();
            PathToStrokePaint.Clear();
            ColorTransformation.Clear();

            NonScalingStroke = false;
            ColorTransformationEnabled = false;
            MaskingEnabled = false;
            StrokeThickness = 1f;
            StrokeMiterLimit = 4f;
            ClearColor = Color.Transparent;
            StrokeStartCap = StrokeEndCap = VGLineCap.Butt;
            StrokeJoin = VGLineJoin.Miter;
            BlendMode = VGBlendMode.SrcOver;
            Mask = null;
            Font = null;
            MaskChannels = Vector4.UnitW;
            ColorChannels = ColorWriteChannels.All;
            TabSize = Vector2.One;
            FillPaint = StrokePaint = GlyphPaint = new VGColorPaint(Device, Color.White);

            // Not create states twice
            _fillRule = VGFillRule.EvenOdd;
            _readMask = VGStencilMasks.None;
            WriteStencilMask = VGStencilMasks.None;
        }
Exemple #5
0
        internal void ClearStencilMasks(VGStencilMasks masks)
        {
            // Setup stenciling
            _device.BlendState = Device.BlendStates.NoColor;
            _device.DepthStencilState = StencilStates.ClearMasks(masks);
            Device.EffectManager.StencilSolid.Apply(VGMatrix.Identity, VGMatrix.Identity);

            // Render mesh
            _device.MultiSampleMask = -1;
            Vector4 extents = Constants.ScreenExtents * 1.1f;
            RenderRectangle(ref extents);
        }
Exemple #6
0
 public static DSS ClearMasks(VGStencilMasks masks)
 {
     var dss = Clone(_Clear);
     dss.StencilMask = dss.StencilWriteMask = (int)masks;
     return dss;
 }
Exemple #7
0
        public StencilStates(VGStencilMasks writeMask, VGStencilMasks readMask)
        {
            Set = Clone(_Set);
            EvenOdd = Clone(_EvenOdd);
            NonZero = Clone(_NonZero);
            Cover = Clone(_Cover);

            if (writeMask != VGStencilMasks.None)
            {
                Set.StencilMask = Set.StencilWriteMask = (int)writeMask;
                EvenOdd.StencilMask = EvenOdd.StencilWriteMask = (int)writeMask;
                NonZero.StencilMask = NonZero.StencilWriteMask = (int)writeMask;
            }

            if (readMask != VGStencilMasks.None)
                Cover.StencilMask |= (int)readMask;
        }