From b238cc64d85af7fe81d61ac2e13c708effc578df Mon Sep 17 00:00:00 2001 From: Max Katz Date: Wed, 9 Feb 2022 01:04:21 -0500 Subject: [PATCH 01/26] Move iOS projects to a new sdk --- .../ControlCatalog.iOS.csproj | 185 +----------------- samples/ControlCatalog.iOS/Main.cs | 4 +- .../Properties/AssemblyInfo.cs | 36 ---- src/iOS/Avalonia.iOS/Avalonia.iOS.csproj | 14 +- src/iOS/Avalonia.iOS/AvaloniaAppDelegate.cs | 4 +- .../Avalonia.iOS/Boilerplate/AppBuilder.cs | 14 -- src/iOS/Avalonia.iOS/EaglDisplay.cs | 1 - src/iOS/Avalonia.iOS/Platform.cs | 15 ++ 8 files changed, 28 insertions(+), 245 deletions(-) delete mode 100644 samples/ControlCatalog.iOS/Properties/AssemblyInfo.cs delete mode 100644 src/iOS/Avalonia.iOS/Boilerplate/AppBuilder.cs diff --git a/samples/ControlCatalog.iOS/ControlCatalog.iOS.csproj b/samples/ControlCatalog.iOS/ControlCatalog.iOS.csproj index db1e16166a..409223fa81 100644 --- a/samples/ControlCatalog.iOS/ControlCatalog.iOS.csproj +++ b/samples/ControlCatalog.iOS/ControlCatalog.iOS.csproj @@ -1,186 +1,11 @@ - - + - Debug - iPhoneSimulator - {57E0455D-D565-44BB-B069-EE1AA20F8337} - {FEACFBD2-3405-455C-9665-78FE426C6842};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} Exe - ControlCatalog.iOS - Resources - ControlCatalogiOS - true - NSUrlSessionHandler - PackageReference - automatic + net6.0-ios + 14.2 - - true - full - false - bin\iPhoneSimulator\Debug - DEBUG - prompt - 4 - false - x86_64 - None - True - 9.1 - False - False - False - False - False - False - False - False - True - Default - HttpClientHandler - False - - - none - true - bin\iPhoneSimulator\Release - prompt - 4 - None - x86_64 - false - - - true - full - false - bin\iPhone\Debug - DEBUG - prompt - 4 - false - ARMv7, ARM64 - Entitlements.plist - iPhone Developer - true - - - none - true - bin\iPhone\Release - prompt - 4 - Entitlements.plist - ARMv7, ARM64 - false - iPhone Developer - - - none - True - bin\iPhone\Ad-Hoc - prompt - 4 - False - ARMv7, ARM64 - Entitlements.plist - True - Automatic:AdHoc - iPhone Distribution - - - none - True - bin\iPhone\AppStore - prompt - 4 - False - ARMv7, ARM64 - Entitlements.plist - Automatic:AppStore - iPhone Distribution - - - - - - - - - - - - - - - - - {4488AD85-1495-4809-9AA4-DDFE0A48527E} - Avalonia.iOS - false - false - - - {3E53A01A-B331-47F3-B828-4A5717E77A24} - Avalonia.Markup.Xaml - - - {6417E941-21BC-467B-A771-0DE389353CE6} - Avalonia.Markup - - - {D211E587-D8BC-45B9-95A4-F297C8FA5200} - Avalonia.Animation - - - {B09B78D8-9B26-48B0-9149-D64A2F120F3F} - Avalonia.Base - - - {D2221C82-4A25-4583-9B43-D791E3F6820C} - Avalonia.Controls - - - {7062AE20-5DCC-4442-9645-8195BDECE63E} - Avalonia.Diagnostics - - - {62024B2D-53EB-4638-B26B-85EEAA54866E} - Avalonia.Input - - - {6B0ED19D-A08B-461C-A9D9-A9EE40B0C06B} - Avalonia.Interactivity - - - {42472427-4774-4C81-8AFF-9F27B8E31721} - Avalonia.Layout - - - {EB582467-6ABB-43A1-B052-E981BA910E3A} - Avalonia.Visuals - - - {F1BAA01A-F176-4C6A-B39D-5B40BB1B148F} - Avalonia.Styling - - - {3E10A5FA-E8DA-48B1-AD44-6A5B6CB7750F} - Avalonia.Themes.Default - - - {7d2d3083-71dd-4cc9-8907-39a0d86fb322} - Avalonia.Skia - - - {d0a739b9-3c68-4ba6-a328-41606954b6bd} - ControlCatalog - - + + - - - - diff --git a/samples/ControlCatalog.iOS/Main.cs b/samples/ControlCatalog.iOS/Main.cs index fe039ba69e..2400115041 100644 --- a/samples/ControlCatalog.iOS/Main.cs +++ b/samples/ControlCatalog.iOS/Main.cs @@ -9,7 +9,7 @@ namespace ControlCatalog.iOS { // if you want to use a different Application Delegate class from "AppDelegate" // you can specify it here. - UIApplication.Main(args, null, "AppDelegate"); + UIApplication.Main(args, null, typeof(AppDelegate)); } } -} \ No newline at end of file +} diff --git a/samples/ControlCatalog.iOS/Properties/AssemblyInfo.cs b/samples/ControlCatalog.iOS/Properties/AssemblyInfo.cs deleted file mode 100644 index 0a5a598651..0000000000 --- a/samples/ControlCatalog.iOS/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("ControlCatalog.iOS")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("ControlCatalog.iOS")] -[assembly: AssemblyCopyright("Copyright © 2016")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("57e0455d-d565-44bb-b069-ee1aa20f8337")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/iOS/Avalonia.iOS/Avalonia.iOS.csproj b/src/iOS/Avalonia.iOS/Avalonia.iOS.csproj index e9015d857c..f1fef8fd14 100644 --- a/src/iOS/Avalonia.iOS/Avalonia.iOS.csproj +++ b/src/iOS/Avalonia.iOS/Avalonia.iOS.csproj @@ -1,17 +1,11 @@ - + - xamarin.ios10 + net6.0-ios true - latest + 10.0 - - - - - - TargetFramework=netstandard2.0 - + diff --git a/src/iOS/Avalonia.iOS/AvaloniaAppDelegate.cs b/src/iOS/Avalonia.iOS/AvaloniaAppDelegate.cs index b75aad17cf..65a6743f9d 100644 --- a/src/iOS/Avalonia.iOS/AvaloniaAppDelegate.cs +++ b/src/iOS/Avalonia.iOS/AvaloniaAppDelegate.cs @@ -8,7 +8,7 @@ namespace Avalonia.iOS public class AvaloniaAppDelegate : UIResponder, IUIApplicationDelegate where TApp : Application, new() { - protected virtual AppBuilder CustomizeAppBuilder(AppBuilder builder) => builder; + protected virtual AppBuilder CustomizeAppBuilder(AppBuilder builder) => builder.UseiOS(); [Export("window")] public UIWindow Window { get; set; } @@ -46,4 +46,4 @@ namespace Avalonia.iOS } } } -} \ No newline at end of file +} diff --git a/src/iOS/Avalonia.iOS/Boilerplate/AppBuilder.cs b/src/iOS/Avalonia.iOS/Boilerplate/AppBuilder.cs deleted file mode 100644 index d5830510f6..0000000000 --- a/src/iOS/Avalonia.iOS/Boilerplate/AppBuilder.cs +++ /dev/null @@ -1,14 +0,0 @@ -using Avalonia.Controls; -using Avalonia.PlatformSupport; - -namespace Avalonia -{ - public class AppBuilder : AppBuilderBase - { - public AppBuilder() : base(new StandardRuntimePlatform(), - b => StandardRuntimePlatformServices.Register(b.ApplicationType.Assembly)) - { - this.UseSkia().UseWindowingSubsystem(iOS.Platform.Register); - } - } -} diff --git a/src/iOS/Avalonia.iOS/EaglDisplay.cs b/src/iOS/Avalonia.iOS/EaglDisplay.cs index f9c787b6a8..f1d46fcb92 100644 --- a/src/iOS/Avalonia.iOS/EaglDisplay.cs +++ b/src/iOS/Avalonia.iOS/EaglDisplay.cs @@ -2,7 +2,6 @@ using System; using System.Reactive.Disposables; using Avalonia.OpenGL; using OpenGLES; -using OpenTK.Graphics.ES30; namespace Avalonia.iOS { diff --git a/src/iOS/Avalonia.iOS/Platform.cs b/src/iOS/Avalonia.iOS/Platform.cs index 88f60ace1f..57a86cbfd8 100644 --- a/src/iOS/Avalonia.iOS/Platform.cs +++ b/src/iOS/Avalonia.iOS/Platform.cs @@ -1,10 +1,25 @@ using System; + +using Avalonia.Controls; using Avalonia.Input; using Avalonia.Input.Platform; using Avalonia.OpenGL; using Avalonia.Platform; using Avalonia.Rendering; +namespace Avalonia +{ + public static class IOSApplicationExtensions + { + public static T UseiOS(this T builder) where T : AppBuilderBase, new() + { + return builder + .UseWindowingSubsystem(iOS.Platform.Register, "iOS") + .UseSkia(); + } + } +} + namespace Avalonia.iOS { static class Platform From b045393df3931e33d4fbefc8ff3ea28068386014 Mon Sep 17 00:00:00 2001 From: Max Katz Date: Tue, 22 Feb 2022 22:07:16 -0500 Subject: [PATCH 02/26] Do not reference DevTools from shared control catalog --- .../ControlCatalog.NetCore/ControlCatalog.NetCore.csproj | 1 + samples/ControlCatalog.NetCore/Program.cs | 7 +++++++ samples/ControlCatalog/App.xaml.cs | 5 ----- samples/ControlCatalog/ControlCatalog.csproj | 1 - .../interop/WindowsInteropTest/WindowsInteropTest.csproj | 1 + 5 files changed, 9 insertions(+), 6 deletions(-) diff --git a/samples/ControlCatalog.NetCore/ControlCatalog.NetCore.csproj b/samples/ControlCatalog.NetCore/ControlCatalog.NetCore.csproj index 5968a11b05..d1b657722c 100644 --- a/samples/ControlCatalog.NetCore/ControlCatalog.NetCore.csproj +++ b/samples/ControlCatalog.NetCore/ControlCatalog.NetCore.csproj @@ -13,6 +13,7 @@ + diff --git a/samples/ControlCatalog.NetCore/Program.cs b/samples/ControlCatalog.NetCore/Program.cs index 0c8fd9465c..4b81935452 100644 --- a/samples/ControlCatalog.NetCore/Program.cs +++ b/samples/ControlCatalog.NetCore/Program.cs @@ -118,6 +118,13 @@ namespace ControlCatalog.NetCore }) .UseSkia() .UseManagedSystemDialogs() + .AfterSetup(builder => + { + builder.Instance!.AttachDevTools(new Avalonia.Diagnostics.DevToolsOptions() + { + StartupScreenIndex = 1, + }); + }) .LogToTrace(); static void SilenceConsole() diff --git a/samples/ControlCatalog/App.xaml.cs b/samples/ControlCatalog/App.xaml.cs index f6d382f99d..866fb8632a 100644 --- a/samples/ControlCatalog/App.xaml.cs +++ b/samples/ControlCatalog/App.xaml.cs @@ -78,11 +78,6 @@ namespace ControlCatalog if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktopLifetime) { desktopLifetime.MainWindow = new MainWindow(); - - this.AttachDevTools(new Avalonia.Diagnostics.DevToolsOptions() - { - StartupScreenIndex = 1, - }); } else if (ApplicationLifetime is ISingleViewApplicationLifetime singleViewLifetime) { diff --git a/samples/ControlCatalog/ControlCatalog.csproj b/samples/ControlCatalog/ControlCatalog.csproj index 7864459e77..c0e24357ca 100644 --- a/samples/ControlCatalog/ControlCatalog.csproj +++ b/samples/ControlCatalog/ControlCatalog.csproj @@ -23,7 +23,6 @@ - diff --git a/samples/interop/WindowsInteropTest/WindowsInteropTest.csproj b/samples/interop/WindowsInteropTest/WindowsInteropTest.csproj index 0c18a1f58b..223a53d8c5 100644 --- a/samples/interop/WindowsInteropTest/WindowsInteropTest.csproj +++ b/samples/interop/WindowsInteropTest/WindowsInteropTest.csproj @@ -8,6 +8,7 @@ + {d0a739b9-3c68-4ba6-a328-41606954b6bd} From 4756a0a769de4b3ddbba5fda42a8ebb7b78ee69f Mon Sep 17 00:00:00 2001 From: Max Katz Date: Wed, 23 Feb 2022 22:56:39 -0500 Subject: [PATCH 03/26] Fix iOS OpenGL rendering with newer Skia --- .../Avalonia.Skia/Gpu/OpenGl/GlRenderTarget.cs | 13 +++++++++---- src/iOS/Avalonia.iOS/EaglDisplay.cs | 18 ++++++++++++++++-- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/src/Skia/Avalonia.Skia/Gpu/OpenGl/GlRenderTarget.cs b/src/Skia/Avalonia.Skia/Gpu/OpenGl/GlRenderTarget.cs index b4c5619c85..809f50ab8b 100644 --- a/src/Skia/Avalonia.Skia/Gpu/OpenGl/GlRenderTarget.cs +++ b/src/Skia/Avalonia.Skia/Gpu/OpenGl/GlRenderTarget.cs @@ -69,6 +69,7 @@ namespace Avalonia.Skia gl.GetIntegerv(GL_FRAMEBUFFER_BINDING, out var fb); var size = glSession.Size; + var colorType = SKColorType.Rgba8888; var scaling = glSession.Scaling; if (size.Width <= 0 || size.Height <= 0 || scaling < 0) { @@ -81,12 +82,16 @@ namespace Avalonia.Skia { _grContext.ResetContext(); - var renderTarget = - new GRBackendRenderTarget(size.Width, size.Height, disp.SampleCount, disp.StencilSize, - new GRGlFramebufferInfo((uint)fb, SKColorType.Rgba8888.ToGlSizedFormat())); + var samples = disp.SampleCount; + var maxSamples = _grContext.GetMaxSurfaceSampleCount(colorType); + if (samples > maxSamples) + samples = maxSamples; + + var glInfo = new GRGlFramebufferInfo((uint)fb, colorType.ToGlSizedFormat()); + var renderTarget = new GRBackendRenderTarget(size.Width, size.Height, samples, disp.StencilSize, glInfo); var surface = SKSurface.Create(_grContext, renderTarget, glSession.IsYFlipped ? GRSurfaceOrigin.TopLeft : GRSurfaceOrigin.BottomLeft, - SKColorType.Rgba8888); + colorType); success = true; diff --git a/src/iOS/Avalonia.iOS/EaglDisplay.cs b/src/iOS/Avalonia.iOS/EaglDisplay.cs index f1d46fcb92..bd1969081d 100644 --- a/src/iOS/Avalonia.iOS/EaglDisplay.cs +++ b/src/iOS/Avalonia.iOS/EaglDisplay.cs @@ -74,7 +74,21 @@ namespace Avalonia.iOS public GlVersion Version { get; } = new GlVersion(GlProfileType.OpenGLES, 3, 0); public GlInterface GlInterface { get; } - public int SampleCount { get; } = 0; - public int StencilSize { get; } = 9; + public int SampleCount + { + get + { + GlInterface.GetIntegerv(GlConsts.GL_SAMPLES, out var samples); + return samples; + } + } + public int StencilSize + { + get + { + GlInterface.GetIntegerv(GlConsts.GL_STENCIL_BITS, out var stencil); + return stencil; + } + } } } From 138d65556bdff43e14d6ceef1b26275fa36984d1 Mon Sep 17 00:00:00 2001 From: Max Katz Date: Wed, 23 Feb 2022 23:01:00 -0500 Subject: [PATCH 04/26] Use out own opengl interface wrapper --- src/iOS/Avalonia.iOS/EaglLayerSurface.cs | 5 +- src/iOS/Avalonia.iOS/Extensions.cs | 3 +- src/iOS/Avalonia.iOS/LayerFbo.cs | 79 +++++++++++++----------- 3 files changed, 48 insertions(+), 39 deletions(-) diff --git a/src/iOS/Avalonia.iOS/EaglLayerSurface.cs b/src/iOS/Avalonia.iOS/EaglLayerSurface.cs index 5e5e1da949..0e8945d921 100644 --- a/src/iOS/Avalonia.iOS/EaglLayerSurface.cs +++ b/src/iOS/Avalonia.iOS/EaglLayerSurface.cs @@ -4,7 +4,6 @@ using System.Threading; using Avalonia.OpenGL; using Avalonia.OpenGL.Surfaces; using CoreAnimation; -using OpenTK.Graphics.ES30; namespace Avalonia.iOS { @@ -35,7 +34,7 @@ namespace Avalonia.iOS public void Dispose() { - GL.Finish(); + _ctx.GlInterface.Finish(); _fbo.Present(); _restoreContext.Dispose(); } @@ -85,7 +84,7 @@ namespace Avalonia.iOS var ctx = Platform.GlFeature.Context; using (ctx.MakeCurrent()) { - var fbo = new SizeSynchronizedLayerFbo(ctx.Context, _layer); + var fbo = new SizeSynchronizedLayerFbo(ctx.Context, ctx.GlInterface, _layer); if (!fbo.Sync()) throw new InvalidOperationException("Unable to create render target"); return new RenderTarget(ctx, fbo); diff --git a/src/iOS/Avalonia.iOS/Extensions.cs b/src/iOS/Avalonia.iOS/Extensions.cs index bf6262e5c5..819a1386e8 100644 --- a/src/iOS/Avalonia.iOS/Extensions.cs +++ b/src/iOS/Avalonia.iOS/Extensions.cs @@ -1,6 +1,7 @@ using System; using Avalonia.Media; using CoreGraphics; +using ObjCRuntime; using UIKit; namespace Avalonia.iOS @@ -20,4 +21,4 @@ namespace Avalonia.iOS ColorComponent(color.B), ColorComponent(color.A)); } -} \ No newline at end of file +} diff --git a/src/iOS/Avalonia.iOS/LayerFbo.cs b/src/iOS/Avalonia.iOS/LayerFbo.cs index 907af58c7e..bd05f3b852 100644 --- a/src/iOS/Avalonia.iOS/LayerFbo.cs +++ b/src/iOS/Avalonia.iOS/LayerFbo.cs @@ -1,64 +1,72 @@ using System; +using Avalonia.OpenGL; using CoreAnimation; +using ObjCRuntime; using OpenGLES; -using OpenTK.Graphics.ES20; namespace Avalonia.iOS { public class LayerFbo { private readonly EAGLContext _context; + private readonly GlInterface _gl; private readonly CAEAGLLayer _layer; - private int _framebuffer; - private int _renderbuffer; - private int _depthBuffer; + private int[] _framebuffer; + private int[] _renderbuffer; + private int[] _depthBuffer; private bool _disposed; - private LayerFbo(EAGLContext context, CAEAGLLayer layer, in int framebuffer, in int renderbuffer, in int depthBuffer) + private LayerFbo(EAGLContext context, GlInterface gl, CAEAGLLayer layer, int[] framebuffer, int[] renderbuffer, int[] depthBuffer) { _context = context; + _gl = gl; _layer = layer; _framebuffer = framebuffer; _renderbuffer = renderbuffer; _depthBuffer = depthBuffer; } - public static LayerFbo TryCreate(EAGLContext context, CAEAGLLayer layer) + public static LayerFbo TryCreate(EAGLContext context, GlInterface gl, CAEAGLLayer layer) { if (context != EAGLContext.CurrentContext) return null; - GL.GenFramebuffers(1, out int fb); - GL.GenRenderbuffers(1, out int rb); - GL.BindFramebuffer(FramebufferTarget.Framebuffer, fb); - GL.BindRenderbuffer(RenderbufferTarget.Renderbuffer, rb); - context.RenderBufferStorage((uint) All.Renderbuffer, layer); + + var fb = new int[2]; + var rb = new int[2]; + var db = new int[2]; - GL.FramebufferRenderbuffer(FramebufferTarget.Framebuffer, FramebufferSlot.ColorAttachment0, RenderbufferTarget.Renderbuffer, rb); + gl.GenRenderbuffers(1, rb); + gl.BindRenderbuffer(GlConsts.GL_RENDERBUFFER, rb[0]); + context.RenderBufferStorage(GlConsts.GL_RENDERBUFFER, layer); + + gl.GenFramebuffers(1, fb); + gl.BindFramebuffer(GlConsts.GL_FRAMEBUFFER, fb[0]); + gl.FramebufferRenderbuffer(GlConsts.GL_FRAMEBUFFER, GlConsts.GL_COLOR_ATTACHMENT0, GlConsts.GL_RENDERBUFFER, rb[0]); - int w; - int h; - GL.GetRenderbufferParameter(RenderbufferTarget.Renderbuffer, RenderbufferParameterName.RenderbufferWidth, out w); - GL.GetRenderbufferParameter(RenderbufferTarget.Renderbuffer, RenderbufferParameterName.RenderbufferHeight, out h); + int[] w = new int[1]; + int[] h = new int[1]; + gl.GetRenderbufferParameteriv(GlConsts.GL_RENDERBUFFER, GlConsts.GL_RENDERBUFFER_WIDTH, w); + gl.GetRenderbufferParameteriv(GlConsts.GL_RENDERBUFFER, GlConsts.GL_RENDERBUFFER_HEIGHT, h); - GL.GenRenderbuffers(1, out int depthBuffer); + gl.GenRenderbuffers(1, db); //GL.BindRenderbuffer(RenderbufferTarget.Renderbuffer, depthBuffer); //GL.RenderbufferStorage(RenderbufferTarget.Renderbuffer, RenderbufferInternalFormat.DepthComponent16, w, h); - GL.FramebufferRenderbuffer(FramebufferTarget.Framebuffer, FramebufferSlot.DepthAttachment, RenderbufferTarget.Renderbuffer, depthBuffer); + gl.FramebufferRenderbuffer(GlConsts.GL_FRAMEBUFFER, GlConsts.GL_DEPTH_ATTACHMENT, GlConsts.GL_RENDERBUFFER, db[0]); - var frameBufferError = GL.CheckFramebufferStatus(FramebufferTarget.Framebuffer); - if(frameBufferError != FramebufferErrorCode.FramebufferComplete) + var frameBufferError = gl.CheckFramebufferStatus(GlConsts.GL_FRAMEBUFFER); + if(frameBufferError != GlConsts.GL_FRAMEBUFFER_COMPLETE) { - GL.DeleteFramebuffers(1, ref fb); - GL.DeleteRenderbuffers(1, ref depthBuffer); - GL.DeleteRenderbuffers(1, ref rb); + gl.DeleteFramebuffers(1, fb); + gl.DeleteRenderbuffers(1, db); + gl.DeleteRenderbuffers(1, rb); return null; } - return new LayerFbo(context, layer, fb, rb, depthBuffer) + return new LayerFbo(context, gl, layer, fb, rb, db) { - Width = w, - Height = h + Width = w[0], + Height = h[0] }; } @@ -67,13 +75,13 @@ namespace Avalonia.iOS public void Bind() { - GL.BindFramebuffer(FramebufferTarget.Framebuffer, _framebuffer); + _gl.BindFramebuffer(GlConsts.GL_FRAMEBUFFER, _framebuffer[0]); } public void Present() { Bind(); - var success = _context.PresentRenderBuffer((uint) All.Renderbuffer); + var success = _context.PresentRenderBuffer(GlConsts.GL_RENDERBUFFER); } public void Dispose() @@ -81,9 +89,9 @@ namespace Avalonia.iOS if(_disposed) return; _disposed = true; - GL.DeleteFramebuffers(1, ref _framebuffer); - GL.DeleteRenderbuffers(1, ref _depthBuffer); - GL.DeleteRenderbuffers(1, ref _renderbuffer); + _gl.DeleteFramebuffers(1, _framebuffer); + _gl.DeleteRenderbuffers(1, _depthBuffer); + _gl.DeleteRenderbuffers(1, _renderbuffer); if (_context != EAGLContext.CurrentContext) throw new InvalidOperationException("Associated EAGLContext is not current"); } @@ -92,15 +100,16 @@ namespace Avalonia.iOS class SizeSynchronizedLayerFbo : IDisposable { private readonly EAGLContext _context; + private readonly GlInterface _gl; private readonly CAEAGLLayer _layer; private LayerFbo _fbo; private nfloat _oldLayerWidth, _oldLayerHeight, _oldLayerScale; - public SizeSynchronizedLayerFbo(EAGLContext context, CAEAGLLayer layer) + public SizeSynchronizedLayerFbo(EAGLContext context, GlInterface gl, CAEAGLLayer layer) { _context = context; + _gl = gl; _layer = layer; - } public bool Sync() @@ -112,7 +121,7 @@ namespace Avalonia.iOS return true; _fbo?.Dispose(); _fbo = null; - _fbo = LayerFbo.TryCreate(_context, _layer); + _fbo = LayerFbo.TryCreate(_context, _gl, _layer); _oldLayerWidth = _layer.Bounds.Width; _oldLayerHeight = _layer.Bounds.Height; _oldLayerScale = _layer.ContentsScale; @@ -140,4 +149,4 @@ namespace Avalonia.iOS public int Height => _fbo?.Height ?? 0; public double Scaling => _oldLayerScale; } -} \ No newline at end of file +} From bc1d950a9bc91a131cb337879668f13253701d4a Mon Sep 17 00:00:00 2001 From: Max Katz Date: Wed, 23 Feb 2022 23:04:09 -0500 Subject: [PATCH 05/26] Update legacy projects targets --- src/Android/Avalonia.Android/Avalonia.Android.csproj | 3 ++- src/iOS/Avalonia.iOS/Avalonia.iOS.csproj | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Android/Avalonia.Android/Avalonia.Android.csproj b/src/Android/Avalonia.Android/Avalonia.Android.csproj index 6393ef3405..4fac2fcf21 100644 --- a/src/Android/Avalonia.Android/Avalonia.Android.csproj +++ b/src/Android/Avalonia.Android/Avalonia.Android.csproj @@ -1,6 +1,7 @@  - net6.0-android;monoandroid11.0 + net6.0-android + net6.0-ios;monoandroid11.0 21 true true diff --git a/src/iOS/Avalonia.iOS/Avalonia.iOS.csproj b/src/iOS/Avalonia.iOS/Avalonia.iOS.csproj index f1fef8fd14..1b3a952e8f 100644 --- a/src/iOS/Avalonia.iOS/Avalonia.iOS.csproj +++ b/src/iOS/Avalonia.iOS/Avalonia.iOS.csproj @@ -1,8 +1,9 @@ - + - net6.0-ios - true + net6.0-ios + $(TargetFrameworks);xamarin.ios10 10.0 + true From 9bc881e4a707872b024aabe314769fe8e192ed3a Mon Sep 17 00:00:00 2001 From: Max Katz Date: Wed, 23 Feb 2022 23:12:25 -0500 Subject: [PATCH 06/26] Update iOS control catalog projects --- .gitignore | 1 - Avalonia.sln | 78 ++++++++---- azure-pipelines.yml | 2 +- dirs.proj | 9 +- .../ControlCatalog.iOS.Legacy/AppDelegate.cs | 15 +++ .../AppIcon.appiconset/Contents.json | 117 ++++++++++++++++++ .../ControlCatalog.iOS.Legacy.csproj | 99 +++++++++++++++ .../Entitlements.plist | 6 + samples/ControlCatalog.iOS.Legacy/Info.plist | 43 +++++++ samples/ControlCatalog.iOS.Legacy/Main.cs | 15 +++ .../Resources/LaunchScreen.xib | 43 +++++++ .../ControlCatalog.iOS.csproj | 15 ++- samples/ControlCatalog.iOS/Info.plist | 3 +- 13 files changed, 412 insertions(+), 34 deletions(-) create mode 100644 samples/ControlCatalog.iOS.Legacy/AppDelegate.cs create mode 100644 samples/ControlCatalog.iOS.Legacy/Assets.xcassets/AppIcon.appiconset/Contents.json create mode 100644 samples/ControlCatalog.iOS.Legacy/ControlCatalog.iOS.Legacy.csproj create mode 100644 samples/ControlCatalog.iOS.Legacy/Entitlements.plist create mode 100644 samples/ControlCatalog.iOS.Legacy/Info.plist create mode 100644 samples/ControlCatalog.iOS.Legacy/Main.cs create mode 100644 samples/ControlCatalog.iOS.Legacy/Resources/LaunchScreen.xib diff --git a/.gitignore b/.gitignore index 9b15011929..d7c4cdefde 100644 --- a/.gitignore +++ b/.gitignore @@ -198,7 +198,6 @@ Index/ Logs/ ModuleCache.noindex/ Build/Intermediates.noindex/ -info.plist build-intermediate obj-Direct2D1/ obj-Skia/ diff --git a/Avalonia.sln b/Avalonia.sln index 104245118a..e0b3eaed71 100644 --- a/Avalonia.sln +++ b/Avalonia.sln @@ -95,8 +95,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ControlCatalog", "samples\C EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ControlCatalog.Desktop", "samples\ControlCatalog.Desktop\ControlCatalog.Desktop.csproj", "{2B888490-D14A-4BCA-AB4B-48676FA93C9B}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ControlCatalog.iOS", "samples\ControlCatalog.iOS\ControlCatalog.iOS.csproj", "{57E0455D-D565-44BB-B069-EE1AA20F8337}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Avalonia.DesignerSupport.Tests", "tests\Avalonia.DesignerSupport.Tests\Avalonia.DesignerSupport.Tests.csproj", "{52F55355-D120-42AC-8116-8410A7D602FA}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Avalonia.DesignerSupport.TestApp", "tests\Avalonia.DesignerSupport.TestApp\Avalonia.DesignerSupport.TestApp.csproj", "{F1381F98-4D24-409A-A6C5-1C5B1E08BB08}" @@ -121,7 +119,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Props", "Props", "{F3AC8BC1 build\CoreLibraries.props = build\CoreLibraries.props build\EmbedXaml.props = build\EmbedXaml.props build\HarfBuzzSharp.props = build\HarfBuzzSharp.props - build\iOSWorkarounds.props = build\iOSWorkarounds.props build\JetBrains.Annotations.props = build\JetBrains.Annotations.props build\JetBrains.dotMemoryUnit.props = build\JetBrains.dotMemoryUnit.props build\Magick.NET-Q16-AnyCPU.props = build\Magick.NET-Q16-AnyCPU.props @@ -231,6 +228,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ControlSamples", "samples\S EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Avalonia.PlatformSupport", "src\Avalonia.PlatformSupport\Avalonia.PlatformSupport.csproj", "{E8A597F0-2AB5-4BDA-A235-41162DAF53CF}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ControlCatalog.iOS", "samples\ControlCatalog.iOS\ControlCatalog.iOS.csproj", "{70B9F5CC-E2F9-4314-9514-EDE762ACCC4B}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ControlCatalog.iOS.Legacy", "samples\ControlCatalog.iOS.Legacy\ControlCatalog.iOS.Legacy.csproj", "{3AF75F00-B497-4517-9491-922173DE216E}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Ad-Hoc|Any CPU = Ad-Hoc|Any CPU @@ -1093,26 +1094,6 @@ Global {2B888490-D14A-4BCA-AB4B-48676FA93C9B}.Release|iPhone.Build.0 = Release|Any CPU {2B888490-D14A-4BCA-AB4B-48676FA93C9B}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU {2B888490-D14A-4BCA-AB4B-48676FA93C9B}.Release|iPhoneSimulator.Build.0 = Release|Any CPU - {57E0455D-D565-44BB-B069-EE1AA20F8337}.Ad-Hoc|Any CPU.ActiveCfg = Ad-Hoc|iPhone - {57E0455D-D565-44BB-B069-EE1AA20F8337}.Ad-Hoc|iPhone.ActiveCfg = Ad-Hoc|iPhone - {57E0455D-D565-44BB-B069-EE1AA20F8337}.Ad-Hoc|iPhone.Build.0 = Ad-Hoc|iPhone - {57E0455D-D565-44BB-B069-EE1AA20F8337}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Ad-Hoc|iPhoneSimulator - {57E0455D-D565-44BB-B069-EE1AA20F8337}.Ad-Hoc|iPhoneSimulator.Build.0 = Ad-Hoc|iPhoneSimulator - {57E0455D-D565-44BB-B069-EE1AA20F8337}.AppStore|Any CPU.ActiveCfg = AppStore|iPhone - {57E0455D-D565-44BB-B069-EE1AA20F8337}.AppStore|iPhone.ActiveCfg = AppStore|iPhone - {57E0455D-D565-44BB-B069-EE1AA20F8337}.AppStore|iPhone.Build.0 = AppStore|iPhone - {57E0455D-D565-44BB-B069-EE1AA20F8337}.AppStore|iPhoneSimulator.ActiveCfg = AppStore|iPhoneSimulator - {57E0455D-D565-44BB-B069-EE1AA20F8337}.AppStore|iPhoneSimulator.Build.0 = AppStore|iPhoneSimulator - {57E0455D-D565-44BB-B069-EE1AA20F8337}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {57E0455D-D565-44BB-B069-EE1AA20F8337}.Debug|iPhone.ActiveCfg = Debug|iPhone - {57E0455D-D565-44BB-B069-EE1AA20F8337}.Debug|iPhone.Build.0 = Debug|iPhone - {57E0455D-D565-44BB-B069-EE1AA20F8337}.Debug|iPhoneSimulator.ActiveCfg = Debug|iPhoneSimulator - {57E0455D-D565-44BB-B069-EE1AA20F8337}.Debug|iPhoneSimulator.Build.0 = Debug|iPhoneSimulator - {57E0455D-D565-44BB-B069-EE1AA20F8337}.Release|Any CPU.ActiveCfg = Release|iPhone - {57E0455D-D565-44BB-B069-EE1AA20F8337}.Release|iPhone.ActiveCfg = Release|iPhone - {57E0455D-D565-44BB-B069-EE1AA20F8337}.Release|iPhone.Build.0 = Release|iPhone - {57E0455D-D565-44BB-B069-EE1AA20F8337}.Release|iPhoneSimulator.ActiveCfg = Release|iPhoneSimulator - {57E0455D-D565-44BB-B069-EE1AA20F8337}.Release|iPhoneSimulator.Build.0 = Release|iPhoneSimulator {52F55355-D120-42AC-8116-8410A7D602FA}.Ad-Hoc|Any CPU.ActiveCfg = Release|Any CPU {52F55355-D120-42AC-8116-8410A7D602FA}.Ad-Hoc|Any CPU.Build.0 = Release|Any CPU {52F55355-D120-42AC-8116-8410A7D602FA}.Ad-Hoc|iPhone.ActiveCfg = Release|Any CPU @@ -2157,6 +2138,54 @@ Global {E8A597F0-2AB5-4BDA-A235-41162DAF53CF}.Release|iPhone.Build.0 = Release|Any CPU {E8A597F0-2AB5-4BDA-A235-41162DAF53CF}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU {E8A597F0-2AB5-4BDA-A235-41162DAF53CF}.Release|iPhoneSimulator.Build.0 = Release|Any CPU + {70B9F5CC-E2F9-4314-9514-EDE762ACCC4B}.Ad-Hoc|Any CPU.ActiveCfg = Debug|Any CPU + {70B9F5CC-E2F9-4314-9514-EDE762ACCC4B}.Ad-Hoc|Any CPU.Build.0 = Debug|Any CPU + {70B9F5CC-E2F9-4314-9514-EDE762ACCC4B}.Ad-Hoc|iPhone.ActiveCfg = Debug|Any CPU + {70B9F5CC-E2F9-4314-9514-EDE762ACCC4B}.Ad-Hoc|iPhone.Build.0 = Debug|Any CPU + {70B9F5CC-E2F9-4314-9514-EDE762ACCC4B}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {70B9F5CC-E2F9-4314-9514-EDE762ACCC4B}.Ad-Hoc|iPhoneSimulator.Build.0 = Debug|Any CPU + {70B9F5CC-E2F9-4314-9514-EDE762ACCC4B}.AppStore|Any CPU.ActiveCfg = Debug|Any CPU + {70B9F5CC-E2F9-4314-9514-EDE762ACCC4B}.AppStore|Any CPU.Build.0 = Debug|Any CPU + {70B9F5CC-E2F9-4314-9514-EDE762ACCC4B}.AppStore|iPhone.ActiveCfg = Debug|Any CPU + {70B9F5CC-E2F9-4314-9514-EDE762ACCC4B}.AppStore|iPhone.Build.0 = Debug|Any CPU + {70B9F5CC-E2F9-4314-9514-EDE762ACCC4B}.AppStore|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {70B9F5CC-E2F9-4314-9514-EDE762ACCC4B}.AppStore|iPhoneSimulator.Build.0 = Debug|Any CPU + {70B9F5CC-E2F9-4314-9514-EDE762ACCC4B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {70B9F5CC-E2F9-4314-9514-EDE762ACCC4B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {70B9F5CC-E2F9-4314-9514-EDE762ACCC4B}.Debug|iPhone.ActiveCfg = Debug|Any CPU + {70B9F5CC-E2F9-4314-9514-EDE762ACCC4B}.Debug|iPhone.Build.0 = Debug|Any CPU + {70B9F5CC-E2F9-4314-9514-EDE762ACCC4B}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {70B9F5CC-E2F9-4314-9514-EDE762ACCC4B}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU + {70B9F5CC-E2F9-4314-9514-EDE762ACCC4B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {70B9F5CC-E2F9-4314-9514-EDE762ACCC4B}.Release|Any CPU.Build.0 = Release|Any CPU + {70B9F5CC-E2F9-4314-9514-EDE762ACCC4B}.Release|iPhone.ActiveCfg = Release|Any CPU + {70B9F5CC-E2F9-4314-9514-EDE762ACCC4B}.Release|iPhone.Build.0 = Release|Any CPU + {70B9F5CC-E2F9-4314-9514-EDE762ACCC4B}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU + {70B9F5CC-E2F9-4314-9514-EDE762ACCC4B}.Release|iPhoneSimulator.Build.0 = Release|Any CPU + {3AF75F00-B497-4517-9491-922173DE216E}.Ad-Hoc|Any CPU.ActiveCfg = Debug|Any CPU + {3AF75F00-B497-4517-9491-922173DE216E}.Ad-Hoc|Any CPU.Build.0 = Debug|Any CPU + {3AF75F00-B497-4517-9491-922173DE216E}.Ad-Hoc|iPhone.ActiveCfg = Debug|Any CPU + {3AF75F00-B497-4517-9491-922173DE216E}.Ad-Hoc|iPhone.Build.0 = Debug|Any CPU + {3AF75F00-B497-4517-9491-922173DE216E}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {3AF75F00-B497-4517-9491-922173DE216E}.Ad-Hoc|iPhoneSimulator.Build.0 = Debug|Any CPU + {3AF75F00-B497-4517-9491-922173DE216E}.AppStore|Any CPU.ActiveCfg = Debug|Any CPU + {3AF75F00-B497-4517-9491-922173DE216E}.AppStore|Any CPU.Build.0 = Debug|Any CPU + {3AF75F00-B497-4517-9491-922173DE216E}.AppStore|iPhone.ActiveCfg = Debug|Any CPU + {3AF75F00-B497-4517-9491-922173DE216E}.AppStore|iPhone.Build.0 = Debug|Any CPU + {3AF75F00-B497-4517-9491-922173DE216E}.AppStore|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {3AF75F00-B497-4517-9491-922173DE216E}.AppStore|iPhoneSimulator.Build.0 = Debug|Any CPU + {3AF75F00-B497-4517-9491-922173DE216E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3AF75F00-B497-4517-9491-922173DE216E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3AF75F00-B497-4517-9491-922173DE216E}.Debug|iPhone.ActiveCfg = Debug|Any CPU + {3AF75F00-B497-4517-9491-922173DE216E}.Debug|iPhone.Build.0 = Debug|Any CPU + {3AF75F00-B497-4517-9491-922173DE216E}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {3AF75F00-B497-4517-9491-922173DE216E}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU + {3AF75F00-B497-4517-9491-922173DE216E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3AF75F00-B497-4517-9491-922173DE216E}.Release|Any CPU.Build.0 = Release|Any CPU + {3AF75F00-B497-4517-9491-922173DE216E}.Release|iPhone.ActiveCfg = Release|Any CPU + {3AF75F00-B497-4517-9491-922173DE216E}.Release|iPhone.Build.0 = Release|Any CPU + {3AF75F00-B497-4517-9491-922173DE216E}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU + {3AF75F00-B497-4517-9491-922173DE216E}.Release|iPhoneSimulator.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -2186,7 +2215,6 @@ Global {410AC439-81A1-4EB5-B5E9-6A7FC6B77F4B} = {C5A00AC3-B34C-4564-9BDD-2DA473EF4D8B} {D0A739B9-3C68-4BA6-A328-41606954B6BD} = {9B9E3891-2366-4253-A952-D08BCEB71098} {2B888490-D14A-4BCA-AB4B-48676FA93C9B} = {9B9E3891-2366-4253-A952-D08BCEB71098} - {57E0455D-D565-44BB-B069-EE1AA20F8337} = {9B9E3891-2366-4253-A952-D08BCEB71098} {52F55355-D120-42AC-8116-8410A7D602FA} = {C5A00AC3-B34C-4564-9BDD-2DA473EF4D8B} {F1381F98-4D24-409A-A6C5-1C5B1E08BB08} = {C5A00AC3-B34C-4564-9BDD-2DA473EF4D8B} {FBCAF3D0-2808-4934-8E96-3F607594517B} = {9B9E3891-2366-4253-A952-D08BCEB71098} @@ -2218,6 +2246,8 @@ Global {C08E9894-AA92-426E-BF56-033E262CAD3E} = {9B9E3891-2366-4253-A952-D08BCEB71098} {26A98DA1-D89D-4A95-8152-349F404DA2E2} = {A0CC0258-D18C-4AB3-854F-7101680FC3F9} {A0D0A6A4-5C72-4ADA-9B27-621C7D94F270} = {9B9E3891-2366-4253-A952-D08BCEB71098} + {70B9F5CC-E2F9-4314-9514-EDE762ACCC4B} = {9B9E3891-2366-4253-A952-D08BCEB71098} + {3AF75F00-B497-4517-9491-922173DE216E} = {9B9E3891-2366-4253-A952-D08BCEB71098} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {87366D66-1391-4D90-8999-95A620AD786A} diff --git a/azure-pipelines.yml b/azure-pipelines.yml index ede5aec0e8..ddb47c67db 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -147,7 +147,7 @@ jobs: displayName: 'Install Workloads' inputs: script: | - dotnet workload install android + dotnet workload install android ios - task: CmdLine@2 displayName: 'Install Nuke' diff --git a/dirs.proj b/dirs.proj index 74d7b482cc..396e0c915c 100644 --- a/dirs.proj +++ b/dirs.proj @@ -10,21 +10,20 @@ + + - - - - - + + diff --git a/samples/ControlCatalog.iOS.Legacy/AppDelegate.cs b/samples/ControlCatalog.iOS.Legacy/AppDelegate.cs new file mode 100644 index 0000000000..a67de98259 --- /dev/null +++ b/samples/ControlCatalog.iOS.Legacy/AppDelegate.cs @@ -0,0 +1,15 @@ +using Avalonia.iOS; +using Foundation; +using UIKit; + +namespace ControlCatalog.iOS.Legacy +{ + // The UIApplicationDelegate for the application. This class is responsible for launching the + // User Interface of the application, as well as listening (and optionally responding) to + // application events from iOS. + [Register("AppDelegate")] + public partial class AppDelegate : AvaloniaAppDelegate + { + + } +} diff --git a/samples/ControlCatalog.iOS.Legacy/Assets.xcassets/AppIcon.appiconset/Contents.json b/samples/ControlCatalog.iOS.Legacy/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000000..98f4d035c8 --- /dev/null +++ b/samples/ControlCatalog.iOS.Legacy/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,117 @@ +{ + "images": [ + { + "scale": "2x", + "size": "20x20", + "idiom": "iphone", + "filename": "Icon40.png" + }, + { + "scale": "3x", + "size": "20x20", + "idiom": "iphone", + "filename": "Icon60.png" + }, + { + "scale": "2x", + "size": "29x29", + "idiom": "iphone", + "filename": "Icon58.png" + }, + { + "scale": "3x", + "size": "29x29", + "idiom": "iphone", + "filename": "Icon87.png" + }, + { + "scale": "2x", + "size": "40x40", + "idiom": "iphone", + "filename": "Icon80.png" + }, + { + "scale": "3x", + "size": "40x40", + "idiom": "iphone", + "filename": "Icon120.png" + }, + { + "scale": "2x", + "size": "60x60", + "idiom": "iphone", + "filename": "Icon120.png" + }, + { + "scale": "3x", + "size": "60x60", + "idiom": "iphone", + "filename": "Icon180.png" + }, + { + "scale": "1x", + "size": "20x20", + "idiom": "ipad", + "filename": "Icon20.png" + }, + { + "scale": "2x", + "size": "20x20", + "idiom": "ipad", + "filename": "Icon40.png" + }, + { + "scale": "1x", + "size": "29x29", + "idiom": "ipad", + "filename": "Icon29.png" + }, + { + "scale": "2x", + "size": "29x29", + "idiom": "ipad", + "filename": "Icon58.png" + }, + { + "scale": "1x", + "size": "40x40", + "idiom": "ipad", + "filename": "Icon40.png" + }, + { + "scale": "2x", + "size": "40x40", + "idiom": "ipad", + "filename": "Icon80.png" + }, + { + "scale": "1x", + "size": "76x76", + "idiom": "ipad", + "filename": "Icon76.png" + }, + { + "scale": "2x", + "size": "76x76", + "idiom": "ipad", + "filename": "Icon152.png" + }, + { + "scale": "2x", + "size": "83.5x83.5", + "idiom": "ipad", + "filename": "Icon167.png" + }, + { + "scale": "1x", + "size": "1024x1024", + "idiom": "ios-marketing", + "filename": "Icon1024.png" + } + ], + "properties": {}, + "info": { + "version": 1, + "author": "xcode" + } +} \ No newline at end of file diff --git a/samples/ControlCatalog.iOS.Legacy/ControlCatalog.iOS.Legacy.csproj b/samples/ControlCatalog.iOS.Legacy/ControlCatalog.iOS.Legacy.csproj new file mode 100644 index 0000000000..045114ff5a --- /dev/null +++ b/samples/ControlCatalog.iOS.Legacy/ControlCatalog.iOS.Legacy.csproj @@ -0,0 +1,99 @@ + + + xamarin.ios10 + 15.0 + true + Debug + iPhoneSimulator + {3AF75F00-B497-4517-9491-922173DE216E} + {FEACFBD2-3405-455C-9665-78FE426C6842};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + Exe + ControlCatalog.iOS.Legacy + Resources + ControlCatalog.iOS.Legacy + NSUrlSessionHandler + manual + -all + + + true + full + false + bin\iPhoneSimulator\Debug + DEBUG + prompt + 4 + false + x86_64 + None + true + + + none + true + bin\iPhoneSimulator\Release + prompt + 4 + None + x86_64 + false + + + true + full + false + bin\iPhone\Debug + DEBUG + prompt + 4 + false + ARM64 + Entitlements.plist + true + + + none + true + bin\iPhone\Release + prompt + 4 + Entitlements.plist + ARM64 + false + + + + + + + + + + + + + + false + + + + + + + + {d2221c82-4a25-4583-9b43-d791e3f6820c} + Avalonia.Controls + + + {4488ad85-1495-4809-9aa4-ddfe0a48527e} + Avalonia.iOS + + + {d0a739b9-3c68-4ba6-a328-41606954b6bd} + ControlCatalog + + + + + + diff --git a/samples/ControlCatalog.iOS.Legacy/Entitlements.plist b/samples/ControlCatalog.iOS.Legacy/Entitlements.plist new file mode 100644 index 0000000000..36a8706706 --- /dev/null +++ b/samples/ControlCatalog.iOS.Legacy/Entitlements.plist @@ -0,0 +1,6 @@ + + + + + + diff --git a/samples/ControlCatalog.iOS.Legacy/Info.plist b/samples/ControlCatalog.iOS.Legacy/Info.plist new file mode 100644 index 0000000000..45dbd05726 --- /dev/null +++ b/samples/ControlCatalog.iOS.Legacy/Info.plist @@ -0,0 +1,43 @@ + + + + + CFBundleDisplayName + ControlCatalog + CFBundleIdentifier + com.companyname.ControlCatalog.iOS + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1.0 + LSRequiresIPhoneOS + + MinimumOSVersion + 15.0 + UIDeviceFamily + + 12 + + UILaunchStoryboardName + LaunchScreen + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + XSAppIconAssets + Assets.xcassets/AppIcon.appiconset + + diff --git a/samples/ControlCatalog.iOS.Legacy/Main.cs b/samples/ControlCatalog.iOS.Legacy/Main.cs new file mode 100644 index 0000000000..08b3831d73 --- /dev/null +++ b/samples/ControlCatalog.iOS.Legacy/Main.cs @@ -0,0 +1,15 @@ +using UIKit; + +namespace ControlCatalog.iOS.Legacy +{ + public class Application + { + // This is the main entry point of the application. + static void Main(string[] args) + { + // if you want to use a different Application Delegate class from "AppDelegate" + // you can specify it here. + UIApplication.Main(args, null, "AppDelegate"); + } + } +} diff --git a/samples/ControlCatalog.iOS.Legacy/Resources/LaunchScreen.xib b/samples/ControlCatalog.iOS.Legacy/Resources/LaunchScreen.xib new file mode 100644 index 0000000000..35c3013b0e --- /dev/null +++ b/samples/ControlCatalog.iOS.Legacy/Resources/LaunchScreen.xib @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/samples/ControlCatalog.iOS/ControlCatalog.iOS.csproj b/samples/ControlCatalog.iOS/ControlCatalog.iOS.csproj index 409223fa81..ec3d304c34 100644 --- a/samples/ControlCatalog.iOS/ControlCatalog.iOS.csproj +++ b/samples/ControlCatalog.iOS/ControlCatalog.iOS.csproj @@ -1,11 +1,22 @@ - + + Exe + manual net6.0-ios - 14.2 + 10.0 + + True + iossimulator-x64 + + + + + + diff --git a/samples/ControlCatalog.iOS/Info.plist b/samples/ControlCatalog.iOS/Info.plist index 216fd9c333..144cb165ab 100644 --- a/samples/ControlCatalog.iOS/Info.plist +++ b/samples/ControlCatalog.iOS/Info.plist @@ -13,7 +13,7 @@ LSRequiresIPhoneOS MinimumOSVersion - 8.0 + 10.0 UIDeviceFamily 1 @@ -28,6 +28,7 @@ UISupportedInterfaceOrientations UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight From 6d506a65b6c70e32317011812c5fb1adf78b382d Mon Sep 17 00:00:00 2001 From: Max Katz Date: Wed, 23 Feb 2022 23:52:34 -0500 Subject: [PATCH 07/26] Add UnmanagedFunctionPointer --- src/Avalonia.OpenGL/Egl/EglInterface.cs | 46 +++++++-- src/Avalonia.OpenGL/GlBasicInfoInterface.cs | 5 +- src/Avalonia.OpenGL/GlInterface.cs | 105 +++++++++++++++----- 3 files changed, 120 insertions(+), 36 deletions(-) diff --git a/src/Avalonia.OpenGL/Egl/EglInterface.cs b/src/Avalonia.OpenGL/Egl/EglInterface.cs index cadd7cc1f2..6148e58440 100644 --- a/src/Avalonia.OpenGL/Egl/EglInterface.cs +++ b/src/Avalonia.OpenGL/Egl/EglInterface.cs @@ -46,93 +46,114 @@ namespace Avalonia.OpenGL.Egl } // ReSharper disable UnassignedGetOnlyAutoProperty + [UnmanagedFunctionPointer(CallingConvention.StdCall)] public delegate int EglGetError(); [GlEntryPoint("eglGetError")] public EglGetError GetError { get; } + [UnmanagedFunctionPointer(CallingConvention.StdCall)] public delegate IntPtr EglGetDisplay(IntPtr nativeDisplay); [GlEntryPoint("eglGetDisplay")] public EglGetDisplay GetDisplay { get; } - + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] public delegate IntPtr EglGetPlatformDisplayEXT(int platform, IntPtr nativeDisplay, int[] attrs); [GlEntryPoint("eglGetPlatformDisplayEXT")] [GlOptionalEntryPoint] public EglGetPlatformDisplayEXT GetPlatformDisplayEXT { get; } + [UnmanagedFunctionPointer(CallingConvention.StdCall)] public delegate bool EglInitialize(IntPtr display, out int major, out int minor); [GlEntryPoint("eglInitialize")] - public EglInitialize Initialize { get; } - + public EglInitialize Initialize { get; } + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] public delegate IntPtr EglGetProcAddress(Utf8Buffer proc); [GlEntryPoint("eglGetProcAddress")] public EglGetProcAddress GetProcAddress { get; } + [UnmanagedFunctionPointer(CallingConvention.StdCall)] public delegate bool EglBindApi(int api); [GlEntryPoint("eglBindAPI")] public EglBindApi BindApi { get; } + [UnmanagedFunctionPointer(CallingConvention.StdCall)] public delegate bool EglChooseConfig(IntPtr display, int[] attribs, out IntPtr surfaceConfig, int numConfigs, out int choosenConfig); [GlEntryPoint("eglChooseConfig")] public EglChooseConfig ChooseConfig { get; } + [UnmanagedFunctionPointer(CallingConvention.StdCall)] public delegate IntPtr EglCreateContext(IntPtr display, IntPtr config, IntPtr share, int[] attrs); [GlEntryPoint("eglCreateContext")] public EglCreateContext CreateContext { get; } - + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] public delegate bool EglDestroyContext(IntPtr display, IntPtr context); [GlEntryPoint("eglDestroyContext")] public EglDestroyContext DestroyContext { get; } + [UnmanagedFunctionPointer(CallingConvention.StdCall)] public delegate IntPtr EglCreatePBufferSurface(IntPtr display, IntPtr config, int[] attrs); [GlEntryPoint("eglCreatePbufferSurface")] public EglCreatePBufferSurface CreatePBufferSurface { get; } + [UnmanagedFunctionPointer(CallingConvention.StdCall)] public delegate bool EglMakeCurrent(IntPtr display, IntPtr draw, IntPtr read, IntPtr context); [GlEntryPoint("eglMakeCurrent")] public EglMakeCurrent MakeCurrent { get; } + [UnmanagedFunctionPointer(CallingConvention.StdCall)] public delegate IntPtr EglGetCurrentContext(); [GlEntryPoint("eglGetCurrentContext")] public EglGetCurrentContext GetCurrentContext { get; } - + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] public delegate IntPtr EglGetCurrentDisplay(); [GlEntryPoint("eglGetCurrentDisplay")] public EglGetCurrentContext GetCurrentDisplay { get; } + [UnmanagedFunctionPointer(CallingConvention.StdCall)] public delegate IntPtr EglGetCurrentSurface(int readDraw); [GlEntryPoint("eglGetCurrentSurface")] public EglGetCurrentSurface GetCurrentSurface { get; } + [UnmanagedFunctionPointer(CallingConvention.StdCall)] public delegate void EglDisplaySurfaceVoidDelegate(IntPtr display, IntPtr surface); [GlEntryPoint("eglDestroySurface")] public EglDisplaySurfaceVoidDelegate DestroySurface { get; } [GlEntryPoint("eglSwapBuffers")] public EglDisplaySurfaceVoidDelegate SwapBuffers { get; } - + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] public delegate IntPtr EglCreateWindowSurface(IntPtr display, IntPtr config, IntPtr window, int[] attrs); [GlEntryPoint("eglCreateWindowSurface")] public EglCreateWindowSurface CreateWindowSurface { get; } + [UnmanagedFunctionPointer(CallingConvention.StdCall)] public delegate bool EglGetConfigAttrib(IntPtr display, IntPtr config, int attr, out int rv); [GlEntryPoint("eglGetConfigAttrib")] public EglGetConfigAttrib GetConfigAttrib { get; } + [UnmanagedFunctionPointer(CallingConvention.StdCall)] public delegate bool EglWaitGL(); [GlEntryPoint("eglWaitGL")] public EglWaitGL WaitGL { get; } - + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] public delegate bool EglWaitClient(); [GlEntryPoint("eglWaitClient")] public EglWaitGL WaitClient { get; } - + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] public delegate bool EglWaitNative(int engine); [GlEntryPoint("eglWaitNative")] public EglWaitNative WaitNative { get; } - + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] public delegate IntPtr EglQueryString(IntPtr display, int i); [GlEntryPoint("eglQueryString")] @@ -145,17 +166,20 @@ namespace Avalonia.OpenGL.Egl return null; return Marshal.PtrToStringAnsi(rv); } - + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] public delegate IntPtr EglCreatePbufferFromClientBuffer(IntPtr display, int buftype, IntPtr buffer, IntPtr config, int[] attrib_list); [GlEntryPoint("eglCreatePbufferFromClientBuffer")] public EglCreatePbufferFromClientBuffer CreatePbufferFromClientBuffer { get; } - + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] public delegate bool EglQueryDisplayAttribEXT(IntPtr display, int attr, out IntPtr res); [GlEntryPoint("eglQueryDisplayAttribEXT"), GlOptionalEntryPoint] public EglQueryDisplayAttribEXT QueryDisplayAttribExt { get; } + [UnmanagedFunctionPointer(CallingConvention.StdCall)] public delegate bool EglQueryDeviceAttribEXT(IntPtr display, int attr, out IntPtr res); [GlEntryPoint("eglQueryDeviceAttribEXT"), GlOptionalEntryPoint] diff --git a/src/Avalonia.OpenGL/GlBasicInfoInterface.cs b/src/Avalonia.OpenGL/GlBasicInfoInterface.cs index a3383ac5ae..aaba2ec09c 100644 --- a/src/Avalonia.OpenGL/GlBasicInfoInterface.cs +++ b/src/Avalonia.OpenGL/GlBasicInfoInterface.cs @@ -15,9 +15,12 @@ namespace Avalonia.OpenGL public GlBasicInfoInterface(Func nativeGetProcAddress) : base(nativeGetProcAddress, null) { } - + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] public delegate void GlGetIntegerv(int name, out int rv); + [UnmanagedFunctionPointer(CallingConvention.StdCall)] public delegate IntPtr GlGetString(int v); + [UnmanagedFunctionPointer(CallingConvention.StdCall)] public delegate IntPtr GlGetStringi(int v, int v1); } diff --git a/src/Avalonia.OpenGL/GlInterface.cs b/src/Avalonia.OpenGL/GlInterface.cs index cae245732f..3d947998af 100644 --- a/src/Avalonia.OpenGL/GlInterface.cs +++ b/src/Avalonia.OpenGL/GlInterface.cs @@ -60,22 +60,27 @@ namespace Avalonia.OpenGL public T GetProcAddress(string proc) => Marshal.GetDelegateForFunctionPointer(GetProcAddress(proc)); // ReSharper disable UnassignedGetOnlyAutoProperty + [UnmanagedFunctionPointer(CallingConvention.StdCall)] public delegate int GlGetError(); [GlEntryPoint("glGetError")] public GlGetError GetError { get; } + [UnmanagedFunctionPointer(CallingConvention.StdCall)] public delegate void GlClearStencil(int s); [GlEntryPoint("glClearStencil")] public GlClearStencil ClearStencil { get; } + [UnmanagedFunctionPointer(CallingConvention.StdCall)] public delegate void GlClearColor(float r, float g, float b, float a); [GlEntryPoint("glClearColor")] public GlClearColor ClearColor { get; } + [UnmanagedFunctionPointer(CallingConvention.StdCall)] public delegate void GlClear(int bits); [GlEntryPoint("glClear")] public GlClear Clear { get; } + [UnmanagedFunctionPointer(CallingConvention.StdCall)] public delegate void GlViewport(int x, int y, int width, int height); [GlEntryPoint("glViewport")] public GlViewport Viewport { get; } @@ -86,6 +91,7 @@ namespace Avalonia.OpenGL [GlEntryPoint("glFinish")] public Action Finish { get; } + [UnmanagedFunctionPointer(CallingConvention.StdCall)] public delegate IntPtr GlGetString(int v); [GlEntryPoint("glGetString")] public GlGetString GetStringNative { get; } @@ -98,26 +104,32 @@ namespace Avalonia.OpenGL return null; } + [UnmanagedFunctionPointer(CallingConvention.StdCall)] public delegate void GlGetIntegerv(int name, out int rv); [GlEntryPoint("glGetIntegerv")] public GlGetIntegerv GetIntegerv { get; } + [UnmanagedFunctionPointer(CallingConvention.StdCall)] public delegate void GlGenFramebuffers(int count, int[] res); [GlEntryPoint("glGenFramebuffers")] public GlGenFramebuffers GenFramebuffers { get; } - + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] public delegate void GlDeleteFramebuffers(int count, int[] framebuffers); [GlEntryPoint("glDeleteFramebuffers")] public GlDeleteFramebuffers DeleteFramebuffers { get; } - + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] public delegate void GlBindFramebuffer(int target, int fb); [GlEntryPoint("glBindFramebuffer")] public GlBindFramebuffer BindFramebuffer { get; } - + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] public delegate int GlCheckFramebufferStatus(int target); [GlEntryPoint("glCheckFramebufferStatus")] public GlCheckFramebufferStatus CheckFramebufferStatus { get; } + [UnmanagedFunctionPointer(CallingConvention.StdCall)] public delegate void GlBlitFramebuffer(int srcX0, int srcY0, int srcX1, @@ -130,69 +142,84 @@ namespace Avalonia.OpenGL int filter); [GlMinVersionEntryPoint("glBlitFramebuffer", 3, 0), GlOptionalEntryPoint] public GlBlitFramebuffer BlitFramebuffer { get; } - + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] public delegate void GlGenRenderbuffers(int count, int[] res); [GlEntryPoint("glGenRenderbuffers")] public GlGenRenderbuffers GenRenderbuffers { get; } - + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] public delegate void GlDeleteRenderbuffers(int count, int[] renderbuffers); [GlEntryPoint("glDeleteRenderbuffers")] public GlDeleteTextures DeleteRenderbuffers { get; } - + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] public delegate void GlBindRenderbuffer(int target, int fb); [GlEntryPoint("glBindRenderbuffer")] public GlBindRenderbuffer BindRenderbuffer { get; } - + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] public delegate void GlRenderbufferStorage(int target, int internalFormat, int width, int height); [GlEntryPoint("glRenderbufferStorage")] public GlRenderbufferStorage RenderbufferStorage { get; } + [UnmanagedFunctionPointer(CallingConvention.StdCall)] public delegate void GlFramebufferRenderbuffer(int target, int attachment, int renderbufferTarget, int renderbuffer); [GlEntryPoint("glFramebufferRenderbuffer")] public GlFramebufferRenderbuffer FramebufferRenderbuffer { get; } - + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] public delegate void GlGenTextures(int count, int[] res); [GlEntryPoint("glGenTextures")] public GlGenTextures GenTextures { get; } - + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] public delegate void GlBindTexture(int target, int fb); [GlEntryPoint("glBindTexture")] public GlBindTexture BindTexture { get; } - + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] public delegate void GlActiveTexture(int texture); [GlEntryPoint("glActiveTexture")] public GlActiveTexture ActiveTexture { get; } - + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] public delegate void GlDeleteTextures(int count, int[] textures); [GlEntryPoint("glDeleteTextures")] public GlDeleteTextures DeleteTextures { get; } + [UnmanagedFunctionPointer(CallingConvention.StdCall)] public delegate void GlTexImage2D(int target, int level, int internalFormat, int width, int height, int border, int format, int type, IntPtr data); [GlEntryPoint("glTexImage2D")] public GlTexImage2D TexImage2D { get; } + [UnmanagedFunctionPointer(CallingConvention.StdCall)] public delegate void GlCopyTexSubImage2D(int target, int level, int xoffset, int yoffset, int x, int y, int width, int height); [GlEntryPoint("glCopyTexSubImage2D")] public GlCopyTexSubImage2D CopyTexSubImage2D { get; } + [UnmanagedFunctionPointer(CallingConvention.StdCall)] public delegate void GlTexParameteri(int target, int name, int value); [GlEntryPoint("glTexParameteri")] public GlTexParameteri TexParameteri { get; } + [UnmanagedFunctionPointer(CallingConvention.StdCall)] public delegate void GlFramebufferTexture2D(int target, int attachment, int texTarget, int texture, int level); [GlEntryPoint("glFramebufferTexture2D")] public GlFramebufferTexture2D FramebufferTexture2D { get; } - + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] public delegate int GlCreateShader(int shaderType); [GlEntryPoint("glCreateShader")] public GlCreateShader CreateShader { get; } + [UnmanagedFunctionPointer(CallingConvention.StdCall)] public delegate void GlShaderSource(int shader, int count, IntPtr strings, IntPtr lengths); [GlEntryPoint("glShaderSource")] public GlShaderSource ShaderSource { get; } @@ -207,14 +234,17 @@ namespace Avalonia.OpenGL } } + [UnmanagedFunctionPointer(CallingConvention.StdCall)] public delegate void GlCompileShader(int shader); [GlEntryPoint("glCompileShader")] public GlCompileShader CompileShader { get; } - + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] public delegate void GlGetShaderiv(int shader, int name, int* parameters); [GlEntryPoint("glGetShaderiv")] public GlGetShaderiv GetShaderiv { get; } + [UnmanagedFunctionPointer(CallingConvention.StdCall)] public delegate void GlGetShaderInfoLog(int shader, int maxLength, out int length, void*infoLog); [GlEntryPoint("glGetShaderInfoLog")] public GlGetShaderInfoLog GetShaderInfoLog { get; } @@ -237,23 +267,28 @@ namespace Avalonia.OpenGL GetShaderInfoLog(shader, logLength, out len, ptr); return Encoding.UTF8.GetString(logData,0, len); } - + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] public delegate int GlCreateProgram(); [GlEntryPoint("glCreateProgram")] public GlCreateProgram CreateProgram { get; } + [UnmanagedFunctionPointer(CallingConvention.StdCall)] public delegate void GlAttachShader(int program, int shader); [GlEntryPoint("glAttachShader")] public GlAttachShader AttachShader { get; } + [UnmanagedFunctionPointer(CallingConvention.StdCall)] public delegate void GlLinkProgram(int program); [GlEntryPoint("glLinkProgram")] public GlLinkProgram LinkProgram { get; } - + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] public delegate void GlGetProgramiv(int program, int name, int* parameters); [GlEntryPoint("glGetProgramiv")] public GlGetProgramiv GetProgramiv { get; } + [UnmanagedFunctionPointer(CallingConvention.StdCall)] public delegate void GlGetProgramInfoLog(int program, int maxLength, out int len, void* infoLog); [GlEntryPoint("glGetProgramInfoLog")] public GlGetProgramInfoLog GetProgramInfoLog { get; } @@ -274,6 +309,7 @@ namespace Avalonia.OpenGL return Encoding.UTF8.GetString(logData,0, len); } + [UnmanagedFunctionPointer(CallingConvention.StdCall)] public delegate void GlBindAttribLocation(int program, int index, IntPtr name); [GlEntryPoint("glBindAttribLocation")] public GlBindAttribLocation BindAttribLocation { get; } @@ -283,7 +319,8 @@ namespace Avalonia.OpenGL using (var b = new Utf8Buffer(name)) BindAttribLocation(program, index, b.DangerousGetHandle()); } - + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] public delegate void GlGenBuffers(int len, int[] rv); [GlEntryPoint("glGenBuffers")] public GlGenBuffers GenBuffers { get; } @@ -294,15 +331,18 @@ namespace Avalonia.OpenGL GenBuffers(1, rv); return rv[0]; } - + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] public delegate void GlBindBuffer(int target, int buffer); [GlEntryPoint("glBindBuffer")] public GlBindBuffer BindBuffer { get; } + [UnmanagedFunctionPointer(CallingConvention.StdCall)] public delegate void GlBufferData(int target, IntPtr size, IntPtr data, int usage); [GlEntryPoint("glBufferData")] public GlBufferData BufferData { get; } - + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] public delegate int GlGetAttribLocation(int program, IntPtr name); [GlEntryPoint("glGetAttribLocation")] public GlGetAttribLocation GetAttribLocation { get; } @@ -313,27 +353,33 @@ namespace Avalonia.OpenGL return GetAttribLocation(program, b.DangerousGetHandle()); } + [UnmanagedFunctionPointer(CallingConvention.StdCall)] public delegate void GlVertexAttribPointer(int index, int size, int type, int normalized, int stride, IntPtr pointer); [GlEntryPoint("glVertexAttribPointer")] public GlVertexAttribPointer VertexAttribPointer { get; } - + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] public delegate void GlEnableVertexAttribArray(int index); [GlEntryPoint("glEnableVertexAttribArray")] public GlEnableVertexAttribArray EnableVertexAttribArray { get; } + [UnmanagedFunctionPointer(CallingConvention.StdCall)] public delegate void GlUseProgram(int program); [GlEntryPoint("glUseProgram")] public GlUseProgram UseProgram { get; } - + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] public delegate void GlDrawArrays(int mode, int first, IntPtr count); [GlEntryPoint("glDrawArrays")] public GlDrawArrays DrawArrays { get; } - + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] public delegate void GlDrawElements(int mode, int count, int type, IntPtr indices); [GlEntryPoint("glDrawElements")] public GlDrawElements DrawElements { get; } + [UnmanagedFunctionPointer(CallingConvention.StdCall)] public delegate int GlGetUniformLocation(int program, IntPtr name); [GlEntryPoint("glGetUniformLocation")] public GlGetUniformLocation GetUniformLocation { get; } @@ -343,31 +389,42 @@ namespace Avalonia.OpenGL using (var b = new Utf8Buffer(name)) return GetUniformLocation(program, b.DangerousGetHandle()); } - + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] public delegate void GlUniform1f(int location, float falue); [GlEntryPoint("glUniform1f")] public GlUniform1f Uniform1f { get; } - + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] public delegate void GlUniformMatrix4fv(int location, int count, bool transpose, void* value); [GlEntryPoint("glUniformMatrix4fv")] public GlUniformMatrix4fv UniformMatrix4fv { get; } - + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] public delegate void GlEnable(int what); [GlEntryPoint("glEnable")] public GlEnable Enable { get; } + [UnmanagedFunctionPointer(CallingConvention.StdCall)] public delegate void GlDeleteBuffers(int count, int[] buffers); [GlEntryPoint("glDeleteBuffers")] public GlDeleteBuffers DeleteBuffers { get; } + [UnmanagedFunctionPointer(CallingConvention.StdCall)] public delegate void GlDeleteProgram(int program); [GlEntryPoint("glDeleteProgram")] public GlDeleteProgram DeleteProgram { get; } + [UnmanagedFunctionPointer(CallingConvention.StdCall)] public delegate void GlDeleteShader(int shader); [GlEntryPoint("glDeleteShader")] public GlDeleteShader DeleteShader { get; } + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + public delegate void GLGetRenderbufferParameteriv(int target, int name, int[] value); + [GlEntryPoint("glGetRenderbufferParameteriv")] + public GLGetRenderbufferParameteriv GetRenderbufferParameteriv { get; } // ReSharper restore UnassignedGetOnlyAutoProperty } } From 1a7a70f801c41329f9a436e3db10acf188274fb1 Mon Sep 17 00:00:00 2001 From: Max Katz Date: Thu, 24 Feb 2022 00:11:57 -0500 Subject: [PATCH 08/26] Fix android build --- src/Android/Avalonia.Android/Avalonia.Android.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Android/Avalonia.Android/Avalonia.Android.csproj b/src/Android/Avalonia.Android/Avalonia.Android.csproj index 4fac2fcf21..203c3accd6 100644 --- a/src/Android/Avalonia.Android/Avalonia.Android.csproj +++ b/src/Android/Avalonia.Android/Avalonia.Android.csproj @@ -1,7 +1,7 @@  net6.0-android - net6.0-ios;monoandroid11.0 + $(TargetFrameworks);monoandroid11.0 21 true true From 4e703efbc5574cb375bc241d6cf5ae027f0736a6 Mon Sep 17 00:00:00 2001 From: Max Katz Date: Thu, 24 Feb 2022 00:59:32 -0500 Subject: [PATCH 09/26] Update SDK --- azure-pipelines.yml | 6 +++--- global.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index ddb47c67db..f64bffde51 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -38,7 +38,7 @@ jobs: - task: UseDotNet@2 displayName: 'Use .NET Core SDK 6.0.100' inputs: - version: 6.0.100 + version: 6.0.200 - task: CmdLine@2 displayName: 'Run Build' @@ -69,7 +69,7 @@ jobs: - task: UseDotNet@2 displayName: 'Use .NET Core SDK 6.0.100' inputs: - version: 6.0.100 + version: 6.0.200 - task: CmdLine@2 displayName: 'Install Mono 5.18' @@ -141,7 +141,7 @@ jobs: - task: UseDotNet@2 displayName: 'Use .NET Core SDK 6.0.100' inputs: - version: 6.0.100 + version: 6.0.200 - task: CmdLine@2 displayName: 'Install Workloads' diff --git a/global.json b/global.json index 1f93ed27c3..f136d6911b 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "6.0.100" + "version": "6.0.200" }, "msbuild-sdks": { "Microsoft.Build.Traversal": "1.0.43", From 09e088d4e84f73199f2cc736cd737391a24f40f2 Mon Sep 17 00:00:00 2001 From: Max Katz Date: Thu, 24 Feb 2022 20:48:33 -0500 Subject: [PATCH 10/26] iOS project nuget packaging workaround --- src/iOS/Avalonia.iOS/Avalonia.iOS.csproj | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/iOS/Avalonia.iOS/Avalonia.iOS.csproj b/src/iOS/Avalonia.iOS/Avalonia.iOS.csproj index 1b3a952e8f..39a0305b1e 100644 --- a/src/iOS/Avalonia.iOS/Avalonia.iOS.csproj +++ b/src/iOS/Avalonia.iOS/Avalonia.iOS.csproj @@ -1,4 +1,5 @@ - + + net6.0-ios $(TargetFrameworks);xamarin.ios10 @@ -9,4 +10,13 @@ + + + + + + <_BuiltProjectOutputGroupOutputIntermediate Remove="$(OutDir)$(_DeploymentTargetApplicationManifestFileName)" /> + + + From df0a04b311926f25151167535043b15992899d48 Mon Sep 17 00:00:00 2001 From: Max Katz Date: Thu, 24 Feb 2022 22:15:03 -0500 Subject: [PATCH 11/26] Revert SDK changes, but allow latestFeature --- azure-pipelines.yml | 6 +++--- global.json | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index f64bffde51..ddb47c67db 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -38,7 +38,7 @@ jobs: - task: UseDotNet@2 displayName: 'Use .NET Core SDK 6.0.100' inputs: - version: 6.0.200 + version: 6.0.100 - task: CmdLine@2 displayName: 'Run Build' @@ -69,7 +69,7 @@ jobs: - task: UseDotNet@2 displayName: 'Use .NET Core SDK 6.0.100' inputs: - version: 6.0.200 + version: 6.0.100 - task: CmdLine@2 displayName: 'Install Mono 5.18' @@ -141,7 +141,7 @@ jobs: - task: UseDotNet@2 displayName: 'Use .NET Core SDK 6.0.100' inputs: - version: 6.0.200 + version: 6.0.100 - task: CmdLine@2 displayName: 'Install Workloads' diff --git a/global.json b/global.json index f136d6911b..fbb4a272bf 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,7 @@ { "sdk": { - "version": "6.0.200" + "version": "6.0.100", + "rollForward": "latestFeature" }, "msbuild-sdks": { "Microsoft.Build.Traversal": "1.0.43", From c643782a217b385d3b7dfed42fa31e858571b437 Mon Sep 17 00:00:00 2001 From: Max Katz Date: Thu, 24 Feb 2022 23:45:18 -0500 Subject: [PATCH 12/26] Update Copyright year --- samples/ControlCatalog.iOS.Legacy/Resources/LaunchScreen.xib | 2 +- samples/ControlCatalog.iOS/Resources/LaunchScreen.xib | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/samples/ControlCatalog.iOS.Legacy/Resources/LaunchScreen.xib b/samples/ControlCatalog.iOS.Legacy/Resources/LaunchScreen.xib index 35c3013b0e..3a3df8b38e 100644 --- a/samples/ControlCatalog.iOS.Legacy/Resources/LaunchScreen.xib +++ b/samples/ControlCatalog.iOS.Legacy/Resources/LaunchScreen.xib @@ -11,7 +11,7 @@ - - - - - - From 6f13012ba70c4f0fa699206744b6dc6ce81101b0 Mon Sep 17 00:00:00 2001 From: Max Katz Date: Fri, 25 Feb 2022 08:57:07 -0500 Subject: [PATCH 15/26] Hide status bar from sample projects --- samples/ControlCatalog.iOS.Legacy/Info.plist | 4 ++++ samples/ControlCatalog.iOS/Info.plist | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/samples/ControlCatalog.iOS.Legacy/Info.plist b/samples/ControlCatalog.iOS.Legacy/Info.plist index 45dbd05726..430ffb3aca 100644 --- a/samples/ControlCatalog.iOS.Legacy/Info.plist +++ b/samples/ControlCatalog.iOS.Legacy/Info.plist @@ -39,5 +39,9 @@ XSAppIconAssets Assets.xcassets/AppIcon.appiconset + UIStatusBarHidden + + UIViewControllerBasedStatusBarAppearance + diff --git a/samples/ControlCatalog.iOS/Info.plist b/samples/ControlCatalog.iOS/Info.plist index 144cb165ab..d4b91b381e 100644 --- a/samples/ControlCatalog.iOS/Info.plist +++ b/samples/ControlCatalog.iOS/Info.plist @@ -39,5 +39,9 @@ UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight + UIStatusBarHidden + + UIViewControllerBasedStatusBarAppearance + From b47abdb9a108c3e712e1df84cf97db98eaf3da2e Mon Sep 17 00:00:00 2001 From: Max Katz Date: Sat, 26 Feb 2022 05:04:53 -0500 Subject: [PATCH 16/26] Avoid nfloat in the codebase --- src/iOS/Avalonia.iOS/Extensions.cs | 3 +-- src/iOS/Avalonia.iOS/LayerFbo.cs | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/iOS/Avalonia.iOS/Extensions.cs b/src/iOS/Avalonia.iOS/Extensions.cs index 819a1386e8..80f6b419c9 100644 --- a/src/iOS/Avalonia.iOS/Extensions.cs +++ b/src/iOS/Avalonia.iOS/Extensions.cs @@ -1,7 +1,6 @@ using System; using Avalonia.Media; using CoreGraphics; -using ObjCRuntime; using UIKit; namespace Avalonia.iOS @@ -13,7 +12,7 @@ namespace Avalonia.iOS public static Point ToAvalonia(this CGPoint point) => new Point(point.X, point.Y); - static nfloat ColorComponent(byte c) => ((float) c) / 255; + static float ColorComponent(byte c) => (float) c / 255; public static UIColor ToUiColor(this Color color) => new UIColor( ColorComponent(color.R), diff --git a/src/iOS/Avalonia.iOS/LayerFbo.cs b/src/iOS/Avalonia.iOS/LayerFbo.cs index bd05f3b852..955aaef59f 100644 --- a/src/iOS/Avalonia.iOS/LayerFbo.cs +++ b/src/iOS/Avalonia.iOS/LayerFbo.cs @@ -1,7 +1,6 @@ using System; using Avalonia.OpenGL; using CoreAnimation; -using ObjCRuntime; using OpenGLES; namespace Avalonia.iOS @@ -103,7 +102,7 @@ namespace Avalonia.iOS private readonly GlInterface _gl; private readonly CAEAGLLayer _layer; private LayerFbo _fbo; - private nfloat _oldLayerWidth, _oldLayerHeight, _oldLayerScale; + private double _oldLayerWidth, _oldLayerHeight, _oldLayerScale; public SizeSynchronizedLayerFbo(EAGLContext context, GlInterface gl, CAEAGLLayer layer) { From 34b4f970e9fca967bbcbc5df7e2aec27e9a6d918 Mon Sep 17 00:00:00 2001 From: Max Katz Date: Mon, 28 Feb 2022 20:45:23 -0500 Subject: [PATCH 17/26] Avoid "using system" because --- src/iOS/Avalonia.iOS/AvaloniaAppDelegate.cs | 2 +- src/iOS/Avalonia.iOS/AvaloniaView.cs | 17 ++++++++--------- src/iOS/Avalonia.iOS/ClipboardImpl.cs | 9 ++++----- src/iOS/Avalonia.iOS/DisplayLinkTimer.cs | 5 ++--- src/iOS/Avalonia.iOS/EaglDisplay.cs | 11 +++++------ src/iOS/Avalonia.iOS/EaglLayerSurface.cs | 10 ++++------ src/iOS/Avalonia.iOS/Extensions.cs | 1 - src/iOS/Avalonia.iOS/LayerFbo.cs | 14 +++++++++----- src/iOS/Avalonia.iOS/Platform.cs | 6 ++---- .../Avalonia.iOS/PlatformThreadingInterface.cs | 9 ++++----- src/iOS/Avalonia.iOS/Stubs.cs | 5 ++--- 11 files changed, 41 insertions(+), 48 deletions(-) diff --git a/src/iOS/Avalonia.iOS/AvaloniaAppDelegate.cs b/src/iOS/Avalonia.iOS/AvaloniaAppDelegate.cs index 65a6743f9d..e1b5189845 100644 --- a/src/iOS/Avalonia.iOS/AvaloniaAppDelegate.cs +++ b/src/iOS/Avalonia.iOS/AvaloniaAppDelegate.cs @@ -12,7 +12,7 @@ namespace Avalonia.iOS [Export("window")] public UIWindow Window { get; set; } - + [Export("application:didFinishLaunchingWithOptions:")] public bool FinishedLaunching(UIApplication application, NSDictionary launchOptions) { diff --git a/src/iOS/Avalonia.iOS/AvaloniaView.cs b/src/iOS/Avalonia.iOS/AvaloniaView.cs index 5bb2f64879..c789c07d00 100644 --- a/src/iOS/Avalonia.iOS/AvaloniaView.cs +++ b/src/iOS/Avalonia.iOS/AvaloniaView.cs @@ -1,4 +1,3 @@ -using System; using System.Collections.Generic; using Avalonia.Controls; using Avalonia.Controls.Embedding; @@ -94,14 +93,14 @@ namespace Avalonia.iOS public Size? FrameSize => null; public double RenderScaling => _view.ContentScaleFactor; public IEnumerable Surfaces { get; set; } - public Action Input { get; set; } - public Action Paint { get; set; } - public Action Resized { get; set; } - public Action ScalingChanged { get; set; } - public Action TransparencyLevelChanged { get; set; } - public Action Closed { get; set; } - - public Action LostFocus { get; set; } + public System.Action Input { get; set; } + public System.Action Paint { get; set; } + public System.Action Resized { get; set; } + public System.Action ScalingChanged { get; set; } + public System.Action TransparencyLevelChanged { get; set; } + public System.Action Closed { get; set; } + + public System.Action LostFocus { get; set; } // legacy no-op public IMouseDevice MouseDevice { get; } = new MouseDevice(); diff --git a/src/iOS/Avalonia.iOS/ClipboardImpl.cs b/src/iOS/Avalonia.iOS/ClipboardImpl.cs index b9f74d69c6..9b230016c7 100644 --- a/src/iOS/Avalonia.iOS/ClipboardImpl.cs +++ b/src/iOS/Avalonia.iOS/ClipboardImpl.cs @@ -1,4 +1,3 @@ -using System; using System.Threading.Tasks; using Avalonia.Input; using Avalonia.Input.Platform; @@ -25,10 +24,10 @@ namespace Avalonia.iOS return Task.FromResult(0); } - public Task SetDataObjectAsync(IDataObject data) => throw new PlatformNotSupportedException(); + public Task SetDataObjectAsync(IDataObject data) => throw new System.PlatformNotSupportedException(); - public Task GetFormatsAsync() => throw new PlatformNotSupportedException(); + public Task GetFormatsAsync() => throw new System.PlatformNotSupportedException(); - public Task GetDataAsync(string format) => throw new PlatformNotSupportedException(); + public Task GetDataAsync(string format) => throw new System.PlatformNotSupportedException(); } -} \ No newline at end of file +} diff --git a/src/iOS/Avalonia.iOS/DisplayLinkTimer.cs b/src/iOS/Avalonia.iOS/DisplayLinkTimer.cs index df73479a65..f92f0b1aa2 100644 --- a/src/iOS/Avalonia.iOS/DisplayLinkTimer.cs +++ b/src/iOS/Avalonia.iOS/DisplayLinkTimer.cs @@ -1,4 +1,3 @@ -using System; using System.Diagnostics; using System.Threading; using System.Threading.Tasks; @@ -11,7 +10,7 @@ namespace Avalonia.iOS { class DisplayLinkTimer : IRenderTimer { - public event Action Tick; + public event System.Action Tick; private Stopwatch _st = Stopwatch.StartNew(); public DisplayLinkTimer() @@ -34,4 +33,4 @@ namespace Avalonia.iOS Tick?.Invoke(_st.Elapsed); } } -} \ No newline at end of file +} diff --git a/src/iOS/Avalonia.iOS/EaglDisplay.cs b/src/iOS/Avalonia.iOS/EaglDisplay.cs index bd1969081d..c24895e733 100644 --- a/src/iOS/Avalonia.iOS/EaglDisplay.cs +++ b/src/iOS/Avalonia.iOS/EaglDisplay.cs @@ -1,4 +1,3 @@ -using System; using System.Reactive.Disposables; using Avalonia.OpenGL; using OpenGLES; @@ -8,7 +7,7 @@ namespace Avalonia.iOS class EaglFeature : IPlatformOpenGlInterface { public IGlContext PrimaryContext => Context; - public IGlContext CreateSharedContext() => throw new NotSupportedException(); + public IGlContext CreateSharedContext() => throw new System.NotSupportedException(); public bool CanShareContexts => false; public bool CanCreateContexts => false; public IGlContext CreateContext() => throw new System.NotSupportedException(); @@ -23,7 +22,7 @@ namespace Avalonia.iOS { const string path = "/System/Library/Frameworks/OpenGLES.framework/OpenGLES"; var libGl = ObjCRuntime.Dlfcn.dlopen(path, 1); - if (libGl == IntPtr.Zero) + if (libGl == System.IntPtr.Zero) throw new OpenGlException("Unable to load " + path); GlInterface = new GlInterface(Version, proc => ObjCRuntime.Dlfcn.dlsym(libGl, proc)); Context = new EAGLContext(EAGLRenderingAPI.OpenGLES3); @@ -35,7 +34,7 @@ namespace Avalonia.iOS Context = null; } - class ResetContext : IDisposable + class ResetContext : System.IDisposable { private EAGLContext _old; private bool _disposed; @@ -55,7 +54,7 @@ namespace Avalonia.iOS } } - public IDisposable MakeCurrent() + public System.IDisposable MakeCurrent() { var old = EAGLContext.CurrentContext; if (!EAGLContext.SetCurrentContext(Context)) @@ -63,7 +62,7 @@ namespace Avalonia.iOS return new ResetContext(old); } - public IDisposable EnsureCurrent() + public System.IDisposable EnsureCurrent() { if(EAGLContext.CurrentContext == Context) return Disposable.Empty; diff --git a/src/iOS/Avalonia.iOS/EaglLayerSurface.cs b/src/iOS/Avalonia.iOS/EaglLayerSurface.cs index 0e8945d921..5d714077bc 100644 --- a/src/iOS/Avalonia.iOS/EaglLayerSurface.cs +++ b/src/iOS/Avalonia.iOS/EaglLayerSurface.cs @@ -1,5 +1,3 @@ - -using System; using System.Threading; using Avalonia.OpenGL; using Avalonia.OpenGL.Surfaces; @@ -19,10 +17,10 @@ namespace Avalonia.iOS class RenderSession : IGlPlatformSurfaceRenderingSession { private readonly GlContext _ctx; - private readonly IDisposable _restoreContext; + private readonly System.IDisposable _restoreContext; private readonly SizeSynchronizedLayerFbo _fbo; - public RenderSession(GlContext ctx, IDisposable restoreContext, SizeSynchronizedLayerFbo fbo) + public RenderSession(GlContext ctx, System.IDisposable restoreContext, SizeSynchronizedLayerFbo fbo) { _ctx = ctx; _restoreContext = restoreContext; @@ -75,7 +73,7 @@ namespace Avalonia.iOS static void CheckThread() { if (Platform.Timer.TimerThread != Thread.CurrentThread) - throw new InvalidOperationException("Invalid thread, go away"); + throw new System.InvalidOperationException("Invalid thread, go away"); } public IGlPlatformSurfaceRenderTarget CreateGlRenderTarget() @@ -86,7 +84,7 @@ namespace Avalonia.iOS { var fbo = new SizeSynchronizedLayerFbo(ctx.Context, ctx.GlInterface, _layer); if (!fbo.Sync()) - throw new InvalidOperationException("Unable to create render target"); + throw new System.InvalidOperationException("Unable to create render target"); return new RenderTarget(ctx, fbo); } } diff --git a/src/iOS/Avalonia.iOS/Extensions.cs b/src/iOS/Avalonia.iOS/Extensions.cs index 80f6b419c9..d57a22ddf3 100644 --- a/src/iOS/Avalonia.iOS/Extensions.cs +++ b/src/iOS/Avalonia.iOS/Extensions.cs @@ -1,4 +1,3 @@ -using System; using Avalonia.Media; using CoreGraphics; using UIKit; diff --git a/src/iOS/Avalonia.iOS/LayerFbo.cs b/src/iOS/Avalonia.iOS/LayerFbo.cs index 955aaef59f..e221a9c9b3 100644 --- a/src/iOS/Avalonia.iOS/LayerFbo.cs +++ b/src/iOS/Avalonia.iOS/LayerFbo.cs @@ -1,8 +1,12 @@ -using System; using Avalonia.OpenGL; using CoreAnimation; using OpenGLES; +// We can't import System because System has a type called nint on iOS and Mac Catalyst. +// As such, throughout this file System is fully qualified. +// See https://github.com/xamarin/xamarin-macios/issues/10508 +// And https://github.com/dotnet/Silk.NET/blob/main/src/Windowing/Silk.NET.Windowing.Sdl/SdlView.cs + namespace Avalonia.iOS { public class LayerFbo @@ -92,11 +96,11 @@ namespace Avalonia.iOS _gl.DeleteRenderbuffers(1, _depthBuffer); _gl.DeleteRenderbuffers(1, _renderbuffer); if (_context != EAGLContext.CurrentContext) - throw new InvalidOperationException("Associated EAGLContext is not current"); + throw new System.InvalidOperationException("Associated EAGLContext is not current"); } } - class SizeSynchronizedLayerFbo : IDisposable + class SizeSynchronizedLayerFbo : System.IDisposable { private readonly EAGLContext _context; private readonly GlInterface _gl; @@ -130,7 +134,7 @@ namespace Avalonia.iOS public void Dispose() { if (_context != EAGLContext.CurrentContext) - throw new InvalidOperationException("Associated EAGLContext is not current"); + throw new System.InvalidOperationException("Associated EAGLContext is not current"); _fbo?.Dispose(); _fbo = null; } @@ -138,7 +142,7 @@ namespace Avalonia.iOS public void Bind() { if(!Sync()) - throw new InvalidOperationException("Unable to create a render target"); + throw new System.InvalidOperationException("Unable to create a render target"); _fbo.Bind(); } diff --git a/src/iOS/Avalonia.iOS/Platform.cs b/src/iOS/Avalonia.iOS/Platform.cs index 57a86cbfd8..4c31c192c6 100644 --- a/src/iOS/Avalonia.iOS/Platform.cs +++ b/src/iOS/Avalonia.iOS/Platform.cs @@ -1,5 +1,3 @@ -using System; - using Avalonia.Controls; using Avalonia.Input; using Avalonia.Input.Platform; @@ -32,11 +30,11 @@ namespace Avalonia.iOS public Size TouchDoubleClickSize => new Size(10, 10); /// - public TimeSpan TouchDoubleClickTime => TimeSpan.FromMilliseconds(500); + public System.TimeSpan TouchDoubleClickTime => System.TimeSpan.FromMilliseconds(500); public Size DoubleClickSize => new Size(4, 4); - public TimeSpan DoubleClickTime => TouchDoubleClickTime; + public System.TimeSpan DoubleClickTime => TouchDoubleClickTime; } public static void Register() diff --git a/src/iOS/Avalonia.iOS/PlatformThreadingInterface.cs b/src/iOS/Avalonia.iOS/PlatformThreadingInterface.cs index fa36ab6c79..c9e8f36c44 100644 --- a/src/iOS/Avalonia.iOS/PlatformThreadingInterface.cs +++ b/src/iOS/Avalonia.iOS/PlatformThreadingInterface.cs @@ -1,4 +1,3 @@ -using System; using System.Threading; using Avalonia.Platform; using Avalonia.Threading; @@ -13,14 +12,14 @@ namespace Avalonia.iOS public static PlatformThreadingInterface Instance { get; } = new PlatformThreadingInterface(); public bool CurrentThreadIsLoopThread => NSThread.Current.IsMainThread; - public event Action Signaled; + public event System.Action Signaled; public void RunLoop(CancellationToken cancellationToken) { //Mobile platforms are using external main loop - throw new NotSupportedException(); + throw new System.NotSupportedException(); } - public IDisposable StartTimer(DispatcherPriority priority, TimeSpan interval, Action tick) + public System.IDisposable StartTimer(DispatcherPriority priority, System.TimeSpan interval, System.Action tick) => NSTimer.CreateRepeatingScheduledTimer(interval, _ => tick()); public void Signal(DispatcherPriority prio) @@ -40,4 +39,4 @@ namespace Avalonia.iOS }); } } -} \ No newline at end of file +} diff --git a/src/iOS/Avalonia.iOS/Stubs.cs b/src/iOS/Avalonia.iOS/Stubs.cs index 9c46aa78cc..3ec582a254 100644 --- a/src/iOS/Avalonia.iOS/Stubs.cs +++ b/src/iOS/Avalonia.iOS/Stubs.cs @@ -1,4 +1,3 @@ -using System; using System.IO; using Avalonia.Input; using Avalonia.Platform; @@ -18,9 +17,9 @@ namespace Avalonia.iOS class WindowingPlatformStub : IWindowingPlatform { - public IWindowImpl CreateWindow() => throw new NotSupportedException(); + public IWindowImpl CreateWindow() => throw new System.NotSupportedException(); - public IWindowImpl CreateEmbeddableWindow() => throw new NotSupportedException(); + public IWindowImpl CreateEmbeddableWindow() => throw new System.NotSupportedException(); public ITrayIconImpl CreateTrayIcon() => null; } From 44125040ceebae3076cecd66417f9ff5f030511a Mon Sep 17 00:00:00 2001 From: Max Katz Date: Mon, 28 Feb 2022 21:19:28 -0500 Subject: [PATCH 18/26] Temporary build only new sdk ios --- src/iOS/Avalonia.iOS/Avalonia.iOS.csproj | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/iOS/Avalonia.iOS/Avalonia.iOS.csproj b/src/iOS/Avalonia.iOS/Avalonia.iOS.csproj index 39a0305b1e..9486fbb829 100644 --- a/src/iOS/Avalonia.iOS/Avalonia.iOS.csproj +++ b/src/iOS/Avalonia.iOS/Avalonia.iOS.csproj @@ -1,8 +1,8 @@ - - + + net6.0-ios - $(TargetFrameworks);xamarin.ios10 + 10.0 true @@ -10,13 +10,13 @@ - + - - - <_BuiltProjectOutputGroupOutputIntermediate Remove="$(OutDir)$(_DeploymentTargetApplicationManifestFileName)" /> - - - + + + + + + From e74b51e7afc55a25d7a9b5c8b635cf409fc8b002 Mon Sep 17 00:00:00 2001 From: Max Katz Date: Mon, 28 Feb 2022 21:56:59 -0500 Subject: [PATCH 19/26] Use as latest as possible SDK --- azure-pipelines.yml | 8 ++++---- global.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index ddb47c67db..82982b0659 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -38,7 +38,7 @@ jobs: - task: UseDotNet@2 displayName: 'Use .NET Core SDK 6.0.100' inputs: - version: 6.0.100 + version: 6.0.200 - task: CmdLine@2 displayName: 'Run Build' @@ -69,7 +69,7 @@ jobs: - task: UseDotNet@2 displayName: 'Use .NET Core SDK 6.0.100' inputs: - version: 6.0.100 + version: 6.0.200 - task: CmdLine@2 displayName: 'Install Mono 5.18' @@ -141,13 +141,13 @@ jobs: - task: UseDotNet@2 displayName: 'Use .NET Core SDK 6.0.100' inputs: - version: 6.0.100 + version: 6.0.200 - task: CmdLine@2 displayName: 'Install Workloads' inputs: script: | - dotnet workload install android ios + dotnet workload install --no-cache --disable-parallel ios --skip-manifest-update --source "https://pkgs.dev.azure.com/xamarin/public/_packaging/maui-main/nuget/v3/index.json" --source "https://pkgs.dev.azure.com/azure-public/vside/_packaging/xamarin-impl/nuget/v3/index.json" --source "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/index.json" --source "https://api.nuget.org/v3/index.json" - task: CmdLine@2 displayName: 'Install Nuke' diff --git a/global.json b/global.json index fbb4a272bf..30265268dc 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "6.0.100", + "version": "6.0.200", "rollForward": "latestFeature" }, "msbuild-sdks": { From bd757cb5e74822f8a0fedc69fec7b031bd36b3b2 Mon Sep 17 00:00:00 2001 From: Max Katz Date: Mon, 28 Feb 2022 21:57:06 -0500 Subject: [PATCH 20/26] Revert "Temporary build only new sdk ios" This reverts commit 44125040ceebae3076cecd66417f9ff5f030511a. --- src/iOS/Avalonia.iOS/Avalonia.iOS.csproj | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/iOS/Avalonia.iOS/Avalonia.iOS.csproj b/src/iOS/Avalonia.iOS/Avalonia.iOS.csproj index 9486fbb829..39a0305b1e 100644 --- a/src/iOS/Avalonia.iOS/Avalonia.iOS.csproj +++ b/src/iOS/Avalonia.iOS/Avalonia.iOS.csproj @@ -1,8 +1,8 @@ - - + + net6.0-ios - + $(TargetFrameworks);xamarin.ios10 10.0 true @@ -10,13 +10,13 @@ - + - - - - - - + + + <_BuiltProjectOutputGroupOutputIntermediate Remove="$(OutDir)$(_DeploymentTargetApplicationManifestFileName)" /> + + + From 0ae32a2d628907896e557296fc83c4ad2f6d0928 Mon Sep 17 00:00:00 2001 From: Max Katz Date: Mon, 28 Feb 2022 22:16:06 -0500 Subject: [PATCH 21/26] Use only nuget source --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 82982b0659..bc1362cdb7 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -147,7 +147,7 @@ jobs: displayName: 'Install Workloads' inputs: script: | - dotnet workload install --no-cache --disable-parallel ios --skip-manifest-update --source "https://pkgs.dev.azure.com/xamarin/public/_packaging/maui-main/nuget/v3/index.json" --source "https://pkgs.dev.azure.com/azure-public/vside/_packaging/xamarin-impl/nuget/v3/index.json" --source "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/index.json" --source "https://api.nuget.org/v3/index.json" + dotnet workload install --no-cache --disable-parallel ios --skip-manifest-update --source "https://api.nuget.org/v3/index.json" - task: CmdLine@2 displayName: 'Install Nuke' From 741c4a8bb19875aa6474810e76d7249bd1ed5af5 Mon Sep 17 00:00:00 2001 From: Max Katz Date: Mon, 28 Feb 2022 22:30:05 -0500 Subject: [PATCH 22/26] Missed workload --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index bc1362cdb7..79456b117b 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -147,7 +147,7 @@ jobs: displayName: 'Install Workloads' inputs: script: | - dotnet workload install --no-cache --disable-parallel ios --skip-manifest-update --source "https://api.nuget.org/v3/index.json" + dotnet workload install --no-cache --disable-parallel android ios --skip-manifest-update --source "https://api.nuget.org/v3/index.json" - task: CmdLine@2 displayName: 'Install Nuke' From 09acf151b464e5354393d28d892004de06c9943d Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Sat, 5 Mar 2022 17:18:48 +0000 Subject: [PATCH 23/26] attempt to fix native aot. --- src/Avalonia.OpenGL/GlInterface.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Avalonia.OpenGL/GlInterface.cs b/src/Avalonia.OpenGL/GlInterface.cs index 3d947998af..18bebe4cb5 100644 --- a/src/Avalonia.OpenGL/GlInterface.cs +++ b/src/Avalonia.OpenGL/GlInterface.cs @@ -86,10 +86,13 @@ namespace Avalonia.OpenGL public GlViewport Viewport { get; } [GlEntryPoint("glFlush")] - public Action Flush { get; } + public UnmanagedAction Flush { get; } + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + public delegate void UnmanagedAction(); [GlEntryPoint("glFinish")] - public Action Finish { get; } + public UnmanagedAction Finish { get; } [UnmanagedFunctionPointer(CallingConvention.StdCall)] public delegate IntPtr GlGetString(int v); From 5210bb12e48f1eabeba5a6655c64bf9874a9982f Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Sat, 5 Mar 2022 17:33:28 +0000 Subject: [PATCH 24/26] use newer preview skiasharp. --- build/SkiaSharp.props | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build/SkiaSharp.props b/build/SkiaSharp.props index 60bebaad40..9afcc135c5 100644 --- a/build/SkiaSharp.props +++ b/build/SkiaSharp.props @@ -1,7 +1,7 @@  - - - + + + From 95ac5122e48cad34888655142325070af5fbbfeb Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Sat, 5 Mar 2022 17:40:10 +0000 Subject: [PATCH 25/26] Revert "use newer preview skiasharp." This reverts commit 5210bb12e48f1eabeba5a6655c64bf9874a9982f. --- build/SkiaSharp.props | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build/SkiaSharp.props b/build/SkiaSharp.props index 9afcc135c5..60bebaad40 100644 --- a/build/SkiaSharp.props +++ b/build/SkiaSharp.props @@ -1,7 +1,7 @@  - - - + + + From 3344e436b384d6284f8fa5ee16deeaee833aa3bb Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Sat, 5 Mar 2022 17:40:50 +0000 Subject: [PATCH 26/26] Revert "Avoid "using system" because" This reverts commit 34b4f970e9fca967bbcbc5df7e2aec27e9a6d918. --- src/iOS/Avalonia.iOS/AvaloniaAppDelegate.cs | 2 +- src/iOS/Avalonia.iOS/AvaloniaView.cs | 17 +++++++++-------- src/iOS/Avalonia.iOS/ClipboardImpl.cs | 9 +++++---- src/iOS/Avalonia.iOS/DisplayLinkTimer.cs | 5 +++-- src/iOS/Avalonia.iOS/EaglDisplay.cs | 11 ++++++----- src/iOS/Avalonia.iOS/EaglLayerSurface.cs | 10 ++++++---- src/iOS/Avalonia.iOS/Extensions.cs | 1 + src/iOS/Avalonia.iOS/LayerFbo.cs | 14 +++++--------- src/iOS/Avalonia.iOS/Platform.cs | 6 ++++-- .../Avalonia.iOS/PlatformThreadingInterface.cs | 9 +++++---- src/iOS/Avalonia.iOS/Stubs.cs | 5 +++-- 11 files changed, 48 insertions(+), 41 deletions(-) diff --git a/src/iOS/Avalonia.iOS/AvaloniaAppDelegate.cs b/src/iOS/Avalonia.iOS/AvaloniaAppDelegate.cs index e1b5189845..65a6743f9d 100644 --- a/src/iOS/Avalonia.iOS/AvaloniaAppDelegate.cs +++ b/src/iOS/Avalonia.iOS/AvaloniaAppDelegate.cs @@ -12,7 +12,7 @@ namespace Avalonia.iOS [Export("window")] public UIWindow Window { get; set; } - + [Export("application:didFinishLaunchingWithOptions:")] public bool FinishedLaunching(UIApplication application, NSDictionary launchOptions) { diff --git a/src/iOS/Avalonia.iOS/AvaloniaView.cs b/src/iOS/Avalonia.iOS/AvaloniaView.cs index c789c07d00..5bb2f64879 100644 --- a/src/iOS/Avalonia.iOS/AvaloniaView.cs +++ b/src/iOS/Avalonia.iOS/AvaloniaView.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using Avalonia.Controls; using Avalonia.Controls.Embedding; @@ -93,14 +94,14 @@ namespace Avalonia.iOS public Size? FrameSize => null; public double RenderScaling => _view.ContentScaleFactor; public IEnumerable Surfaces { get; set; } - public System.Action Input { get; set; } - public System.Action Paint { get; set; } - public System.Action Resized { get; set; } - public System.Action ScalingChanged { get; set; } - public System.Action TransparencyLevelChanged { get; set; } - public System.Action Closed { get; set; } - - public System.Action LostFocus { get; set; } + public Action Input { get; set; } + public Action Paint { get; set; } + public Action Resized { get; set; } + public Action ScalingChanged { get; set; } + public Action TransparencyLevelChanged { get; set; } + public Action Closed { get; set; } + + public Action LostFocus { get; set; } // legacy no-op public IMouseDevice MouseDevice { get; } = new MouseDevice(); diff --git a/src/iOS/Avalonia.iOS/ClipboardImpl.cs b/src/iOS/Avalonia.iOS/ClipboardImpl.cs index 9b230016c7..b9f74d69c6 100644 --- a/src/iOS/Avalonia.iOS/ClipboardImpl.cs +++ b/src/iOS/Avalonia.iOS/ClipboardImpl.cs @@ -1,3 +1,4 @@ +using System; using System.Threading.Tasks; using Avalonia.Input; using Avalonia.Input.Platform; @@ -24,10 +25,10 @@ namespace Avalonia.iOS return Task.FromResult(0); } - public Task SetDataObjectAsync(IDataObject data) => throw new System.PlatformNotSupportedException(); + public Task SetDataObjectAsync(IDataObject data) => throw new PlatformNotSupportedException(); - public Task GetFormatsAsync() => throw new System.PlatformNotSupportedException(); + public Task GetFormatsAsync() => throw new PlatformNotSupportedException(); - public Task GetDataAsync(string format) => throw new System.PlatformNotSupportedException(); + public Task GetDataAsync(string format) => throw new PlatformNotSupportedException(); } -} +} \ No newline at end of file diff --git a/src/iOS/Avalonia.iOS/DisplayLinkTimer.cs b/src/iOS/Avalonia.iOS/DisplayLinkTimer.cs index f92f0b1aa2..df73479a65 100644 --- a/src/iOS/Avalonia.iOS/DisplayLinkTimer.cs +++ b/src/iOS/Avalonia.iOS/DisplayLinkTimer.cs @@ -1,3 +1,4 @@ +using System; using System.Diagnostics; using System.Threading; using System.Threading.Tasks; @@ -10,7 +11,7 @@ namespace Avalonia.iOS { class DisplayLinkTimer : IRenderTimer { - public event System.Action Tick; + public event Action Tick; private Stopwatch _st = Stopwatch.StartNew(); public DisplayLinkTimer() @@ -33,4 +34,4 @@ namespace Avalonia.iOS Tick?.Invoke(_st.Elapsed); } } -} +} \ No newline at end of file diff --git a/src/iOS/Avalonia.iOS/EaglDisplay.cs b/src/iOS/Avalonia.iOS/EaglDisplay.cs index c24895e733..bd1969081d 100644 --- a/src/iOS/Avalonia.iOS/EaglDisplay.cs +++ b/src/iOS/Avalonia.iOS/EaglDisplay.cs @@ -1,3 +1,4 @@ +using System; using System.Reactive.Disposables; using Avalonia.OpenGL; using OpenGLES; @@ -7,7 +8,7 @@ namespace Avalonia.iOS class EaglFeature : IPlatformOpenGlInterface { public IGlContext PrimaryContext => Context; - public IGlContext CreateSharedContext() => throw new System.NotSupportedException(); + public IGlContext CreateSharedContext() => throw new NotSupportedException(); public bool CanShareContexts => false; public bool CanCreateContexts => false; public IGlContext CreateContext() => throw new System.NotSupportedException(); @@ -22,7 +23,7 @@ namespace Avalonia.iOS { const string path = "/System/Library/Frameworks/OpenGLES.framework/OpenGLES"; var libGl = ObjCRuntime.Dlfcn.dlopen(path, 1); - if (libGl == System.IntPtr.Zero) + if (libGl == IntPtr.Zero) throw new OpenGlException("Unable to load " + path); GlInterface = new GlInterface(Version, proc => ObjCRuntime.Dlfcn.dlsym(libGl, proc)); Context = new EAGLContext(EAGLRenderingAPI.OpenGLES3); @@ -34,7 +35,7 @@ namespace Avalonia.iOS Context = null; } - class ResetContext : System.IDisposable + class ResetContext : IDisposable { private EAGLContext _old; private bool _disposed; @@ -54,7 +55,7 @@ namespace Avalonia.iOS } } - public System.IDisposable MakeCurrent() + public IDisposable MakeCurrent() { var old = EAGLContext.CurrentContext; if (!EAGLContext.SetCurrentContext(Context)) @@ -62,7 +63,7 @@ namespace Avalonia.iOS return new ResetContext(old); } - public System.IDisposable EnsureCurrent() + public IDisposable EnsureCurrent() { if(EAGLContext.CurrentContext == Context) return Disposable.Empty; diff --git a/src/iOS/Avalonia.iOS/EaglLayerSurface.cs b/src/iOS/Avalonia.iOS/EaglLayerSurface.cs index 5d714077bc..0e8945d921 100644 --- a/src/iOS/Avalonia.iOS/EaglLayerSurface.cs +++ b/src/iOS/Avalonia.iOS/EaglLayerSurface.cs @@ -1,3 +1,5 @@ + +using System; using System.Threading; using Avalonia.OpenGL; using Avalonia.OpenGL.Surfaces; @@ -17,10 +19,10 @@ namespace Avalonia.iOS class RenderSession : IGlPlatformSurfaceRenderingSession { private readonly GlContext _ctx; - private readonly System.IDisposable _restoreContext; + private readonly IDisposable _restoreContext; private readonly SizeSynchronizedLayerFbo _fbo; - public RenderSession(GlContext ctx, System.IDisposable restoreContext, SizeSynchronizedLayerFbo fbo) + public RenderSession(GlContext ctx, IDisposable restoreContext, SizeSynchronizedLayerFbo fbo) { _ctx = ctx; _restoreContext = restoreContext; @@ -73,7 +75,7 @@ namespace Avalonia.iOS static void CheckThread() { if (Platform.Timer.TimerThread != Thread.CurrentThread) - throw new System.InvalidOperationException("Invalid thread, go away"); + throw new InvalidOperationException("Invalid thread, go away"); } public IGlPlatformSurfaceRenderTarget CreateGlRenderTarget() @@ -84,7 +86,7 @@ namespace Avalonia.iOS { var fbo = new SizeSynchronizedLayerFbo(ctx.Context, ctx.GlInterface, _layer); if (!fbo.Sync()) - throw new System.InvalidOperationException("Unable to create render target"); + throw new InvalidOperationException("Unable to create render target"); return new RenderTarget(ctx, fbo); } } diff --git a/src/iOS/Avalonia.iOS/Extensions.cs b/src/iOS/Avalonia.iOS/Extensions.cs index d57a22ddf3..80f6b419c9 100644 --- a/src/iOS/Avalonia.iOS/Extensions.cs +++ b/src/iOS/Avalonia.iOS/Extensions.cs @@ -1,3 +1,4 @@ +using System; using Avalonia.Media; using CoreGraphics; using UIKit; diff --git a/src/iOS/Avalonia.iOS/LayerFbo.cs b/src/iOS/Avalonia.iOS/LayerFbo.cs index e221a9c9b3..955aaef59f 100644 --- a/src/iOS/Avalonia.iOS/LayerFbo.cs +++ b/src/iOS/Avalonia.iOS/LayerFbo.cs @@ -1,12 +1,8 @@ +using System; using Avalonia.OpenGL; using CoreAnimation; using OpenGLES; -// We can't import System because System has a type called nint on iOS and Mac Catalyst. -// As such, throughout this file System is fully qualified. -// See https://github.com/xamarin/xamarin-macios/issues/10508 -// And https://github.com/dotnet/Silk.NET/blob/main/src/Windowing/Silk.NET.Windowing.Sdl/SdlView.cs - namespace Avalonia.iOS { public class LayerFbo @@ -96,11 +92,11 @@ namespace Avalonia.iOS _gl.DeleteRenderbuffers(1, _depthBuffer); _gl.DeleteRenderbuffers(1, _renderbuffer); if (_context != EAGLContext.CurrentContext) - throw new System.InvalidOperationException("Associated EAGLContext is not current"); + throw new InvalidOperationException("Associated EAGLContext is not current"); } } - class SizeSynchronizedLayerFbo : System.IDisposable + class SizeSynchronizedLayerFbo : IDisposable { private readonly EAGLContext _context; private readonly GlInterface _gl; @@ -134,7 +130,7 @@ namespace Avalonia.iOS public void Dispose() { if (_context != EAGLContext.CurrentContext) - throw new System.InvalidOperationException("Associated EAGLContext is not current"); + throw new InvalidOperationException("Associated EAGLContext is not current"); _fbo?.Dispose(); _fbo = null; } @@ -142,7 +138,7 @@ namespace Avalonia.iOS public void Bind() { if(!Sync()) - throw new System.InvalidOperationException("Unable to create a render target"); + throw new InvalidOperationException("Unable to create a render target"); _fbo.Bind(); } diff --git a/src/iOS/Avalonia.iOS/Platform.cs b/src/iOS/Avalonia.iOS/Platform.cs index 4c31c192c6..57a86cbfd8 100644 --- a/src/iOS/Avalonia.iOS/Platform.cs +++ b/src/iOS/Avalonia.iOS/Platform.cs @@ -1,3 +1,5 @@ +using System; + using Avalonia.Controls; using Avalonia.Input; using Avalonia.Input.Platform; @@ -30,11 +32,11 @@ namespace Avalonia.iOS public Size TouchDoubleClickSize => new Size(10, 10); /// - public System.TimeSpan TouchDoubleClickTime => System.TimeSpan.FromMilliseconds(500); + public TimeSpan TouchDoubleClickTime => TimeSpan.FromMilliseconds(500); public Size DoubleClickSize => new Size(4, 4); - public System.TimeSpan DoubleClickTime => TouchDoubleClickTime; + public TimeSpan DoubleClickTime => TouchDoubleClickTime; } public static void Register() diff --git a/src/iOS/Avalonia.iOS/PlatformThreadingInterface.cs b/src/iOS/Avalonia.iOS/PlatformThreadingInterface.cs index c9e8f36c44..fa36ab6c79 100644 --- a/src/iOS/Avalonia.iOS/PlatformThreadingInterface.cs +++ b/src/iOS/Avalonia.iOS/PlatformThreadingInterface.cs @@ -1,3 +1,4 @@ +using System; using System.Threading; using Avalonia.Platform; using Avalonia.Threading; @@ -12,14 +13,14 @@ namespace Avalonia.iOS public static PlatformThreadingInterface Instance { get; } = new PlatformThreadingInterface(); public bool CurrentThreadIsLoopThread => NSThread.Current.IsMainThread; - public event System.Action Signaled; + public event Action Signaled; public void RunLoop(CancellationToken cancellationToken) { //Mobile platforms are using external main loop - throw new System.NotSupportedException(); + throw new NotSupportedException(); } - public System.IDisposable StartTimer(DispatcherPriority priority, System.TimeSpan interval, System.Action tick) + public IDisposable StartTimer(DispatcherPriority priority, TimeSpan interval, Action tick) => NSTimer.CreateRepeatingScheduledTimer(interval, _ => tick()); public void Signal(DispatcherPriority prio) @@ -39,4 +40,4 @@ namespace Avalonia.iOS }); } } -} +} \ No newline at end of file diff --git a/src/iOS/Avalonia.iOS/Stubs.cs b/src/iOS/Avalonia.iOS/Stubs.cs index 3ec582a254..9c46aa78cc 100644 --- a/src/iOS/Avalonia.iOS/Stubs.cs +++ b/src/iOS/Avalonia.iOS/Stubs.cs @@ -1,3 +1,4 @@ +using System; using System.IO; using Avalonia.Input; using Avalonia.Platform; @@ -17,9 +18,9 @@ namespace Avalonia.iOS class WindowingPlatformStub : IWindowingPlatform { - public IWindowImpl CreateWindow() => throw new System.NotSupportedException(); + public IWindowImpl CreateWindow() => throw new NotSupportedException(); - public IWindowImpl CreateEmbeddableWindow() => throw new System.NotSupportedException(); + public IWindowImpl CreateEmbeddableWindow() => throw new NotSupportedException(); public ITrayIconImpl CreateTrayIcon() => null; }