|
|
|
@ -1,6 +1,7 @@ |
|
|
|
using Avalonia.OpenGL; |
|
|
|
using Avalonia.OpenGL.Angle; |
|
|
|
using Avalonia.OpenGL.Egl; |
|
|
|
using Avalonia.Platform; |
|
|
|
using Avalonia.Win32.OpenGl; |
|
|
|
using Avalonia.Win32.WinRT.Composition; |
|
|
|
|
|
|
|
@ -9,45 +10,53 @@ namespace Avalonia.Win32 |
|
|
|
static class Win32GlManager |
|
|
|
{ |
|
|
|
|
|
|
|
public static void Initialize() |
|
|
|
public static IPlatformOpenGlInterface Initialize() |
|
|
|
{ |
|
|
|
AvaloniaLocator.CurrentMutable.Bind<IPlatformOpenGlInterface>().ToLazy<IPlatformOpenGlInterface>(() => |
|
|
|
var gl = InitializeCore(); |
|
|
|
AvaloniaLocator.CurrentMutable.Bind<IPlatformOpenGlInterface>().ToConstant(gl); |
|
|
|
AvaloniaLocator.CurrentMutable.Bind<IPlatformGpu>().ToConstant(gl); |
|
|
|
return gl; |
|
|
|
} |
|
|
|
|
|
|
|
static IPlatformOpenGlInterface InitializeCore() |
|
|
|
{ |
|
|
|
|
|
|
|
var opts = AvaloniaLocator.Current.GetService<Win32PlatformOptions>() ?? new Win32PlatformOptions(); |
|
|
|
if (opts.UseWgl) |
|
|
|
{ |
|
|
|
var opts = AvaloniaLocator.Current.GetService<Win32PlatformOptions>() ?? new Win32PlatformOptions(); |
|
|
|
if (opts.UseWgl) |
|
|
|
{ |
|
|
|
var wgl = WglPlatformOpenGlInterface.TryCreate(); |
|
|
|
return wgl; |
|
|
|
} |
|
|
|
var wgl = WglPlatformOpenGlInterface.TryCreate(); |
|
|
|
return wgl; |
|
|
|
} |
|
|
|
|
|
|
|
if (opts.AllowEglInitialization ?? Win32Platform.WindowsVersion > PlatformConstants.Windows7) |
|
|
|
{ |
|
|
|
var egl = EglPlatformOpenGlInterface.TryCreate(() => new AngleWin32EglDisplay()); |
|
|
|
if (opts.AllowEglInitialization ?? Win32Platform.WindowsVersion > PlatformConstants.Windows7) |
|
|
|
{ |
|
|
|
var egl = EglPlatformOpenGlInterface.TryCreate(() => new AngleWin32EglDisplay()); |
|
|
|
|
|
|
|
if (egl != null) |
|
|
|
if (egl != null) |
|
|
|
{ |
|
|
|
if (opts.EglRendererBlacklist != null) |
|
|
|
{ |
|
|
|
if (opts.EglRendererBlacklist != null) |
|
|
|
foreach (var item in opts.EglRendererBlacklist) |
|
|
|
{ |
|
|
|
foreach (var item in opts.EglRendererBlacklist) |
|
|
|
if (egl.PrimaryEglContext.GlInterface.Renderer.Contains(item)) |
|
|
|
{ |
|
|
|
if (egl.PrimaryEglContext.GlInterface.Renderer.Contains(item)) |
|
|
|
{ |
|
|
|
return null; |
|
|
|
} |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (opts.UseWindowsUIComposition) |
|
|
|
{ |
|
|
|
WinUICompositorConnection.TryCreateAndRegister(egl, opts.CompositionBackdropCornerRadius); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return egl; |
|
|
|
if (opts.UseWindowsUIComposition) |
|
|
|
{ |
|
|
|
WinUICompositorConnection.TryCreateAndRegister(egl, opts.CompositionBackdropCornerRadius); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return null; |
|
|
|
}); |
|
|
|
return egl; |
|
|
|
} |
|
|
|
|
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|