diff --git a/src/Avalonia.Controls/Utils/BorderRenderHelper.cs b/src/Avalonia.Controls/Utils/BorderRenderHelper.cs index a91e6a3a48..d6cf3df536 100644 --- a/src/Avalonia.Controls/Utils/BorderRenderHelper.cs +++ b/src/Avalonia.Controls/Utils/BorderRenderHelper.cs @@ -90,23 +90,17 @@ namespace Avalonia.Controls.Utils { var borderThickness = borders.Top; var top = borderThickness * 0.5; - var cornerRadius = (float)Math.Max(0, radii.TopLeft - borderThickness - top); - if (background != null) - { - var topLeft = new Point(borders.Left, borders.Top); - var bottomRight = new Point(size.Width - borders.Right, size.Height - borders.Bottom); - var innerRect = new Rect(topLeft, bottomRight); - context.FillRectangle(background, innerRect, cornerRadius); - } + IPen pen = null; - if (borderBrush != null && borderThickness > 0) + if (borderThickness > 0) { - var topLeft = new Point(top, top); - var bottomRight = new Point(size.Width - top, size.Height - top); - var outerRect = new Rect(topLeft, bottomRight); - context.DrawRectangle(new Pen(borderBrush, borderThickness), outerRect, (float)radii.TopLeft); + pen = new Pen(borderBrush, borderThickness); } + + var rect = new Rect(top, top, size.Width - borderThickness, size.Height - borderThickness); + + context.DrawRectangle(background, pen, rect, radii.TopLeft, radii.TopLeft); } } diff --git a/src/Avalonia.Visuals/Media/DrawingContext.cs b/src/Avalonia.Visuals/Media/DrawingContext.cs index 4c9bf9ebd4..8aa0bac41a 100644 --- a/src/Avalonia.Visuals/Media/DrawingContext.cs +++ b/src/Avalonia.Visuals/Media/DrawingContext.cs @@ -118,6 +118,42 @@ namespace Avalonia.Media } } + /// + /// Draws a rectangle with the specified Brush and Pen. + /// + /// The brush used to fill the rectangle, or null for no fill. + /// The pen used to stroke the rectangle, or null for no stroke. + /// The rectangle bounds. + /// The radius in the X dimension of the rounded corners. + /// This value will be clamped to the range of 0 to Width/2 + /// + /// The radius in the Y dimension of the rounded corners. + /// This value will be clamped to the range of 0 to Height/2 + /// + /// + /// The brush and the pen can both be null. If the brush is null, then no fill is performed. + /// If the pen is null, then no stoke is performed. If both the pen and the brush are null, then the drawing is not visible. + /// + public void DrawRectangle(IBrush brush, IPen pen, Rect rect, double radiusX = 0, double radiusY = 0) + { + if (brush == null && !PenIsVisible(pen)) + { + return; + } + + if (Math.Abs(radiusX) > double.Epsilon) + { + radiusX = Math.Min(radiusX, rect.Width / 2); + } + + if (Math.Abs(radiusY) > double.Epsilon) + { + radiusY = Math.Min(radiusY, rect.Height / 2); + } + + PlatformImpl.DrawRectangle(brush, pen, rect, radiusX, radiusY); + } + /// /// Draws the outline of a rectangle. /// @@ -126,10 +162,7 @@ namespace Avalonia.Media /// The corner radius. public void DrawRectangle(IPen pen, Rect rect, float cornerRadius = 0.0f) { - if (PenIsVisible(pen)) - { - PlatformImpl.DrawRectangle(pen, rect, cornerRadius); - } + DrawRectangle(null, pen, rect, cornerRadius, cornerRadius); } /// @@ -162,10 +195,7 @@ namespace Avalonia.Media /// The corner radius. public void FillRectangle(IBrush brush, Rect rect, float cornerRadius = 0.0f) { - if (brush != null && rect != Rect.Empty) - { - PlatformImpl.FillRectangle(brush, rect, cornerRadius); - } + DrawRectangle(brush, null, rect, cornerRadius, cornerRadius); } public readonly struct PushedState : IDisposable diff --git a/src/Avalonia.Visuals/Platform/IDrawingContextImpl.cs b/src/Avalonia.Visuals/Platform/IDrawingContextImpl.cs index f74c551fe0..5edb1c9760 100644 --- a/src/Avalonia.Visuals/Platform/IDrawingContextImpl.cs +++ b/src/Avalonia.Visuals/Platform/IDrawingContextImpl.cs @@ -61,12 +61,22 @@ namespace Avalonia.Platform void DrawGeometry(IBrush brush, IPen pen, IGeometryImpl geometry); /// - /// Draws the outline of a rectangle. + /// Draws a rectangle with the specified Brush and Pen. /// - /// The pen. + /// The brush used to fill the rectangle, or null for no fill. + /// The pen used to stroke the rectangle, or null for no stroke. /// The rectangle bounds. - /// The corner radius. - void DrawRectangle(IPen pen, Rect rect, float cornerRadius = 0.0f); + /// The radius in the X dimension of the rounded corners. + /// This value will be clamped to the range of 0 to Width/2 + /// + /// The radius in the Y dimension of the rounded corners. + /// This value will be clamped to the range of 0 to Height/2 + /// + /// + /// The brush and the pen can both be null. If the brush is null, then no fill is performed. + /// If the pen is null, then no stoke is performed. If both the pen and the brush are null, then the drawing is not visible. + /// + void DrawRectangle(IBrush brush, IPen pen, Rect rect, double radiusX = 0, double radiusY = 0); /// /// Draws text. @@ -76,14 +86,6 @@ namespace Avalonia.Platform /// The text. void DrawText(IBrush foreground, Point origin, IFormattedTextImpl text); - /// - /// Draws a filled rectangle. - /// - /// The brush. - /// The rectangle bounds. - /// The corner radius. - void FillRectangle(IBrush brush, Rect rect, float cornerRadius = 0.0f); - /// /// Creates a new that can be used as a render layer /// for the current render target. diff --git a/src/Avalonia.Visuals/Rendering/DeferredRenderer.cs b/src/Avalonia.Visuals/Rendering/DeferredRenderer.cs index d9a68b236a..2fa249f101 100644 --- a/src/Avalonia.Visuals/Rendering/DeferredRenderer.cs +++ b/src/Avalonia.Visuals/Rendering/DeferredRenderer.cs @@ -445,7 +445,7 @@ namespace Avalonia.Rendering foreach (var r in _dirtyRectsDisplay) { var brush = new ImmutableSolidColorBrush(Colors.Magenta, r.Opacity); - context.FillRectangle(brush, r.Rect); + context.DrawRectangle(brush,null, r.Rect); } } diff --git a/src/Avalonia.Visuals/Rendering/RendererBase.cs b/src/Avalonia.Visuals/Rendering/RendererBase.cs index e341f02901..e39581fc57 100644 --- a/src/Avalonia.Visuals/Rendering/RendererBase.cs +++ b/src/Avalonia.Visuals/Rendering/RendererBase.cs @@ -51,7 +51,7 @@ namespace Avalonia.Rendering var rect = new Rect(clientRect.Right - size.Width, 0, size.Width, size.Height); context.Transform = Matrix.Identity; - context.FillRectangle(Brushes.Black, rect); + context.DrawRectangle(Brushes.Black,null, rect); context.DrawText(Brushes.White, rect.TopLeft, _fpsText.PlatformImpl); } } diff --git a/src/Avalonia.Visuals/Rendering/SceneGraph/DeferredDrawingContextImpl.cs b/src/Avalonia.Visuals/Rendering/SceneGraph/DeferredDrawingContextImpl.cs index 3af56f5215..4fbfb02660 100644 --- a/src/Avalonia.Visuals/Rendering/SceneGraph/DeferredDrawingContextImpl.cs +++ b/src/Avalonia.Visuals/Rendering/SceneGraph/DeferredDrawingContextImpl.cs @@ -152,13 +152,13 @@ namespace Avalonia.Rendering.SceneGraph } /// - public void DrawRectangle(IPen pen, Rect rect, float cornerRadius = 0) + public void DrawRectangle(IBrush brush, IPen pen, Rect rect, double radiusX = 0, double radiusY = 0) { var next = NextDrawAs(); - if (next == null || !next.Item.Equals(Transform, null, pen, rect, cornerRadius)) + if (next == null || !next.Item.Equals(Transform, brush, pen, rect, radiusX, radiusY)) { - Add(new RectangleNode(Transform, null, pen, rect, cornerRadius, CreateChildScene(pen.Brush))); + Add(new RectangleNode(Transform, brush, pen, rect, radiusX, radiusY, CreateChildScene(brush))); } else { @@ -190,21 +190,6 @@ namespace Avalonia.Rendering.SceneGraph } } - /// - public void FillRectangle(IBrush brush, Rect rect, float cornerRadius = 0) - { - var next = NextDrawAs(); - - if (next == null || !next.Item.Equals(Transform, brush, null, rect, cornerRadius)) - { - Add(new RectangleNode(Transform, brush, null, rect, cornerRadius, CreateChildScene(brush))); - } - else - { - ++_drawOperationindex; - } - } - public IRenderTargetBitmapImpl CreateLayer(Size size) { throw new NotSupportedException("Creating layers on a deferred drawing context not supported"); diff --git a/src/Avalonia.Visuals/Rendering/SceneGraph/RectangleNode.cs b/src/Avalonia.Visuals/Rendering/SceneGraph/RectangleNode.cs index 0f3581b84c..b40afe78c5 100644 --- a/src/Avalonia.Visuals/Rendering/SceneGraph/RectangleNode.cs +++ b/src/Avalonia.Visuals/Rendering/SceneGraph/RectangleNode.cs @@ -1,6 +1,7 @@ // Copyright (c) The Avalonia Project. All rights reserved. // Licensed under the MIT license. See licence.md file in the project root for full license information. +using System; using System.Collections.Generic; using Avalonia.Media; using Avalonia.Media.Immutable; @@ -21,14 +22,16 @@ namespace Avalonia.Rendering.SceneGraph /// The fill brush. /// The stroke pen. /// The rectangle to draw. - /// The rectangle corner radius. + /// The radius in the Y dimension of the rounded corners. + /// The radius in the X dimension of the rounded corners. /// Child scenes for drawing visual brushes. public RectangleNode( Matrix transform, IBrush brush, IPen pen, Rect rect, - float cornerRadius, + double radiusX, + double radiusY, IDictionary childScenes = null) : base(rect, transform, pen) { @@ -36,7 +39,8 @@ namespace Avalonia.Rendering.SceneGraph Brush = brush?.ToImmutable(); Pen = pen?.ToImmutable(); Rect = rect; - CornerRadius = cornerRadius; + RadiusX = radiusX; + RadiusY = radiusY; ChildScenes = childScenes; } @@ -61,9 +65,14 @@ namespace Avalonia.Rendering.SceneGraph public Rect Rect { get; } /// - /// Gets the rectangle corner radius. + /// The radius in the X dimension of the rounded corners. /// - public float CornerRadius { get; } + public double RadiusX { get; } + + /// + /// The radius in the Y dimension of the rounded corners. + /// + public double RadiusY { get; } /// public override IDictionary ChildScenes { get; } @@ -75,19 +84,21 @@ namespace Avalonia.Rendering.SceneGraph /// The fill of the other draw operation. /// The stroke of the other draw operation. /// The rectangle of the other draw operation. - /// The rectangle corner radius of the other draw operation. + /// + /// /// True if the draw operations are the same, otherwise false. /// /// The properties of the other draw operation are passed in as arguments to prevent /// allocation of a not-yet-constructed draw operation object. /// - public bool Equals(Matrix transform, IBrush brush, IPen pen, Rect rect, float cornerRadius) + public bool Equals(Matrix transform, IBrush brush, IPen pen, Rect rect, double radiusX, double radiusY) { return transform == Transform && - Equals(brush, Brush) && - Equals(Pen, pen) && - rect == Rect && - cornerRadius == CornerRadius; + Equals(brush, Brush) && + Equals(Pen, pen) && + rect == Rect && + Math.Abs(radiusX - RadiusX) < double.Epsilon && + Math.Abs(radiusY - RadiusY) < double.Epsilon; } /// @@ -95,15 +106,7 @@ namespace Avalonia.Rendering.SceneGraph { context.Transform = Transform; - if (Brush != null) - { - context.FillRectangle(Brush, Rect, CornerRadius); - } - - if (Pen != null) - { - context.DrawRectangle(Pen, Rect, CornerRadius); - } + context.DrawRectangle(Brush, Pen, Rect, RadiusX, RadiusY); } /// diff --git a/src/Skia/Avalonia.Skia/DrawingContextImpl.cs b/src/Skia/Avalonia.Skia/DrawingContextImpl.cs index 47e651ce91..fe93215040 100644 --- a/src/Skia/Avalonia.Skia/DrawingContextImpl.cs +++ b/src/Skia/Avalonia.Skia/DrawingContextImpl.cs @@ -184,37 +184,40 @@ namespace Avalonia.Skia } /// - public void DrawRectangle(IPen pen, Rect rect, float cornerRadius = 0) + public void DrawRectangle(IBrush brush, IPen pen, Rect rect, double radiusX, double radiusY) { - using (var paint = CreatePaint(pen, rect.Size)) - { - var rc = rect.ToSKRect(); + var rc = rect.ToSKRect(); + var isRounded = Math.Abs(radiusX) > double.Epsilon || Math.Abs(radiusX) > double.Epsilon; - if (Math.Abs(cornerRadius) < float.Epsilon) - { - Canvas.DrawRect(rc, paint.Paint); - } - else + if (brush != null) + { + using (var paint = CreatePaint(brush, rect.Size)) { - Canvas.DrawRoundRect(rc, cornerRadius, cornerRadius, paint.Paint); + if (isRounded) + { + Canvas.DrawRoundRect(rc, (float)radiusX, (float)radiusY, paint.Paint); + } + else + { + Canvas.DrawRect(rc, paint.Paint); + } + } } - } - /// - public void FillRectangle(IBrush brush, Rect rect, float cornerRadius = 0) - { - using (var paint = CreatePaint(brush, rect.Size)) + if (pen?.Brush != null) { - var rc = rect.ToSKRect(); - - if (Math.Abs(cornerRadius) < float.Epsilon) - { - Canvas.DrawRect(rc, paint.Paint); - } - else + using (var paint = CreatePaint(pen, rect.Size)) { - Canvas.DrawRoundRect(rc, cornerRadius, cornerRadius, paint.Paint); + if (isRounded) + { + Canvas.DrawRoundRect(rc, (float)radiusX, (float)radiusY, paint.Paint); + } + else + { + Canvas.DrawRect(rc, paint.Paint); + } + } } } diff --git a/src/Windows/Avalonia.Direct2D1/Media/DrawingContextImpl.cs b/src/Windows/Avalonia.Direct2D1/Media/DrawingContextImpl.cs index 39d801eb2f..394c9b14d1 100644 --- a/src/Windows/Avalonia.Direct2D1/Media/DrawingContextImpl.cs +++ b/src/Windows/Avalonia.Direct2D1/Media/DrawingContextImpl.cs @@ -230,34 +230,64 @@ namespace Avalonia.Direct2D1.Media } } - /// - /// Draws the outline of a rectangle. - /// - /// The pen. - /// The rectangle bounds. - /// The corner radius. - public void DrawRectangle(IPen pen, Rect rect, float cornerRadius) + /// + public void DrawRectangle(IBrush brush, IPen pen, Rect rect, double radiusX, double radiusY) { - using (var brush = CreateBrush(pen.Brush, rect.Size)) - using (var d2dStroke = pen.ToDirect2DStrokeStyle(_deviceContext)) + var rc = rect.ToDirect2D(); + var isRounded = Math.Abs(radiusX) > double.Epsilon || Math.Abs(radiusX) > double.Epsilon; + + if (brush != null) { - if (brush.PlatformBrush != null) + using (var b = CreateBrush(brush, rect.Size)) { - if (cornerRadius == 0) + if (b.PlatformBrush != null) { - _deviceContext.DrawRectangle( - rect.ToDirect2D(), - brush.PlatformBrush, - (float)pen.Thickness, - d2dStroke); + if (isRounded) + { + _deviceContext.FillRoundedRectangle( + new RoundedRectangle + { + Rect = new RawRectangleF( + (float)rect.X, + (float)rect.Y, + (float)rect.Right, + (float)rect.Bottom), + RadiusX = (float)radiusX, + RadiusY = (float)radiusY + }, + b.PlatformBrush); + } + else + { + _deviceContext.FillRectangle(rc, b.PlatformBrush); + } } - else + } + } + + if (pen?.Brush != null) + { + using (var wrapper = CreateBrush(pen.Brush, rect.Size)) + using (var d2dStroke = pen.ToDirect2DStrokeStyle(_deviceContext)) + { + if (wrapper.PlatformBrush != null) { - _deviceContext.DrawRoundedRectangle( - new RoundedRectangle { Rect = rect.ToDirect2D(), RadiusX = cornerRadius, RadiusY = cornerRadius }, - brush.PlatformBrush, - (float)pen.Thickness, - d2dStroke); + if (isRounded) + { + _deviceContext.DrawRoundedRectangle( + new RoundedRectangle { Rect = rc, RadiusX = (float)radiusX, RadiusY = (float)radiusY }, + wrapper.PlatformBrush, + (float)pen.Thickness, + d2dStroke); + } + else + { + _deviceContext.DrawRectangle( + rc, + wrapper.PlatformBrush, + (float)pen.Thickness, + d2dStroke); + } } } } @@ -286,41 +316,6 @@ namespace Avalonia.Direct2D1.Media } } - /// - /// Draws a filled rectangle. - /// - /// The brush. - /// The rectangle bounds. - /// The corner radius. - public void FillRectangle(IBrush brush, Rect rect, float cornerRadius) - { - using (var b = CreateBrush(brush, rect.Size)) - { - if (b.PlatformBrush != null) - { - if (cornerRadius == 0) - { - _deviceContext.FillRectangle(rect.ToDirect2D(), b.PlatformBrush); - } - else - { - _deviceContext.FillRoundedRectangle( - new RoundedRectangle - { - Rect = new RawRectangleF( - (float)rect.X, - (float)rect.Y, - (float)rect.Right, - (float)rect.Bottom), - RadiusX = cornerRadius, - RadiusY = cornerRadius - }, - b.PlatformBrush); - } - } - } - } - public IRenderTargetBitmapImpl CreateLayer(Size size) { if (_layerFactory != null) diff --git a/tests/Avalonia.RenderTests/Media/BitmapTests.cs b/tests/Avalonia.RenderTests/Media/BitmapTests.cs index e6cd800529..97e234a55b 100644 --- a/tests/Avalonia.RenderTests/Media/BitmapTests.cs +++ b/tests/Avalonia.RenderTests/Media/BitmapTests.cs @@ -78,9 +78,9 @@ namespace Avalonia.Direct2D1.RenderTests.Media { ctx.Clear(Colors.Transparent); ctx.PushOpacity(0.8); - ctx.FillRectangle(Brushes.Chartreuse, new Rect(0, 0, 20, 100)); - ctx.FillRectangle(Brushes.Crimson, new Rect(20, 0, 20, 100)); - ctx.FillRectangle(Brushes.Gold, new Rect(40, 0, 20, 100)); + ctx.DrawRectangle(Brushes.Chartreuse, null, new Rect(0, 0, 20, 100)); + ctx.DrawRectangle(Brushes.Crimson, null, new Rect(20, 0, 20, 100)); + ctx.DrawRectangle(Brushes.Gold,null, new Rect(40, 0, 20, 100)); ctx.PopOpacity(); } @@ -90,8 +90,8 @@ namespace Avalonia.Direct2D1.RenderTests.Media { using (var ctx = rtb.CreateDrawingContext(null)) { - ctx.FillRectangle(Brushes.Blue, new Rect(0, 0, 100, 100)); - ctx.FillRectangle(Brushes.Pink, new Rect(0, 20, 100, 10)); + ctx.DrawRectangle(Brushes.Blue, null, new Rect(0, 0, 100, 100)); + ctx.DrawRectangle(Brushes.Pink, null, new Rect(0, 20, 100, 10)); var rc = new Rect(0, 0, 60, 60); ctx.DrawImage(bmp.PlatformImpl, 1, rc, rc); diff --git a/tests/Avalonia.Visuals.UnitTests/Rendering/DeferredRendererTests.cs b/tests/Avalonia.Visuals.UnitTests/Rendering/DeferredRendererTests.cs index 6063a382a0..2061caa320 100644 --- a/tests/Avalonia.Visuals.UnitTests/Rendering/DeferredRendererTests.cs +++ b/tests/Avalonia.Visuals.UnitTests/Rendering/DeferredRendererTests.cs @@ -466,7 +466,7 @@ namespace Avalonia.Visuals.UnitTests.Rendering var animation = new BehaviorSubject(0.5); context.Verify(x => x.PushOpacity(0.5), Times.Once); - context.Verify(x => x.FillRectangle(Brushes.Red, new Rect(0, 0, 100, 100), 0), Times.Once); + context.Verify(x => x.DrawRectangle(Brushes.Red, null, new Rect(0, 0, 100, 100), 0, 0), Times.Once); context.Verify(x => x.PopOpacity(), Times.Once); } @@ -496,7 +496,7 @@ namespace Avalonia.Visuals.UnitTests.Rendering var animation = new BehaviorSubject(0.5); context.Verify(x => x.PushOpacity(0.5), Times.Never); - context.Verify(x => x.FillRectangle(Brushes.Red, new Rect(0, 0, 100, 100), 0), Times.Never); + context.Verify(x => x.DrawRectangle(Brushes.Red, null, new Rect(0, 0, 100, 100), 0, 0), Times.Never); context.Verify(x => x.PopOpacity(), Times.Never); } @@ -522,7 +522,7 @@ namespace Avalonia.Visuals.UnitTests.Rendering var animation = new BehaviorSubject(0.5); context.Verify(x => x.PushOpacityMask(Brushes.Green, new Rect(0, 0, 100, 100)), Times.Once); - context.Verify(x => x.FillRectangle(Brushes.Red, new Rect(0, 0, 100, 100), 0), Times.Once); + context.Verify(x => x.DrawRectangle(Brushes.Red, null, new Rect(0, 0, 100, 100), 0, 0), Times.Once); context.Verify(x => x.PopOpacityMask(), Times.Once); } @@ -641,7 +641,7 @@ namespace Avalonia.Visuals.UnitTests.Rendering var context = GetLayerContext(target, border); context.Verify(x => x.PushOpacity(0.5), Times.Never); - context.Verify(x => x.FillRectangle(Brushes.Red, new Rect(0, 0, 100, 100), 0), Times.Once); + context.Verify(x => x.DrawRectangle(Brushes.Red, null, new Rect(0, 0, 100, 100), 0, 0), Times.Once); context.Verify(x => x.PopOpacity(), Times.Never); } diff --git a/tests/Avalonia.Visuals.UnitTests/Rendering/SceneGraph/DeferredDrawingContextImplTests.cs b/tests/Avalonia.Visuals.UnitTests/Rendering/SceneGraph/DeferredDrawingContextImplTests.cs index f57c73c45c..5fe92ba039 100644 --- a/tests/Avalonia.Visuals.UnitTests/Rendering/SceneGraph/DeferredDrawingContextImplTests.cs +++ b/tests/Avalonia.Visuals.UnitTests/Rendering/SceneGraph/DeferredDrawingContextImplTests.cs @@ -100,20 +100,18 @@ namespace Avalonia.Visuals.UnitTests.Rendering.SceneGraph using (target.BeginUpdate(node)) { - target.FillRectangle(Brushes.Red, new Rect(0, 0, 100, 100)); - target.DrawRectangle(new Pen(Brushes.Green, 1), new Rect(0, 0, 100, 100)); + target.DrawRectangle(Brushes.Red, new Pen(Brushes.Green, 1), new Rect(0, 0, 100, 100)); } - Assert.Equal(2, node.DrawOperations.Count); + Assert.Equal(1, node.DrawOperations.Count); Assert.IsType(node.DrawOperations[0].Item); - Assert.IsType(node.DrawOperations[1].Item); } [Fact] public void Should_Not_Replace_Identical_DrawOperation() { var node = new VisualNode(new TestRoot(), null); - var operation = RefCountable.Create(new RectangleNode(Matrix.Identity, Brushes.Red, null, new Rect(0, 0, 100, 100), 0)); + var operation = RefCountable.Create(new RectangleNode(Matrix.Identity, Brushes.Red, null, new Rect(0, 0, 100, 100), 0, 0)); var layers = new SceneLayers(node.Visual); var target = new DeferredDrawingContextImpl(null, layers); @@ -122,7 +120,7 @@ namespace Avalonia.Visuals.UnitTests.Rendering.SceneGraph using (target.BeginUpdate(node)) { - target.FillRectangle(Brushes.Red, new Rect(0, 0, 100, 100)); + target.DrawRectangle(Brushes.Red, null, new Rect(0, 0, 100, 100)); } Assert.Equal(1, node.DrawOperations.Count); @@ -135,7 +133,7 @@ namespace Avalonia.Visuals.UnitTests.Rendering.SceneGraph public void Should_Replace_Different_DrawOperation() { var node = new VisualNode(new TestRoot(), null); - var operation = RefCountable.Create(new RectangleNode(Matrix.Identity, Brushes.Red, null, new Rect(0, 0, 100, 100), 0)); + var operation = RefCountable.Create(new RectangleNode(Matrix.Identity, Brushes.Red, null, new Rect(0, 0, 100, 100), 0, 0)); var layers = new SceneLayers(node.Visual); var target = new DeferredDrawingContextImpl(null, layers); @@ -144,7 +142,7 @@ namespace Avalonia.Visuals.UnitTests.Rendering.SceneGraph using (target.BeginUpdate(node)) { - target.FillRectangle(Brushes.Green, new Rect(0, 0, 100, 100)); + target.DrawRectangle(Brushes.Green, null, new Rect(0, 0, 100, 100)); } Assert.Equal(1, node.DrawOperations.Count); @@ -157,7 +155,7 @@ namespace Avalonia.Visuals.UnitTests.Rendering.SceneGraph public void Should_Update_DirtyRects() { var node = new VisualNode(new TestRoot(), null); - var operation = new RectangleNode(Matrix.Identity, Brushes.Red, null, new Rect(0, 0, 100, 100), 0); + var operation = new RectangleNode(Matrix.Identity, Brushes.Red, null, new Rect(0, 0, 100, 100), 0, 0); var layers = new SceneLayers(node.Visual); var target = new DeferredDrawingContextImpl(null, layers); @@ -165,7 +163,7 @@ namespace Avalonia.Visuals.UnitTests.Rendering.SceneGraph using (target.BeginUpdate(node)) { - target.FillRectangle(Brushes.Green, new Rect(0, 0, 100, 100)); + target.DrawRectangle(Brushes.Green, null, new Rect(0, 0, 100, 100)); } Assert.Equal(new Rect(0, 0, 100, 100), layers.Single().Dirty.Single()); @@ -192,8 +190,8 @@ namespace Avalonia.Visuals.UnitTests.Rendering.SceneGraph using (target.BeginUpdate(node)) { - target.FillRectangle(Brushes.Green, new Rect(0, 0, 10, 100)); - target.FillRectangle(Brushes.Blue, new Rect(0, 0, 20, 100)); + target.DrawRectangle(Brushes.Green, null, new Rect(0, 0, 10, 100)); + target.DrawRectangle(Brushes.Blue, null, new Rect(0, 0, 20, 100)); } Assert.Equal(2, node.DrawOperations.Count); @@ -208,7 +206,7 @@ namespace Avalonia.Visuals.UnitTests.Rendering.SceneGraph public void Trimmed_DrawOperations_Releases_Reference() { var node = new VisualNode(new TestRoot(), null); - var operation = RefCountable.Create(new RectangleNode(Matrix.Identity, Brushes.Red, null, new Rect(0, 0, 100, 100), 0)); + var operation = RefCountable.Create(new RectangleNode(Matrix.Identity, Brushes.Red, null, new Rect(0, 0, 100, 100), 0, 0)); var layers = new SceneLayers(node.Visual); var target = new DeferredDrawingContextImpl(null, layers); @@ -218,7 +216,7 @@ namespace Avalonia.Visuals.UnitTests.Rendering.SceneGraph using (target.BeginUpdate(node)) { - target.FillRectangle(Brushes.Green, new Rect(0, 0, 100, 100)); + target.DrawRectangle(Brushes.Green, null, new Rect(0, 0, 100, 100)); } Assert.Equal(1, node.DrawOperations.Count);