Skip to content

Commit

Permalink
Update MAUI to RC 1 and use a macOS Monterey pool (#1986)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattleibow authored Apr 13, 2022
1 parent b7728fa commit 486317a
Show file tree
Hide file tree
Showing 21 changed files with 99 additions and 54 deletions.
7 changes: 7 additions & 0 deletions nuget/SkiaSharp.Views.WinUI.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ Please visit https://go.microsoft.com/fwlink/?linkid=868517 to view the release
<dependency id="SkiaSharp" version="1.0.0" />
<dependency id="Microsoft.WindowsAppSDK" version="1.0.0" />
</group>
<group targetFramework="net6.0-windows10.0.18362">
<dependency id="SkiaSharp" version="1.0.0" />
<dependency id="Microsoft.WindowsAppSDK" version="1.0.0" />
</group>
</dependencies>

</metadata>
Expand All @@ -40,6 +44,9 @@ Please visit https://go.microsoft.com/fwlink/?linkid=868517 to view the release
<file platform="windows" src="lib/net5.0-windows10.0.18362/SkiaSharp.Views.Windows.dll" />
<file platform="windows" src="lib/net5.0-windows10.0.18362/SkiaSharp.Views.Windows.pdb" />
<file platform="windows" src="lib/net5.0-windows10.0.18362/SkiaSharp.Views.Windows.xml" />
<file platform="windows" src="lib/net6.0-windows10.0.18362/SkiaSharp.Views.Windows.dll" />
<file platform="windows" src="lib/net6.0-windows10.0.18362/SkiaSharp.Views.Windows.pdb" />
<file platform="windows" src="lib/net6.0-windows10.0.18362/SkiaSharp.Views.Windows.xml" />

<!-- legal -->
<file src="LICENSE.txt" />
Expand Down
1 change: 1 addition & 0 deletions samples/Basic/Maui/SkiaSharpSample/MauiProgram.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Microsoft.Maui.Hosting;
using Microsoft.Maui.Controls.Hosting;
using SkiaSharp.Views.Maui.Controls.Hosting;
using Microsoft.Maui.Controls.Compatibility.Hosting;

namespace SkiaSharpSample
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,5 @@ public App()
}

protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();

protected override void OnLaunched(LaunchActivatedEventArgs args)
{
base.OnLaunched(args);

Microsoft.Maui.Essentials.Platform.OnLaunched(args);
}
}
}
14 changes: 2 additions & 12 deletions samples/Basic/Maui/SkiaSharpSample/SkiaSharpSample.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFrameworks>net6.0-ios;net6.0-maccatalyst;net6.0-android</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows')) and '$(MSBuildRuntimeType)' == 'Full'">$(TargetFrameworks);net6.0-windows10.0.19041</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows')) and '$(MSBuildRuntimeType)' == 'Full'">$(TargetFrameworks);net6.0-windows10.0.19041.0</TargetFrameworks>
<OutputType>Exe</OutputType>
<UseMaui>true</UseMaui>
<SingleProject>true</SingleProject>
Expand All @@ -18,7 +18,7 @@
<SupportedOSPlatformVersion Condition="'$(TargetFramework)' == 'net6.0-ios'">14.2</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="'$(TargetFramework)' == 'net6.0-maccatalyst'">14.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="'$(TargetFramework)' == 'net6.0-android'">21.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$(TargetFramework.Contains('-windows'))">10.0.18362.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$(TargetFramework.Contains('-windows'))">10.0.17763.0</SupportedOSPlatformVersion>
</PropertyGroup>

<ItemGroup>
Expand All @@ -37,23 +37,13 @@
<ProjectReference Include="..\..\..\..\source\SkiaSharp.Views.Maui\SkiaSharp.Views.Maui.Controls\SkiaSharp.Views.Maui.Controls.csproj" />
</ItemGroup>

<ItemGroup Condition="$(TargetFramework.Contains('-windows'))">
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.0.0" />
<PackageReference Include="Microsoft.Graphics.Win2D" Version="1.0.0.30" />
</ItemGroup>

