diff --git a/src/Android/Avalonia.Android/Platform/SkiaPlatform/WindowImpl.cs b/src/Android/Avalonia.Android/Platform/SkiaPlatform/WindowImpl.cs index 7816a8af27..0ce7bdca22 100644 --- a/src/Android/Avalonia.Android/Platform/SkiaPlatform/WindowImpl.cs +++ b/src/Android/Avalonia.Android/Platform/SkiaPlatform/WindowImpl.cs @@ -96,6 +96,8 @@ namespace Avalonia.Android.Platform.SkiaPlatform IPlatformHandle ITopLevelImpl.Handle => this; + public IEnumerable Surfaces => new object[] { this }; + public void Activate() { } @@ -194,7 +196,5 @@ namespace Avalonia.Android.Platform.SkiaPlatform { // No window icons for mobile platforms } - - public IEnumerable Surfaces => new object[] {this}; - } + } } \ No newline at end of file diff --git a/src/Avalonia.Controls/Platform/Surfaces/ILockedFramebuffer.cs b/src/Avalonia.Controls/Platform/Surfaces/ILockedFramebuffer.cs index e771401dfe..d6402d170d 100644 --- a/src/Avalonia.Controls/Platform/Surfaces/ILockedFramebuffer.cs +++ b/src/Avalonia.Controls/Platform/Surfaces/ILockedFramebuffer.cs @@ -1,8 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Avalonia.Controls.Platform.Surfaces { @@ -12,22 +8,27 @@ namespace Avalonia.Controls.Platform.Surfaces /// Address of the first pixel /// IntPtr Address { get; } + /// /// Framebuffer width /// int Width { get; } + /// /// Framebuffer height /// int Height { get; } + /// /// Number of bytes per row /// int RowBytes { get; } + /// /// DPI of underling screen /// Size Dpi { get; } + /// /// Pixel format /// diff --git a/src/Avalonia.Visuals/Platform/IPlatformRenderInterface.cs b/src/Avalonia.Visuals/Platform/IPlatformRenderInterface.cs index 34600c145f..cdec0a07a1 100644 --- a/src/Avalonia.Visuals/Platform/IPlatformRenderInterface.cs +++ b/src/Avalonia.Visuals/Platform/IPlatformRenderInterface.cs @@ -41,7 +41,9 @@ namespace Avalonia.Platform /// /// Creates a renderer. /// - /// The list of native platform's surfaces that can be used for output. + /// + /// The list of native platform surfaces that can be used for output. + /// /// An . IRenderTarget CreateRenderTarget(IEnumerable surfaces); diff --git a/src/Gtk/Avalonia.Cairo/CairoPlatform.cs b/src/Gtk/Avalonia.Cairo/CairoPlatform.cs index 8b3c6899d3..e6c493320f 100644 --- a/src/Gtk/Avalonia.Cairo/CairoPlatform.cs +++ b/src/Gtk/Avalonia.Cairo/CairoPlatform.cs @@ -59,7 +59,7 @@ namespace Avalonia.Cairo return new RenderTarget(accessor); throw new NotSupportedException(string.Format( - "Don't know how to create a Cairo renderer from any of provided surfaces")); + "Don't know how to create a Cairo renderer from any of the provided surfaces.")); } public IRenderTargetBitmapImpl CreateRenderTargetBitmap(int width, int height) diff --git a/src/Gtk/Avalonia.Gtk/FramebufferManager.cs b/src/Gtk/Avalonia.Gtk/FramebufferManager.cs index 3da3c3d70c..72c977b2b4 100644 --- a/src/Gtk/Avalonia.Gtk/FramebufferManager.cs +++ b/src/Gtk/Avalonia.Gtk/FramebufferManager.cs @@ -1,8 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using Avalonia.Controls.Platform.Surfaces; namespace Avalonia.Gtk @@ -11,6 +7,7 @@ namespace Avalonia.Gtk { private readonly WindowImplBase _window; private PixbufFramebuffer _fb; + public FramebufferManager(WindowImplBase window) { _window = window; diff --git a/src/Gtk/Avalonia.Gtk/WindowImplBase.cs b/src/Gtk/Avalonia.Gtk/WindowImplBase.cs index bd48998dff..a8bd7836ec 100644 --- a/src/Gtk/Avalonia.Gtk/WindowImplBase.cs +++ b/src/Gtk/Avalonia.Gtk/WindowImplBase.cs @@ -3,15 +3,10 @@ using System; using System.Collections.Generic; -using System.Reactive.Disposables; -using System.Runtime.InteropServices; -using Gdk; -using Avalonia.Controls; -using Avalonia.Controls.Platform.Surfaces; +using Avalonia.Input; using Avalonia.Input.Raw; using Avalonia.Platform; -using Avalonia.Input; -using Avalonia.Threading; +using Gdk; using Action = System.Action; using WindowEdge = Avalonia.Controls.WindowEdge; @@ -23,8 +18,6 @@ namespace Avalonia.Gtk { private IInputRoot _inputRoot; protected Gtk.Widget _window; - public Gtk.Widget Widget => _window; - public Gdk.Drawable CurrentDrawable { get; private set; } private FramebufferManager _framebuffer; private Gtk.IMContext _imContext; @@ -60,6 +53,8 @@ namespace Avalonia.Gtk } public IPlatformHandle Handle { get; private set; } + public Gtk.Widget Widget => _window; + public Gdk.Drawable CurrentDrawable { get; private set; } void OnRealized (object sender, EventArgs eventArgs) { diff --git a/src/Skia/Avalonia.Skia/PlatformRenderInterface.cs b/src/Skia/Avalonia.Skia/PlatformRenderInterface.cs index 56b334073b..4cfe1e3e40 100644 --- a/src/Skia/Avalonia.Skia/PlatformRenderInterface.cs +++ b/src/Skia/Avalonia.Skia/PlatformRenderInterface.cs @@ -55,8 +55,6 @@ namespace Avalonia.Skia return new Renderer(root, renderLoop); } - - public IRenderTargetBitmapImpl CreateRenderTargetBitmap(int width, int height) { if (width < 1) diff --git a/src/Windows/Avalonia.Win32/WindowFramebuffer.cs b/src/Windows/Avalonia.Win32/WindowFramebuffer.cs index cd89c01131..f7ea79e78a 100644 --- a/src/Windows/Avalonia.Win32/WindowFramebuffer.cs +++ b/src/Windows/Avalonia.Win32/WindowFramebuffer.cs @@ -18,8 +18,7 @@ namespace Avalonia.Win32 { private readonly IntPtr _handle; private IntPtr _pBitmap; - UnmanagedMethods.BITMAPINFOHEADER _bmpInfo; - + private UnmanagedMethods.BITMAPINFOHEADER _bmpInfo; public WindowFramebuffer(IntPtr handle, int width, int height) { @@ -38,7 +37,38 @@ namespace Avalonia.Win32 _pBitmap = Marshal.AllocHGlobal(width * height * 4); } + ~WindowFramebuffer() + { + Deallocate(); + } + + public IntPtr Address => _pBitmap; + public int RowBytes => Width * 4; + public PixelFormat Format => PixelFormat.Bgra8888; + + public Size Dpi + { + get + { + if (UnmanagedMethods.ShCoreAvailable) + { + uint dpix, dpiy; + + var monitor = UnmanagedMethods.MonitorFromWindow(_handle, + UnmanagedMethods.MONITOR.MONITOR_DEFAULTTONEAREST); + if (UnmanagedMethods.GetDpiForMonitor( + monitor, + UnmanagedMethods.MONITOR_DPI_TYPE.MDT_EFFECTIVE_DPI, + out dpix, + out dpiy) == 0) + { + return new Size(dpix, dpiy); + } + } + return new Size(96, 96); + } + } public int Width => _bmpInfo.biWidth; @@ -73,11 +103,9 @@ namespace Avalonia.Win32 return true; } - - public void Dispose() { - //It's not an *actual* dispose. This call meand "We are done drawing" + //It's not an *actual* dispose. This call means "We are done drawing" DrawToWindow(_handle); } @@ -89,38 +117,5 @@ namespace Avalonia.Win32 _pBitmap = IntPtr.Zero; } } - - ~WindowFramebuffer() - { - Deallocate(); - } - - public IntPtr Address => _pBitmap; - public int RowBytes => Width * 4; - public PixelFormat Format => PixelFormat.Bgra8888; - - public Size Dpi - { - get - { - if (UnmanagedMethods.ShCoreAvailable) - { - uint dpix, dpiy; - - var monitor = UnmanagedMethods.MonitorFromWindow(_handle, - UnmanagedMethods.MONITOR.MONITOR_DEFAULTTONEAREST); - - if (UnmanagedMethods.GetDpiForMonitor( - monitor, - UnmanagedMethods.MONITOR_DPI_TYPE.MDT_EFFECTIVE_DPI, - out dpix, - out dpiy) == 0) - { - return new Size(dpix, dpiy); - } - } - return new Size(96, 96); - } - } } } \ No newline at end of file diff --git a/src/Windows/Avalonia.Win32/WindowImpl.cs b/src/Windows/Avalonia.Win32/WindowImpl.cs index 19a7ca5e58..90bc684292 100644 --- a/src/Windows/Avalonia.Win32/WindowImpl.cs +++ b/src/Windows/Avalonia.Win32/WindowImpl.cs @@ -38,6 +38,7 @@ namespace Avalonia.Win32 private double _scaling = 1; private WindowState _showWindowState; private FramebufferManager _framebuffer; + public WindowImpl() { CreateWindow(); @@ -164,6 +165,11 @@ namespace Avalonia.Win32 } } + public IEnumerable Surfaces => new object[] + { + Handle, _framebuffer + }; + public void Activate() { UnmanagedMethods.SetActiveWindow(_hwnd); @@ -764,10 +770,5 @@ namespace Avalonia.Win32 ShowWindow(WindowState.Maximized); } } - - public IEnumerable Surfaces => new object[] - { - Handle, _framebuffer - }; } } diff --git a/src/iOS/Avalonia.iOS/AvaloniaView.cs b/src/iOS/Avalonia.iOS/AvaloniaView.cs index e9d095483b..1ef034b87c 100644 --- a/src/iOS/Avalonia.iOS/AvaloniaView.cs +++ b/src/iOS/Avalonia.iOS/AvaloniaView.cs @@ -149,6 +149,9 @@ namespace Avalonia.iOS } public Size MaxClientSize => Bounds.Size.ToAvalonia(); + + public IEnumerable Surfaces => new object[] { this }; + public void SetTitle(string title) { //Not supported @@ -232,8 +235,6 @@ namespace Avalonia.iOS public void SetIcon(IWindowIconImpl icon) { } - - public IEnumerable Surfaces => new object[]{this}; } class AvaloniaViewController : UIViewController