diff --git a/src/Avalonia.Controls/TopLevel.cs b/src/Avalonia.Controls/TopLevel.cs
index 4dcd2d0533..811a6a0735 100644
--- a/src/Avalonia.Controls/TopLevel.cs
+++ b/src/Avalonia.Controls/TopLevel.cs
@@ -100,7 +100,7 @@ namespace Avalonia.Controls
PlatformImpl.Paint = HandlePaint;
PlatformImpl.Resized = HandleResized;
PlatformImpl.ScalingChanged = HandleScalingChanged;
-
+
_keyboardNavigationHandler?.SetOwner(this);
_accessKeyHandler?.SetOwner(this);
diff --git a/src/Avalonia.Visuals/Platform/IRenderTarget.cs b/src/Avalonia.Visuals/Platform/IRenderTarget.cs
index 765d7a9d9d..522de64ec7 100644
--- a/src/Avalonia.Visuals/Platform/IRenderTarget.cs
+++ b/src/Avalonia.Visuals/Platform/IRenderTarget.cs
@@ -2,7 +2,6 @@
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System;
-using Avalonia.Media;
using Avalonia.Rendering;
namespace Avalonia.Platform
@@ -16,7 +15,7 @@ namespace Avalonia.Platform
public interface IRenderTarget : IDisposable
{
///
- /// Creates an for a rendering session.
+ /// Creates an for a rendering session.
///
///
/// A render to be used to render visual brushes. May be null if no visual brushes are
diff --git a/src/Avalonia.Visuals/Rendering/ImmediateRenderer.cs b/src/Avalonia.Visuals/Rendering/ImmediateRenderer.cs
index d647b3ce7a..af51eacaed 100644
--- a/src/Avalonia.Visuals/Rendering/ImmediateRenderer.cs
+++ b/src/Avalonia.Visuals/Rendering/ImmediateRenderer.cs
@@ -5,7 +5,6 @@ using System;
using Avalonia.Platform;
using Avalonia.VisualTree;
using System.Collections.Generic;
-using Avalonia.Threading;
using Avalonia.Media;
using System.Linq;
diff --git a/src/Gtk/Avalonia.Cairo/Media/DrawingContext.cs b/src/Gtk/Avalonia.Cairo/Media/DrawingContext.cs
index c671d5fa08..7d1776db0b 100644
--- a/src/Gtk/Avalonia.Cairo/Media/DrawingContext.cs
+++ b/src/Gtk/Avalonia.Cairo/Media/DrawingContext.cs
@@ -54,7 +54,7 @@ namespace Avalonia.Cairo.Media
{
_transform = value;
_context.Matrix = value.ToCairo();
-
+
}
}
@@ -90,7 +90,7 @@ namespace Avalonia.Cairo.Media
_context.Scale(scale.X, scale.Y);
destRect /= scale;
- _context.PushGroup ();
+ _context.PushGroup();
if (pixbuf != null)
{
@@ -108,10 +108,10 @@ namespace Avalonia.Cairo.Media
(int)(-sourceRect.Y + destRect.Y));
}
- _context.Rectangle (destRect.ToCairo ());
- _context.Fill ();
- _context.PopGroupToSource ();
- _context.PaintWithAlpha (opacityOverride);
+ _context.Rectangle(destRect.ToCairo());
+ _context.Fill();
+ _context.PopGroupToSource();
+ _context.PaintWithAlpha(opacityOverride);
_context.Restore();
}
@@ -131,8 +131,8 @@ namespace Avalonia.Cairo.Media
public void DrawLine(Pen pen, Point p1, Point p2)
{
var size = new Rect(p1, p2).Size;
-
- using (var p = SetPen(pen, size))
+
+ using (var p = SetPen(pen, size))
{
_context.MoveTo(p1.ToCairo());
_context.LineTo(p2.ToCairo());
@@ -153,7 +153,7 @@ namespace Avalonia.Cairo.Media
var oldMatrix = Transform;
Transform = impl.Transform * Transform;
-
+
if (brush != null)
{
_context.AppendPath(impl.Path);
@@ -188,9 +188,9 @@ namespace Avalonia.Cairo.Media
/// The rectangle bounds.
public void DrawRectangle(Pen pen, Rect rect, float cornerRadius)
{
- using (var p = SetPen(pen, rect.Size))
+ using (var p = SetPen(pen, rect.Size))
{
- _context.Rectangle(rect.ToCairo ());
+ _context.Rectangle(rect.ToCairo());
_context.Stroke();
}
}
@@ -206,7 +206,7 @@ namespace Avalonia.Cairo.Media
var layout = ((FormattedTextImpl)text).Layout;
_context.MoveTo(origin.X, origin.Y);
- using (var b = SetBrush(foreground, new Size(0, 0)))
+ using (var b = SetBrush(foreground, new Size(0, 0)))
{
Pango.CairoHelper.ShowLayout(_context, layout);
}
@@ -219,9 +219,9 @@ namespace Avalonia.Cairo.Media
/// The rectangle bounds.
public void FillRectangle(IBrush brush, Rect rect, float cornerRadius)
{
- using (var b = SetBrush(brush, rect.Size))
+ using (var b = SetBrush(brush, rect.Size))
{
- _context.Rectangle(rect.ToCairo ());
+ _context.Rectangle(rect.ToCairo());
_context.Fill();
}
}
@@ -276,10 +276,10 @@ namespace Avalonia.Cairo.Media
return Disposable.Create(() =>
{
- _context.Restore();
+ _context.Restore();
});
}
-
+
private double opacityOverride = 1.0f;
private IDisposable SetBrush(IBrush brush, Size destinationSize)
@@ -379,7 +379,7 @@ namespace Avalonia.Cairo.Media
if (pen.Brush == null)
return Disposable.Empty;
-
+
return SetBrush(pen.Brush, destinationSize);
}
@@ -405,10 +405,10 @@ namespace Avalonia.Cairo.Media
public void PopOpacityMask()
{
_context.PopGroupToSource();
- var brushImpl = _maskStack.Pop ();
+ var brushImpl = _maskStack.Pop();
_context.Mask(brushImpl.PlatformBrush);
- brushImpl.Dispose ();
+ brushImpl.Dispose();
}
}
}
diff --git a/src/Gtk/Avalonia.Cairo/Media/ImageBrushImpl.cs b/src/Gtk/Avalonia.Cairo/Media/ImageBrushImpl.cs
index 94aa4e6b25..14c9dee9e2 100644
--- a/src/Gtk/Avalonia.Cairo/Media/ImageBrushImpl.cs
+++ b/src/Gtk/Avalonia.Cairo/Media/ImageBrushImpl.cs
@@ -1,16 +1,12 @@
-using System;
-using Avalonia.Cairo.Media.Imaging;
using Avalonia.Media;
using Avalonia.Platform;
using Avalonia.Rendering.Utilities;
-using Gdk;
-using Avalonia.Media;
using global::Cairo;
namespace Avalonia.Cairo.Media
{
- public class ImageBrushImpl : BrushImpl
- {
+ public class ImageBrushImpl : BrushImpl
+ {
public ImageBrushImpl(
ITileBrush brush,
IBitmapImpl bitmap,
diff --git a/src/Gtk/Avalonia.Cairo/Media/TileBrushes.cs b/src/Gtk/Avalonia.Cairo/Media/TileBrushes.cs
deleted file mode 100644
index eb78c9d2f3..0000000000
--- a/src/Gtk/Avalonia.Cairo/Media/TileBrushes.cs
+++ /dev/null
@@ -1,55 +0,0 @@
-// 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 Cairo;
-using Avalonia.Cairo.Media.Imaging;
-using Avalonia.Layout;
-using Avalonia.Media;
-using Avalonia.Platform;
-using Avalonia.Rendering;
-using Avalonia.RenderHelpers;
-
-namespace Avalonia.Cairo.Media
-{
- internal static class TileBrushes
- {
- public static SurfacePattern CreateTileBrush(ITileBrush brush, Size targetSize)
- {
- var helper = new TileBrushImplHelper(brush, targetSize);
- if (!helper.IsValid)
- return null;
-
- using (var intermediate = new ImageSurface(Format.ARGB32, (int)helper.IntermediateSize.Width, (int)helper.IntermediateSize.Height))
- using (var ctx = new RenderTarget(intermediate).CreateDrawingContext())
- {
- helper.DrawIntermediate(ctx);
-
- var result = new SurfacePattern(intermediate);
-
- if ((brush.TileMode & TileMode.FlipXY) != 0)
- {
- // TODO: Currently always FlipXY as that's all cairo supports natively.
- // Support separate FlipX and FlipY by drawing flipped images to intermediate
- // surface.
- result.Extend = Extend.Reflect;
- }
- else
- {
- result.Extend = Extend.Repeat;
- }
-
- if (brush.TileMode != TileMode.None)
- {
- var matrix = result.Matrix;
- matrix.InitTranslate(-helper.DestinationRect.X, -helper.DestinationRect.Y);
- result.Matrix = matrix;
- }
-
- return result;
- }
- }
-
-
- }
-}
diff --git a/src/Gtk/Avalonia.Cairo/Media/VisualBrushImpl.cs b/src/Gtk/Avalonia.Cairo/Media/VisualBrushImpl.cs
deleted file mode 100644
index e820c50420..0000000000
--- a/src/Gtk/Avalonia.Cairo/Media/VisualBrushImpl.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-using System;
-using Avalonia.Media;
-using global::Cairo;
-
-namespace Avalonia.Cairo.Media
-{
- public class VisualBrushImpl : BrushImpl
- {
- public VisualBrushImpl(IVisualBrush brush, Size destinationSize)
- {
- this.PlatformBrush = TileBrushes.CreateTileBrush(brush, destinationSize);
- }
- }
-}
-
diff --git a/src/Shared/RenderHelpers/RenderHelpers.projitems b/src/Shared/RenderHelpers/RenderHelpers.projitems
index 8be6300957..c088097a9f 100644
--- a/src/Shared/RenderHelpers/RenderHelpers.projitems
+++ b/src/Shared/RenderHelpers/RenderHelpers.projitems
@@ -1,4 +1,4 @@
-
+
$(MSBuildAllProjects);$(MSBuildThisFileFullPath)
@@ -11,6 +11,5 @@
-
\ No newline at end of file
diff --git a/src/Shared/RenderHelpers/TileBrushImplHelper.cs b/src/Shared/RenderHelpers/TileBrushImplHelper.cs
deleted file mode 100644
index b6d09101c9..0000000000
--- a/src/Shared/RenderHelpers/TileBrushImplHelper.cs
+++ /dev/null
@@ -1,213 +0,0 @@
-// 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 Avalonia.Controls;
-using Avalonia.Media;
-using Avalonia.Rendering;
-using Avalonia.VisualTree;
-
-namespace Avalonia.RenderHelpers
-{
- internal class TileBrushImplHelper
- {
- public Size IntermediateSize { get; }
- public Rect DestinationRect { get; }
- private readonly TileMode _tileMode;
- private readonly Rect _sourceRect;
- private readonly Vector _scale;
- private readonly Vector _translate;
- private readonly Size _imageSize;
- private readonly IVisualBrush _visualBrush;
- private readonly IImageBrush _imageBrush;
- private readonly Matrix _transform;
- private readonly Rect _drawRect;
-
- public bool IsValid { get; }
-
- public TileBrushImplHelper(ITileBrush brush, Size targetSize)
- {
- _imageBrush = brush as IImageBrush;
- _visualBrush = brush as IVisualBrush;
- if (_imageBrush != null)
- {
- if (_imageBrush.Source == null)
- return;
- _imageSize = new Size(_imageBrush.Source.PixelWidth, _imageBrush.Source.PixelHeight);
- IsValid = true;
- }
- else if (_visualBrush != null)
- {
- var control = _visualBrush.Visual as IControl;
-
- if (control != null)
- {
- EnsureInitialized(control);
- _imageSize = control.Bounds.Size;
- IsValid = true;
- }
- }
- else
- return;
-
- _tileMode = brush.TileMode;
- _sourceRect = brush.SourceRect.ToPixels(_imageSize);
- DestinationRect = brush.DestinationRect.ToPixels(targetSize);
- _scale = brush.Stretch.CalculateScaling(DestinationRect.Size, _sourceRect.Size);
- _translate = CalculateTranslate(brush, _sourceRect, DestinationRect, _scale);
- IntermediateSize = CalculateIntermediateSize(_tileMode, targetSize, DestinationRect.Size);
- _transform = CalculateIntermediateTransform(
- _tileMode,
- _sourceRect,
- DestinationRect,
- _scale,
- _translate,
- out _drawRect);
- }
-
- public bool NeedsIntermediateSurface
- {
- get
- {
- if (_imageBrush == null)
- return true;
- if (_transform != Matrix.Identity)
- return true;
- if (_sourceRect.Position != default(Point))
- return true;
- if ((int) _sourceRect.Width != _imageBrush.Source.PixelWidth ||
- (int) _sourceRect.Height != _imageBrush.Source.PixelHeight)
- return true;
- return false;
- }
- }
-
- public T GetDirect() => (T) _imageBrush?.Source.PlatformImpl;
-
- public void DrawIntermediate(DrawingContext ctx)
- {
- using (ctx.PushClip(_drawRect))
- using (ctx.PushPostTransform(_transform))
- {
- if (_imageBrush != null)
- {
- var bmpRc = new Rect(0, 0, _imageBrush.Source.PixelWidth, _imageBrush.Source.PixelHeight);
- ctx.DrawImage(_imageBrush.Source, 1, bmpRc, bmpRc);
- }
- else if (_visualBrush != null)
- {
- using (ctx.PushPostTransform(Matrix.CreateTranslation(-_visualBrush.Visual.Bounds.Position)))
- {
- ImmediateRenderer.Render(_visualBrush.Visual, ctx);
- }
- }
- }
- }
-
-
- ///
- /// Calculates a translate based on an , a source and destination
- /// rectangle and a scale.
- ///
- /// The brush.
- /// The source rectangle.
- /// The destination rectangle.
- /// The _scale factor.
- /// A vector with the X and Y _translate.
-
- public static Vector CalculateTranslate(
- ITileBrush brush,
- Rect sourceRect,
- Rect destinationRect,
- Vector scale)
- {
- var x = 0.0;
- var y = 0.0;
- var size = sourceRect.Size*scale;
-
- switch (brush.AlignmentX)
- {
- case AlignmentX.Center:
- x += (destinationRect.Width - size.Width)/2;
- break;
- case AlignmentX.Right:
- x += destinationRect.Width - size.Width;
- break;
- }
-
- switch (brush.AlignmentY)
- {
- case AlignmentY.Center:
- y += (destinationRect.Height - size.Height)/2;
- break;
- case AlignmentY.Bottom:
- y += destinationRect.Height - size.Height;
- break;
- }
-
- return new Vector(x, y);
- }
-
- public static Matrix CalculateIntermediateTransform(
- TileMode tileMode,
- Rect sourceRect,
- Rect destinationRect,
- Vector scale,
- Vector translate,
- out Rect drawRect)
- {
- var transform = Matrix.CreateTranslation(-sourceRect.Position)*
- Matrix.CreateScale(scale)*
- Matrix.CreateTranslation(translate);
- Rect dr;
-
- if (tileMode == TileMode.None)
- {
- dr = destinationRect;
- transform *= Matrix.CreateTranslation(destinationRect.Position);
- }
- else
- {
- dr = new Rect(destinationRect.Size);
- }
-
- drawRect = dr;
-
- return transform;
- }
-
- public static void EnsureInitialized(IVisual visual)
- {
- var control = visual as IControl;
-
- if (control != null)
- {
- foreach (var i in control.GetSelfAndVisualDescendents())
- {
- var c = i as IControl;
-
- if (c?.IsInitialized == false)
- {
- var init = c as ISupportInitialize;
-
- if (init != null)
- {
- init.BeginInit();
- init.EndInit();
- }
- }
- }
-
- if (!control.IsArrangeValid)
- {
- control.Measure(Size.Infinity);
- control.Arrange(new Rect(control.DesiredSize));
- }
- }
- }
-
- private static Size CalculateIntermediateSize(
- TileMode tileMode,
- Size targetSize,
- Size destinationSize) => tileMode == TileMode.None ? targetSize : destinationSize;
- }
-}
\ No newline at end of file
diff --git a/src/Skia/Avalonia.Skia/BitmapImpl.cs b/src/Skia/Avalonia.Skia/BitmapImpl.cs
index b458954029..c8ec186e98 100644
--- a/src/Skia/Avalonia.Skia/BitmapImpl.cs
+++ b/src/Skia/Avalonia.Skia/BitmapImpl.cs
@@ -72,10 +72,10 @@ namespace Avalonia.Skia
{
private readonly SKSurface _surface;
- public BitmapDrawingContext(SKBitmap bitmap, IVisualBrushRenderer visualBrushRenderer)
+ public BitmapDrawingContext(SKBitmap bitmap, IVisualBrushRenderer visualBrushRenderer)
: this(CreateSurface(bitmap), visualBrushRenderer)
{
-
+
}
private static SKSurface CreateSurface(SKBitmap bitmap)
diff --git a/src/Skia/Avalonia.Skia/DrawingContextImpl.cs b/src/Skia/Avalonia.Skia/DrawingContextImpl.cs
index 5d99cce128..cce85f805d 100644
--- a/src/Skia/Avalonia.Skia/DrawingContextImpl.cs
+++ b/src/Skia/Avalonia.Skia/DrawingContextImpl.cs
@@ -1,13 +1,11 @@
using Avalonia.Media;
-using Avalonia.Media.Imaging;
-using Avalonia.RenderHelpers;
using SkiaSharp;
using System;
using System.Collections.Generic;
using System.Linq;
using Avalonia.Platform;
-using Avalonia.Rendering.Utilities;
using Avalonia.Rendering;
+using Avalonia.Rendering.Utilities;
namespace Avalonia.Skia
{
diff --git a/src/Skia/Avalonia.Skia/FramebufferRenderTarget.cs b/src/Skia/Avalonia.Skia/FramebufferRenderTarget.cs
index 023eb47859..0eacdf41ac 100644
--- a/src/Skia/Avalonia.Skia/FramebufferRenderTarget.cs
+++ b/src/Skia/Avalonia.Skia/FramebufferRenderTarget.cs
@@ -70,9 +70,9 @@ namespace Avalonia.Skia
throw new Exception("Unable to create a surface for pixel format " + fb.Format +
" or pixel format translator");
var canvas = surface.Canvas;
-
-
-
+
+
+
canvas.RestoreToCount(0);
canvas.Save();
canvas.ResetMatrix();
diff --git a/src/Windows/Avalonia.Direct2D1/Avalonia.Direct2D1.csproj b/src/Windows/Avalonia.Direct2D1/Avalonia.Direct2D1.csproj
index 48ffb34a8f..87c6a56479 100644
--- a/src/Windows/Avalonia.Direct2D1/Avalonia.Direct2D1.csproj
+++ b/src/Windows/Avalonia.Direct2D1/Avalonia.Direct2D1.csproj
@@ -81,6 +81,7 @@
+
diff --git a/src/Windows/Avalonia.Direct2D1/Direct2D1Platform.cs b/src/Windows/Avalonia.Direct2D1/Direct2D1Platform.cs
index 1a5fed50c0..d8f93679ac 100644
--- a/src/Windows/Avalonia.Direct2D1/Direct2D1Platform.cs
+++ b/src/Windows/Avalonia.Direct2D1/Direct2D1Platform.cs
@@ -105,7 +105,6 @@ namespace Avalonia.Direct2D1
spans);
}
-
public IRenderTarget CreateRenderTarget(IEnumerable