8 changed files with 197 additions and 10 deletions
@ -0,0 +1,103 @@ |
|||
using Avalonia.Media; |
|||
using Avalonia.Platform; |
|||
using Avalonia.Rendering.SceneGraph; |
|||
using Avalonia.Utilities; |
|||
using Avalonia.Visuals.Media.Imaging; |
|||
|
|||
namespace Avalonia.Benchmarks |
|||
{ |
|||
internal class NullDrawingContextImpl : IDrawingContextImpl |
|||
{ |
|||
public void Dispose() |
|||
{ |
|||
} |
|||
|
|||
public Matrix Transform { get; set; } |
|||
|
|||
public void Clear(Color color) |
|||
{ |
|||
} |
|||
|
|||
public void DrawBitmap(IRef<IBitmapImpl> source, double opacity, Rect sourceRect, Rect destRect, |
|||
BitmapInterpolationMode bitmapInterpolationMode = BitmapInterpolationMode.Default) |
|||
{ |
|||
} |
|||
|
|||
public void DrawBitmap(IRef<IBitmapImpl> source, IBrush opacityMask, Rect opacityMaskRect, Rect destRect) |
|||
{ |
|||
} |
|||
|
|||
public void DrawLine(IPen pen, Point p1, Point p2) |
|||
{ |
|||
} |
|||
|
|||
public void DrawGeometry(IBrush brush, IPen pen, IGeometryImpl geometry) |
|||
{ |
|||
} |
|||
|
|||
public void DrawRectangle(IBrush brush, IPen pen, RoundedRect rect, BoxShadows boxShadows = default) |
|||
{ |
|||
} |
|||
|
|||
public void DrawText(IBrush foreground, Point origin, IFormattedTextImpl text) |
|||
{ |
|||
} |
|||
|
|||
public void DrawGlyphRun(IBrush foreground, GlyphRun glyphRun) |
|||
{ |
|||
} |
|||
|
|||
public IDrawingContextLayerImpl CreateLayer(Size size) |
|||
{ |
|||
return null; |
|||
} |
|||
|
|||
public void PushClip(Rect clip) |
|||
{ |
|||
} |
|||
|
|||
public void PushClip(RoundedRect clip) |
|||
{ |
|||
} |
|||
|
|||
public void PopClip() |
|||
{ |
|||
} |
|||
|
|||
public void PushOpacity(double opacity) |
|||
{ |
|||
} |
|||
|
|||
public void PopOpacity() |
|||
{ |
|||
} |
|||
|
|||
public void PushOpacityMask(IBrush mask, Rect bounds) |
|||
{ |
|||
} |
|||
|
|||
public void PopOpacityMask() |
|||
{ |
|||
} |
|||
|
|||
public void PushGeometryClip(IGeometryImpl clip) |
|||
{ |
|||
} |
|||
|
|||
public void PopGeometryClip() |
|||
{ |
|||
} |
|||
|
|||
public void PushBitmapBlendMode(BitmapBlendingMode blendingMode) |
|||
{ |
|||
} |
|||
|
|||
public void PopBitmapBlendMode() |
|||
{ |
|||
} |
|||
|
|||
public void Custom(ICustomDrawOperation custom) |
|||
{ |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,53 @@ |
|||
using Avalonia.Controls.Shapes; |
|||
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 DrawingContext(new NullDrawingContextImpl(), true); |
|||
|
|||
AvaloniaLocator.CurrentMutable.Bind<IPlatformRenderInterface>().ToConstant(new NullRenderingPlatform()); |
|||
} |
|||
|
|||
[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); |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue