Example #1
0
 internal VGSurface(VGDevice device, int width, int height, SurfaceFormat format)
     : this(device, new RenderTarget2D(
         device.GraphicsDevice, width, height, false, 
         format, DepthFormat.Depth24Stencil8, 
         device.GraphicsDevice.PresentationParameters.MultiSampleCount,
         RenderTargetUsage.PreserveContents))
 {
 }
Example #2
0
 internal VGFont(VGDevice device, VGFillRule fillRule, float emSquareSize, float leadingSize)
 {
     Device = device;
     FillRule = fillRule;
     EmSquareSize = emSquareSize;
     LeadingSize = leadingSize;
     FontMode = VGFontMode.CPU;
 }
Example #3
0
 public VGTextureUtils(VGDevice device)
 {
     Device = device;
     _spriteBatch = new SpriteBatch(device.GraphicsDevice);
     _getDataMethodInfo = typeof(Texture2D).GetMethods().Where(m => m.Name == "GetData" && m.GetParameters().Length == 1).FirstOrDefault();
     _setDataMethodInfo = typeof(Texture2D).GetMethods().Where(m => m.Name == "SetData" && m.GetParameters().Length == 1).FirstOrDefault();
     _getBackBufferDataMethodInfo = typeof(GraphicsDevice).GetMethods().Where(m => m.Name == "GetBackBufferData" && m.GetParameters().Length == 1).FirstOrDefault();
 }
Example #4
0
 internal VGImage(VGDevice device, Texture2D texture, bool linearColorspace, bool premultiplied)
 {
     Device = device;
     Texture = texture;
     LinearColorspace = linearColorspace;
     ImageFilter = TextureFilter.Linear;
     Premultiplied = premultiplied;
 }
Example #5
0
 internal VGSurface(VGDevice device, RenderTarget2D renderTarget)
 {
     Width = renderTarget.Width;
     Height = renderTarget.Height;
     Format = renderTarget.Format;
     Target = renderTarget;
     Device = device;
     UpdateMSAAPattern();
 }
Example #6
0
 internal VGSurface(VGDevice device)
 {
     var displayMode = device.GraphicsDevice.DisplayMode;
     Width = displayMode.Width;
     Height = displayMode.Height;
     Format = displayMode.Format;
     Target = null;
     Device = device;
     UpdateMSAAPattern();
 }
Example #7
0
        internal Pipeline(VGDevice device, VGSurface surface, VGState state)
        {
            Device = device;
            Surface = surface;
            State = state;

            _device = device.GraphicsDevice;
            _device.SetRenderTarget(surface.Target);
            _device.RasterizerState = State.RasterizerState;
        }
Example #8
0
        protected VGGradientPaint(VGDevice device, bool linear, IEnumerable<KeyValuePair<byte, VGColor>> stops)
            : base(device)
        {
            LinearColorspace = linear;
            GradientFilter = TextureFilter.Linear;
            AddressMode = TextureAddressMode.Clamp;

            var colors = GetColors(stops);
            Gradient = new Texture2D(device.GraphicsDevice, colors.Length, 1, false, SurfaceFormat.Color);
            Gradient.SetData(colors);
        }
Example #9
0
 internal StaticString(VGDevice device, IEnumerable<KeyValuePair<Vector2, VGPath>> glyphs)
     : base(null)
 {
     VGPath result = new VGPath();
     foreach (var g in glyphs)
     {
         var p = g.Value.Clone();
         p.Offset(g.Key);
         result.Append(p);
     }
     _path = device.PreparePath(result, VGPaintMode.Fill);
     Extents = _path.Extents;
 }
Example #10
0
        internal VGState(VGDevice device)
        {
            IsActive = false;
            Device = device;
            Projection = new VGMatrixStack(2);
            ImageToSurface = new VGMatrixStack(2);
            GlyphToSurface = new VGMatrixStack(3);
            PathToSurface = new VGMatrixStack(4);
            PathToFillPaint = new VGMatrixStack(4);
            PathToTextPaint = new VGMatrixStack(4);
            PathToStrokePaint = new VGMatrixStack(4);
            ColorTransformation = new VGCxFormStack(4);

            SetAntialiasing(VGAntialiasing.Better);
            ResetDefaultValues();
        }
