From 238bffe896f18407886b9adc7fd803f9dc94a6cc Mon Sep 17 00:00:00 2001
From: Nick Kovalsky <nickyboom@mail.ru>
Date: Sat, 23 Mar 2024 08:13:45 +0300
Subject: [PATCH 1/4] fixes snapshot returning surface default color

---
 .../SkiaSharp.Views/Platform/Apple/SKMetalView.cs                | 1 +
 1 file changed, 1 insertion(+)

diff --git a/source/SkiaSharp.Views/SkiaSharp.Views/Platform/Apple/SKMetalView.cs b/source/SkiaSharp.Views/SkiaSharp.Views/Platform/Apple/SKMetalView.cs
index f9c1dc97ff..fe0dabc5b9 100644
--- a/source/SkiaSharp.Views/SkiaSharp.Views/Platform/Apple/SKMetalView.cs
+++ b/source/SkiaSharp.Views/SkiaSharp.Views/Platform/Apple/SKMetalView.cs
@@ -83,6 +83,7 @@ private void Initialize()
 			ColorPixelFormat = MTLPixelFormat.BGRA8Unorm;
 			DepthStencilPixelFormat = MTLPixelFormat.Depth32Float_Stencil8;
 			SampleCount = 1;
+			FramebufferOnly = false;
 			Device = device;
 			backendContext = new GRMtlBackendContext
 			{

From 2441d9dcf18b084cb3faf8b7e3c87085d4b4be3b Mon Sep 17 00:00:00 2001
From: Nick Kovalsky <nickyboom@mail.ru>
Date: Sat, 23 Mar 2024 08:41:16 +0300
Subject: [PATCH 2/4] fix snapshot returning magenta color

---
 .../SkiaSharp.Views/Platform/Apple/SKMetalView.cs                | 1 +
 1 file changed, 1 insertion(+)

diff --git a/source/SkiaSharp.Views/SkiaSharp.Views/Platform/Apple/SKMetalView.cs b/source/SkiaSharp.Views/SkiaSharp.Views/Platform/Apple/SKMetalView.cs
index f9c1dc97ff..5570c890b9 100644
--- a/source/SkiaSharp.Views/SkiaSharp.Views/Platform/Apple/SKMetalView.cs
+++ b/source/SkiaSharp.Views/SkiaSharp.Views/Platform/Apple/SKMetalView.cs
@@ -84,6 +84,7 @@ private void Initialize()
 			DepthStencilPixelFormat = MTLPixelFormat.Depth32Float_Stencil8;
 			SampleCount = 1;
 			Device = device;
+			FramebufferOnly=false;
 			backendContext = new GRMtlBackendContext
 			{
 				Device = device,

From 8a1be54fd9c84e3c224acec840a5c3e16740e46e Mon Sep 17 00:00:00 2001
From: Nick Kovalsky <taublast@gmail.com>
Date: Sat, 23 Mar 2024 09:04:23 +0300
Subject: [PATCH 3/4] Update SKMetalView.cs

---
 .../SkiaSharp.Views/Platform/Apple/SKMetalView.cs                | 1 -
 1 file changed, 1 deletion(-)

diff --git a/source/SkiaSharp.Views/SkiaSharp.Views/Platform/Apple/SKMetalView.cs b/source/SkiaSharp.Views/SkiaSharp.Views/Platform/Apple/SKMetalView.cs
index e078c3ecab..fe0dabc5b9 100644
--- a/source/SkiaSharp.Views/SkiaSharp.Views/Platform/Apple/SKMetalView.cs
+++ b/source/SkiaSharp.Views/SkiaSharp.Views/Platform/Apple/SKMetalView.cs
@@ -85,7 +85,6 @@ private void Initialize()
 			SampleCount = 1;
 			FramebufferOnly = false;
 			Device = device;
-			FramebufferOnly=false;
 			backendContext = new GRMtlBackendContext
 			{
 				Device = device,

From 7018c3538227708a4aecb52e9f33c24460a96646 Mon Sep 17 00:00:00 2001
From: Nick Kovalsky <nickyboom@mail.ru>
Date: Thu, 30 Jan 2025 16:06:31 +0300
Subject: [PATCH 4/4] fix ios simulator metal

*add MSAA for ios real device
*fix ios simulator performance
---
 .../SkiaSharp.Views/Platform/Apple/SKMetalView.cs     | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/source/SkiaSharp.Views/SkiaSharp.Views/Platform/Apple/SKMetalView.cs b/source/SkiaSharp.Views/SkiaSharp.Views/Platform/Apple/SKMetalView.cs
index fe0dabc5b9..f2100935bd 100644
--- a/source/SkiaSharp.Views/SkiaSharp.Views/Platform/Apple/SKMetalView.cs
+++ b/source/SkiaSharp.Views/SkiaSharp.Views/Platform/Apple/SKMetalView.cs
@@ -82,7 +82,16 @@ private void Initialize()
 
 			ColorPixelFormat = MTLPixelFormat.BGRA8Unorm;
 			DepthStencilPixelFormat = MTLPixelFormat.Depth32Float_Stencil8;
-			SampleCount = 1;
+			if (DeviceInfo.Current.DeviceType == DeviceType.Virtual)
+			{
+				DepthStencilStorageMode = MTLStorageMode.Private;
+				SampleCount = 4;
+			}
+			else
+			{
+				DepthStencilStorageMode = MTLStorageMode.Shared;
+				SampleCount = 2;
+			}
 			FramebufferOnly = false;
 			Device = device;
 			backendContext = new GRMtlBackendContext