diff --git a/nuget/SkiaSharp.Views.WinUI.nuspec b/nuget/SkiaSharp.Views.WinUI.nuspec index e6842a788bb..2337f7aedc0 100644 --- a/nuget/SkiaSharp.Views.WinUI.nuspec +++ b/nuget/SkiaSharp.Views.WinUI.nuspec @@ -39,6 +39,14 @@ Please visit https://go.microsoft.com/fwlink/?linkid=868517 to view the release + + + + + + + + diff --git a/samples/Basic/WinUI/UWP/SkiaSharpSample.sln b/samples/Basic/WinUI/UWP/SkiaSharpSample.sln new file mode 100644 index 00000000000..886bf90911c --- /dev/null +++ b/samples/Basic/WinUI/UWP/SkiaSharpSample.sln @@ -0,0 +1,87 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30407.236 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SkiaSharp.UWP", "..\..\..\..\binding\SkiaSharp.UWP\SkiaSharp.UWP.csproj", "{8320763C-3EA5-4A99-8B10-C91EAC28F7E3}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SkiaSharpSample", "SkiaSharpSample\SkiaSharpSample.csproj", "{B8DECB45-08CD-4A12-AAFB-FE5AE553AB84}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SkiaSharp.Views.WinUI.UWP", "..\..\..\..\source\SkiaSharp.Views.WinUI\SkiaSharp.Views.WinUI.UWP\SkiaSharp.Views.WinUI.UWP.csproj", "{765A4E19-B377-4BFE-A4D0-53C31F691731}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|ARM64 = Debug|ARM64 + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|ARM64 = Release|ARM64 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {8320763C-3EA5-4A99-8B10-C91EAC28F7E3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8320763C-3EA5-4A99-8B10-C91EAC28F7E3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8320763C-3EA5-4A99-8B10-C91EAC28F7E3}.Debug|ARM64.ActiveCfg = Debug|Any CPU + {8320763C-3EA5-4A99-8B10-C91EAC28F7E3}.Debug|ARM64.Build.0 = Debug|Any CPU + {8320763C-3EA5-4A99-8B10-C91EAC28F7E3}.Debug|x64.ActiveCfg = Debug|Any CPU + {8320763C-3EA5-4A99-8B10-C91EAC28F7E3}.Debug|x64.Build.0 = Debug|Any CPU + {8320763C-3EA5-4A99-8B10-C91EAC28F7E3}.Debug|x86.ActiveCfg = Debug|Any CPU + {8320763C-3EA5-4A99-8B10-C91EAC28F7E3}.Debug|x86.Build.0 = Debug|Any CPU + {8320763C-3EA5-4A99-8B10-C91EAC28F7E3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8320763C-3EA5-4A99-8B10-C91EAC28F7E3}.Release|Any CPU.Build.0 = Release|Any CPU + {8320763C-3EA5-4A99-8B10-C91EAC28F7E3}.Release|ARM64.ActiveCfg = Release|Any CPU + {8320763C-3EA5-4A99-8B10-C91EAC28F7E3}.Release|ARM64.Build.0 = Release|Any CPU + {8320763C-3EA5-4A99-8B10-C91EAC28F7E3}.Release|x64.ActiveCfg = Release|Any CPU + {8320763C-3EA5-4A99-8B10-C91EAC28F7E3}.Release|x64.Build.0 = Release|Any CPU + {8320763C-3EA5-4A99-8B10-C91EAC28F7E3}.Release|x86.ActiveCfg = Release|Any CPU + {8320763C-3EA5-4A99-8B10-C91EAC28F7E3}.Release|x86.Build.0 = Release|Any CPU + {B8DECB45-08CD-4A12-AAFB-FE5AE553AB84}.Debug|Any CPU.ActiveCfg = Debug|x64 + {B8DECB45-08CD-4A12-AAFB-FE5AE553AB84}.Debug|Any CPU.Build.0 = Debug|x64 + {B8DECB45-08CD-4A12-AAFB-FE5AE553AB84}.Debug|Any CPU.Deploy.0 = Debug|x64 + {B8DECB45-08CD-4A12-AAFB-FE5AE553AB84}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {B8DECB45-08CD-4A12-AAFB-FE5AE553AB84}.Debug|ARM64.Build.0 = Debug|ARM64 + {B8DECB45-08CD-4A12-AAFB-FE5AE553AB84}.Debug|ARM64.Deploy.0 = Debug|ARM64 + {B8DECB45-08CD-4A12-AAFB-FE5AE553AB84}.Debug|x64.ActiveCfg = Debug|x64 + {B8DECB45-08CD-4A12-AAFB-FE5AE553AB84}.Debug|x64.Build.0 = Debug|x64 + {B8DECB45-08CD-4A12-AAFB-FE5AE553AB84}.Debug|x64.Deploy.0 = Debug|x64 + {B8DECB45-08CD-4A12-AAFB-FE5AE553AB84}.Debug|x86.ActiveCfg = Debug|x86 + {B8DECB45-08CD-4A12-AAFB-FE5AE553AB84}.Debug|x86.Build.0 = Debug|x86 + {B8DECB45-08CD-4A12-AAFB-FE5AE553AB84}.Debug|x86.Deploy.0 = Debug|x86 + {B8DECB45-08CD-4A12-AAFB-FE5AE553AB84}.Release|Any CPU.ActiveCfg = Release|x64 + {B8DECB45-08CD-4A12-AAFB-FE5AE553AB84}.Release|Any CPU.Build.0 = Release|x64 + {B8DECB45-08CD-4A12-AAFB-FE5AE553AB84}.Release|Any CPU.Deploy.0 = Release|x64 + {B8DECB45-08CD-4A12-AAFB-FE5AE553AB84}.Release|ARM64.ActiveCfg = Release|ARM64 + {B8DECB45-08CD-4A12-AAFB-FE5AE553AB84}.Release|ARM64.Build.0 = Release|ARM64 + {B8DECB45-08CD-4A12-AAFB-FE5AE553AB84}.Release|ARM64.Deploy.0 = Release|ARM64 + {B8DECB45-08CD-4A12-AAFB-FE5AE553AB84}.Release|x64.ActiveCfg = Release|x64 + {B8DECB45-08CD-4A12-AAFB-FE5AE553AB84}.Release|x64.Build.0 = Release|x64 + {B8DECB45-08CD-4A12-AAFB-FE5AE553AB84}.Release|x64.Deploy.0 = Release|x64 + {B8DECB45-08CD-4A12-AAFB-FE5AE553AB84}.Release|x86.ActiveCfg = Release|x86 + {B8DECB45-08CD-4A12-AAFB-FE5AE553AB84}.Release|x86.Build.0 = Release|x86 + {B8DECB45-08CD-4A12-AAFB-FE5AE553AB84}.Release|x86.Deploy.0 = Release|x86 + {765A4E19-B377-4BFE-A4D0-53C31F691731}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {765A4E19-B377-4BFE-A4D0-53C31F691731}.Debug|Any CPU.Build.0 = Debug|Any CPU + {765A4E19-B377-4BFE-A4D0-53C31F691731}.Debug|ARM64.ActiveCfg = Debug|Any CPU + {765A4E19-B377-4BFE-A4D0-53C31F691731}.Debug|ARM64.Build.0 = Debug|Any CPU + {765A4E19-B377-4BFE-A4D0-53C31F691731}.Debug|x64.ActiveCfg = Debug|Any CPU + {765A4E19-B377-4BFE-A4D0-53C31F691731}.Debug|x64.Build.0 = Debug|Any CPU + {765A4E19-B377-4BFE-A4D0-53C31F691731}.Debug|x86.ActiveCfg = Debug|Any CPU + {765A4E19-B377-4BFE-A4D0-53C31F691731}.Debug|x86.Build.0 = Debug|Any CPU + {765A4E19-B377-4BFE-A4D0-53C31F691731}.Release|Any CPU.ActiveCfg = Release|Any CPU + {765A4E19-B377-4BFE-A4D0-53C31F691731}.Release|Any CPU.Build.0 = Release|Any CPU + {765A4E19-B377-4BFE-A4D0-53C31F691731}.Release|ARM64.ActiveCfg = Release|Any CPU + {765A4E19-B377-4BFE-A4D0-53C31F691731}.Release|ARM64.Build.0 = Release|Any CPU + {765A4E19-B377-4BFE-A4D0-53C31F691731}.Release|x64.ActiveCfg = Release|Any CPU + {765A4E19-B377-4BFE-A4D0-53C31F691731}.Release|x64.Build.0 = Release|Any CPU + {765A4E19-B377-4BFE-A4D0-53C31F691731}.Release|x86.ActiveCfg = Release|Any CPU + {765A4E19-B377-4BFE-A4D0-53C31F691731}.Release|x86.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {9024EEAE-E061-42FA-90FD-4C97F114E21D} + EndGlobalSection +EndGlobal diff --git a/samples/Basic/WinUI/UWP/SkiaSharpSample/App.xaml b/samples/Basic/WinUI/UWP/SkiaSharpSample/App.xaml new file mode 100644 index 00000000000..4ef7c6d3af8 --- /dev/null +++ b/samples/Basic/WinUI/UWP/SkiaSharpSample/App.xaml @@ -0,0 +1,15 @@ + + + + + + + + + + + diff --git a/samples/Basic/WinUI/UWP/SkiaSharpSample/App.xaml.cs b/samples/Basic/WinUI/UWP/SkiaSharpSample/App.xaml.cs new file mode 100644 index 00000000000..39bf95d8992 --- /dev/null +++ b/samples/Basic/WinUI/UWP/SkiaSharpSample/App.xaml.cs @@ -0,0 +1,90 @@ +using System; +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Controls; +using Microsoft.UI.Xaml.Navigation; +using Windows.ApplicationModel; +using Windows.ApplicationModel.Activation; + +namespace SkiaSharpSample +{ + /// + /// Provides application-specific behavior to supplement the default Application class. + /// + sealed partial class App : Application + { + /// + /// Initializes the singleton application object. This is the first line of authored code + /// executed, and as such is the logical equivalent of main() or WinMain(). + /// + public App() + { + InitializeComponent(); + Suspending += OnSuspending; + } + + /// + /// Invoked when the application is launched normally by the end user. Other entry points + /// will be used such as when the application is launched to open a specific file. + /// + /// Details about the launch request and process. + protected override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs e) + { + var rootFrame = Window.Current.Content as Frame; + + // Do not repeat app initialization when the Window already has content, + // just ensure that the window is active + if (rootFrame == null) + { + // Create a Frame to act as the navigation context and navigate to the first page + rootFrame = new Frame(); + + rootFrame.NavigationFailed += OnNavigationFailed; + + if (e.UWPLaunchActivatedEventArgs.PreviousExecutionState == ApplicationExecutionState.Terminated) + { + //TODO: Load state from previously suspended application + } + + // Place the frame in the current Window + Window.Current.Content = rootFrame; + } + + if (e.UWPLaunchActivatedEventArgs.PrelaunchActivated == false) + { + if (rootFrame.Content == null) + { + // When the navigation stack isn't restored navigate to the first page, + // configuring the new page by passing required information as a navigation + // parameter + rootFrame.Navigate(typeof(MainPage), e.Arguments); + } + // Ensure the current window is active + Window.Current.Activate(); + } + } + + /// + /// Invoked when Navigation to a certain page fails + /// + /// The Frame which failed navigation + /// Details about the navigation failure + private void OnNavigationFailed(object sender, NavigationFailedEventArgs e) + { + throw new Exception("Failed to load Page " + e.SourcePageType.FullName); + } + + /// + /// Invoked when application execution is being suspended. Application state is saved + /// without knowing whether the application will be terminated or resumed with the contents + /// of memory still intact. + /// + /// The source of the suspend request. + /// Details about the suspend request. + private void OnSuspending(object sender, SuspendingEventArgs e) + { + var deferral = e.SuspendingOperation.GetDeferral(); + //TODO: Save application state and stop any background activity + deferral.Complete(); + } + } +} diff --git a/samples/Basic/WinUI/UWP/SkiaSharpSample/Assets/LockScreenLogo.scale-200.png b/samples/Basic/WinUI/UWP/SkiaSharpSample/Assets/LockScreenLogo.scale-200.png new file mode 100644 index 00000000000..735f57adb5d Binary files /dev/null and b/samples/Basic/WinUI/UWP/SkiaSharpSample/Assets/LockScreenLogo.scale-200.png differ diff --git a/samples/Basic/WinUI/UWP/SkiaSharpSample/Assets/SplashScreen.scale-200.png b/samples/Basic/WinUI/UWP/SkiaSharpSample/Assets/SplashScreen.scale-200.png new file mode 100644 index 00000000000..023e7f1feda Binary files /dev/null and b/samples/Basic/WinUI/UWP/SkiaSharpSample/Assets/SplashScreen.scale-200.png differ diff --git a/samples/Basic/WinUI/UWP/SkiaSharpSample/Assets/Square150x150Logo.scale-200.png b/samples/Basic/WinUI/UWP/SkiaSharpSample/Assets/Square150x150Logo.scale-200.png new file mode 100644 index 00000000000..af49fec1a54 Binary files /dev/null and b/samples/Basic/WinUI/UWP/SkiaSharpSample/Assets/Square150x150Logo.scale-200.png differ diff --git a/samples/Basic/WinUI/UWP/SkiaSharpSample/Assets/Square44x44Logo.scale-200.png b/samples/Basic/WinUI/UWP/SkiaSharpSample/Assets/Square44x44Logo.scale-200.png new file mode 100644 index 00000000000..ce342a2ec8a Binary files /dev/null and b/samples/Basic/WinUI/UWP/SkiaSharpSample/Assets/Square44x44Logo.scale-200.png differ diff --git a/samples/Basic/WinUI/UWP/SkiaSharpSample/Assets/Square44x44Logo.targetsize-24_altform-unplated.png b/samples/Basic/WinUI/UWP/SkiaSharpSample/Assets/Square44x44Logo.targetsize-24_altform-unplated.png new file mode 100644 index 00000000000..f6c02ce97e0 Binary files /dev/null and b/samples/Basic/WinUI/UWP/SkiaSharpSample/Assets/Square44x44Logo.targetsize-24_altform-unplated.png differ diff --git a/samples/Basic/WinUI/UWP/SkiaSharpSample/Assets/StoreLogo.png b/samples/Basic/WinUI/UWP/SkiaSharpSample/Assets/StoreLogo.png new file mode 100644 index 00000000000..7385b56c0e4 Binary files /dev/null and b/samples/Basic/WinUI/UWP/SkiaSharpSample/Assets/StoreLogo.png differ diff --git a/samples/Basic/WinUI/UWP/SkiaSharpSample/Assets/Wide310x150Logo.scale-200.png b/samples/Basic/WinUI/UWP/SkiaSharpSample/Assets/Wide310x150Logo.scale-200.png new file mode 100644 index 00000000000..288995b397f Binary files /dev/null and b/samples/Basic/WinUI/UWP/SkiaSharpSample/Assets/Wide310x150Logo.scale-200.png differ diff --git a/samples/Basic/WinUI/UWP/SkiaSharpSample/MainPage.xaml b/samples/Basic/WinUI/UWP/SkiaSharpSample/MainPage.xaml new file mode 100644 index 00000000000..502a20c1fbd --- /dev/null +++ b/samples/Basic/WinUI/UWP/SkiaSharpSample/MainPage.xaml @@ -0,0 +1,14 @@ + + + + + diff --git a/samples/Basic/WinUI/UWP/SkiaSharpSample/MainPage.xaml.cs b/samples/Basic/WinUI/UWP/SkiaSharpSample/MainPage.xaml.cs new file mode 100644 index 00000000000..fe968aa2a77 --- /dev/null +++ b/samples/Basic/WinUI/UWP/SkiaSharpSample/MainPage.xaml.cs @@ -0,0 +1,44 @@ +using Microsoft.UI.Xaml.Controls; +using SkiaSharp; +using SkiaSharp.Views.WinUI; +using Windows.Graphics.Display; + +namespace SkiaSharpSample +{ + public sealed partial class MainPage : Page + { + public MainPage() + { + InitializeComponent(); + } + + private void OnPaintSurface(object sender, SKPaintSurfaceEventArgs e) + { + // the the canvas and properties + var canvas = e.Surface.Canvas; + + // get the screen density for scaling + var display = DisplayInformation.GetForCurrentView(); + var scale = display.LogicalDpi / 96.0f; + var scaledSize = new SKSize(e.Info.Width / scale, e.Info.Height / scale); + + // handle the device screen density + canvas.Scale(scale); + + // make sure the canvas is blank + canvas.Clear(SKColors.White); + + // draw some text + var paint = new SKPaint + { + Color = SKColors.Black, + IsAntialias = true, + Style = SKPaintStyle.Fill, + TextAlign = SKTextAlign.Center, + TextSize = 24 + }; + var coord = new SKPoint(scaledSize.Width / 2, (scaledSize.Height + paint.TextSize) / 2); + canvas.DrawText("SkiaSharp", coord, paint); + } + } +} diff --git a/samples/Basic/WinUI/UWP/SkiaSharpSample/Package.appxmanifest b/samples/Basic/WinUI/UWP/SkiaSharpSample/Package.appxmanifest new file mode 100644 index 00000000000..57623bbe294 --- /dev/null +++ b/samples/Basic/WinUI/UWP/SkiaSharpSample/Package.appxmanifest @@ -0,0 +1,49 @@ + + + + + + + + + + SkiaSharpSample + mattl + Assets\StoreLogo.png + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/samples/Basic/WinUI/UWP/SkiaSharpSample/Properties/AssemblyInfo.cs b/samples/Basic/WinUI/UWP/SkiaSharpSample/Properties/AssemblyInfo.cs new file mode 100644 index 00000000000..fbc7681cb12 --- /dev/null +++ b/samples/Basic/WinUI/UWP/SkiaSharpSample/Properties/AssemblyInfo.cs @@ -0,0 +1,29 @@ +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("SkiaSharpSample")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("SkiaSharpSample")] +[assembly: AssemblyCopyright("Copyright © 2020")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 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")] +[assembly: ComVisible(false)] \ No newline at end of file diff --git a/samples/Basic/WinUI/UWP/SkiaSharpSample/Properties/Default.rd.xml b/samples/Basic/WinUI/UWP/SkiaSharpSample/Properties/Default.rd.xml new file mode 100644 index 00000000000..af00722cdf9 --- /dev/null +++ b/samples/Basic/WinUI/UWP/SkiaSharpSample/Properties/Default.rd.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/samples/Basic/WinUI/UWP/SkiaSharpSample/SkiaSharpSample.csproj b/samples/Basic/WinUI/UWP/SkiaSharpSample/SkiaSharpSample.csproj new file mode 100644 index 00000000000..4090527bbad --- /dev/null +++ b/samples/Basic/WinUI/UWP/SkiaSharpSample/SkiaSharpSample.csproj @@ -0,0 +1,145 @@ + + + + + Debug + x86 + {B8DECB45-08CD-4A12-AAFB-FE5AE553AB84} + AppContainerExe + Properties + SkiaSharpSample + SkiaSharpSample + en-US + UAP + 10.0.18362.0 + 10.0.17763.0 + 16 + 512 + {A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + true + ..\..\..\..\AppStoreCertificates\SkiaSharpSample_TemporaryKey.pfx + 5FC604ABEDFB78C8B4E57214FEB937949F44ABE4 + PackageReference + 8.0 + + + true + bin\x86\Debug\ + DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP + full + x86 + false + prompt + true + + + bin\x86\Release\ + TRACE;NETFX_CORE;WINDOWS_UWP + true + pdbonly + x86 + false + prompt + true + true + + + true + bin\x64\Debug\ + DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP + full + x64 + false + prompt + true + + + bin\x64\Release\ + TRACE;NETFX_CORE;WINDOWS_UWP + true + pdbonly + x64 + false + prompt + true + true + + + true + bin\ARM64\Debug\ + DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP + full + ARM64 + false + prompt + true + + + bin\ARM64\Release\ + TRACE;NETFX_CORE;WINDOWS_UWP + true + pdbonly + ARM64 + false + prompt + true + true + + + + + + + + {8320763c-3ea5-4a99-8b10-c91eac28f7e3} + SkiaSharp.UWP + + + {765a4e19-b377-4bfe-a4d0-53c31f691731} + SkiaSharp.Views.WinUI.UWP + + + + + + + + + + + App.xaml + + + MainPage.xaml + + + + + + Designer + + + + + + + + + + + + + + + + MSBuild:Compile + + + MSBuild:Compile + + + + $(MinimumVisualStudioVersion) + + + \ No newline at end of file diff --git a/source/SkiaSharp.Views.WinUI/SkiaSharp.Views.WinUI.UWP/SkiaSharp.Views.WinUI.UWP.csproj b/source/SkiaSharp.Views.WinUI/SkiaSharp.Views.WinUI.UWP/SkiaSharp.Views.WinUI.UWP.csproj new file mode 100644 index 00000000000..7d1f472ac08 --- /dev/null +++ b/source/SkiaSharp.Views.WinUI/SkiaSharp.Views.WinUI.UWP/SkiaSharp.Views.WinUI.UWP.csproj @@ -0,0 +1,28 @@ + + + uap10.0.18362 + SkiaSharp.Views.Windows + SkiaSharp.Views.Windows + SkiaSharp.Views.WinUI + uap10.0 + 10.0.18362.0 + 10.0.17134.0 + $(DefineConstants);WINDOWS + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/source/SkiaSharp.Views/SkiaSharp.Views.Shared/Extensions.cs b/source/SkiaSharp.Views/SkiaSharp.Views.Shared/Extensions.cs index d2f0dc52877..137fd6dd18c 100644 --- a/source/SkiaSharp.Views/SkiaSharp.Views.Shared/Extensions.cs +++ b/source/SkiaSharp.Views/SkiaSharp.Views.Shared/Extensions.cs @@ -1,6 +1,8 @@ using System; -#if WINDOWS_UWP || HAS_UNO +#if WINDOWS +namespace SkiaSharp.Views.Windows +#elif WINDOWS_UWP || HAS_UNO namespace SkiaSharp.Views.UWP #elif __ANDROID__ namespace SkiaSharp.Views.Android @@ -16,8 +18,6 @@ namespace SkiaSharp.Views.Desktop namespace SkiaSharp.Views.Mac #elif __TIZEN__ namespace SkiaSharp.Views.Tizen -#elif WINDOWS -namespace SkiaSharp.Views.Windows #endif { public static class Extensions diff --git a/source/SkiaSharp.Views/SkiaSharp.Views.Shared/SKPaintGLSurfaceEventArgs.cs b/source/SkiaSharp.Views/SkiaSharp.Views.Shared/SKPaintGLSurfaceEventArgs.cs index 81620facdc6..bc45b89dd18 100644 --- a/source/SkiaSharp.Views/SkiaSharp.Views.Shared/SKPaintGLSurfaceEventArgs.cs +++ b/source/SkiaSharp.Views/SkiaSharp.Views.Shared/SKPaintGLSurfaceEventArgs.cs @@ -2,7 +2,9 @@ using System; using System.ComponentModel; -#if WINDOWS_UWP || HAS_UNO +#if WINDOWS +namespace SkiaSharp.Views.Windows +#elif WINDOWS_UWP || HAS_UNO namespace SkiaSharp.Views.UWP #elif __ANDROID__ namespace SkiaSharp.Views.Android @@ -16,8 +18,6 @@ namespace SkiaSharp.Views.Desktop namespace SkiaSharp.Views.Mac #elif __TIZEN__ namespace SkiaSharp.Views.Tizen -#elif WINDOWS -namespace SkiaSharp.Views.Windows #endif { public class SKPaintGLSurfaceEventArgs : EventArgs diff --git a/source/SkiaSharp.Views/SkiaSharp.Views.Shared/SKPaintSurfaceEventArgs.cs b/source/SkiaSharp.Views/SkiaSharp.Views.Shared/SKPaintSurfaceEventArgs.cs index 835ef31fff7..0d4917a57cf 100644 --- a/source/SkiaSharp.Views/SkiaSharp.Views.Shared/SKPaintSurfaceEventArgs.cs +++ b/source/SkiaSharp.Views/SkiaSharp.Views.Shared/SKPaintSurfaceEventArgs.cs @@ -1,6 +1,8 @@ using System; -#if WINDOWS_UWP || HAS_UNO +#if WINDOWS +namespace SkiaSharp.Views.Windows +#elif WINDOWS_UWP || HAS_UNO namespace SkiaSharp.Views.UWP #elif __ANDROID__ namespace SkiaSharp.Views.Android @@ -16,8 +18,6 @@ namespace SkiaSharp.Views.Desktop namespace SkiaSharp.Views.Mac #elif __TIZEN__ namespace SkiaSharp.Views.Tizen -#elif WINDOWS -namespace SkiaSharp.Views.Windows #endif { public class SKPaintSurfaceEventArgs : EventArgs diff --git a/source/SkiaSharp.Views/SkiaSharp.Views.UWP/AngleSwapChainPanel.cs b/source/SkiaSharp.Views/SkiaSharp.Views.UWP/AngleSwapChainPanel.cs index 9491cae7291..75d96c143ea 100644 --- a/source/SkiaSharp.Views/SkiaSharp.Views.UWP/AngleSwapChainPanel.cs +++ b/source/SkiaSharp.Views/SkiaSharp.Views.UWP/AngleSwapChainPanel.cs @@ -1,14 +1,19 @@ -#if !WINDOWS - -using System; +using System; using SkiaSharp.Views.GlesInterop; using Windows.ApplicationModel; using Windows.Foundation; using Windows.System.Threading; +#if WINDOWS +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Controls; +using Microsoft.UI.Xaml.Data; +using CoreDispatcherPriority = Windows.UI.Core.CoreDispatcherPriority; +#else using Windows.UI.Core; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Data; +#endif #if WINDOWS namespace SkiaSharp.Views.Windows @@ -299,5 +304,3 @@ private void RenderLoop(IAsyncAction action) } } } - -#endif diff --git a/source/SkiaSharp.Views/SkiaSharp.Views.UWP/GlesInterop/GlesContext.cs b/source/SkiaSharp.Views/SkiaSharp.Views.UWP/GlesInterop/GlesContext.cs index 8acfaa520ed..8d807aea266 100644 --- a/source/SkiaSharp.Views/SkiaSharp.Views.UWP/GlesInterop/GlesContext.cs +++ b/source/SkiaSharp.Views/SkiaSharp.Views.UWP/GlesInterop/GlesContext.cs @@ -105,7 +105,7 @@ public void CreateSurface(SwapChainPanel panel, Size? renderSurfaceSize, float? surface = Egl.eglCreateWindowSurface(eglDisplay, eglConfig, surfaceCreationProperties, surfaceAttributes); if (surface == Egl.EGL_NO_SURFACE) { - throw new Exception("Failed to create EGL surface"); + throw new Exception($"Failed to create EGL surface: {Egl.eglGetError():X}"); } eglSurface = surface; @@ -135,7 +135,7 @@ public void MakeCurrent() { if (Egl.eglMakeCurrent(eglDisplay, eglSurface, eglSurface, eglContext) == Egl.EGL_FALSE) { - throw new Exception("Failed to make EGLSurface current"); + throw new Exception($"Failed to make EGLSurface current: {Egl.eglGetError():X}"); } } @@ -211,7 +211,7 @@ private void InitializeDisplay() eglDisplay = Egl.eglGetPlatformDisplayEXT(Egl.EGL_PLATFORM_ANGLE_ANGLE, Egl.EGL_DEFAULT_DISPLAY, defaultDisplayAttributes); if (eglDisplay == Egl.EGL_NO_DISPLAY) { - throw new Exception("Failed to get EGL display"); + throw new Exception($"Failed to get EGL display: {Egl.eglGetError():X}"); } if (Egl.eglInitialize(eglDisplay, out int major, out int minor) == Egl.EGL_FALSE) @@ -220,7 +220,7 @@ private void InitializeDisplay() eglDisplay = Egl.eglGetPlatformDisplayEXT(Egl.EGL_PLATFORM_ANGLE_ANGLE, Egl.EGL_DEFAULT_DISPLAY, fl9_3DisplayAttributes); if (eglDisplay == Egl.EGL_NO_DISPLAY) { - throw new Exception("Failed to get EGL display"); + throw new Exception($"Failed to get EGL display: {Egl.eglGetError():X}"); } if (Egl.eglInitialize(eglDisplay, out major, out minor) == Egl.EGL_FALSE) @@ -229,13 +229,13 @@ private void InitializeDisplay() eglDisplay = Egl.eglGetPlatformDisplayEXT(Egl.EGL_PLATFORM_ANGLE_ANGLE, Egl.EGL_DEFAULT_DISPLAY, warpDisplayAttributes); if (eglDisplay == Egl.EGL_NO_DISPLAY) { - throw new Exception("Failed to get EGL display"); + throw new Exception($"Failed to get EGL display: {Egl.eglGetError():X}"); } if (Egl.eglInitialize(eglDisplay, out major, out minor) == Egl.EGL_FALSE) { // If all of the calls to eglInitialize returned EGL_FALSE then an error has occurred. - throw new Exception("Failed to initialize EGL"); + throw new Exception($"Failed to initialize EGL: {Egl.eglGetError():X}"); } } } @@ -263,14 +263,14 @@ public void Initialize() EGLDisplay[] configs = new EGLDisplay[1]; if ((Egl.eglChooseConfig(eglDisplay, configAttributes, configs, configs.Length, out int numConfigs) == Egl.EGL_FALSE) || (numConfigs == 0)) { - throw new Exception("Failed to choose first EGLConfig"); + throw new Exception($"Failed to choose first EGLConfig: {Egl.eglGetError():X}"); } eglConfig = configs[0]; eglContext = Egl.eglCreateContext(eglDisplay, eglConfig, Egl.EGL_NO_CONTEXT, contextAttributes); if (eglContext == Egl.EGL_NO_CONTEXT) { - throw new Exception("Failed to create EGL context"); + throw new Exception($"Failed to create EGL context: {Egl.eglGetError():X}"); } } diff --git a/source/SkiaSharp.Views/SkiaSharp.Views.UWP/SKSwapChainPanel.cs b/source/SkiaSharp.Views/SkiaSharp.Views.UWP/SKSwapChainPanel.cs index e2ef5a63f9e..a0facf0fddd 100644 --- a/source/SkiaSharp.Views/SkiaSharp.Views.UWP/SKSwapChainPanel.cs +++ b/source/SkiaSharp.Views/SkiaSharp.Views.UWP/SKSwapChainPanel.cs @@ -1,6 +1,4 @@ -#if !WINDOWS - -using System; +using System; using SkiaSharp.Views.GlesInterop; using Windows.Foundation; @@ -125,5 +123,3 @@ protected override void OnDestroyingContext() } } } - -#endif diff --git a/source/SkiaSharpSource.Windows.sln b/source/SkiaSharpSource.Windows.sln index 8e463eebe49..c1ba2836fed 100644 --- a/source/SkiaSharpSource.Windows.sln +++ b/source/SkiaSharpSource.Windows.sln @@ -73,6 +73,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SkiaSharp.Views.WinUI", "Sk EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SkiaSharp.Views.WinUI", "SkiaSharp.Views.WinUI", "{32AE56A0-F3E1-4721-9BED-B1F609DEA8E8}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SkiaSharp.Views.WinUI.UWP", "SkiaSharp.Views.WinUI\SkiaSharp.Views.WinUI.UWP\SkiaSharp.Views.WinUI.UWP.csproj", "{19E8BCE9-CDB0-4EFB-85C8-C1C7113C22F7}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -187,6 +189,10 @@ Global {F50AE765-D9B9-4025-88A8-E8B080D5D624}.Debug|Any CPU.Build.0 = Debug|Any CPU {F50AE765-D9B9-4025-88A8-E8B080D5D624}.Release|Any CPU.ActiveCfg = Release|Any CPU {F50AE765-D9B9-4025-88A8-E8B080D5D624}.Release|Any CPU.Build.0 = Release|Any CPU + {19E8BCE9-CDB0-4EFB-85C8-C1C7113C22F7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {19E8BCE9-CDB0-4EFB-85C8-C1C7113C22F7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {19E8BCE9-CDB0-4EFB-85C8-C1C7113C22F7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {19E8BCE9-CDB0-4EFB-85C8-C1C7113C22F7}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -219,6 +225,7 @@ Global {F675A841-ECDB-4571-8AA3-7D4642FD57DB} = {E53351EA-FE40-47D2-B388-4A75DA6CCD71} {D5C7D157-609E-4D64-8E42-C1DB0FAA86EB} = {E53351EA-FE40-47D2-B388-4A75DA6CCD71} {F50AE765-D9B9-4025-88A8-E8B080D5D624} = {32AE56A0-F3E1-4721-9BED-B1F609DEA8E8} + {19E8BCE9-CDB0-4EFB-85C8-C1C7113C22F7} = {32AE56A0-F3E1-4721-9BED-B1F609DEA8E8} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {63A8C36E-4917-46DB-9AAD-522B8EC00C23} diff --git a/source/SkiaSharpSource.sln b/source/SkiaSharpSource.sln index af4848986d3..da2b65e9f2e 100644 --- a/source/SkiaSharpSource.sln +++ b/source/SkiaSharpSource.sln @@ -109,6 +109,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SkiaSharp.Views.WinUI", "Sk EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SkiaSharp.Views.WinUI", "SkiaSharp.Views.WinUI\SkiaSharp.Views.WinUI\SkiaSharp.Views.WinUI.csproj", "{02CA4107-1FC6-4676-B284-9981694A450E}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SkiaSharp.Views.WinUI.UWP", "SkiaSharp.Views.WinUI\SkiaSharp.Views.WinUI.UWP\SkiaSharp.Views.WinUI.UWP.csproj", "{E76C80EF-D37D-4EA9-8C30-0AA678FFA5BF}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -295,6 +297,10 @@ Global {02CA4107-1FC6-4676-B284-9981694A450E}.Debug|Any CPU.Build.0 = Debug|Any CPU {02CA4107-1FC6-4676-B284-9981694A450E}.Release|Any CPU.ActiveCfg = Release|Any CPU {02CA4107-1FC6-4676-B284-9981694A450E}.Release|Any CPU.Build.0 = Release|Any CPU + {E76C80EF-D37D-4EA9-8C30-0AA678FFA5BF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E76C80EF-D37D-4EA9-8C30-0AA678FFA5BF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E76C80EF-D37D-4EA9-8C30-0AA678FFA5BF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E76C80EF-D37D-4EA9-8C30-0AA678FFA5BF}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -345,6 +351,7 @@ Global {047C460D-7470-418C-AF2C-30620A1AF61C} = {E53351EA-FE40-47D2-B388-4A75DA6CCD71} {D5C7D157-609E-4D64-8E42-C1DB0FAA86EB} = {E53351EA-FE40-47D2-B388-4A75DA6CCD71} {02CA4107-1FC6-4676-B284-9981694A450E} = {6430EC5F-EDA1-4202-AB7B-22ED0496E016} + {E76C80EF-D37D-4EA9-8C30-0AA678FFA5BF} = {6430EC5F-EDA1-4202-AB7B-22ED0496E016} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {67EACD19-0CEA-4127-9842-549AA6FB84C9}