-
Notifications
You must be signed in to change notification settings - Fork 550
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bind Skottie's Animation Builder (#2630)
- Loading branch information
1 parent
c4fd517
commit 42fc018
Showing
45 changed files
with
1,219 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
binding/SkiaSharp.Resources/Properties/SkiaSharpResourcesAssemblyInfo.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
Oops, something went wrong.