<ItemGroup Condition="$(TargetFramework.Contains('-windows'))">
<None Include="..\..\..\..\output\native\windows\x64\libSkiaSharp.dll" Condition="Exists('..\..\..\..\output\native\windows\x64\libSkiaSharp.dll')">
<Link>libSkiaSharp.dll</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

<PropertyGroup Condition="$(TargetFramework.Contains('-windows'))">
<OutputType>WinExe</OutputType>
<RuntimeIdentifier>win10-x64</RuntimeIdentifier>
</PropertyGroup>

<Import Project="..\..\..\..\output\SkiaSharp\nuget\build\$(TargetFramework)\SkiaSharp.Local.targets" Condition="Exists('..\..\..\..\output\SkiaSharp\nuget\build\$(TargetFramework)\SkiaSharp.Local.targets')" />

</Project>
6 changes: 3 additions & 3 deletions scripts/azure-pipelines-variables.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ variables:
MONO_VERSION_MACOS: '6_12_13'
MONO_VERSION_LINUX: ''
XCODE_VERSION: 13.2.1
VISUAL_STUDIO_VERSION: ''
DOTNET_VERSION_PREVIEW: '6.0.200-rtm.22107.3'
DOTNET_WORKLOAD_SOURCE: 'https://aka.ms/dotnet/maui/6.0.200/preview.14.json'
VISUAL_STUDIO_VERSION: '17/pre'
DOTNET_VERSION_PREVIEW: '6.0.300-preview.22179.2'
DOTNET_WORKLOAD_SOURCE: 'https://aka.ms/dotnet/maui/6.0.300/rc.1.json'
CONFIGURATION: 'Release'
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
THROW_ON_TEST_FAILURE: true
Expand Down
25 changes: 23 additions & 2 deletions scripts/azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,33 @@ parameters:
pool:
name: Azure Pipelines
vmImage: windows-2022
- name: VM_IMAGE_MAC
- name: VM_IMAGE_MAC_NATIVE
type: object
default:
pool:
name: Azure Pipelines
vmImage: macos-11
- name: VM_IMAGE_MAC
type: object
default:
pool:
name: VSEng-VSMac-Xamarin-Shared
vmImage: VSEng-VSMac-Xamarin-Shared
demands:
- macOS.Name -equals Monterey
- macOS.Architecture -equals x64
- Agent.HasDevices -equals False
- Agent.IsPaired -equals False
variables:
XCODE_VERSION: 13.3.0
provisioningSteps:
- task: xamops.azdevex.provisionator-task.provisionator@1
displayName: 'Provision Xamarin'
inputs:
provisioning_script: ./scripts/provisionator.csx
provisioning_extra_args: --force
env:
AUTH_TOKEN_GITHUB_COM: $(github--pat--vs-mobiletools-engineering-service2)
- name: VM_IMAGE_LINUX
type: object
default:
Expand All @@ -51,6 +72,6 @@ stages:
VM_IMAGE_WINDOWS: ${{ parameters.VM_IMAGE_WINDOWS }}
VM_IMAGE_WINDOWS_NATIVE: ${{ parameters.VM_IMAGE_WINDOWS }}
VM_IMAGE_MAC: ${{ parameters.VM_IMAGE_MAC }}
VM_IMAGE_MAC_NATIVE: ${{ parameters.VM_IMAGE_MAC }}
VM_IMAGE_MAC_NATIVE: ${{ parameters.VM_IMAGE_MAC_NATIVE }}
VM_IMAGE_LINUX: ${{ parameters.VM_IMAGE_LINUX }}
VM_IMAGE_LINUX_NATIVE: ${{ parameters.VM_IMAGE_LINUX }}
3 changes: 2 additions & 1 deletion scripts/azure-templates-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,10 @@ jobs:
displayName: Display all the .NET information
# install VS
- ${{ if endsWith(parameters.name, '_windows') }}:
- ${{ if and(eq(parameters.installPreviewVs, 'true'), ne(variables.VISUAL_STUDIO_VERSION, '')) }}:
- ${{ if eq(parameters.installPreviewVs, 'true') }}:
- pwsh: .\scripts\install-vs.ps1 -Version $(VISUAL_STUDIO_VERSION)
displayName: Install Visual Studio
condition: ne(variables.VISUAL_STUDIO_VERSION, '')
# install workloads
- ${{ if not(endsWith(parameters.name, '_linux')) }}:
- pwsh: .\scripts\install-dotnet-workloads.ps1 -InstallDir "$env:AGENT_TOOLSDIRECTORY/dotnet" -SourceUrl "$env:DOTNET_WORKLOAD_SOURCE" -IsPreview $true
Expand Down
18 changes: 11 additions & 7 deletions scripts/azure-templates-variables.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,17 @@ steps:
- pwsh: |
Write-Host "Working with $env:RESOURCES_PIPELINE_SKIASHARP_RUNNAME"
$match = [regex]::Match("$env:RESOURCES_PIPELINE_SKIASHARP_RUNNAME", '.*\-(.+)\.(\d+)')
$label = $match.Groups[1].Value
Write-Host "Preview label: $label"
Write-Host "##vso[task.setvariable variable=PREVIEW_LABEL]$label"
$buildnumber = $match.Groups[2].Value
Write-Host "Build number: $buildnumber"
Write-Host "##vso[task.setvariable variable=BUILD_NUMBER]$buildnumber"
if ($env:RESOURCES_PIPELINE_SKIASHARP_RUNNAME) {
$match = [regex]::Match("$env:RESOURCES_PIPELINE_SKIASHARP_RUNNAME", '.*\-(.+)\.(\d+)')
$label = $match.Groups[1].Value
Write-Host "Preview label: $label"
Write-Host "##vso[task.setvariable variable=PREVIEW_LABEL]$label"
$buildnumber = $match.Groups[2].Value
Write-Host "Build number: $buildnumber"
Write-Host "##vso[task.setvariable variable=BUILD_NUMBER]$buildnumber"
} else {
Write-Host "Not a secondary build."
}
condition: or(eq(variables['Build.Reason'], 'ResourceTrigger'), eq(variables['Build.Reason'], 'Manual'))
displayName: Override the preview label and build number if this is a secondary build
Expand Down
15 changes: 10 additions & 5 deletions scripts/install-vs.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,30 @@ if (Test-Path $fullPath) {
exit 0
}

