Skip to content

Commit

Permalink
Merge branch 'main' into dev/jela/winui-xamlroot
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromelaban authored May 17, 2024
2 parents 458f5b7 + bfd166e commit 52fcab5
Show file tree
Hide file tree
Showing 178 changed files with 6,267 additions and 4,113 deletions.
2,834 changes: 0 additions & 2,834 deletions .github/fabricbot.json

This file was deleted.

562 changes: 562 additions & 0 deletions .github/policies/resourceManagement.yml

Large diffs are not rendered by default.

38 changes: 38 additions & 0 deletions .github/workflows/similarissues.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Find Similar Issues

on:
issues:
types: [opened]
issue_comment:
types: [created]

jobs:
getSimilarIssues:
runs-on: ubuntu-latest
if: >-
(github.event_name == 'issues' && github.event.action == 'opened') ||
(github.event_name == 'issue_comment' && github.event.action == 'created' && startsWith(github.event.comment.body, '/similarissues'))
outputs:
message: ${{ steps.getBody.outputs.message }}
steps:
- id: getBody
uses: craigloewen-msft/GitGudSimilarIssues@main
with:
issueTitle: ${{ github.event.issue.title }}
issueBody: ${{ github.event.issue.body }}
repo: ${{ github.repository }}
similaritytolerance: "0.70"
add-comment:
needs: getSimilarIssues
runs-on: ubuntu-latest
permissions:
issues: write
if: needs.getSimilarIssues.outputs.message != ''
steps:
- name: Add comment
run: gh issue comment "$NUMBER" --repo "$REPO" --body "$BODY"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NUMBER: ${{ github.event.issue.number }}
REPO: ${{ github.repository }}
BODY: ${{ needs.getSimilarIssues.outputs.message }}
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,6 @@ However, these are easy to install as they are found on the various websites. If

Here are some links to show the differences in our code as compared to Google's code.

