Browse Source
* Use 2.88.8-preview.1.1 skiasharp * Use SKImageFilter directly, as we don't need compat anymore * Add SkiaSharp 3 render tests * Enable SkiaSharp 3 tests on CI * Add IncludeLinuxSkia in Skia tests * Update Skia version, remove SkiaCompat * Remove Skia3 test project, reuse single Skia render test project, so they won't conflictpull/15460/head
committed by
GitHub
16 changed files with 43 additions and 159 deletions
@ -1,7 +1,7 @@ |
|||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|||
<ItemGroup> |
|||
<PackageReference Include="HarfBuzzSharp" Version="7.3.0" /> |
|||
<PackageReference Condition="'$(IncludeLinuxSkia)' == 'true'" Include="HarfBuzzSharp.NativeAssets.Linux" Version="7.3.0" /> |
|||
<PackageReference Condition="'$(IncludeWasmSkia)' == 'true'" Include="HarfBuzzSharp.NativeAssets.WebAssembly" Version="7.3.0" /> |
|||
<PackageReference Include="HarfBuzzSharp" Version="7.3.0.2" /> |
|||
<PackageReference Condition="'$(IncludeLinuxSkia)' == 'true'" Include="HarfBuzzSharp.NativeAssets.Linux" Version="7.3.0.2" /> |
|||
<PackageReference Condition="'$(IncludeWasmSkia)' == 'true'" Include="HarfBuzzSharp.NativeAssets.WebAssembly" Version="7.3.0.2" /> |
|||
</ItemGroup> |
|||
</Project> |
|||
|
|||
@ -1,7 +1,12 @@ |
|||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|||
<ItemGroup> |
|||
<PackageReference Include="SkiaSharp" Version="2.88.7" /> |
|||
<PackageReference Condition="'$(IncludeLinuxSkia)' == 'true'" Include="SkiaSharp.NativeAssets.Linux" Version="2.88.7" /> |
|||
<PackageReference Condition="'$(IncludeWasmSkia)' == 'true'" Include="SkiaSharp.NativeAssets.WebAssembly" Version="2.88.7" /> |
|||
<ItemGroup Condition="'$(AvsIncludeSkiaSharp3)' != 'true'"> |
|||
<PackageReference Include="SkiaSharp" Version="2.88.8" /> |
|||
<PackageReference Condition="'$(IncludeLinuxSkia)' == 'true'" Include="SkiaSharp.NativeAssets.Linux" Version="2.88.8" /> |
|||
<PackageReference Condition="'$(IncludeWasmSkia)' == 'true'" Include="SkiaSharp.NativeAssets.WebAssembly" Version="2.88.8" /> |
|||
</ItemGroup> |
|||
<ItemGroup Condition="'$(AvsIncludeSkiaSharp3)' == 'true'"> |
|||
<PackageReference Include="SkiaSharp" Version="3.0.0-preview.3.1" /> |
|||
<PackageReference Condition="'$(IncludeLinuxSkia)' == 'true'" Include="SkiaSharp.NativeAssets.Linux" Version="3.0.0-preview.3.1" /> |
|||
<PackageReference Condition="'$(IncludeWasmSkia)' == 'true'" Include="SkiaSharp.NativeAssets.WebAssembly" Version="3.0.0-preview.3.1" /> |
|||
</ItemGroup> |
|||
</Project> |
|||
|
|||
@ -1,34 +0,0 @@ |
|||
using System; |
|||
using System.Runtime.CompilerServices; |
|||
using SkiaSharp; |
|||
|
|||
namespace Avalonia.Skia; |
|||
|
|||
internal static partial class SkiaCompat |
|||
{ |
|||
public static void SetMatrix(SKCanvas canvas, in SKMatrix matrix) |
|||
{ |
|||
if (s_isSkiaSharp3) |
|||
{ |
|||
#if NET8_0_OR_GREATER
|
|||
NewCanvasSetMatrix(canvas, matrix); |
|||
#else
|
|||
throw UnsupportedException(); |
|||
#endif
|
|||
} |
|||
else |
|||
{ |
|||
LegacyCall(canvas, matrix); |
|||
|
|||
static void LegacyCall(SKCanvas canvas, in SKMatrix matrix) |
|||
{ |
|||
canvas.SetMatrix(matrix); |
|||
} |
|||
} |
|||
} |
|||
|
|||
#if NET8_0_OR_GREATER
|
|||
[UnsafeAccessor(UnsafeAccessorKind.Method, Name = "SetMatrix")] |
|||
private static extern void NewCanvasSetMatrix(SKCanvas canvas, in SKMatrix matrix); |
|||
#endif
|
|||
} |
|||
@ -1,57 +0,0 @@ |
|||
using System; |
|||
using System.Runtime.CompilerServices; |
|||
using SkiaSharp; |
|||
|
|||
namespace Avalonia.Skia; |
|||
|
|||
internal static partial class SkiaCompat |
|||
{ |
|||
public static SKImageFilter CreateBlur(float sigmaX, float sigmaY) |
|||
{ |
|||
if (s_isSkiaSharp3) |
|||
{ |
|||
#if NET8_0_OR_GREATER
|
|||
return NewSKImageFilterCreateBlur(null, sigmaX, sigmaY); |
|||
#else
|
|||
throw UnsupportedException(); |
|||
#endif
|
|||
} |
|||
else |
|||
{ |
|||
return LegacyBlurCall(sigmaX, sigmaY); |
|||
|
|||
static SKImageFilter LegacyBlurCall(float sigmaX, float sigmaY) => |
|||
SKImageFilter.CreateBlur(sigmaX, sigmaY); |
|||
} |
|||
} |
|||
|
|||
public static SKImageFilter CreateDropShadow(float dropOffsetX, float dropOffsetY, float sigma, float f, |
|||
SKColor color) |
|||
{ |
|||
if (s_isSkiaSharp3) |
|||
{ |
|||
#if NET8_0_OR_GREATER
|
|||
return NewSKImageFilterCreateDropShadow(null!, dropOffsetX, dropOffsetY, sigma, f, color); |
|||
#else
|
|||
throw UnsupportedException(); |
|||
#endif
|
|||
} |
|||
else |
|||
{ |
|||
return LegacyDropShadowCall(dropOffsetX, dropOffsetY, sigma, f, color); |
|||
|
|||
static SKImageFilter LegacyDropShadowCall(float dropOffsetX, float dropOffsetY, float sigma, float f, SKColor color) => |
|||
SKImageFilter.CreateDropShadow(dropOffsetX, dropOffsetY, sigma, f, color); |
|||
} |
|||
} |
|||
|
|||
#if NET8_0_OR_GREATER
|
|||
// See https://github.com/dotnet/runtime/issues/90081 why we need `SKImageFilter _`
|
|||
[UnsafeAccessor(UnsafeAccessorKind.StaticMethod, Name = "CreateBlur")] |
|||
private static extern SKImageFilter NewSKImageFilterCreateBlur(SKImageFilter? _, float sigmaX, float sigmaY); |
|||
|
|||
[UnsafeAccessor(UnsafeAccessorKind.StaticMethod, Name = "CreateDropShadow")] |
|||
private static extern SKImageFilter NewSKImageFilterCreateDropShadow(SKImageFilter? _, float dropOffsetX, |
|||
float dropOffsetY, float sigma, float f, SKColor color); |
|||
#endif
|
|||
} |
|||
@ -1,32 +0,0 @@ |
|||
using System; |
|||
using System.Runtime.CompilerServices; |
|||
using SkiaSharp; |
|||
|
|||
namespace Avalonia.Skia; |
|||
|
|||
internal static partial class SkiaCompat |
|||
{ |
|||
public static void Transform(SKPath path, in SKMatrix matrix) |
|||
{ |
|||
if (s_isSkiaSharp3) |
|||
{ |
|||
#if NET8_0_OR_GREATER
|
|||
NewPathTransform(path, matrix); |
|||
#else
|
|||
throw UnsupportedException(); |
|||
#endif
|
|||
} |
|||
else |
|||
{ |
|||
LegacyCall(path, matrix); |
|||
|
|||
static void LegacyCall(SKPath path, in SKMatrix matrix) => |
|||
path.Transform(matrix); |
|||
} |
|||
} |
|||
|
|||
#if NET8_0_OR_GREATER
|
|||
[UnsafeAccessor(UnsafeAccessorKind.Method, Name = "Transform")] |
|||
private static extern void NewPathTransform(SKPath path, in SKMatrix matrix); |
|||
#endif
|
|||
} |
|||
@ -1,16 +0,0 @@ |
|||
using System; |
|||
using SkiaSharp; |
|||
|
|||
namespace Avalonia.Skia; |
|||
|
|||
internal static partial class SkiaCompat |
|||
{ |
|||
private static readonly bool s_isSkiaSharp3 = typeof(SKPaint).Assembly.GetName().Version?.Major == 3; |
|||
|
|||
#if !NET8_0_OR_GREATER
|
|||
private static Exception UnsupportedException() |
|||
{ |
|||
return new InvalidOperationException("Avalonia doesn't support SkiaSharp 3.0 on .NET 7 and older. Please upgrade to .NET 8."); |
|||
} |
|||
#endif
|
|||
} |
|||
Loading…
Reference in new issue