$temp = "$env:TEMP"
if ("$env:AGENT_TEMPDIRECTORY") {
$temp = "$env:AGENT_TEMPDIRECTORY"
}

$startTime = Get-Date

Write-Host "Downloading Visual Studio Installer..."
Invoke-WebRequest -UseBasicParsing `
-Uri "https://aka.ms/vs/install/latest/vs_setup.exe" `
-OutFile "$env:TEMP\dd_vs_setup.exe"
-OutFile "$temp\dd_vs_setup.exe"

Write-Host "Updating the Visual Studio Installer..."
$exitCode = & "$env:TEMP\dd_vs_setup.exe" --update --quiet --wait | Out-Null
$exitCode = & "$temp\dd_vs_setup.exe" --update --quiet --wait | Out-Null

Write-Host "Exit code: $exitCode"

Write-Host "Downloading Visual Studio ($Version)..."
Invoke-WebRequest -UseBasicParsing `
-Uri "https://aka.ms/vs/$Version/vs_community.exe" `
-OutFile "$env:TEMP\dd_vs_community.exe"
-OutFile "$temp\dd_vs_community.exe"

Write-Host "Installing Visual Studio..."
$exitCode = & "$env:TEMP\dd_vs_community.exe" --quiet --norestart --wait `
$exitCode = & "$temp\dd_vs_community.exe" --quiet --norestart --wait `
--includeRecommended `
--add Microsoft.VisualStudio.Workload.NetCrossPlat `
--add Microsoft.VisualStudio.Workload.NetCoreTools `
Expand All @@ -41,7 +46,7 @@ Write-Host "Exit code: $exitCode"

$vsLogs = 'output\logs\vs-logs'
New-Item -ItemType Directory -Force -Path "$vsLogs" | Out-Null
Get-ChildItem "$env:TEMP\dd_*" |
Get-ChildItem "$temp\dd_*" |
Where-Object { $_.CreationTime -gt $startTime } |
Copy-Item -Destination "$vsLogs"

Expand Down
1 change: 1 addition & 0 deletions scripts/provisionator.csx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
XamarinChannel("Stable");
2 changes: 1 addition & 1 deletion source/SkiaSharp.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<SupportedOSPlatformVersion Condition="$(TargetFramework.Contains('-macos'))">10.14</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$(TargetFramework.Contains('-maccatalyst'))">13.1</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$(TargetFramework.Contains('-android'))">21.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$(TargetFramework.Contains('-windows'))">10.0.18362.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$(TargetFramework.Contains('-windows'))">10.0.17763.0</SupportedOSPlatformVersion>

<!--
Suppress version attribute generation in Microsoft.NET.Sdk projects to avoid build failures
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@

#if __ANDROID__
using Android.Content;
using Microsoft.Maui.Controls.Compatibility.Platform.Android;
using Microsoft.Maui.Controls.Handlers.Compatibility;
using SKNativeView = SkiaSharp.Views.Android.SKCanvasView;
using SKNativePaintSurfaceEventArgs = SkiaSharp.Views.Android.SKPaintSurfaceEventArgs;
#elif __IOS__
using Microsoft.Maui.Controls.Compatibility.Platform.iOS;
using Microsoft.Maui.Controls.Handlers.Compatibility;
using SKNativeView = SkiaSharp.Views.iOS.SKCanvasView;
using SKNativePaintSurfaceEventArgs = SkiaSharp.Views.iOS.SKPaintSurfaceEventArgs;
#elif WINDOWS
using Windows.Graphics.Display;
using Microsoft.Maui.Controls.Compatibility.Platform.UWP;
using Microsoft.Maui.Controls.Handlers.Compatibility;
using SKNativeView = SkiaSharp.Views.Windows.SKXamlCanvas;
using SKNativePaintSurfaceEventArgs = SkiaSharp.Views.Windows.SKPaintSurfaceEventArgs;
using WVisibility = Microsoft.UI.Xaml.Visibility;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@

#if __ANDROID__
using Android.Content;
using Microsoft.Maui.Controls.Compatibility.Platform.Android;
using Microsoft.Maui.Controls.Handlers.Compatibility;
using SKNativeView = SkiaSharp.Views.Android.SKGLTextureView;
using SKNativePaintGLSurfaceEventArgs = SkiaSharp.Views.Android.SKPaintGLSurfaceEventArgs;
#elif __IOS__
using Microsoft.Maui.Controls.Compatibility.Platform.iOS;
using Microsoft.Maui.Controls.Handlers.Compatibility;
using SKNativeView = SkiaSharp.Views.iOS.SKGLView;
using SKNativePaintGLSurfaceEventArgs = SkiaSharp.Views.iOS.SKPaintGLSurfaceEventArgs;
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ protected override void OnPropertyChanged(string propertyName = null)
{
if (propertyName == PictureProperty.PropertyName)
OnSourceChanged();
else if (propertyName == DimensionsProperty.PropertyName)
OnSourceChanged();
base.OnPropertyChanged(propertyName);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using Microsoft.Maui;
using Microsoft.Maui.Controls.Compatibility;
using Microsoft.Maui.Hosting;
using SkiaSharp.Views.Maui.Controls.Compatibility;
using SkiaSharp.Views.Maui.Controls.Hosting;
Expand All @@ -27,12 +25,12 @@ public static MauiAppBuilder UseSkiaSharp(this MauiAppBuilder builder, bool regi
{
#if !NETSTANDARD
if (replaceHandlers)
handlers.AddCompatibilityRenderer(typeof(SKCanvasView), typeof(SKCanvasViewRenderer));
handlers.AddHandler<SKCanvasView, SKCanvasViewRenderer>();
else
handlers.TryAddCompatibilityRenderer(typeof(SKCanvasView), typeof(SKCanvasViewRenderer));
handlers.TryAddHandler<SKCanvasView, SKCanvasViewRenderer>();

#if !WINDOWS && !__MACCATALYST__
handlers.AddCompatibilityRenderer(typeof(SKGLView), typeof(SKGLViewRenderer));
handlers.AddHandler<SKGLView, SKGLViewRenderer>();
#endif

CompatRegistrar.Registered.Register(typeof(SKImageImageSource), typeof(SKImageSourceHandler));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ private void OnPaintSurface(object? sender, Android.SKPaintSurfaceEventArgs e)
VirtualView?.OnCanvasSizeChanged(newCanvasSize);
}

VirtualView?.OnPaintSurface(new SKPaintSurfaceEventArgs(e.Surface, e.Info));
VirtualView?.OnPaintSurface(new SKPaintSurfaceEventArgs(e.Surface, e.Info, e.RawInfo));
}

private SKPoint OnGetScaledCoord(double x, double y)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ private void OnPaintSurface(object? sender, Windows.SKPaintSurfaceEventArgs e)
VirtualView?.OnCanvasSizeChanged(newCanvasSize);
}

VirtualView?.OnPaintSurface(new SKPaintSurfaceEventArgs(e.Surface, e.Info));
VirtualView?.OnPaintSurface(new SKPaintSurfaceEventArgs(e.Surface, e.Info, e.RawInfo));
}

private SKPoint OnGetScaledCoord(double x, double y)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ private void OnPaintSurface(object? sender, iOS.SKPaintSurfaceEventArgs e)
VirtualView?.OnCanvasSizeChanged(newCanvasSize);
}

VirtualView?.OnPaintSurface(new SKPaintSurfaceEventArgs(e.Surface, e.Info));
VirtualView?.OnPaintSurface(new SKPaintSurfaceEventArgs(e.Surface, e.Info, e.RawInfo));
}

private SKPoint OnGetScaledCoord(double x, double y)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,29 @@ namespace SkiaSharp.Views.Maui.Handlers
{
public partial class SKImageSourceService
{
public override Task<IImageSourceServiceResult<Drawable>?> GetDrawableAsync(IImageSource imageSource, Context context, CancellationToken cancellationToken = default)
public override async Task<IImageSourceServiceResult?> LoadDrawableAsync(
IImageSource imageSource,
global::Android.Widget.ImageView imageView,
CancellationToken cancellationToken = default)
{
var realResult = await GetDrawableAsync(imageView.Context!, imageSource, cancellationToken);

if (realResult is null)
{
imageView.SetImageDrawable(null);
return null;
}

imageView.SetImageDrawable(realResult.Value);

var result = new ImageSourceServiceLoadResult(
realResult.IsResolutionDependent,
() => realResult.Dispose());

return result;
}

public override Task<IImageSourceServiceResult<Drawable>?> GetDrawableAsync(Context context, IImageSource imageSource, CancellationToken cancellationToken = default)
{
var bitmap = imageSource switch
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0-windows10.0.18362</TargetFramework>
<TargetFrameworks>net5.0-windows10.0.18362;net6.0-windows10.0.18362</TargetFrameworks>
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
<RootNamespace>SkiaSharp.Views.Windows</RootNamespace>
<AssemblyName>SkiaSharp.Views.Windows</AssemblyName>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public static WriteableBitmap ToWriteableBitmap(this SKPicture picture, SKSizeI
{
using (var image = SKImage.FromPicture(picture, dimensions))
{
return image.ToWriteableBitmap();
return image?.ToWriteableBitmap();
}
}

Expand Down

0 comments on commit 486317a

Please sign in to comment.