Example #11
0
        internal VGFont(VGDevice device, VGFillRule fillRule, float emSquareSize, float leadingSize, IDictionary<char, VGGlyphInfo> glyphs, VGFontMode mode)
            : this(device, fillRule, emSquareSize, leadingSize)
        {
            StencilVertex[] vertices;
            CharBuffer[] defs;
            CombineVertices(glyphs, out vertices, out defs, out _maxGlyphExtents);

            FontMode = mode;
            if (mode == VGFontMode.CPU)
            {
                _bufferedGlyphs = new VertexBuffer(device.GraphicsDevice, StencilVertex.VertexDeclaration, vertices.Length, BufferUsage.WriteOnly);
                _bufferedGlyphs.SetData(vertices);
            }
            else
            {
                int h = vertices.Length / device.MaxTextureSize;
                int s = device.MaxTextureSize * h;
                if (h > 0)
                {
                    Vertices = new Texture2D(device.GraphicsDevice, device.MaxTextureSize, 1 + h, false, SurfaceFormat.Vector4);
                    Vertices.SetData(0, new Rectangle(0, 0, device.MaxTextureSize, h), vertices, 0, s);
                    Vertices.SetData(0, new Rectangle(0, h, vertices.Length - s, 1), vertices, s, vertices.Length - s);
                }
                else
                {
                    Vertices = new Texture2D(device.GraphicsDevice, vertices.Length, 1, false, SurfaceFormat.Vector4);
                    Vertices.SetData(vertices);
                }
            }

            for (int i = 0; i < defs.Length; i++)
            {
                var def = defs[i];
                var info = glyphs[def.Character];
                _glyphs[def.Character] = new BufferGlyph(_bufferedGlyphs, def.Offset, def.Triangles, info.Advance);
            }
        }
Example #12
0
        internal VGFont(VGDevice device, Loaders.VGFontData fontData, VGFontMode mode)
            : this(device, fontData.FillRule, fontData.EmSquareSize, fontData.LeadingSize)
        {
            _maxGlyphExtents = fontData.Extents;

            KerningTable = fontData.Kerning;
            FontMode = mode;
            if (mode == VGFontMode.CPU)
            {
                _bufferedGlyphs = new VertexBuffer(device.GraphicsDevice, StencilVertex.VertexDeclaration, fontData.Vertices.Length, BufferUsage.WriteOnly);
                _bufferedGlyphs.SetData(fontData.Vertices);
            }
            else
            {
                int h = fontData.Vertices.Length / device.MaxTextureSize;
                int s = device.MaxTextureSize * h;
                Vertices = new Texture2D(device.GraphicsDevice, device.MaxTextureSize, 1 + h, false, SurfaceFormat.Vector4);
                if (h > 0) Vertices.SetData(0, new Rectangle(0, 0, device.MaxTextureSize, h), fontData.Vertices, 0, s);
                Vertices.SetData(0, new Rectangle(0, h, fontData.Vertices.Length - s, 1), fontData.Vertices, s, fontData.Vertices.Length - s);
            }

            foreach(var def in fontData.Glyphs)
                _glyphs[def.Character] = new BufferGlyph(_bufferedGlyphs, def.Offset, def.Triangles, def.Escape);
        }
Example #13
0
 internal VGLinearPaint(VGDevice device, bool linear, IEnumerable<KeyValuePair<byte, VGColor>> stops)
     : base(device, linear, stops)
 {
 }
Example #14
0
 internal VGPatternPaint(VGDevice device, VGImage image)
     : base(device)
 {
     Pattern = image;
 }
Example #15
0
 internal VGColorPaint(VGDevice device, VGColor color)
     : base(device)
 {
     Color = color;
 }
Example #16
0
 protected VGPaint(VGDevice device)
 {
     Device = device;
 }