1
0
Steven Kirk 8 жил өмнө
parent
commit
8f3e56963a

+ 3 - 3
src/Android/Avalonia.Android/Platform/SkiaPlatform/WindowImpl.cs

@@ -96,6 +96,8 @@ namespace Avalonia.Android.Platform.SkiaPlatform
 
         IPlatformHandle ITopLevelImpl.Handle => this;
 
+        public IEnumerable<object> Surfaces => new object[] { this };
+
         public void Activate()
         {
         }
@@ -194,7 +196,5 @@ namespace Avalonia.Android.Platform.SkiaPlatform
         {
             // No window icons for mobile platforms
         }
-
-        public IEnumerable<object> Surfaces => new object[] {this};
-    }
+            }
 }

+ 5 - 4
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
         /// </summary>
         IntPtr Address { get; }
+
         /// <summary>
         /// Framebuffer width
         /// </summary>
         int Width { get; }
+        
         /// <summary>
         /// Framebuffer height
         /// </summary>
         int Height { get; }
+        
         /// <summary>
         /// Number of bytes per row
         /// </summary>
         int RowBytes { get; }
+        
         /// <summary>
         /// DPI of underling screen
         /// </summary>
         Size Dpi { get; }
+        
         /// <summary>
         /// Pixel format
         /// </summary>

+ 3 - 1
src/Avalonia.Visuals/Platform/IPlatformRenderInterface.cs

@@ -41,7 +41,9 @@ namespace Avalonia.Platform
         /// <summary>
         /// Creates a renderer.
         /// </summary>
-        /// <param name="surfaces">The list of native platform's surfaces that can be used for output.</param>
+        /// <param name="surfaces">
+        /// The list of native platform surfaces that can be used for output.
+        /// </param>
         /// <returns>An <see cref="IRenderTarget"/>.</returns>
         IRenderTarget CreateRenderTarget(IEnumerable<object> surfaces);
 

+ 1 - 1
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)

+ 1 - 4
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;

+ 4 - 9
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)
         {

+ 0 - 2
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)

+ 33 - 38
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);
-            }
-        }
     }
 }

+ 6 - 5
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<object> Surfaces => new object[]
+        {
+            Handle, _framebuffer
+        };
+
         public void Activate()
         {
             UnmanagedMethods.SetActiveWindow(_hwnd);
@@ -764,10 +770,5 @@ namespace Avalonia.Win32
                 ShowWindow(WindowState.Maximized);
             }
         }
-
-        public IEnumerable<object> Surfaces => new object[]
-        {
-            Handle, _framebuffer 
-        };
     }
 }

+ 3 - 2
src/iOS/Avalonia.iOS/AvaloniaView.cs

@@ -149,6 +149,9 @@ namespace Avalonia.iOS
         }
 
         public Size MaxClientSize => Bounds.Size.ToAvalonia();
+
+        public IEnumerable<object> 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<object> Surfaces => new object[]{this};
     }
 
     class AvaloniaViewController : UIViewController