What version are we on? [**m115**](https://github.com/google/skia/tree/chrome/m115)
Are we up-to-date with Google? [Compare](https://github.com/mono/skia/compare/skiasharp...google:chrome/m115)
What have we added? [Compare](https://github.com/google/skia/compare/chrome/m115...mono:skiasharp)
What version are we on? [**m116**](https://github.com/google/skia/tree/chrome/m116)
Are we up-to-date with Google? [Compare](https://github.com/mono/skia/compare/skiasharp...google:chrome/m116)
What have we added? [Compare](https://github.com/google/skia/compare/chrome/m116...mono:skiasharp)
6 changes: 6 additions & 0 deletions benchmarks/SkiaSharp.Benchmarks.sln
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SkiaSharp.Benchmarks", "Ski
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SkiaSharp.SceneGraph", "..\binding\SkiaSharp.SceneGraph\SkiaSharp.SceneGraph.csproj", "{42B5D998-A676-4B50-B558-1D3ACA7D3FC4}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SkiaSharp.Resources", "..\binding\SkiaSharp.Resources\SkiaSharp.Resources.csproj", "{AD2C6978-4F5E-E592-B565-26C357877B2C}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SkiaSharp.Skottie", "..\binding\SkiaSharp.Skottie\SkiaSharp.Skottie.csproj", "{DD03EAA1-A85D-4588-8B84-8285EC1979C8}"
EndProject
Global
Expand Down Expand Up @@ -41,6 +43,10 @@ Global
{42B5D998-A676-4B50-B558-1D3ACA7D3FC4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{42B5D998-A676-4B50-B558-1D3ACA7D3FC4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{42B5D998-A676-4B50-B558-1D3ACA7D3FC4}.Release|Any CPU.Build.0 = Release|Any CPU
{AD2C6978-4F5E-E592-B565-26C357877B2C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AD2C6978-4F5E-E592-B565-26C357877B2C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AD2C6978-4F5E-E592-B565-26C357877B2C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AD2C6978-4F5E-E592-B565-26C357877B2C}.Release|Any CPU.Build.0 = Release|Any CPU
{DD03EAA1-A85D-4588-8B84-8285EC1979C8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DD03EAA1-A85D-4588-8B84-8285EC1979C8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DD03EAA1-A85D-4588-8B84-8285EC1979C8}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down
64 changes: 37 additions & 27 deletions binding/Binding.Shared/PlatformConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,42 +18,52 @@ public static class PlatformConfiguration
{
private const string LibCLibrary = "libc";

public static bool IsUnix { get; }
public static bool IsUnix => IsMac || IsLinux;

public static bool IsWindows { get; }

public static bool IsMac { get; }

public static bool IsLinux { get; }

public static bool IsArm { get; }

public static bool Is64Bit { get; }
public static bool IsWindows {
#if WINDOWS_UWP
get => true;
#elif NET6_0_OR_GREATER
get => OperatingSystem.IsWindows ();
#else
get => RuntimeInformation.IsOSPlatform (OSPlatform.Windows);
#endif
}

static PlatformConfiguration ()
{
public static bool IsMac {
#if WINDOWS_UWP
IsMac = false;
IsLinux = false;
IsUnix = false;
IsWindows = true;

var arch = Package.Current.Id.Architecture;
const ProcessorArchitecture arm64 = (ProcessorArchitecture)12;
IsArm = arch == ProcessorArchitecture.Arm || arch == arm64;
get => false;
#elif NET6_0_OR_GREATER
get => OperatingSystem.IsMacOS ();
#else
IsMac = RuntimeInformation.IsOSPlatform (OSPlatform.OSX);
IsLinux = RuntimeInformation.IsOSPlatform (OSPlatform.Linux);
IsUnix = IsMac || IsLinux;
IsWindows = RuntimeInformation.IsOSPlatform (OSPlatform.Windows);
get => RuntimeInformation.IsOSPlatform (OSPlatform.OSX);
#endif
}

var arch = RuntimeInformation.ProcessArchitecture;
IsArm = arch == Architecture.Arm || arch == Architecture.Arm64;
public static bool IsLinux {
#if WINDOWS_UWP
get => false;
#elif NET6_0_OR_GREATER
get => OperatingSystem.IsLinux ();
#else
get => RuntimeInformation.IsOSPlatform (OSPlatform.Linux);
#endif
}

Is64Bit = IntPtr.Size == 8;
public static bool IsArm {
#if WINDOWS_UWP
get {
var arch = Package.Current.Id.Architecture;
const ProcessorArchitecture arm64 = (ProcessorArchitecture)12;
return arch == ProcessorArchitecture.Arm || arch == arm64;
}
#else
get => RuntimeInformation.ProcessArchitecture is Architecture.Arm or Architecture.Arm64;
#endif
}

public static bool Is64Bit => IntPtr.Size == 8;

private static string linuxFlavor;

public static string LinuxFlavor
Expand Down
4 changes: 4 additions & 0 deletions binding/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
<PackageReference Include="System.Memory" Version="4.5.5" />
</ItemGroup>

<ItemGroup Condition=" ('$(TargetFramework)' == 'netstandard2.1') and (!$(MSBuildProjectName.Contains('.NativeAssets.'))) ">
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="4.5.3" />
</ItemGroup>

<PropertyGroup Condition="'$(PackagingGroup)' == 'SkiaSharp'">
<PackageDescription Condition="'$(PackageDescription)' == ''">SkiaSharp is a cross-platform 2D graphics API for .NET platforms based on Google's Skia Graphics Library.
It provides a comprehensive 2D API that can be used across mobile, server and desktop models to render images.</PackageDescription>
Expand Down
19 changes: 19 additions & 0 deletions binding/IncludeNativeAssets.SkiaSharp.WinUI.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<ItemGroup>
<Content Include="$(MSBuildThisFileDirectory)..\output\native\winui\any\*.dll" Visible="False" />
</ItemGroup>

<ItemGroup Condition="$(TargetFramework.Contains('-windows')) and '$(Platform)' != 'AnyCPU' and '$(Platform)' != 'Any CPU'">
<Content Include="$(MSBuildThisFileDirectory)..\output\native\winui\$(Platform)\*" Visible="False" />
</ItemGroup>

<ItemGroup Condition="$(TargetFramework.Contains('-windows')) and ('$(Platform)' == 'AnyCPU' or '$(Platform)' == 'Any CPU')">
<Content Include="$(MSBuildThisFileDirectory)..\output\native\winui\x64\*" Condition="'$(RuntimeIdentifier)' == 'win10-x64'" Visible="False" />
<Content Include="$(MSBuildThisFileDirectory)..\output\native\winui\x86\*" Condition="'$(RuntimeIdentifier)' == 'win10-x86'" Visible="False" />
<Content Include="$(MSBuildThisFileDirectory)..\output\native\winui\arm64\*" Condition="'$(RuntimeIdentifier)' == 'win10-arm64'" Visible="False" />
<Content Include="$(MSBuildThisFileDirectory)..\output\native\winui\x64\*" Condition="'$(RuntimeIdentifier)' == ''" Visible="False" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>

</Project>
12 changes: 8 additions & 4 deletions binding/NativeAssets.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,20 @@
</PropertyGroup>

<ItemGroup Condition="'$(IsWindowsNativeAssets)' == 'true'">
<None Include="@(NativeWindowsPackageFile)" Link="runtimes\%(RuntimeIdentifier)\native\%(Filename)%(Extension)" />
<_NativeWindowsPackageFileToUse Include="@(NativeWindowsPackageFile->HasMetadata('Folder'))" />
<_NativeWindowsPackageFileWithNoFolder Include="@(NativeWindowsPackageFile)" />
<_NativeWindowsPackageFileWithNoFolder Remove="@(_NativeWindowsPackageFileToUse)" />
<_NativeWindowsPackageFileToUse Include="@(_NativeWindowsPackageFileWithNoFolder)" Folder="native" />
<None Include="@(_NativeWindowsPackageFileToUse)" Link="runtimes\%(RuntimeIdentifier)\%(Folder)\%(Filename)%(Extension)" />
</ItemGroup>

<Target Name="_IncludeRuntimesPackageFiles" BeforeTargets="_GetPackageFiles" Condition="'$(IsWindowsNativeAssets)' == 'true'">
<ItemGroup>
<_CompletedNativeWindowsPackageFile
Include="@(NativeWindowsPackageFile)"
Include="@(_NativeWindowsPackageFileToUse)"
TargetFramework="%(RuntimeIdentifier)"
TargetPath="native\%(Filename)%(Extension)"
PackagePath="runtimes\%(RuntimeIdentifier)\native\%(Filename)%(Extension)" />
TargetPath="%(Folder)\%(Filename)%(Extension)"
PackagePath="runtimes\%(RuntimeIdentifier)\%(Folder)\%(Filename)%(Extension)" />
<_BuildOutputInPackage Remove="@(_BuildOutputInPackage)" />
<_BuildOutputInPackage Include="@(_CompletedNativeWindowsPackageFile)" Condition="'%(Extension)' != '.pdb'" />
<_TargetPathsToSymbols Remove="@(_TargetPathsToSymbols)" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>$(WindowsTargetFrameworks)</TargetFrameworks>
<PackagingGroup>SkiaSharp</PackagingGroup>
<Title>$(PackagingGroup) - Native Assets for Windows UI (WinUI 3)</Title>
<IsWindowsNativeAssets>true</IsWindowsNativeAssets>
</PropertyGroup>
<ItemGroup>
<NativeWindowsPackageFile Include="..\..\output\native\winui\any\*" RuntimeIdentifier="win-x64" Folder="lib\$(WindowsTargetFrameworksCurrent)" />
<NativeWindowsPackageFile Include="..\..\output\native\winui\x64\*" RuntimeIdentifier="win-x64" />
<NativeWindowsPackageFile Include="..\..\output\native\winui\any\*" RuntimeIdentifier="win-x86" Folder="lib\$(WindowsTargetFrameworksCurrent)" />
<NativeWindowsPackageFile Include="..\..\output\native\winui\x86\*" RuntimeIdentifier="win-x86" />
<NativeWindowsPackageFile Include="..\..\output\native\winui\any\*" RuntimeIdentifier="win-arm64" Folder="lib\$(WindowsTargetFrameworksCurrent)" />
<NativeWindowsPackageFile Include="..\..\output\native\winui\arm64\*" RuntimeIdentifier="win-arm64" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;

[assembly: AssemblyTitle("SkiaSharp.Resources")]
[assembly: AssemblyDescription("This package adds lottie support to SkiaSharp via skottie.")]
[assembly: AssemblyCompany("Microsoft Corporation")]
[assembly: AssemblyProduct("SkiaSharp")]
[assembly: AssemblyCopyright("© Microsoft Corporation. All rights reserved.")]
[assembly: NeutralResourcesLanguage("en")]

[assembly: InternalsVisibleTo("SkiaSharp.Tests, PublicKey=" +
"002400000480000094000000060200000024000052534131000400000100010079159977d2d03a" +
"8e6bea7a2e74e8d1afcc93e8851974952bb480a12c9134474d04062447c37e0e68c080536fcf3c" +
"3fbe2ff9c979ce998475e506e8ce82dd5b0f350dc10e93bf2eeecf874b24770c5081dbea7447fd" +
"dafa277b22de47d6ffea449674a4f9fccf84d15069089380284dbdd35f46cdff12a1bd78e4ef00" +
"65d016df")]

[assembly: InternalsVisibleTo("SkiaSharp.Benchmarks, PublicKey=" +
"002400000480000094000000060200000024000052534131000400000100010079159977d2d03a" +
"8e6bea7a2e74e8d1afcc93e8851974952bb480a12c9134474d04062447c37e0e68c080536fcf3c" +
"3fbe2ff9c979ce998475e506e8ce82dd5b0f350dc10e93bf2eeecf874b24770c5081dbea7447fd" +
"dafa277b22de47d6ffea449674a4f9fccf84d15069089380284dbdd35f46cdff12a1bd78e4ef00" +
"65d016df")]

[assembly: AssemblyMetadata("IsTrimmable", "True")]

#if __IOS__ || __TVOS__ || __MACOS__
// This attribute allows you to mark your assemblies as “safe to link”.
// When the attribute is present, the linker—if enabled—will process the assembly
// even if you’re using the “Link SDK assemblies only” option, which is the default for device builds.
#pragma warning disable CS0618 // Type or member is obsolete
[assembly: Foundation.LinkerSafe]
#pragma warning restore CS0618 // Type or member is obsolete
#endif
64 changes: 64 additions & 0 deletions binding/SkiaSharp.Resources/ResourceProvider.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
using System;

namespace SkiaSharp.Resources
{
public abstract unsafe class ResourceProvider : SKObject, ISKReferenceCounted, ISKSkipObjectRegistration
{
internal ResourceProvider (IntPtr handle, bool owns)
: base (handle, owns)
{
}

public SKData? Load (string resourceName) =>
Load ("", resourceName);

public SKData? Load (string resourcePath, string resourceName) =>
SKData.GetObject (ResourcesApi.skresources_resource_provider_load (Handle, resourcePath, resourceName));
}

public sealed class CachingResourceProvider : ResourceProvider
{
public CachingResourceProvider (ResourceProvider resourceProvider)
: base (Create (resourceProvider), true)
{
Referenced(this, resourceProvider);
}

private static IntPtr Create (ResourceProvider resourceProvider)
{
_ = resourceProvider ?? throw new ArgumentNullException (nameof (resourceProvider));
return ResourcesApi.skresources_caching_resource_provider_proxy_make (resourceProvider.Handle);
}
}

public sealed class DataUriResourceProvider : ResourceProvider
{
public DataUriResourceProvider (bool preDecode = false)
: this (null, preDecode)
{
}

public DataUriResourceProvider (ResourceProvider? fallbackProvider, bool preDecode = false)
: base (Create (fallbackProvider, preDecode), true)
{
Referenced (this, fallbackProvider);
}

private static IntPtr Create (ResourceProvider? fallbackProvider, bool preDecode = false) =>
ResourcesApi.skresources_data_uri_resource_provider_proxy_make (fallbackProvider?.Handle ?? IntPtr.Zero, preDecode);
}

public sealed class FileResourceProvider : ResourceProvider
{
public FileResourceProvider (string baseDirectory, bool preDecode = false)
: base (Create (baseDirectory, preDecode), true)
{
}

private static IntPtr Create (string baseDirectory, bool preDecode)
{
using var baseDir = new SKString(baseDirectory ?? throw new ArgumentNullException (nameof (baseDirectory)));
return ResourcesApi.skresources_file_resource_provider_make (baseDir.Handle, preDecode);
}
}
}
23 changes: 23 additions & 0 deletions binding/SkiaSharp.Resources/ResourcesApi.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#nullable disable

using System;

namespace SkiaSharp
{
internal partial class ResourcesApi
{
#if __IOS__ || __TVOS__
private const string SKIA = "@rpath/libSkiaSharp.framework/libSkiaSharp";
#else
private const string SKIA = "libSkiaSharp";
#endif

#if USE_DELEGATES
private static readonly Lazy<IntPtr> libSkiaSharpHandle =
new Lazy<IntPtr> (() => LibraryLoader.LoadLocalLibrary<SkiaApi> (SKIA));

private static T GetSymbol<T> (string name) where T : Delegate =>
LibraryLoader.GetSymbolDelegate<T> (libSkiaSharpHandle.Value, name);
#endif
}
}
Loading

0 comments on commit 52fcab5

Please sign in to comment.