A cross-platform UI framework for .NET
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

54 lines
1.6 KiB

using Avalonia.Controls.Shapes;
using Avalonia.Headless;
using Avalonia.Media;
using Avalonia.Platform;
using BenchmarkDotNet.Attributes;
namespace Avalonia.Benchmarks.Rendering
{
[MemoryDiagnoser]
public class ShapeRendering
{
private readonly DrawingContext _drawingContext;
private readonly Line _lineFill;
private readonly Line _lineFillAndStroke;
private readonly Line _lineNoBrushes;
private readonly Line _lineStroke;
public ShapeRendering()
{
_lineNoBrushes = new Line();
_lineStroke = new Line { Stroke = new SolidColorBrush() };
_lineFill = new Line { Fill = new SolidColorBrush() };
_lineFillAndStroke = new Line { Stroke = new SolidColorBrush(), Fill = new SolidColorBrush() };
_drawingContext = new PlatformDrawingContext(new HeadlessPlatformRenderInterface.HeadlessDrawingContextStub(), true);
AvaloniaLocator.CurrentMutable.Bind<IPlatformRenderInterface>().ToConstant(new HeadlessPlatformRenderInterface());
}
[Benchmark]
public void Render_Line_NoBrushes()
{
_lineNoBrushes.Render(_drawingContext);
}
[Benchmark]
public void Render_Line_WithStroke()
{
_lineStroke.Render(_drawingContext);
}
[Benchmark]
public void Render_Line_WithFill()
{
_lineFill.Render(_drawingContext);
}
[Benchmark]
public void Render_Line_WithFillAndStroke()
{
_lineFillAndStroke.Render(_drawingContext);
}
}
}