From 70d062ba39e618d5084720324d5996e2609465d7 Mon Sep 17 00:00:00 2001 From: danwalmsley Date: Thu, 10 Sep 2020 16:26:47 +0100 Subject: [PATCH 01/10] make code more readable. --- src/Avalonia.OpenGL/Angle/AngleEglInterface.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Avalonia.OpenGL/Angle/AngleEglInterface.cs b/src/Avalonia.OpenGL/Angle/AngleEglInterface.cs index 375b93c27c..3ec6ba1772 100644 --- a/src/Avalonia.OpenGL/Angle/AngleEglInterface.cs +++ b/src/Avalonia.OpenGL/Angle/AngleEglInterface.cs @@ -18,11 +18,18 @@ namespace Avalonia.OpenGL.Angle static Func LoadAngle() { if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { throw new PlatformNotSupportedException(); + } + else { var disp = eglGetProcAddress("eglGetPlatformDisplayEXT"); + if (disp == IntPtr.Zero) + { throw new OpenGlException("libegl.dll doesn't have eglGetPlatformDisplayEXT entry point"); + } + return eglGetProcAddress; } } From c48c82f171ecb4658e10474636505216547c5ec3 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Thu, 10 Sep 2020 17:17:23 +0100 Subject: [PATCH 02/10] formatting. --- src/Avalonia.OpenGL/Angle/AngleEglInterface.cs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/Avalonia.OpenGL/Angle/AngleEglInterface.cs b/src/Avalonia.OpenGL/Angle/AngleEglInterface.cs index 3ec6ba1772..8565d99b45 100644 --- a/src/Avalonia.OpenGL/Angle/AngleEglInterface.cs +++ b/src/Avalonia.OpenGL/Angle/AngleEglInterface.cs @@ -17,21 +17,19 @@ namespace Avalonia.OpenGL.Angle static Func LoadAngle() { - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - throw new PlatformNotSupportedException(); - } - else + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { var disp = eglGetProcAddress("eglGetPlatformDisplayEXT"); - + if (disp == IntPtr.Zero) { throw new OpenGlException("libegl.dll doesn't have eglGetPlatformDisplayEXT entry point"); } - + return eglGetProcAddress; } + + throw new PlatformNotSupportedException(); } } From ca5ec1fba49884af7edba49a982e0b5d849bd8a9 Mon Sep 17 00:00:00 2001 From: Maksym Katsydan Date: Fri, 11 Sep 2020 00:22:56 -0400 Subject: [PATCH 03/10] Add left padding for radiobutton and checkbox --- src/Avalonia.Themes.Fluent/CheckBox.xaml | 1 + src/Avalonia.Themes.Fluent/RadioButton.xaml | 1 + 2 files changed, 2 insertions(+) diff --git a/src/Avalonia.Themes.Fluent/CheckBox.xaml b/src/Avalonia.Themes.Fluent/CheckBox.xaml index 04799b3bc2..73c44c02ab 100644 --- a/src/Avalonia.Themes.Fluent/CheckBox.xaml +++ b/src/Avalonia.Themes.Fluent/CheckBox.xaml @@ -8,6 +8,7 @@ + diff --git a/src/Avalonia.Themes.Fluent/RadioButton.xaml b/src/Avalonia.Themes.Fluent/RadioButton.xaml index 8fd569816d..078f51c87a 100644 --- a/src/Avalonia.Themes.Fluent/RadioButton.xaml +++ b/src/Avalonia.Themes.Fluent/RadioButton.xaml @@ -13,6 +13,7 @@ + From 12f0fc046a892922c6c2b683c467a5a95f720931 Mon Sep 17 00:00:00 2001 From: Rustam Sayfutdinov Date: Sat, 12 Sep 2020 11:47:12 +0500 Subject: [PATCH 04/10] Update Microsoft.NETFramework.ReferenceAssemblies --- build/NetFX.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/NetFX.props b/build/NetFX.props index ed5cb6dd69..8ffc9ec561 100644 --- a/build/NetFX.props +++ b/build/NetFX.props @@ -1,7 +1,7 @@  - + From e1045a09c9a173450afe5c241d583134336cef8d Mon Sep 17 00:00:00 2001 From: Rustam Sayfutdinov Date: Sun, 13 Sep 2020 21:30:19 +0500 Subject: [PATCH 05/10] Improve for the backend web preview --- .../Remote/HtmlTransport/HtmlTransport.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs index 55e2df8890..03dcf85b87 100644 --- a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs +++ b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/HtmlTransport.cs @@ -38,11 +38,13 @@ namespace Avalonia.DesignerSupport.Remote.HtmlTransport public HtmlWebSocketTransport(IAvaloniaRemoteTransportConnection signalTransport, Uri listenUri) { if (listenUri.Scheme != "http") - throw new ArgumentException("listenUri"); + throw new ArgumentException("URI scheme is not HTTP.", nameof(listenUri)); var resourcePrefix = "Avalonia.DesignerSupport.Remote.HtmlTransport.webapp.build."; _resources = typeof(HtmlWebSocketTransport).Assembly.GetManifestResourceNames() - .Where(r => r.StartsWith(resourcePrefix) && r.EndsWith(".gz")).ToDictionary( + .Where(r => r.StartsWith(resourcePrefix, StringComparison.OrdinalIgnoreCase) + && r.EndsWith(".gz", StringComparison.OrdinalIgnoreCase)) + .ToDictionary( r => r.Substring(resourcePrefix.Length).Substring(0,r.Length-resourcePrefix.Length-3), r => { From c01c7c937838265fc8031934c1bca7703ec9952b Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Tue, 15 Sep 2020 02:50:27 -0700 Subject: [PATCH 06/10] opengl es 3.1, 3.0 and 2.0 --- src/Avalonia.OpenGL/EglDisplay.cs | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/src/Avalonia.OpenGL/EglDisplay.cs b/src/Avalonia.OpenGL/EglDisplay.cs index 7b194e4346..ca7e9b66c3 100644 --- a/src/Avalonia.OpenGL/EglDisplay.cs +++ b/src/Avalonia.OpenGL/EglDisplay.cs @@ -67,13 +67,38 @@ namespace Avalonia.OpenGL { Attributes = new[] { - EGL_CONTEXT_CLIENT_VERSION, 2, + EGL_CONTEXT_MAJOR_VERSION, 3, + EGL_CONTEXT_MINOR_VERSION, 1, + EGL_NONE + }, + Api = EGL_OPENGL_ES_API, + RenderableTypeBit = EGL_OPENGL_ES3_BIT, + Version = new GlVersion(GlProfileType.OpenGLES, 3, 1) + }, + new + { + Attributes = new[] + { + EGL_CONTEXT_MAJOR_VERSION, 3, + EGL_CONTEXT_MINOR_VERSION, 0, + EGL_NONE + }, + Api = EGL_OPENGL_ES_API, + RenderableTypeBit = EGL_OPENGL_ES3_BIT, + Version = new GlVersion(GlProfileType.OpenGLES, 3, 0) + }, + new + { + Attributes = new[] + { + EGL_CONTEXT_MAJOR_VERSION, 2, + EGL_CONTEXT_MINOR_VERSION, 0, EGL_NONE }, Api = EGL_OPENGL_ES_API, RenderableTypeBit = EGL_OPENGL_ES2_BIT, Version = new GlVersion(GlProfileType.OpenGLES, 2, 0) - } + }, }) { if (!_egl.BindApi(cfg.Api)) From a6d83cd32a8e373b7b00f58b18b2947f135da3fa Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Tue, 15 Sep 2020 06:12:47 -0700 Subject: [PATCH 07/10] support any gles version with angle using angle options. --- src/Avalonia.OpenGL/AngleOptions.cs | 8 +++ src/Avalonia.OpenGL/EglDisplay.cs | 63 +++++++++++----------- src/Avalonia.X11/Glx/GlxDisplay.cs | 2 +- src/Avalonia.X11/Glx/GlxPlatformFeature.cs | 4 +- src/Avalonia.X11/X11Platform.cs | 4 +- 5 files changed, 45 insertions(+), 36 deletions(-) diff --git a/src/Avalonia.OpenGL/AngleOptions.cs b/src/Avalonia.OpenGL/AngleOptions.cs index 84744288ed..462bd56cbe 100644 --- a/src/Avalonia.OpenGL/AngleOptions.cs +++ b/src/Avalonia.OpenGL/AngleOptions.cs @@ -10,6 +10,14 @@ namespace Avalonia.OpenGL DirectX11 } + public IList GlProfiles { get; set; } = new List + { + new GlVersion(GlProfileType.OpenGLES, 3, 2), + new GlVersion(GlProfileType.OpenGLES, 3, 1), + new GlVersion(GlProfileType.OpenGLES, 3, 0), + new GlVersion(GlProfileType.OpenGLES, 2, 0) + }; + public IList AllowedPlatformApis { get; set; } = null; } } diff --git a/src/Avalonia.OpenGL/EglDisplay.cs b/src/Avalonia.OpenGL/EglDisplay.cs index ca7e9b66c3..9edcaf2bc0 100644 --- a/src/Avalonia.OpenGL/EglDisplay.cs +++ b/src/Avalonia.OpenGL/EglDisplay.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Runtime.InteropServices; using Avalonia.Platform.Interop; using static Avalonia.OpenGL.EglConsts; @@ -61,45 +62,45 @@ namespace Avalonia.OpenGL if (!_egl.Initialize(_display, out var major, out var minor)) throw OpenGlException.GetFormattedException("eglInitialize", _egl); - foreach (var cfg in new[] + var glProfiles = AvaloniaLocator.Current.GetService()?.GlProfiles + ?? new[] + { + new GlVersion(GlProfileType.OpenGLES, 3, 2), + new GlVersion(GlProfileType.OpenGLES, 3, 1), + new GlVersion(GlProfileType.OpenGLES, 3, 0), + new GlVersion(GlProfileType.OpenGLES, 2, 0) + }; + + var cfgs = glProfiles.Select(x => { - new - { - Attributes = new[] - { - EGL_CONTEXT_MAJOR_VERSION, 3, - EGL_CONTEXT_MINOR_VERSION, 1, - EGL_NONE - }, - Api = EGL_OPENGL_ES_API, - RenderableTypeBit = EGL_OPENGL_ES3_BIT, - Version = new GlVersion(GlProfileType.OpenGLES, 3, 1) - }, - new + var typeBit = EGL_OPENGL_ES3_BIT; + + switch (x.Major) { - Attributes = new[] - { - EGL_CONTEXT_MAJOR_VERSION, 3, - EGL_CONTEXT_MINOR_VERSION, 0, - EGL_NONE - }, - Api = EGL_OPENGL_ES_API, - RenderableTypeBit = EGL_OPENGL_ES3_BIT, - Version = new GlVersion(GlProfileType.OpenGLES, 3, 0) - }, - new + case 2: + typeBit = EGL_OPENGL_ES2_BIT; + break; + + case 1: + typeBit = EGL_OPENGL_ES_BIT; + break; + } + + return new { Attributes = new[] { - EGL_CONTEXT_MAJOR_VERSION, 2, - EGL_CONTEXT_MINOR_VERSION, 0, + EGL_CONTEXT_MAJOR_VERSION, x.Major, + EGL_CONTEXT_MINOR_VERSION, x.Minor, EGL_NONE }, Api = EGL_OPENGL_ES_API, - RenderableTypeBit = EGL_OPENGL_ES2_BIT, - Version = new GlVersion(GlProfileType.OpenGLES, 2, 0) - }, - }) + RenderableTypeBit = typeBit, + Version = x + }; + }); + + foreach (var cfg in cfgs) { if (!_egl.BindApi(cfg.Api)) continue; diff --git a/src/Avalonia.X11/Glx/GlxDisplay.cs b/src/Avalonia.X11/Glx/GlxDisplay.cs index 903d6b570b..b82895d12c 100644 --- a/src/Avalonia.X11/Glx/GlxDisplay.cs +++ b/src/Avalonia.X11/Glx/GlxDisplay.cs @@ -18,7 +18,7 @@ namespace Avalonia.X11.Glx public XVisualInfo* VisualInfo => _visual; public GlxContext DeferredContext { get; } public GlxInterface Glx { get; } = new GlxInterface(); - public GlxDisplay(X11Info x11, List probeProfiles) + public GlxDisplay(X11Info x11, IList probeProfiles) { _x11 = x11; _probeProfiles = probeProfiles.ToList(); diff --git a/src/Avalonia.X11/Glx/GlxPlatformFeature.cs b/src/Avalonia.X11/Glx/GlxPlatformFeature.cs index e3250e6733..ad3a54bcc1 100644 --- a/src/Avalonia.X11/Glx/GlxPlatformFeature.cs +++ b/src/Avalonia.X11/Glx/GlxPlatformFeature.cs @@ -12,7 +12,7 @@ namespace Avalonia.X11.Glx public GlxContext DeferredContext { get; private set; } public IGlContext MainContext => DeferredContext; - public static bool TryInitialize(X11Info x11, List glProfiles) + public static bool TryInitialize(X11Info x11, IList glProfiles) { var feature = TryCreate(x11, glProfiles); if (feature != null) @@ -24,7 +24,7 @@ namespace Avalonia.X11.Glx return false; } - public static GlxGlPlatformFeature TryCreate(X11Info x11, List glProfiles) + public static GlxGlPlatformFeature TryCreate(X11Info x11, IList glProfiles) { try { diff --git a/src/Avalonia.X11/X11Platform.cs b/src/Avalonia.X11/X11Platform.cs index 7f3255d4da..d7bd81db98 100644 --- a/src/Avalonia.X11/X11Platform.cs +++ b/src/Avalonia.X11/X11Platform.cs @@ -103,7 +103,7 @@ namespace Avalonia public bool UseDBusMenu { get; set; } public bool UseDeferredRendering { get; set; } = true; - public List GlProfiles { get; set; } = new List + public IList GlProfiles { get; set; } = new List { new GlVersion(GlProfileType.OpenGL, 4, 0), new GlVersion(GlProfileType.OpenGL, 3, 2), @@ -113,7 +113,7 @@ namespace Avalonia new GlVersion(GlProfileType.OpenGLES, 2, 0) }; - public List GlxRendererBlacklist { get; set; } = new List + public IList GlxRendererBlacklist { get; set; } = new List { // llvmpipe is a software GL rasterizer. If it's returned by glGetString, // that usually means that something in the system is horribly misconfigured From 5015c431a8bd07a83e36c156f62d6089fd023c49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dariusz=20Komosi=C5=84ski?= Date: Tue, 15 Sep 2020 17:02:28 +0200 Subject: [PATCH 08/10] Fix nullable annotations. --- src/Avalonia.Input/KeyGesture.cs | 12 +++++------- src/Avalonia.Input/PointerEventArgs.cs | 4 ++-- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/Avalonia.Input/KeyGesture.cs b/src/Avalonia.Input/KeyGesture.cs index ad447794bc..aa6fcc8bff 100644 --- a/src/Avalonia.Input/KeyGesture.cs +++ b/src/Avalonia.Input/KeyGesture.cs @@ -1,7 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Runtime.InteropServices; using System.Text; namespace Avalonia.Input @@ -29,7 +27,7 @@ namespace Avalonia.Input KeyModifiers = modifiers; } - public bool Equals(KeyGesture other) + public bool Equals(KeyGesture? other) { if (ReferenceEquals(null, other)) return false; if (ReferenceEquals(this, other)) return true; @@ -37,12 +35,12 @@ namespace Avalonia.Input return Key == other.Key && KeyModifiers == other.KeyModifiers; } - public override bool Equals(object obj) + public override bool Equals(object? obj) { if (ReferenceEquals(null, obj)) return false; if (ReferenceEquals(this, obj)) return true; - return obj is KeyGesture && Equals((KeyGesture)obj); + return obj is KeyGesture gesture && Equals(gesture); } public override int GetHashCode() @@ -53,12 +51,12 @@ namespace Avalonia.Input } } - public static bool operator ==(KeyGesture left, KeyGesture right) + public static bool operator ==(KeyGesture? left, KeyGesture? right) { return Equals(left, right); } - public static bool operator !=(KeyGesture left, KeyGesture right) + public static bool operator !=(KeyGesture? left, KeyGesture? right) { return !Equals(left, right); } diff --git a/src/Avalonia.Input/PointerEventArgs.cs b/src/Avalonia.Input/PointerEventArgs.cs index 1cbddf89aa..451f80b1df 100644 --- a/src/Avalonia.Input/PointerEventArgs.cs +++ b/src/Avalonia.Input/PointerEventArgs.cs @@ -86,14 +86,14 @@ namespace Avalonia.Input } [Obsolete("Use GetCurrentPoint")] - public PointerPoint GetPointerPoint(IVisual relativeTo) => GetCurrentPoint(relativeTo); + public PointerPoint GetPointerPoint(IVisual? relativeTo) => GetCurrentPoint(relativeTo); /// /// Returns the PointerPoint associated with the current event /// /// The visual which coordinate system to use. Pass null for toplevel coordinate system /// - public PointerPoint GetCurrentPoint(IVisual relativeTo) + public PointerPoint GetCurrentPoint(IVisual? relativeTo) => new PointerPoint(Pointer, GetPosition(relativeTo), _properties); /// From 0fefe3b5af4529624378f47e8cbbd9e980045164 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Wed, 16 Sep 2020 03:02:07 -0700 Subject: [PATCH 09/10] dont use egl 3.2 and 3.1 as they are still wip. --- src/Avalonia.OpenGL/AngleOptions.cs | 2 -- src/Avalonia.OpenGL/EglDisplay.cs | 2 -- 2 files changed, 4 deletions(-) diff --git a/src/Avalonia.OpenGL/AngleOptions.cs b/src/Avalonia.OpenGL/AngleOptions.cs index 462bd56cbe..0807eb7ab4 100644 --- a/src/Avalonia.OpenGL/AngleOptions.cs +++ b/src/Avalonia.OpenGL/AngleOptions.cs @@ -12,8 +12,6 @@ namespace Avalonia.OpenGL public IList GlProfiles { get; set; } = new List { - new GlVersion(GlProfileType.OpenGLES, 3, 2), - new GlVersion(GlProfileType.OpenGLES, 3, 1), new GlVersion(GlProfileType.OpenGLES, 3, 0), new GlVersion(GlProfileType.OpenGLES, 2, 0) }; diff --git a/src/Avalonia.OpenGL/EglDisplay.cs b/src/Avalonia.OpenGL/EglDisplay.cs index 9edcaf2bc0..7f41e75d6a 100644 --- a/src/Avalonia.OpenGL/EglDisplay.cs +++ b/src/Avalonia.OpenGL/EglDisplay.cs @@ -65,8 +65,6 @@ namespace Avalonia.OpenGL var glProfiles = AvaloniaLocator.Current.GetService()?.GlProfiles ?? new[] { - new GlVersion(GlProfileType.OpenGLES, 3, 2), - new GlVersion(GlProfileType.OpenGLES, 3, 1), new GlVersion(GlProfileType.OpenGLES, 3, 0), new GlVersion(GlProfileType.OpenGLES, 2, 0) }; From 8e1c27756582614885fff6d280a7634f0d86e032 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Wed, 16 Sep 2020 03:40:50 -0700 Subject: [PATCH 10/10] update to release of skiasharp. --- build/SkiaSharp.props | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build/SkiaSharp.props b/build/SkiaSharp.props index d7d04c7971..f2e7df36cd 100644 --- a/build/SkiaSharp.props +++ b/build/SkiaSharp.props @@ -1,6 +1,6 @@  - - + +