committed by
GitHub
161 changed files with 2520 additions and 821 deletions
|
After Width: | Height: | Size: 14 KiB |
@ -1,5 +1,5 @@ |
|||
<Project> |
|||
<ItemGroup> |
|||
<PackageReference Include="SourceLink.Create.CommandLine" Version="2.8.0" PrivateAssets="All" /> |
|||
<PackageReference Include="SourceLink.Create.CommandLine" Version="2.8.3" PrivateAssets="All" /> |
|||
</ItemGroup> |
|||
</Project> |
|||
</Project> |
|||
|
|||
Binary file not shown.
@ -1,13 +1,14 @@ |
|||
using System; |
|||
using Avalonia; |
|||
using Avalonia; |
|||
|
|||
namespace Previewer |
|||
{ |
|||
class Program |
|||
{ |
|||
static void Main(string[] args) |
|||
{ |
|||
AppBuilder.Configure<App>().UsePlatformDetect().Start<MainWindow>(); |
|||
} |
|||
public static AppBuilder BuildAvaloniaApp() |
|||
=> AppBuilder.Configure<App>() |
|||
.UsePlatformDetect(); |
|||
|
|||
public static int Main(string[] args) |
|||
=> BuildAvaloniaApp().StartWithClassicDesktopLifetime(args); |
|||
} |
|||
} |
|||
} |
|||
|
|||
@ -1,19 +1,17 @@ |
|||
using System; |
|||
using Avalonia; |
|||
using Avalonia.Controls; |
|||
using Avalonia; |
|||
using Avalonia.ReactiveUI; |
|||
|
|||
namespace VirtualizationDemo |
|||
{ |
|||
class Program |
|||
{ |
|||
static void Main(string[] args) |
|||
{ |
|||
AppBuilder.Configure<App>() |
|||
.UsePlatformDetect() |
|||
.UseReactiveUI() |
|||
.LogToDebug() |
|||
.Start<MainWindow>(); |
|||
} |
|||
public static AppBuilder BuildAvaloniaApp() |
|||
=> AppBuilder.Configure<App>() |
|||
.UsePlatformDetect() |
|||
.UseReactiveUI() |
|||
.LogToTrace(); |
|||
|
|||
public static int Main(string[] args) |
|||
=> BuildAvaloniaApp().StartWithClassicDesktopLifetime(args); |
|||
} |
|||
} |
|||
|
|||
@ -1,19 +1,16 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using Avalonia; |
|||
using Avalonia; |
|||
|
|||
namespace Direct3DInteropSample |
|||
{ |
|||
class Program |
|||
{ |
|||
static void Main(string[] args) |
|||
{ |
|||
AppBuilder.Configure<App>() |
|||
.With(new Win32PlatformOptions {UseDeferredRendering = false}) |
|||
.UseWin32().UseDirect2D1().Start<MainWindow>(); |
|||
} |
|||
public static AppBuilder BuildAvaloniaApp() |
|||
=> AppBuilder.Configure<App>() |
|||
.With(new Win32PlatformOptions { UseDeferredRendering = false }) |
|||
.UseWin32() |
|||
.UseDirect2D1(); |
|||
|
|||
public static int Main(string[] args) |
|||
=> BuildAvaloniaApp().StartWithClassicDesktopLifetime(args); |
|||
} |
|||
} |
|||
|
|||
@ -1,3 +1,4 @@ |
|||
Compat issues with assembly Avalonia.Base: |
|||
CannotAddAbstractMembers : Member 'protected System.IObservable<Avalonia.AvaloniaPropertyChangedEventArgs> Avalonia.AvaloniaProperty.GetChanged()' is abstract in the implementation but is missing in the contract. |
|||
Total Issues: 1 |
|||
TypesMustExist : Type 'Avalonia.Logging.DebugLogSink' does not exist in the implementation but it does exist in the contract. |
|||
Total Issues: 2 |
|||
|
|||
@ -0,0 +1,39 @@ |
|||
using System; |
|||
|
|||
namespace Avalonia.Metadata |
|||
{ |
|||
/// <summary>
|
|||
/// Use to predefine the prefix associated to an xml namespace in a xaml file
|
|||
/// </summary>
|
|||
/// <remarks>
|
|||
/// example:
|
|||
/// [assembly: XmlnsPrefix("https://github.com/avaloniaui", "av")]
|
|||
/// xaml:
|
|||
/// xmlns:av="https://github.com/avaloniaui"
|
|||
/// </remarks>
|
|||
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] |
|||
public sealed class XmlnsPrefixAttribute : Attribute |
|||
{ |
|||
/// <summary>
|
|||
/// Constructor
|
|||
/// </summary>
|
|||
/// <param name="xmlNamespace">XML namespce</param>
|
|||
/// <param name="prefix">recommended prefix</param>
|
|||
public XmlnsPrefixAttribute(string xmlNamespace, string prefix) |
|||
{ |
|||
XmlNamespace = xmlNamespace ?? throw new ArgumentNullException(nameof(xmlNamespace)); |
|||
|
|||
Prefix = prefix ?? throw new ArgumentNullException(nameof(prefix)); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// XML Namespace
|
|||
/// </summary>
|
|||
public string XmlNamespace { get; } |
|||
|
|||
/// <summary>
|
|||
/// New Xml Namespace
|
|||
/// </summary>
|
|||
public string Prefix { get; } |
|||
} |
|||
} |
|||
@ -0,0 +1 @@ |
|||
Total Issues: 0 |
|||
@ -1,7 +1,7 @@ |
|||
using System.Runtime.CompilerServices; |
|||
using Avalonia.Metadata; |
|||
|
|||
[assembly: InternalsVisibleTo("Avalonia.Layout.UnitTests")] |
|||
[assembly: InternalsVisibleTo("Avalonia.Layout.UnitTests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c1bba1142285fe0419326fb25866ba62c47e6c2b5c1ab0c95b46413fad375471232cb81706932e1cef38781b9ebd39d5100401bacb651c6c5bbf59e571e81b3bc08d2a622004e08b1a6ece82a7e0b9857525c86d2b95fab4bc3dce148558d7f3ae61aa3a234086902aeface87d9dfdd32b9d2fe3c6dd4055b5ab4b104998bd87")] |
|||
|
|||
[assembly: XmlnsDefinition("https://github.com/avaloniaui", "Avalonia.Layout")] |
|||
|
|||
|
|||
@ -1,11 +1,19 @@ |
|||
using Avalonia.Platform; |
|||
|
|||
namespace Avalonia.Media |
|||
namespace Avalonia.Media |
|||
{ |
|||
/// <summary>
|
|||
/// Abstract class that describes a 2-D drawing.
|
|||
/// </summary>
|
|||
public abstract class Drawing : AvaloniaObject |
|||
{ |
|||
/// <summary>
|
|||
/// Draws this drawing to the given <see cref="DrawingContext"/>.
|
|||
/// </summary>
|
|||
/// <param name="context">The drawing context.</param>
|
|||
public abstract void Draw(DrawingContext context); |
|||
|
|||
/// <summary>
|
|||
/// Gets the drawing's bounding rectangle.
|
|||
/// </summary>
|
|||
public abstract Rect GetBounds(); |
|||
} |
|||
} |
|||
|
|||
@ -1,4 +1,4 @@ |
|||
using System.Runtime.CompilerServices; |
|||
|
|||
[assembly: InternalsVisibleTo("Avalonia.Skia.RenderTests")] |
|||
[assembly: InternalsVisibleTo("Avalonia.Skia.UnitTests")] |
|||
[assembly: InternalsVisibleTo("Avalonia.Skia.RenderTests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c1bba1142285fe0419326fb25866ba62c47e6c2b5c1ab0c95b46413fad375471232cb81706932e1cef38781b9ebd39d5100401bacb651c6c5bbf59e571e81b3bc08d2a622004e08b1a6ece82a7e0b9857525c86d2b95fab4bc3dce148558d7f3ae61aa3a234086902aeface87d9dfdd32b9d2fe3c6dd4055b5ab4b104998bd87")] |
|||
[assembly: InternalsVisibleTo("Avalonia.Skia.UnitTests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c1bba1142285fe0419326fb25866ba62c47e6c2b5c1ab0c95b46413fad375471232cb81706932e1cef38781b9ebd39d5100401bacb651c6c5bbf59e571e81b3bc08d2a622004e08b1a6ece82a7e0b9857525c86d2b95fab4bc3dce148558d7f3ae61aa3a234086902aeface87d9dfdd32b9d2fe3c6dd4055b5ab4b104998bd87")] |
|||
|
|||
@ -0,0 +1,18 @@ |
|||
namespace Avalonia.Win32 |
|||
{ |
|||
internal class CompositionBlurHost : IBlurHost |
|||
{ |
|||
Windows.UI.Composition.Visual _blurVisual; |
|||
|
|||
public CompositionBlurHost(Windows.UI.Composition.Visual blurVisual) |
|||
{ |
|||
_blurVisual = blurVisual; |
|||
} |
|||
|
|||
public void SetBlur(bool enabled) |
|||
{ |
|||
_blurVisual.IsVisible = enabled; |
|||
} |
|||
} |
|||
} |
|||
|
|||
@ -0,0 +1,143 @@ |
|||
using System; |
|||
using System.Runtime.InteropServices; |
|||
using Avalonia.OpenGL; |
|||
using Avalonia.OpenGL.Angle; |
|||
using Avalonia.OpenGL.Egl; |
|||
using Windows.UI.Composition; |
|||
using Windows.UI.Composition.Interop; |
|||
using WinRT; |
|||
|
|||
namespace Avalonia.Win32 |
|||
{ |
|||
internal class CompositionConnector |
|||
{ |
|||
private Compositor _compositor; |
|||
private Windows.System.DispatcherQueueController _dispatcherQueueController; |
|||
private CompositionGraphicsDevice _graphicsDevice; |
|||
|
|||
internal enum DISPATCHERQUEUE_THREAD_APARTMENTTYPE |
|||
{ |
|||
DQTAT_COM_NONE = 0, |
|||
DQTAT_COM_ASTA = 1, |
|||
DQTAT_COM_STA = 2 |
|||
}; |
|||
|
|||
internal enum DISPATCHERQUEUE_THREAD_TYPE |
|||
{ |
|||
DQTYPE_THREAD_DEDICATED = 1, |
|||
DQTYPE_THREAD_CURRENT = 2, |
|||
}; |
|||
|
|||
[StructLayout(LayoutKind.Sequential)] |
|||
internal struct DispatcherQueueOptions |
|||
{ |
|||
public int dwSize; |
|||
|
|||
[MarshalAs(UnmanagedType.I4)] |
|||
public DISPATCHERQUEUE_THREAD_TYPE threadType; |
|||
|
|||
[MarshalAs(UnmanagedType.I4)] |
|||
public DISPATCHERQUEUE_THREAD_APARTMENTTYPE apartmentType; |
|||
}; |
|||
|
|||
[DllImport("coremessaging.dll", EntryPoint = "CreateDispatcherQueueController", CharSet = CharSet.Unicode)] |
|||
internal static extern IntPtr CreateDispatcherQueueController(DispatcherQueueOptions options, out IntPtr dispatcherQueueController); |
|||
|
|||
public CompositionConnector(EglPlatformOpenGlInterface egl) |
|||
{ |
|||
EnsureDispatcherQueue(); |
|||
|
|||
if (_dispatcherQueueController != null) |
|||
_compositor = new Compositor(); |
|||
|
|||
var interop = _compositor.As<ICompositorInterop>(); |
|||
|
|||
var display = egl.Display as AngleWin32EglDisplay; |
|||
|
|||
_graphicsDevice = interop.CreateGraphicsDevice(display.GetDirect3DDevice()); |
|||
} |
|||
|
|||
public ICompositionDrawingSurfaceInterop InitialiseWindowCompositionTree(IntPtr hwnd, out Windows.UI.Composition.Visual surfaceVisual, out IBlurHost blurHost) |
|||
{ |
|||
var target = CreateDesktopWindowTarget(hwnd); |
|||
|
|||
var surface = _graphicsDevice.CreateDrawingSurface(new Windows.Foundation.Size(0, 0), |
|||
Windows.Graphics.DirectX.DirectXPixelFormat.B8G8R8A8UIntNormalized, |
|||
Windows.Graphics.DirectX.DirectXAlphaMode.Premultiplied); |
|||
|
|||
var surfaceInterop = surface.As<ICompositionDrawingSurfaceInterop>(); |
|||
|
|||
var brush = _compositor.CreateSurfaceBrush(surface); |
|||
var visual = _compositor.CreateSpriteVisual(); |
|||
|
|||
visual.Brush = brush; |
|||
visual.RelativeSizeAdjustment = new System.Numerics.Vector2(1, 1); |
|||
|
|||
var container = _compositor.CreateContainerVisual(); |
|||
|
|||
target.Root = container; |
|||
|
|||
var blur = CreateBlur(); |
|||
|
|||
blurHost = new CompositionBlurHost(blur); |
|||
|
|||
container.Children.InsertAtTop(blur); |
|||
|
|||
container.Children.InsertAtTop(visual); |
|||
|
|||
visual.CompositeMode = CompositionCompositeMode.SourceOver; |
|||
|
|||
surfaceVisual = container; |
|||
|
|||
return surfaceInterop; |
|||
} |
|||
|
|||
private SpriteVisual CreateBlur() |
|||
{ |
|||
var blurEffect = new GaussianBlurEffect(new CompositionEffectSourceParameter("backdrop")); |
|||
var blurEffectFactory = _compositor.CreateEffectFactory(blurEffect); |
|||
|
|||
var blurBrush = blurEffectFactory.CreateBrush(); |
|||
var backDropBrush = _compositor.CreateBackdropBrush(); |
|||
|
|||
blurBrush.SetSourceParameter("backdrop", backDropBrush); |
|||
|
|||
var saturateEffect = new SaturationEffect(blurEffect); |
|||
var satEffectFactory = _compositor.CreateEffectFactory(saturateEffect); |
|||
|
|||
var satBrush = satEffectFactory.CreateBrush(); |
|||
satBrush.SetSourceParameter("backdrop", backDropBrush); |
|||
|
|||
var visual = _compositor.CreateSpriteVisual(); |
|||
visual.IsVisible = false; |
|||
|
|||
visual.RelativeSizeAdjustment = new System.Numerics.Vector2(1.0f, 1.0f); |
|||
visual.Brush = satBrush; |
|||
|
|||
return visual; |
|||
} |
|||
|
|||
private CompositionTarget CreateDesktopWindowTarget(IntPtr window) |
|||
{ |
|||
var interop = _compositor.As<global::Windows.UI.Composition.Desktop.ICompositorDesktopInterop>(); |
|||
|
|||
interop.CreateDesktopWindowTarget(window, false, out var windowTarget); |
|||
return Windows.UI.Composition.Desktop.DesktopWindowTarget.FromAbi(windowTarget); |
|||
} |
|||
|
|||
private void EnsureDispatcherQueue() |
|||
{ |
|||
if (_dispatcherQueueController == null) |
|||
{ |
|||
DispatcherQueueOptions options = new DispatcherQueueOptions(); |
|||
options.apartmentType = DISPATCHERQUEUE_THREAD_APARTMENTTYPE.DQTAT_COM_NONE; |
|||
options.threadType = DISPATCHERQUEUE_THREAD_TYPE.DQTYPE_THREAD_CURRENT; |
|||
options.dwSize = Marshal.SizeOf(typeof(DispatcherQueueOptions)); |
|||
|
|||
CreateDispatcherQueueController(options, out var queue); |
|||
_dispatcherQueueController = Windows.System.DispatcherQueueController.FromAbi(queue); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
@ -0,0 +1,96 @@ |
|||
using System; |
|||
using System.Runtime.InteropServices; |
|||
using Avalonia.OpenGL; |
|||
using Avalonia.OpenGL.Angle; |
|||
using Avalonia.OpenGL.Egl; |
|||
using Avalonia.OpenGL.Surfaces; |
|||
using Windows.UI.Composition.Interop; |
|||
|
|||
namespace Avalonia.Win32 |
|||
{ |
|||
internal class CompositionEglGlPlatformSurface : EglGlPlatformSurfaceBase |
|||
{ |
|||
private EglPlatformOpenGlInterface _egl; |
|||
private readonly IEglWindowGlPlatformSurfaceInfo _info; |
|||
private ICompositionDrawingSurfaceInterop _surfaceInterop; |
|||
private Windows.UI.Composition.Visual _surface; |
|||
|
|||
public CompositionEglGlPlatformSurface(EglPlatformOpenGlInterface egl, IEglWindowGlPlatformSurfaceInfo info) : base() |
|||
{ |
|||
_egl = egl; |
|||
_info = info; |
|||
} |
|||
|
|||
public IBlurHost AttachToCompositionTree(CompositionConnector connector, IntPtr hwnd) |
|||
{ |
|||
using (_egl.PrimaryContext.MakeCurrent()) |
|||
{ |
|||
_surfaceInterop = connector.InitialiseWindowCompositionTree(hwnd, out _surface, out var blurHost); |
|||
return blurHost; |
|||
} |
|||
} |
|||
|
|||
public override IGlPlatformSurfaceRenderTarget CreateGlRenderTarget() |
|||
{ |
|||
return new CompositionRenderTarget(_egl, _surface, _surfaceInterop, _info); |
|||
} |
|||
|
|||
class CompositionRenderTarget : EglPlatformSurfaceRenderTargetBase |
|||
{ |
|||
private readonly EglPlatformOpenGlInterface _egl; |
|||
private readonly IEglWindowGlPlatformSurfaceInfo _info; |
|||
private PixelSize _currentSize; |
|||
private readonly ICompositionDrawingSurfaceInterop _surfaceInterop; |
|||
private static Guid s_Iid = Guid.Parse("6f15aaf2-d208-4e89-9ab4-489535d34f9c"); |
|||
private Windows.UI.Composition.Visual _compositionVisual; |
|||
|
|||
public CompositionRenderTarget(EglPlatformOpenGlInterface egl, |
|||
Windows.UI.Composition.Visual compositionVisual, |
|||
ICompositionDrawingSurfaceInterop interopSurface, |
|||
IEglWindowGlPlatformSurfaceInfo info) |
|||
: base(egl) |
|||
{ |
|||
_egl = egl; |
|||
_surfaceInterop = interopSurface; |
|||
_info = info; |
|||
_currentSize = info.Size; |
|||
_compositionVisual = compositionVisual; |
|||
|
|||
using (_egl.PrimaryContext.MakeCurrent()) |
|||
{ |
|||
_surfaceInterop.Resize(new POINT { X = _info.Size.Width, Y = _info.Size.Height }); |
|||
} |
|||
|
|||
_compositionVisual.Size = new System.Numerics.Vector2(_info.Size.Width, _info.Size.Height); |
|||
} |
|||
|
|||
public override IGlPlatformSurfaceRenderingSession BeginDraw() |
|||
{ |
|||
IntPtr texture; |
|||
EglSurface surface; |
|||
|
|||
using (_egl.PrimaryEglContext.EnsureCurrent()) |
|||
{ |
|||
if (_info.Size != _currentSize) |
|||
{ |
|||
_surfaceInterop.Resize(new POINT { X = _info.Size.Width, Y = _info.Size.Height }); |
|||
_compositionVisual.Size = new System.Numerics.Vector2(_info.Size.Width, _info.Size.Height); |
|||
_currentSize = _info.Size; |
|||
} |
|||
|
|||
var offset = new POINT(); |
|||
|
|||
_surfaceInterop.BeginDraw( |
|||
IntPtr.Zero, |
|||
ref s_Iid, |
|||
out texture, ref offset); |
|||
|
|||
surface = (_egl.Display as AngleWin32EglDisplay).WrapDirect3D11Texture(_egl, texture, offset.X, offset.Y, _info.Size.Width, _info.Size.Height); |
|||
} |
|||
|
|||
return base.BeginDraw(surface, _info, () => { _surfaceInterop.EndDraw(); Marshal.Release(texture); surface.Dispose(); }, true); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue