diff --git a/src/Avalonia.Controls/Avalonia.Controls.csproj b/src/Avalonia.Controls/Avalonia.Controls.csproj
index 0fe068dab5..5fc7329f97 100644
--- a/src/Avalonia.Controls/Avalonia.Controls.csproj
+++ b/src/Avalonia.Controls/Avalonia.Controls.csproj
@@ -59,7 +59,6 @@
-
diff --git a/src/Avalonia.Controls/Platform/ITopLevelImpl.cs b/src/Avalonia.Controls/Platform/ITopLevelImpl.cs
index e11f1a3d79..77884acf73 100644
--- a/src/Avalonia.Controls/Platform/ITopLevelImpl.cs
+++ b/src/Avalonia.Controls/Platform/ITopLevelImpl.cs
@@ -39,8 +39,15 @@ namespace Avalonia.Platform
IPlatformHandle Handle { get; }
///
- /// Supported methods of image output
- ///
+ /// The list of native platform's surfaces that can be consumed by rendering subsystems.
+ ///
+ ///
+ /// Rendering platform will check that list and see if it can utilize one of them to output.
+ /// It should be enough to expose a native window handle via IPlatformHandle
+ /// and add support for framebuffer (even if it's emulated one) via IFramebufferPlatformSurface.
+ /// If you have some rendering platform that's tied to your particular windowing platform,
+ /// just expose some toolkit-specific object (e. g. Func<Gdk.Drawable> in case of GTK#+Cairo)
+ ///
IEnumerable Surfaces { get; }
///
diff --git a/src/Avalonia.Controls/Platform/Surfaces/IFramebufferPlatformSurface.cs b/src/Avalonia.Controls/Platform/Surfaces/IFramebufferPlatformSurface.cs
index 6959947415..84988e912f 100644
--- a/src/Avalonia.Controls/Platform/Surfaces/IFramebufferPlatformSurface.cs
+++ b/src/Avalonia.Controls/Platform/Surfaces/IFramebufferPlatformSurface.cs
@@ -8,6 +8,12 @@ namespace Avalonia.Controls.Platform.Surfaces
{
public interface IFramebufferPlatformSurface
{
+ ///
+ /// Provides a framebuffer descriptor for drawing.
+ ///
+ ///
+ /// Contents should be drawn on actual window after disposing
+ ///
ILockedFramebuffer Lock();
}
}
diff --git a/src/Avalonia.Controls/Platform/Surfaces/ILockedFramebuffer.cs b/src/Avalonia.Controls/Platform/Surfaces/ILockedFramebuffer.cs
index 1810479a70..e771401dfe 100644
--- a/src/Avalonia.Controls/Platform/Surfaces/ILockedFramebuffer.cs
+++ b/src/Avalonia.Controls/Platform/Surfaces/ILockedFramebuffer.cs
@@ -8,11 +8,29 @@ namespace Avalonia.Controls.Platform.Surfaces
{
public interface ILockedFramebuffer : IDisposable
{
+ ///
+ /// 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
+ ///
PixelFormat Format { get; }
}
}
diff --git a/src/Avalonia.Controls/Platform/Surfaces/INativeWindowPlatformSurface.cs b/src/Avalonia.Controls/Platform/Surfaces/INativeWindowPlatformSurface.cs
deleted file mode 100644
index 33aa969c72..0000000000
--- a/src/Avalonia.Controls/Platform/Surfaces/INativeWindowPlatformSurface.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace Avalonia.Controls.Platform.Surfaces
-{
- public interface INativeWindowPlatformSurface
- {
- IntPtr Handle { get; }
- }
-
- public class NativeWindowPlatformSurface : INativeWindowPlatformSurface
- {
- public NativeWindowPlatformSurface(IntPtr handle)
- {
- Handle = handle;
- }
-
- public IntPtr Handle { get; }
- }
-}
diff --git a/src/Avalonia.Visuals/Platform/IPlatformRenderInterface.cs b/src/Avalonia.Visuals/Platform/IPlatformRenderInterface.cs
index ba48a72512..34600c145f 100644
--- a/src/Avalonia.Visuals/Platform/IPlatformRenderInterface.cs
+++ b/src/Avalonia.Visuals/Platform/IPlatformRenderInterface.cs
@@ -41,7 +41,7 @@ namespace Avalonia.Platform
///
/// Creates a renderer.
///
- /// The list of surfaces that can be used for output.
+ /// The list of native platform's surfaces that can be used for output.
/// An .
IRenderTarget CreateRenderTarget(IEnumerable surfaces);
diff --git a/src/Gtk/Avalonia.Gtk/WindowImplBase.cs b/src/Gtk/Avalonia.Gtk/WindowImplBase.cs
index ba9b984c56..bd48998dff 100644
--- a/src/Gtk/Avalonia.Gtk/WindowImplBase.cs
+++ b/src/Gtk/Avalonia.Gtk/WindowImplBase.cs
@@ -322,24 +322,9 @@ namespace Avalonia.Gtk
_window = null;
}
-
- //We need that for DrawingArea which does not have an HWND until parent window is realized
- //and could also *change* it's HWND
- class DynamicNativeWindowSurface : INativeWindowPlatformSurface
- {
- private readonly IPlatformHandle _handle;
-
- public DynamicNativeWindowSurface(IPlatformHandle handle)
- {
- _handle = handle;
- }
-
- public IntPtr Handle => _handle.Handle;
- }
-
public IEnumerable Surfaces => new object[]
{
- new DynamicNativeWindowSurface(Handle),
+ Handle,
new Func(() => CurrentDrawable),
_framebuffer
};
diff --git a/src/Skia/Avalonia.Skia.Android/AndroidPlatformRenderInterface.cs b/src/Skia/Avalonia.Skia.Android/AndroidPlatformRenderInterface.cs
index 610d6f5703..3355839314 100644
--- a/src/Skia/Avalonia.Skia.Android/AndroidPlatformRenderInterface.cs
+++ b/src/Skia/Avalonia.Skia.Android/AndroidPlatformRenderInterface.cs
@@ -19,7 +19,7 @@ namespace Avalonia.Skia
{
var surfaceView = surfaces?.OfType().FirstOrDefault();
if (surfaceView == null)
- throw new ArgumentException("Avalonia.Skia.Android is only capable to draw on SurfaceView");
+ throw new ArgumentException("Avalonia.Skia.Android is only capable of drawing on SurfaceView");
return new WindowRenderTarget(surfaceView);
}
}
diff --git a/src/Windows/Avalonia.Direct2D1/Direct2D1Platform.cs b/src/Windows/Avalonia.Direct2D1/Direct2D1Platform.cs
index 4ef267e0de..34595fecc8 100644
--- a/src/Windows/Avalonia.Direct2D1/Direct2D1Platform.cs
+++ b/src/Windows/Avalonia.Direct2D1/Direct2D1Platform.cs
@@ -104,10 +104,11 @@ namespace Avalonia.Direct2D1
public IRenderTarget CreateRenderTarget(IEnumerable surfaces)
{
- var nativeWindow = surfaces?.OfType().FirstOrDefault();
-
+ var nativeWindow = surfaces?.OfType().FirstOrDefault();
if (nativeWindow != null)
{
+ if(nativeWindow.HandleDescriptor != "HWND")
+ throw new NotSupportedException("Don't know how to create a Direct2D1 renderer from " + nativeWindow.HandleDescriptor);
return new HwndRenderTarget(nativeWindow);
}
throw new NotSupportedException("Don't know how to create a Direct2D1 renderer from any of provided surfaces");
diff --git a/src/Windows/Avalonia.Direct2D1/HwndRenderTarget.cs b/src/Windows/Avalonia.Direct2D1/HwndRenderTarget.cs
index 317e7fc34f..49402d54b9 100644
--- a/src/Windows/Avalonia.Direct2D1/HwndRenderTarget.cs
+++ b/src/Windows/Avalonia.Direct2D1/HwndRenderTarget.cs
@@ -4,6 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Avalonia.Controls.Platform.Surfaces;
+using Avalonia.Platform;
using Avalonia.Win32.Interop;
using SharpDX;
using SharpDX.DXGI;
@@ -12,9 +13,9 @@ namespace Avalonia.Direct2D1
{
class HwndRenderTarget : SwapChainRenderTarget
{
- private readonly INativeWindowPlatformSurface _window;
+ private readonly IPlatformHandle _window;
- public HwndRenderTarget(INativeWindowPlatformSurface window)
+ public HwndRenderTarget(IPlatformHandle window)
{
_window = window;
}
diff --git a/src/Windows/Avalonia.Win32/WindowImpl.cs b/src/Windows/Avalonia.Win32/WindowImpl.cs
index 878be61664..19a7ca5e58 100644
--- a/src/Windows/Avalonia.Win32/WindowImpl.cs
+++ b/src/Windows/Avalonia.Win32/WindowImpl.cs
@@ -767,7 +767,7 @@ namespace Avalonia.Win32
public IEnumerable Surfaces => new object[]
{
- new NativeWindowPlatformSurface(_hwnd), _framebuffer
+ Handle, _framebuffer
};
}
}