Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
d8a98cf
Use a macOS Monterey pool
mattleibow Mar 31, 2022
89acfb4
Use different machines for managed and unmanaged
mattleibow Mar 31, 2022
8ec4cfd
this
mattleibow Mar 31, 2022
996964b
this
mattleibow Mar 31, 2022
f70889c
chmod +x
mattleibow Mar 31, 2022
2a0212f
oops
mattleibow Mar 31, 2022
53a4796
skip if installed
mattleibow Mar 31, 2022
3895074
always set props
mattleibow Mar 31, 2022
e7e5b64
logging
mattleibow Mar 31, 2022
84bacc5
make sure PATH is set?
mattleibow Mar 31, 2022
2bd1d23
???
mattleibow Mar 31, 2022
63f3d26
try this
mattleibow Mar 31, 2022
27351e3
madness
mattleibow Mar 31, 2022
1131a71
sadf
mattleibow Mar 31, 2022
993a824
sxdcfvgbhjnkml,
mattleibow Mar 31, 2022
5041821
scary
mattleibow Mar 31, 2022
b567a84
asdfsadf
mattleibow Mar 31, 2022
6898588
select dotnet
mattleibow Mar 31, 2022
6c97938
dfasdf
mattleibow Mar 31, 2022
bb100f9
quotes
mattleibow Mar 31, 2022
fa6223a
hmmm
mattleibow Mar 31, 2022
d233b1d
/Applications/
mattleibow Mar 31, 2022
82b1cdf
asdf
mattleibow Mar 31, 2022
29de733
Use new APIs
mattleibow Mar 31, 2022
56b3dce
revert
mattleibow Mar 31, 2022
26ba48c
Merge remote-tracking branch 'origin/main' into dev/macos-monterey
mattleibow Apr 5, 2022
396e5e8
new build
mattleibow Apr 5, 2022
40e1423
This is fixed in rc 1.1
mattleibow Apr 5, 2022
bb8817e
install all the dotnets
mattleibow Apr 6, 2022
aac0809
potentially a cool thing
mattleibow Apr 6, 2022
eb8eb65
okay so I am a senior developer...
mattleibow Apr 6, 2022
61e7ac7
try this
mattleibow Apr 6, 2022
a63c142
attempt
mattleibow Apr 6, 2022
8d8ec65
things are weird
mattleibow Apr 6, 2022
148690e
sadf
mattleibow Apr 6, 2022
ecb8ab5
asdf
mattleibow Apr 6, 2022
b2649c0
try this
mattleibow Apr 6, 2022
18cd5d3
asdfas
mattleibow Apr 6, 2022
5b7ada1
tnag
mattleibow Apr 6, 2022
d516173
sdfasdf
mattleibow Apr 6, 2022
127a78a
try this
mattleibow Apr 6, 2022
edb60fb
enable them all
mattleibow Apr 6, 2022
a896eaa
asdfas
mattleibow Apr 6, 2022
ec5f30a
variables: ${{ parameters.variables }}
mattleibow Apr 6, 2022
f89fdda
yay
mattleibow Apr 6, 2022
4296790
this
mattleibow Apr 7, 2022
cba2e09
ok
mattleibow Apr 7, 2022
73e1636
asdf
mattleibow Apr 7, 2022
ef6a37e
adf
mattleibow Apr 7, 2022
5f37ffe
sadf
mattleibow Apr 7, 2022
76e44e7
saves
mattleibow Apr 7, 2022
d3e9cb3
provision early
mattleibow Apr 7, 2022
c45499d
Test
mattleibow Apr 7, 2022
a2c672e
Try install this for now
mattleibow Apr 7, 2022
7db49bc
Merge remote-tracking branch 'origin/main' into dev/macos-monterey
mattleibow Apr 9, 2022
99dfdba
nl
mattleibow Apr 9, 2022
db29a45
Update azure-pipelines-variables.yml
mattleibow Apr 12, 2022
826a7c1
Update azure-pipelines-variables.yml
mattleibow Apr 12, 2022
5c87d0e
Update azure-pipelines-variables.yml
mattleibow Apr 12, 2022
fbef55d
try this
mattleibow Apr 12, 2022
206c10f
not a secondary
mattleibow Apr 12, 2022
def2395
this
mattleibow Apr 12, 2022
3bf473a
no temp for some reason
mattleibow Apr 12, 2022
2d610ff
Revert this
mattleibow Apr 12, 2022
34e65dc
Update azure-pipelines.yml
mattleibow Apr 13, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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