コード例 #1
0
ファイル: Pipeline.cs プロジェクト: liwq-net/XnaVG
        internal void StencilStroke(IRenderable path)
        {
            var effect = Device.EffectManager.StencilStroke;

            // Setup stenciling
            _device.BlendState = Device.BlendStates.NoColor;
            _device.DepthStencilState = State.Stencils.Set;

            // Render solid mesh
            if (path.HasSolidStroke)
            {
                effect.SetSolid(State.NonScalingStroke, State.Projection.Matrix, State.PathToSurface.Matrix, State.StrokeExpand);
                effect.Apply();
                _device.MultiSampleMask = -1;
                path.BeforeRenderSolidStroke();
                path.RenderSolidStroke();
            }

            // Render radial mesh
            if (path.HasRadialStroke)
            {
                effect.SetRadial(State.NonScalingStroke, State.Projection.Matrix, State.PathToSurface.Matrix, State.StrokeExpand);
                path.BeforeRenderRadialStroke();
                if (State.Antialiasing == VGAntialiasing.None)
                {
                    effect.Apply();
                    path.RenderRadialStroke();
                }
                else
                    for (int samples = (int)State.Antialiasing - 1, MSAAMask = _msaaMasks[State.Antialiasing]; samples >= 0; samples--, MSAAMask <<= 1)
                    {
                        _device.MultiSampleMask = MSAAMask;
                        effect.SetOffset(ref Surface.MSAAPattern[samples]);
                        effect.Apply();
                        path.RenderRadialStroke();
                    }
            }
        }