-
Notifications
You must be signed in to change notification settings - Fork 547
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bind Skottie's Animation Builder #2630
Merged
Merged
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
fe56302
Bind the Skottie Animation Builder
mattleibow c3e7f8d
Re-generate the interop
mattleibow cf4c7b8
Rename the project file
mattleibow c9df928
Re-generate C#
mattleibow 9216ed4
Better interop
mattleibow 6a3acb5
better gen
mattleibow 438234a
wrong args
mattleibow d134ba8
Add ResourceProvider and tests
mattleibow 039774f
Better APIs are needed
mattleibow 7736881
Add the rest of the tests
mattleibow 9882f52
build.cake
mattleibow 4e61c04
Linker things
mattleibow b127cd3
versions
mattleibow 13fffb6
Add to the solutions
mattleibow b3ee764
keep alive
mattleibow bf2d9b4
linux
mattleibow 56faff7
GC.KeepAlive
mattleibow d4b627a
this
mattleibow 7893136
more life
mattleibow 3403874
Ignore failing tests on macos
mattleibow 8f4fd26
counting
mattleibow 294b540
These seem to cause issues, maybe
mattleibow 1f2e546
Probably that...
mattleibow 92d4bd8
externals
mattleibow File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note to future self. Don't forget to correctly apply the
ISKReferenceCounted
interface and NOT explicitly delete the reference counted types. This causes a hard-to-debug crash because the type is deleted while in use. Ot sometimes crashes in a debug build with a better log message, but not often.