Bind Skottie's Animation Builder (#2630)

This commit is contained in:
Matthew Leibowitz 2024-02-18 17:33:24 +02:00 коммит произвёл GitHub
Родитель c4fd517f64
Коммит 42fc0181e0
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
45 изменённых файлов: 1219 добавлений и 26 удалений

Просмотреть файл

@ -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

Просмотреть файл

@ -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 youre 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

Просмотреть файл

@ -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);
}
}
}

Просмотреть файл

@ -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
}
}

Просмотреть файл

@ -0,0 +1,267 @@
using System;
using System.Runtime.InteropServices;
#region Namespaces
using SkiaSharp.Resources;
#endregion
#region Class declarations
using gr_backendrendertarget_t = System.IntPtr;
using gr_backendtexture_t = System.IntPtr;
using gr_direct_context_t = System.IntPtr;
using gr_glinterface_t = System.IntPtr;
using gr_recording_context_t = System.IntPtr;
using gr_vk_extensions_t = System.IntPtr;
using gr_vk_memory_allocator_t = System.IntPtr;
using gr_vkinterface_t = System.IntPtr;
using sk_bitmap_t = System.IntPtr;
using sk_canvas_t = System.IntPtr;
using sk_codec_t = System.IntPtr;
using sk_colorfilter_t = System.IntPtr;
using sk_colorspace_icc_profile_t = System.IntPtr;
using sk_colorspace_t = System.IntPtr;
using sk_compatpaint_t = System.IntPtr;
using sk_data_t = System.IntPtr;
using sk_document_t = System.IntPtr;
using sk_drawable_t = System.IntPtr;
using sk_flattenable_t = System.IntPtr;
using sk_font_t = System.IntPtr;
using sk_fontmgr_t = System.IntPtr;
using sk_fontstyle_t = System.IntPtr;
using sk_fontstyleset_t = System.IntPtr;
using sk_image_t = System.IntPtr;
using sk_imagefilter_t = System.IntPtr;
using sk_manageddrawable_t = System.IntPtr;
using sk_managedtracememorydump_t = System.IntPtr;
using sk_maskfilter_t = System.IntPtr;
using sk_nodraw_canvas_t = System.IntPtr;
using sk_nvrefcnt_t = System.IntPtr;
using sk_nway_canvas_t = System.IntPtr;
using sk_opbuilder_t = System.IntPtr;
using sk_overdraw_canvas_t = System.IntPtr;
using sk_paint_t = System.IntPtr;
using sk_path_effect_t = System.IntPtr;
using sk_path_iterator_t = System.IntPtr;
using sk_path_rawiterator_t = System.IntPtr;
using sk_path_t = System.IntPtr;
using sk_pathmeasure_t = System.IntPtr;
using sk_picture_recorder_t = System.IntPtr;
using sk_picture_t = System.IntPtr;
using sk_pixelref_factory_t = System.IntPtr;
using sk_pixmap_t = System.IntPtr;
using sk_refcnt_t = System.IntPtr;
using sk_region_cliperator_t = System.IntPtr;
using sk_region_iterator_t = System.IntPtr;
using sk_region_spanerator_t = System.IntPtr;
using sk_region_t = System.IntPtr;
using sk_rrect_t = System.IntPtr;
using sk_runtimeeffect_t = System.IntPtr;
using sk_shader_t = System.IntPtr;
using sk_stream_asset_t = System.IntPtr;
using sk_stream_filestream_t = System.IntPtr;
using sk_stream_managedstream_t = System.IntPtr;
using sk_stream_memorystream_t = System.IntPtr;
using sk_stream_streamrewindable_t = System.IntPtr;
using sk_stream_t = System.IntPtr;
using sk_string_t = System.IntPtr;
using sk_surface_t = System.IntPtr;
using sk_surfaceprops_t = System.IntPtr;
using sk_svgcanvas_t = System.IntPtr;
using sk_textblob_builder_t = System.IntPtr;
using sk_textblob_t = System.IntPtr;
using sk_tracememorydump_t = System.IntPtr;
using sk_typeface_t = System.IntPtr;
using sk_vertices_t = System.IntPtr;
using sk_wstream_dynamicmemorystream_t = System.IntPtr;
using sk_wstream_filestream_t = System.IntPtr;
using sk_wstream_managedstream_t = System.IntPtr;
using sk_wstream_t = System.IntPtr;
using skottie_animation_builder_t = System.IntPtr;
using skottie_animation_t = System.IntPtr;
using skottie_logger_t = System.IntPtr;
using skottie_marker_observer_t = System.IntPtr;
using skottie_property_observer_t = System.IntPtr;
using skottie_resource_provider_t = System.IntPtr;
using skresources_external_track_asset_t = System.IntPtr;
using skresources_image_asset_t = System.IntPtr;
using skresources_multi_frame_image_asset_t = System.IntPtr;
using skresources_resource_provider_t = System.IntPtr;
using sksg_invalidation_controller_t = System.IntPtr;
using vk_device_t = System.IntPtr;
using vk_instance_t = System.IntPtr;
using vk_physical_device_features_2_t = System.IntPtr;
using vk_physical_device_features_t = System.IntPtr;
using vk_physical_device_t = System.IntPtr;
using vk_queue_t = System.IntPtr;
#endregion
#region Functions
namespace SkiaSharp
{
internal unsafe partial class ResourcesApi
{
#region skresources_resource_provider.h
// skresources_resource_provider_t* skresources_caching_resource_provider_proxy_make(skresources_resource_provider_t* rp)
#if !USE_DELEGATES
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
internal static extern skresources_resource_provider_t skresources_caching_resource_provider_proxy_make (skresources_resource_provider_t rp);
#else
private partial class Delegates {
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
internal delegate skresources_resource_provider_t skresources_caching_resource_provider_proxy_make (skresources_resource_provider_t rp);
}
private static Delegates.skresources_caching_resource_provider_proxy_make skresources_caching_resource_provider_proxy_make_delegate;
internal static skresources_resource_provider_t skresources_caching_resource_provider_proxy_make (skresources_resource_provider_t rp) =>
(skresources_caching_resource_provider_proxy_make_delegate ??= GetSymbol<Delegates.skresources_caching_resource_provider_proxy_make> ("skresources_caching_resource_provider_proxy_make")).Invoke (rp);
#endif
// skresources_resource_provider_t* skresources_data_uri_resource_provider_proxy_make(skresources_resource_provider_t* rp, bool predecode)
#if !USE_DELEGATES
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
internal static extern skresources_resource_provider_t skresources_data_uri_resource_provider_proxy_make (skresources_resource_provider_t rp, [MarshalAs (UnmanagedType.I1)] bool predecode);
#else
private partial class Delegates {
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
internal delegate skresources_resource_provider_t skresources_data_uri_resource_provider_proxy_make (skresources_resource_provider_t rp, [MarshalAs (UnmanagedType.I1)] bool predecode);
}
private static Delegates.skresources_data_uri_resource_provider_proxy_make skresources_data_uri_resource_provider_proxy_make_delegate;
internal static skresources_resource_provider_t skresources_data_uri_resource_provider_proxy_make (skresources_resource_provider_t rp, [MarshalAs (UnmanagedType.I1)] bool predecode) =>
(skresources_data_uri_resource_provider_proxy_make_delegate ??= GetSymbol<Delegates.skresources_data_uri_resource_provider_proxy_make> ("skresources_data_uri_resource_provider_proxy_make")).Invoke (rp, predecode);
#endif
// skresources_resource_provider_t* skresources_file_resource_provider_make(sk_string_t* base_dir, bool predecode)
#if !USE_DELEGATES
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
internal static extern skresources_resource_provider_t skresources_file_resource_provider_make (sk_string_t base_dir, [MarshalAs (UnmanagedType.I1)] bool predecode);
#else
private partial class Delegates {
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
internal delegate skresources_resource_provider_t skresources_file_resource_provider_make (sk_string_t base_dir, [MarshalAs (UnmanagedType.I1)] bool predecode);
}
private static Delegates.skresources_file_resource_provider_make skresources_file_resource_provider_make_delegate;
internal static skresources_resource_provider_t skresources_file_resource_provider_make (sk_string_t base_dir, [MarshalAs (UnmanagedType.I1)] bool predecode) =>
(skresources_file_resource_provider_make_delegate ??= GetSymbol<Delegates.skresources_file_resource_provider_make> ("skresources_file_resource_provider_make")).Invoke (base_dir, predecode);
#endif
// void skresources_resource_provider_delete(skresources_resource_provider_t* instance)
#if !USE_DELEGATES
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
internal static extern void skresources_resource_provider_delete (skresources_resource_provider_t instance);
#else
private partial class Delegates {
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
internal delegate void skresources_resource_provider_delete (skresources_resource_provider_t instance);
}
private static Delegates.skresources_resource_provider_delete skresources_resource_provider_delete_delegate;
internal static void skresources_resource_provider_delete (skresources_resource_provider_t instance) =>
(skresources_resource_provider_delete_delegate ??= GetSymbol<Delegates.skresources_resource_provider_delete> ("skresources_resource_provider_delete")).Invoke (instance);
#endif
// sk_data_t* skresources_resource_provider_load(skresources_resource_provider_t* instance, const char* path, const char* name)
#if !USE_DELEGATES
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
internal static extern sk_data_t skresources_resource_provider_load (skresources_resource_provider_t instance, [MarshalAs (UnmanagedType.LPStr)] String path, [MarshalAs (UnmanagedType.LPStr)] String name);
#else
private partial class Delegates {
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
internal delegate sk_data_t skresources_resource_provider_load (skresources_resource_provider_t instance, [MarshalAs (UnmanagedType.LPStr)] String path, [MarshalAs (UnmanagedType.LPStr)] String name);
}
private static Delegates.skresources_resource_provider_load skresources_resource_provider_load_delegate;
internal static sk_data_t skresources_resource_provider_load (skresources_resource_provider_t instance, [MarshalAs (UnmanagedType.LPStr)] String path, [MarshalAs (UnmanagedType.LPStr)] String name) =>
(skresources_resource_provider_load_delegate ??= GetSymbol<Delegates.skresources_resource_provider_load> ("skresources_resource_provider_load")).Invoke (instance, path, name);
#endif
// skresources_external_track_asset_t* skresources_resource_provider_load_audio_asset(skresources_resource_provider_t* instance, const char* path, const char* name, const char* id)
#if !USE_DELEGATES
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
internal static extern skresources_external_track_asset_t skresources_resource_provider_load_audio_asset (skresources_resource_provider_t instance, [MarshalAs (UnmanagedType.LPStr)] String path, [MarshalAs (UnmanagedType.LPStr)] String name, [MarshalAs (UnmanagedType.LPStr)] String id);
#else
private partial class Delegates {
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
internal delegate skresources_external_track_asset_t skresources_resource_provider_load_audio_asset (skresources_resource_provider_t instance, [MarshalAs (UnmanagedType.LPStr)] String path, [MarshalAs (UnmanagedType.LPStr)] String name, [MarshalAs (UnmanagedType.LPStr)] String id);
}
private static Delegates.skresources_resource_provider_load_audio_asset skresources_resource_provider_load_audio_asset_delegate;
internal static skresources_external_track_asset_t skresources_resource_provider_load_audio_asset (skresources_resource_provider_t instance, [MarshalAs (UnmanagedType.LPStr)] String path, [MarshalAs (UnmanagedType.LPStr)] String name, [MarshalAs (UnmanagedType.LPStr)] String id) =>
(skresources_resource_provider_load_audio_asset_delegate ??= GetSymbol<Delegates.skresources_resource_provider_load_audio_asset> ("skresources_resource_provider_load_audio_asset")).Invoke (instance, path, name, id);
#endif
// skresources_image_asset_t* skresources_resource_provider_load_image_asset(skresources_resource_provider_t* instance, const char* path, const char* name, const char* id)
#if !USE_DELEGATES
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
internal static extern skresources_image_asset_t skresources_resource_provider_load_image_asset (skresources_resource_provider_t instance, [MarshalAs (UnmanagedType.LPStr)] String path, [MarshalAs (UnmanagedType.LPStr)] String name, [MarshalAs (UnmanagedType.LPStr)] String id);
#else
private partial class Delegates {
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
internal delegate skresources_image_asset_t skresources_resource_provider_load_image_asset (skresources_resource_provider_t instance, [MarshalAs (UnmanagedType.LPStr)] String path, [MarshalAs (UnmanagedType.LPStr)] String name, [MarshalAs (UnmanagedType.LPStr)] String id);
}
private static Delegates.skresources_resource_provider_load_image_asset skresources_resource_provider_load_image_asset_delegate;
internal static skresources_image_asset_t skresources_resource_provider_load_image_asset (skresources_resource_provider_t instance, [MarshalAs (UnmanagedType.LPStr)] String path, [MarshalAs (UnmanagedType.LPStr)] String name, [MarshalAs (UnmanagedType.LPStr)] String id) =>
(skresources_resource_provider_load_image_asset_delegate ??= GetSymbol<Delegates.skresources_resource_provider_load_image_asset> ("skresources_resource_provider_load_image_asset")).Invoke (instance, path, name, id);
#endif
// sk_typeface_t* skresources_resource_provider_load_typeface(skresources_resource_provider_t* instance, const char* name, const char* url)
#if !USE_DELEGATES
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
internal static extern sk_typeface_t skresources_resource_provider_load_typeface (skresources_resource_provider_t instance, [MarshalAs (UnmanagedType.LPStr)] String name, [MarshalAs (UnmanagedType.LPStr)] String url);
#else
private partial class Delegates {
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
internal delegate sk_typeface_t skresources_resource_provider_load_typeface (skresources_resource_provider_t instance, [MarshalAs (UnmanagedType.LPStr)] String name, [MarshalAs (UnmanagedType.LPStr)] String url);
}
private static Delegates.skresources_resource_provider_load_typeface skresources_resource_provider_load_typeface_delegate;
internal static sk_typeface_t skresources_resource_provider_load_typeface (skresources_resource_provider_t instance, [MarshalAs (UnmanagedType.LPStr)] String name, [MarshalAs (UnmanagedType.LPStr)] String url) =>
(skresources_resource_provider_load_typeface_delegate ??= GetSymbol<Delegates.skresources_resource_provider_load_typeface> ("skresources_resource_provider_load_typeface")).Invoke (instance, name, url);
#endif
// void skresources_resource_provider_ref(skresources_resource_provider_t* instance)
#if !USE_DELEGATES
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
internal static extern void skresources_resource_provider_ref (skresources_resource_provider_t instance);
#else
private partial class Delegates {
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
internal delegate void skresources_resource_provider_ref (skresources_resource_provider_t instance);
}
private static Delegates.skresources_resource_provider_ref skresources_resource_provider_ref_delegate;
internal static void skresources_resource_provider_ref (skresources_resource_provider_t instance) =>
(skresources_resource_provider_ref_delegate ??= GetSymbol<Delegates.skresources_resource_provider_ref> ("skresources_resource_provider_ref")).Invoke (instance);
#endif
// void skresources_resource_provider_unref(skresources_resource_provider_t* instance)
#if !USE_DELEGATES
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
internal static extern void skresources_resource_provider_unref (skresources_resource_provider_t instance);
#else
private partial class Delegates {
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
internal delegate void skresources_resource_provider_unref (skresources_resource_provider_t instance);
}
private static Delegates.skresources_resource_provider_unref skresources_resource_provider_unref_delegate;
internal static void skresources_resource_provider_unref (skresources_resource_provider_t instance) =>
(skresources_resource_provider_unref_delegate ??= GetSymbol<Delegates.skresources_resource_provider_unref> ("skresources_resource_provider_unref")).Invoke (instance);
#endif
#endregion
}
}
#endregion Functions
#region Delegates
#endregion
#region Structs
#endregion
#region Enums
#endregion

Просмотреть файл

@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>$(AllTargetFrameworks)</TargetFrameworks>
<RootNamespace>SkiaSharp.Resources</RootNamespace>
<AssemblyName>SkiaSharp.Resources</AssemblyName>
<PackagingGroup>SkiaSharp.Resources</PackagingGroup>
<Title>SkiaSharp Resource Providers</Title>
<PackageDescription>SkiaSharp Skottie provides a Lottie implementation using the SkiaSharp library.</PackageDescription>
<PackageTags>skottie;lottie</PackageTags>
<Nullable>enable</Nullable>
</PropertyGroup>
<PropertyGroup Condition="$(TargetFramework.StartsWith('net4'))">
<DefineConstants>$(DefineConstants);USE_DELEGATES</DefineConstants>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\SkiaSharp\SkiaSharp.csproj" />
</ItemGroup>
</Project>

Просмотреть файл

@ -85,6 +85,10 @@ using skottie_logger_t = System.IntPtr;
using skottie_marker_observer_t = System.IntPtr;
using skottie_property_observer_t = System.IntPtr;
using skottie_resource_provider_t = System.IntPtr;
using skresources_external_track_asset_t = System.IntPtr;
using skresources_image_asset_t = System.IntPtr;
using skresources_multi_frame_image_asset_t = System.IntPtr;
using skresources_resource_provider_t = System.IntPtr;
using sksg_invalidation_controller_t = System.IntPtr;
using vk_device_t = System.IntPtr;
using vk_instance_t = System.IntPtr;

Просмотреть файл

@ -1,5 +1,6 @@
using System;
using System.IO;
using SkiaSharp.Resources;
using SkiaSharp.SceneGraph;
namespace SkiaSharp.Skottie
@ -20,6 +21,11 @@ namespace SkiaSharp.Skottie
protected override void DisposeNative ()
=> SkottieApi.skottie_animation_delete (Handle);
// AnimationBuilder
public static AnimationBuilder CreateBuilder (AnimationBuilderFlags flags = AnimationBuilderFlags.None) =>
new AnimationBuilder (flags);
// Parse
public static Animation? Parse (string json) =>
@ -77,6 +83,7 @@ namespace SkiaSharp.Skottie
fixed (byte* ptr = span) {
animation = GetObject (SkottieApi.skottie_animation_make_from_data (ptr, (IntPtr)span.Length));
GC.KeepAlive(data);
return animation != null;
}
}

Просмотреть файл

@ -0,0 +1,88 @@
using System;
using System.IO;
using SkiaSharp.Resources;
namespace SkiaSharp.Skottie
{
public sealed unsafe class AnimationBuilder : SKObject, ISKSkipObjectRegistration
{
internal AnimationBuilder (AnimationBuilderFlags flags)
: this (SkottieApi.skottie_animation_builder_new (flags), true)
{
}
internal AnimationBuilder (IntPtr handle, bool owns)
: base (handle, owns)
{
}
public AnimationBuilder SetFontManager (SKFontManager fontManager)
{
_ = fontManager ?? throw new ArgumentNullException (nameof (fontManager));
SkottieApi.skottie_animation_builder_set_font_manager (Handle, fontManager.Handle);
Referenced (this, fontManager);
return this;
}
public AnimationBuilder SetResourceProvider (ResourceProvider resourceProvider)
{
_ = resourceProvider ?? throw new ArgumentNullException (nameof (resourceProvider));
SkottieApi.skottie_animation_builder_set_resource_provider (Handle, resourceProvider.Handle);
Referenced (this, resourceProvider);
return this;
}
public AnimationBuilderStats Stats
{
get
{
AnimationBuilderStats stats;
SkottieApi.skottie_animation_builder_get_stats (Handle, &stats);
return stats;
}
}
public Animation? Build (Stream stream)
{
_ = stream ?? throw new ArgumentNullException (nameof (stream));
using var data = SKData.Create (stream);
return Build (data);
}
public Animation? Build (SKStream stream)
{
_ = stream ?? throw new ArgumentNullException (nameof (stream));
using var data = SKData.Create (stream);
return Build (data);
}
public Animation? Build (SKData data)
{
_ = data ?? throw new ArgumentNullException (nameof (data));
var preamble = Utils.GetPreambleSize (data);
var span = data.AsSpan ().Slice (preamble);
fixed (byte* ptr = span) {
try {
return Animation.GetObject (SkottieApi.skottie_animation_builder_make_from_data (Handle, ptr, (IntPtr)span.Length));
} finally {
GC.KeepAlive(data);
}
}
}
public Animation? Build (string path)
{
_ = path ?? throw new ArgumentNullException (nameof (path));
using var data = SKData.Create (path);
return Build (data);
}
protected override void DisposeNative ()
=> SkottieApi.skottie_animation_builder_delete (Handle);
}
}

Просмотреть файл

@ -0,0 +1,21 @@
using System;
namespace SkiaSharp.Skottie
{
public partial struct AnimationBuilderStats
{
public readonly TimeSpan TotalLoadTime =>
TimeSpan.FromMilliseconds (fTotalLoadTimeMS);
public readonly TimeSpan JsonParseTime =>
TimeSpan.FromMilliseconds (fJsonParseTimeMS);
public readonly TimeSpan SceneParseTime =>
TimeSpan.FromMilliseconds (fSceneParseTimeMS);
public readonly int JsonSize => (int)fJsonSize;
public readonly int AnimatorCount => (int)fAnimatorCount;
}
}

Просмотреть файл

@ -15,5 +15,6 @@
<ItemGroup>
<ProjectReference Include="..\SkiaSharp\SkiaSharp.csproj" />
<ProjectReference Include="..\SkiaSharp.SceneGraph\SkiaSharp.SceneGraph.csproj" />
<ProjectReference Include="..\SkiaSharp.Resources\SkiaSharp.Resources.csproj" />
</ItemGroup>
</Project>

Просмотреть файл

@ -85,6 +85,10 @@ using skottie_logger_t = System.IntPtr;
using skottie_marker_observer_t = System.IntPtr;
using skottie_property_observer_t = System.IntPtr;
using skottie_resource_provider_t = System.IntPtr;
using skresources_external_track_asset_t = System.IntPtr;
using skresources_image_asset_t = System.IntPtr;
using skresources_multi_frame_image_asset_t = System.IntPtr;
using skresources_resource_provider_t = System.IntPtr;
using sksg_invalidation_controller_t = System.IntPtr;
using vk_device_t = System.IntPtr;
using vk_instance_t = System.IntPtr;
@ -103,6 +107,132 @@ namespace SkiaSharp
{
#region skottie_animation.h
// void skottie_animation_builder_delete(skottie_animation_builder_t* instance)
#if !USE_DELEGATES
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
internal static extern void skottie_animation_builder_delete (skottie_animation_builder_t instance);
#else
private partial class Delegates {
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
internal delegate void skottie_animation_builder_delete (skottie_animation_builder_t instance);
}
private static Delegates.skottie_animation_builder_delete skottie_animation_builder_delete_delegate;
internal static void skottie_animation_builder_delete (skottie_animation_builder_t instance) =>
(skottie_animation_builder_delete_delegate ??= GetSymbol<Delegates.skottie_animation_builder_delete> ("skottie_animation_builder_delete")).Invoke (instance);
#endif
// void skottie_animation_builder_get_stats(skottie_animation_builder_t* instance, skottie_animation_builder_stats_t* stats)
#if !USE_DELEGATES
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
internal static extern void skottie_animation_builder_get_stats (skottie_animation_builder_t instance, AnimationBuilderStats* stats);
#else
private partial class Delegates {
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
internal delegate void skottie_animation_builder_get_stats (skottie_animation_builder_t instance, AnimationBuilderStats* stats);
}
private static Delegates.skottie_animation_builder_get_stats skottie_animation_builder_get_stats_delegate;
internal static void skottie_animation_builder_get_stats (skottie_animation_builder_t instance, AnimationBuilderStats* stats) =>
(skottie_animation_builder_get_stats_delegate ??= GetSymbol<Delegates.skottie_animation_builder_get_stats> ("skottie_animation_builder_get_stats")).Invoke (instance, stats);
#endif
// skottie_animation_t* skottie_animation_builder_make_from_data(skottie_animation_builder_t* instance, const char* data, size_t length)
#if !USE_DELEGATES
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
internal static extern skottie_animation_t skottie_animation_builder_make_from_data (skottie_animation_builder_t instance, /* char */ void* data, /* size_t */ IntPtr length);
#else
private partial class Delegates {
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
internal delegate skottie_animation_t skottie_animation_builder_make_from_data (skottie_animation_builder_t instance, /* char */ void* data, /* size_t */ IntPtr length);
}
private static Delegates.skottie_animation_builder_make_from_data skottie_animation_builder_make_from_data_delegate;
internal static skottie_animation_t skottie_animation_builder_make_from_data (skottie_animation_builder_t instance, /* char */ void* data, /* size_t */ IntPtr length) =>
(skottie_animation_builder_make_from_data_delegate ??= GetSymbol<Delegates.skottie_animation_builder_make_from_data> ("skottie_animation_builder_make_from_data")).Invoke (instance, data, length);
#endif
// skottie_animation_t* skottie_animation_builder_make_from_file(skottie_animation_builder_t* instance, const char* path)
#if !USE_DELEGATES
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
internal static extern skottie_animation_t skottie_animation_builder_make_from_file (skottie_animation_builder_t instance, /* char */ void* path);
#else
private partial class Delegates {
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
internal delegate skottie_animation_t skottie_animation_builder_make_from_file (skottie_animation_builder_t instance, /* char */ void* path);
}
private static Delegates.skottie_animation_builder_make_from_file skottie_animation_builder_make_from_file_delegate;
internal static skottie_animation_t skottie_animation_builder_make_from_file (skottie_animation_builder_t instance, /* char */ void* path) =>
(skottie_animation_builder_make_from_file_delegate ??= GetSymbol<Delegates.skottie_animation_builder_make_from_file> ("skottie_animation_builder_make_from_file")).Invoke (instance, path);
#endif
// skottie_animation_t* skottie_animation_builder_make_from_stream(skottie_animation_builder_t* instance, sk_stream_t* stream)
#if !USE_DELEGATES
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
internal static extern skottie_animation_t skottie_animation_builder_make_from_stream (skottie_animation_builder_t instance, sk_stream_t stream);
#else
private partial class Delegates {
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
internal delegate skottie_animation_t skottie_animation_builder_make_from_stream (skottie_animation_builder_t instance, sk_stream_t stream);
}
private static Delegates.skottie_animation_builder_make_from_stream skottie_animation_builder_make_from_stream_delegate;
internal static skottie_animation_t skottie_animation_builder_make_from_stream (skottie_animation_builder_t instance, sk_stream_t stream) =>
(skottie_animation_builder_make_from_stream_delegate ??= GetSymbol<Delegates.skottie_animation_builder_make_from_stream> ("skottie_animation_builder_make_from_stream")).Invoke (instance, stream);
#endif
// skottie_animation_t* skottie_animation_builder_make_from_string(skottie_animation_builder_t* instance, const char* data, size_t length)
#if !USE_DELEGATES
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
internal static extern skottie_animation_t skottie_animation_builder_make_from_string (skottie_animation_builder_t instance, /* char */ void* data, /* size_t */ IntPtr length);
#else
private partial class Delegates {
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
internal delegate skottie_animation_t skottie_animation_builder_make_from_string (skottie_animation_builder_t instance, /* char */ void* data, /* size_t */ IntPtr length);
}
private static Delegates.skottie_animation_builder_make_from_string skottie_animation_builder_make_from_string_delegate;
internal static skottie_animation_t skottie_animation_builder_make_from_string (skottie_animation_builder_t instance, /* char */ void* data, /* size_t */ IntPtr length) =>
(skottie_animation_builder_make_from_string_delegate ??= GetSymbol<Delegates.skottie_animation_builder_make_from_string> ("skottie_animation_builder_make_from_string")).Invoke (instance, data, length);
#endif
// skottie_animation_builder_t* skottie_animation_builder_new(skottie_animation_builder_flags_t flags)
#if !USE_DELEGATES
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
internal static extern skottie_animation_builder_t skottie_animation_builder_new (AnimationBuilderFlags flags);
#else
private partial class Delegates {
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
internal delegate skottie_animation_builder_t skottie_animation_builder_new (AnimationBuilderFlags flags);
}
private static Delegates.skottie_animation_builder_new skottie_animation_builder_new_delegate;
internal static skottie_animation_builder_t skottie_animation_builder_new (AnimationBuilderFlags flags) =>
(skottie_animation_builder_new_delegate ??= GetSymbol<Delegates.skottie_animation_builder_new> ("skottie_animation_builder_new")).Invoke (flags);
#endif
// void skottie_animation_builder_set_font_manager(skottie_animation_builder_t* instance, sk_fontmgr_t* fontManager)
#if !USE_DELEGATES
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
internal static extern void skottie_animation_builder_set_font_manager (skottie_animation_builder_t instance, sk_fontmgr_t fontManager);
#else
private partial class Delegates {
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
internal delegate void skottie_animation_builder_set_font_manager (skottie_animation_builder_t instance, sk_fontmgr_t fontManager);
}
private static Delegates.skottie_animation_builder_set_font_manager skottie_animation_builder_set_font_manager_delegate;
internal static void skottie_animation_builder_set_font_manager (skottie_animation_builder_t instance, sk_fontmgr_t fontManager) =>
(skottie_animation_builder_set_font_manager_delegate ??= GetSymbol<Delegates.skottie_animation_builder_set_font_manager> ("skottie_animation_builder_set_font_manager")).Invoke (instance, fontManager);
#endif
// void skottie_animation_builder_set_resource_provider(skottie_animation_builder_t* instance, skottie_resource_provider_t* resourceProvider)
#if !USE_DELEGATES
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
internal static extern void skottie_animation_builder_set_resource_provider (skottie_animation_builder_t instance, skottie_resource_provider_t resourceProvider);
#else
private partial class Delegates {
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
internal delegate void skottie_animation_builder_set_resource_provider (skottie_animation_builder_t instance, skottie_resource_provider_t resourceProvider);
}
private static Delegates.skottie_animation_builder_set_resource_provider skottie_animation_builder_set_resource_provider_delegate;
internal static void skottie_animation_builder_set_resource_provider (skottie_animation_builder_t instance, skottie_resource_provider_t resourceProvider) =>
(skottie_animation_builder_set_resource_provider_delegate ??= GetSymbol<Delegates.skottie_animation_builder_set_resource_provider> ("skottie_animation_builder_set_resource_provider")).Invoke (instance, resourceProvider);
#endif
// void skottie_animation_delete(skottie_animation_t* instance)
#if !USE_DELEGATES
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
@ -201,20 +331,6 @@ namespace SkiaSharp
(skottie_animation_get_version_delegate ??= GetSymbol<Delegates.skottie_animation_get_version> ("skottie_animation_get_version")).Invoke (instance, version);
#endif
// void skottie_animation_keepalive()
#if !USE_DELEGATES
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
internal static extern void skottie_animation_keepalive ();
#else
private partial class Delegates {
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
internal delegate void skottie_animation_keepalive ();
}
private static Delegates.skottie_animation_keepalive skottie_animation_keepalive_delegate;
internal static void skottie_animation_keepalive () =>
(skottie_animation_keepalive_delegate ??= GetSymbol<Delegates.skottie_animation_keepalive> ("skottie_animation_keepalive")).Invoke ();
#endif
// skottie_animation_t* skottie_animation_make_from_data(const char* data, size_t length)
#if !USE_DELEGATES
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
@ -382,12 +498,68 @@ namespace SkiaSharp
#region Structs
namespace SkiaSharp.Skottie {
// skottie_animation_builder_stats_t
[StructLayout (LayoutKind.Sequential)]
public readonly unsafe partial struct AnimationBuilderStats : IEquatable<AnimationBuilderStats> {
// public float fTotalLoadTimeMS
private readonly Single fTotalLoadTimeMS;
// public float fJsonParseTimeMS
private readonly Single fJsonParseTimeMS;
// public float fSceneParseTimeMS
private readonly Single fSceneParseTimeMS;
// public size_t fJsonSize
private readonly /* size_t */ IntPtr fJsonSize;
// public size_t fAnimatorCount
private readonly /* size_t */ IntPtr fAnimatorCount;
public readonly bool Equals (AnimationBuilderStats obj) =>
fTotalLoadTimeMS == obj.fTotalLoadTimeMS && fJsonParseTimeMS == obj.fJsonParseTimeMS && fSceneParseTimeMS == obj.fSceneParseTimeMS && fJsonSize == obj.fJsonSize && fAnimatorCount == obj.fAnimatorCount;
public readonly override bool Equals (object obj) =>
obj is AnimationBuilderStats f && Equals (f);
public static bool operator == (AnimationBuilderStats left, AnimationBuilderStats right) =>
left.Equals (right);
public static bool operator != (AnimationBuilderStats left, AnimationBuilderStats right) =>
!left.Equals (right);
public readonly override int GetHashCode ()
{
var hash = new HashCode ();
hash.Add (fTotalLoadTimeMS);
hash.Add (fJsonParseTimeMS);
hash.Add (fSceneParseTimeMS);
hash.Add (fJsonSize);
hash.Add (fAnimatorCount);
return hash.ToHashCode ();
}
}
}
#endregion
#region Enums
namespace SkiaSharp.Skottie {
// skottie_animation_builder_flags_t
public enum AnimationBuilderFlags {
// NONE_SKOTTIE_ANIMATION_BUILDER_FLAGS = 0
None = 0,
// DEFER_IMAGE_LOADING_SKOTTIE_ANIMATION_BUILDER_FLAGS = 0x01
DeferImageLoading = 1,
// PREFER_EMBEDDED_FONTS_SKOTTIE_ANIMATION_BUILDER_FLAGS = 0x02
PreferEmbeddedFonts = 2,
}
// skottie_animation_renderflags_t
[Flags]
public enum AnimationRenderFlags {

Просмотреть файл

@ -45,6 +45,13 @@ using System.Runtime.CompilerServices;
"dafa277b22de47d6ffea449674a4f9fccf84d15069089380284dbdd35f46cdff12a1bd78e4ef00" +
"65d016df")]
[assembly: InternalsVisibleTo("SkiaSharp.Resources, PublicKey=" +
"002400000480000094000000060200000024000052534131000400000100010079159977d2d03a" +
"8e6bea7a2e74e8d1afcc93e8851974952bb480a12c9134474d04062447c37e0e68c080536fcf3c" +
"3fbe2ff9c979ce998475e506e8ce82dd5b0f350dc10e93bf2eeecf874b24770c5081dbea7447fd" +
"dafa277b22de47d6ffea449674a4f9fccf84d15069089380284dbdd35f46cdff12a1bd78e4ef00" +
"65d016df")]
[assembly: AssemblyMetadata("IsTrimmable", "True")]
#if __IOS__ || __TVOS__ || __MACOS__

Просмотреть файл

@ -156,7 +156,11 @@ namespace SkiaSharp
if (stream == null)
throw new ArgumentNullException (nameof (stream));
return GetObject (SkiaApi.sk_data_new_from_stream (stream.Handle, (IntPtr)length));
try {
return GetObject (SkiaApi.sk_data_new_from_stream (stream.Handle, (IntPtr)length));
} finally {
GC.KeepAlive(stream);
}
}
public static SKData Create (SKStream stream, ulong length)
@ -164,7 +168,11 @@ namespace SkiaSharp
if (stream == null)
throw new ArgumentNullException (nameof (stream));
return GetObject (SkiaApi.sk_data_new_from_stream (stream.Handle, (IntPtr)length));
try {
return GetObject (SkiaApi.sk_data_new_from_stream (stream.Handle, (IntPtr)length));
} finally {
GC.KeepAlive(stream);
}
}
public static SKData Create (SKStream stream, long length)
@ -172,7 +180,11 @@ namespace SkiaSharp
if (stream == null)
throw new ArgumentNullException (nameof (stream));
return GetObject (SkiaApi.sk_data_new_from_stream (stream.Handle, (IntPtr)length));
try {
return GetObject (SkiaApi.sk_data_new_from_stream (stream.Handle, (IntPtr)length));
} finally {
GC.KeepAlive(stream);
}
}
public static SKData Create (IntPtr address, int length)

Просмотреть файл

@ -195,7 +195,7 @@ namespace SkiaSharp
return owner;
}
// indicate that the chile should not be garbage collected while
// indicate that the child should not be garbage collected while
// the owner still lives
internal static T Referenced<T> (T owner, SKObject child)
where T : SKObject
@ -350,11 +350,19 @@ namespace SkiaSharp
}
}
/// <summary>
/// This should be implemented on all types that inherit directly or
/// indirectly from SkRefCnt or SkRefCntBase
/// </summary>
internal interface ISKReferenceCounted
{
IntPtr Handle { get; }
}
/// <summary>
/// This should be implemented on all types that inherit directly or
/// indirectly from SkNVRefCnt
/// </summary>
internal interface ISKNonVirtualReferenceCounted : ISKReferenceCounted
{
void ReferenceNative ();
@ -362,6 +370,12 @@ namespace SkiaSharp
void UnreferenceNative ();
}
/// <summary>
/// This should be implemented on all types that can skip the expensive
// registration in the global dictionary. Typically this would be the case
/// if the type os _only_ constructed by the user and not provided as a
/// return type for _any_ member.
/// </summary>
internal interface ISKSkipObjectRegistration
{
}

Просмотреть файл

@ -84,6 +84,10 @@ using skottie_logger_t = System.IntPtr;
using skottie_marker_observer_t = System.IntPtr;
using skottie_property_observer_t = System.IntPtr;
using skottie_resource_provider_t = System.IntPtr;
using skresources_external_track_asset_t = System.IntPtr;
using skresources_image_asset_t = System.IntPtr;
using skresources_multi_frame_image_asset_t = System.IntPtr;
using skresources_resource_provider_t = System.IntPtr;
using sksg_invalidation_controller_t = System.IntPtr;
using vk_device_t = System.IntPtr;
using vk_instance_t = System.IntPtr;

Просмотреть файл

@ -0,0 +1,86 @@
// configuration for the libSkiaSharp binary
{
"dllName": "SKIA",
"namespace": "SkiaSharp",
"namespaces": {
"sk_": {
"prefix": "SK",
"exclude": true
},
"gr_": {
"exclude": true
},
"vk_": {
"exclude": true
},
"sksg_": {
"exclude": true
},
"skottie_": {
"exclude": true
},
"skresources_": {
"cs": "Resources",
"prefix": ""
}
},
"className": "ResourcesApi",
"includeDirs": [
"."
],
"headers": {
"include/c": [ "sk_*", "gr_*", "skottie*", "sksg_*", "skresources_*" ],
"include/xamarin": [ "sk_*" ]
},
"source": {
"src/c": [ "sk_*", "gr_*", "skottie*", "sksg_*" ],
"src/xamarin": [ "sk_*" ]
},
"mappings": {
"types": {
"skottie_animation_builder_flags_t": {
"flags": true
}
},
"functions": {
"skottie_animation_builder_make_from_string": {
"parameters": {
"0": "[MarshalAs (UnmanagedType.LPStr)] String",
"1": "int"
}
},
"skottie_animation_builder_make_from_file": {
"parameters": {
"0": "[MarshalAs (UnmanagedType.LPStr)] String"
}
},
"skresources_resource_provider_load": {
"parameters": {
"1": "[MarshalAs (UnmanagedType.LPStr)] String",
"2": "[MarshalAs (UnmanagedType.LPStr)] String"
}
},
"skresources_resource_provider_load_audio_asset": {
"parameters": {
"1": "[MarshalAs (UnmanagedType.LPStr)] String",
"2": "[MarshalAs (UnmanagedType.LPStr)] String",
"3": "[MarshalAs (UnmanagedType.LPStr)] String"
}
},
"skresources_resource_provider_load_image_asset": {
"parameters": {
"1": "[MarshalAs (UnmanagedType.LPStr)] String",
"2": "[MarshalAs (UnmanagedType.LPStr)] String",
"3": "[MarshalAs (UnmanagedType.LPStr)] String"
}
},
"skresources_resource_provider_load_typeface": {
"parameters": {
"1": "[MarshalAs (UnmanagedType.LPStr)] String",
"2": "[MarshalAs (UnmanagedType.LPStr)] String"
}
}
}
}
}

Просмотреть файл

@ -19,6 +19,9 @@
},
"skottie_": {
"exclude": true
},
"skresources_": {
"exclude": true
}
},
"className": "SceneGraphApi",

Просмотреть файл

@ -19,6 +19,9 @@
"skottie_": {
"cs": "Skottie",
"prefix": ""
},
"skresources_": {
"exclude": true
}
},
"className": "SkottieApi",
@ -35,6 +38,10 @@
},
"mappings": {
"types": {
"skottie_animation_builder_stats_t": {
"readonly": true,
"properties": false
},
"skottie_animation_renderflags_t": {
"cs": "AnimationRenderFlags",
"flags": true

Просмотреть файл

@ -17,6 +17,9 @@
},
"skottie_": {
"exclude": true
},
"skresources_": {
"exclude": true
}
},
"className": "SkiaApi",

Просмотреть файл

@ -125,6 +125,7 @@ var TRACKED_NUGETS = new Dictionary<string, Version> {
{ "SkiaSharp.HarfBuzz", new Version (1, 60, 0) },
{ "SkiaSharp.Skottie", new Version (1, 60, 0) },
{ "SkiaSharp.SceneGraph", new Version (1, 60, 0) },
{ "SkiaSharp.Resources", new Version (1, 60, 0) },
{ "SkiaSharp.Vulkan.SharpVk", new Version (1, 60, 0) },
};

2
externals/skia поставляемый

@ -1 +1 @@
Subproject commit 8990028b2f3a70104c4db924e614f5bccbb2c637
Subproject commit 53d2065ea8724daeb85e839ba47f54c582809615

Просмотреть файл

@ -4,6 +4,7 @@ libSkiaSharp {
gr_*;
skottie_*;
sksg_*;
skresources_*;
local:
*;
};

Просмотреть файл

@ -68,6 +68,7 @@ SkiaSharp.Views.Blazor nuget 3.0.0
SkiaSharp.HarfBuzz nuget 3.0.0
SkiaSharp.Skottie nuget 3.0.0
SkiaSharp.SceneGraph nuget 3.0.0
SkiaSharp.Resources nuget 3.0.0
SkiaSharp.Vulkan.SharpVk nuget 3.0.0
# HarfBuzzSharp
HarfBuzzSharp nuget 8.3.0

Просмотреть файл

@ -13,6 +13,7 @@
"..\\binding\\SkiaSharp.NativeAssets.WebAssembly\\SkiaSharp.NativeAssets.WebAssembly.csproj",
"..\\binding\\SkiaSharp.NativeAssets.Win32\\SkiaSharp.NativeAssets.Win32.csproj",
"..\\binding\\SkiaSharp.NativeAssets.macOS\\SkiaSharp.NativeAssets.macOS.csproj",
"..\\binding\\SkiaSharp.Resources\\SkiaSharp.Resources.csproj",
"..\\binding\\SkiaSharp.SceneGraph\\SkiaSharp.SceneGraph.csproj",
"..\\binding\\SkiaSharp.Skottie\\SkiaSharp.Skottie.csproj",
"..\\binding\\SkiaSharp\\SkiaSharp.csproj",

Просмотреть файл

@ -23,6 +23,7 @@
"..\\binding\\SkiaSharp.NativeAssets.iOS\\SkiaSharp.NativeAssets.iOS.csproj",
"..\\binding\\SkiaSharp.NativeAssets.macOS\\SkiaSharp.NativeAssets.macOS.csproj",
"..\\binding\\SkiaSharp.NativeAssets.tvOS\\SkiaSharp.NativeAssets.tvOS.csproj",
"..\\binding\\SkiaSharp.Resources\\SkiaSharp.Resources.csproj",
"..\\binding\\SkiaSharp.SceneGraph\\SkiaSharp.SceneGraph.csproj",
"..\\binding\\SkiaSharp.Skottie\\SkiaSharp.Skottie.csproj",
"..\\binding\\SkiaSharp\\SkiaSharp.csproj",

Просмотреть файл

@ -24,6 +24,7 @@
"..\\binding\\SkiaSharp.NativeAssets.iOS\\SkiaSharp.NativeAssets.iOS.csproj",
"..\\binding\\SkiaSharp.NativeAssets.macOS\\SkiaSharp.NativeAssets.macOS.csproj",
"..\\binding\\SkiaSharp.NativeAssets.tvOS\\SkiaSharp.NativeAssets.tvOS.csproj",
"..\\binding\\SkiaSharp.Resources\\SkiaSharp.Resources.csproj",
"..\\binding\\SkiaSharp.SceneGraph\\SkiaSharp.SceneGraph.csproj",
"..\\binding\\SkiaSharp.Skottie\\SkiaSharp.Skottie.csproj",
"..\\binding\\SkiaSharp\\SkiaSharp.csproj",

Просмотреть файл

@ -109,6 +109,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "binding", "binding", "{937A
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "source", "source", "{21E35524-DFEB-462F-84DD-A81213A38EEA}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SkiaSharp.Resources", "SkiaSharp.Resources", "{1EE838FE-13D6-4837-B7DE-35DD2805F092}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SkiaSharp.Resources", "..\binding\SkiaSharp.Resources\SkiaSharp.Resources.csproj", "{542CD60D-B619-4555-9A2E-A8C2A85C9CC8}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -275,6 +279,10 @@ Global
{1DE3BDD6-344B-4927-BC67-DAA80C691F6C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1DE3BDD6-344B-4927-BC67-DAA80C691F6C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1DE3BDD6-344B-4927-BC67-DAA80C691F6C}.Release|Any CPU.Build.0 = Release|Any CPU
{542CD60D-B619-4555-9A2E-A8C2A85C9CC8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{542CD60D-B619-4555-9A2E-A8C2A85C9CC8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{542CD60D-B619-4555-9A2E-A8C2A85C9CC8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{542CD60D-B619-4555-9A2E-A8C2A85C9CC8}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -331,6 +339,8 @@ Global
{DD1EAB2E-29FD-4971-8440-055A1A1E69BA} = {2F28C1EB-D020-4A3A-948F-DF0AD0FDCC53}
{2B4DCCF7-8BF3-4027-9A79-344BFBD21B6D} = {2F28C1EB-D020-4A3A-948F-DF0AD0FDCC53}
{1DE3BDD6-344B-4927-BC67-DAA80C691F6C} = {2F28C1EB-D020-4A3A-948F-DF0AD0FDCC53}
{1EE838FE-13D6-4837-B7DE-35DD2805F092} = {937A3EE4-3719-452F-AA5C-2942F5C72D7D}
{542CD60D-B619-4555-9A2E-A8C2A85C9CC8} = {1EE838FE-13D6-4837-B7DE-35DD2805F092}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {67EACD19-0CEA-4127-9842-549AA6FB84C9}

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Просмотреть файл

@ -17,6 +17,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SkiaSharp.Vulkan.SharpVk",
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SkiaSharp.SceneGraph", "..\binding\SkiaSharp.SceneGraph\SkiaSharp.SceneGraph.csproj", "{978AD2C6-E592-4F5E-B565-26C357877B2C}"
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", "{D35696BA-3038-41F2-9BE9-181439E6EF9E}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "source", "source", "{9FAA974B-A671-40BC-82EA-8EF77F463ECB}"
@ -115,6 +117,18 @@ Global
{978AD2C6-E592-4F5E-B565-26C357877B2C}.Release|x64.Build.0 = Release|Any CPU
{978AD2C6-E592-4F5E-B565-26C357877B2C}.Release|x86.ActiveCfg = Release|Any CPU
{978AD2C6-E592-4F5E-B565-26C357877B2C}.Release|x86.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}.Debug|x64.ActiveCfg = Debug|Any CPU
{AD2C6978-4F5E-E592-B565-26C357877B2C}.Debug|x64.Build.0 = Debug|Any CPU
{AD2C6978-4F5E-E592-B565-26C357877B2C}.Debug|x86.ActiveCfg = Debug|Any CPU
{AD2C6978-4F5E-E592-B565-26C357877B2C}.Debug|x86.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
{AD2C6978-4F5E-E592-B565-26C357877B2C}.Release|x64.ActiveCfg = Release|Any CPU
{AD2C6978-4F5E-E592-B565-26C357877B2C}.Release|x64.Build.0 = Release|Any CPU
{AD2C6978-4F5E-E592-B565-26C357877B2C}.Release|x86.ActiveCfg = Release|Any CPU
{AD2C6978-4F5E-E592-B565-26C357877B2C}.Release|x86.Build.0 = Release|Any CPU
{D35696BA-3038-41F2-9BE9-181439E6EF9E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D35696BA-3038-41F2-9BE9-181439E6EF9E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D35696BA-3038-41F2-9BE9-181439E6EF9E}.Debug|x64.ActiveCfg = Debug|Any CPU
@ -137,6 +151,7 @@ Global
{0DE402FA-A101-438E-8528-6EA82E0FF803} = {9FAA974B-A671-40BC-82EA-8EF77F463ECB}
{A53DD2E5-55C4-4F7C-9316-D7FAD9A6F19F} = {9FAA974B-A671-40BC-82EA-8EF77F463ECB}
{978AD2C6-E592-4F5E-B565-26C357877B2C} = {9FAA974B-A671-40BC-82EA-8EF77F463ECB}
{AD2C6978-4F5E-E592-B565-26C357877B2C} = {9FAA974B-A671-40BC-82EA-8EF77F463ECB}
{D35696BA-3038-41F2-9BE9-181439E6EF9E} = {9FAA974B-A671-40BC-82EA-8EF77F463ECB}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution

Просмотреть файл

@ -25,6 +25,7 @@
<ItemGroup>
<ProjectReference Include="..\..\binding\HarfBuzzSharp\HarfBuzzSharp.csproj" />
<ProjectReference Include="..\..\binding\SkiaSharp.SceneGraph\SkiaSharp.SceneGraph.csproj" />
<ProjectReference Include="..\..\binding\SkiaSharp.Resources\SkiaSharp.Resources.csproj" />
<ProjectReference Include="..\..\binding\SkiaSharp.Skottie\SkiaSharp.Skottie.csproj" />
<ProjectReference Include="..\..\binding\SkiaSharp\SkiaSharp.csproj" />
<ProjectReference Include="..\..\source\SkiaSharp.HarfBuzz\SkiaSharp.HarfBuzz\SkiaSharp.HarfBuzz.csproj" />

Просмотреть файл

@ -12,6 +12,7 @@ namespace SkiaSharp.Tests
public class SKBitmapThreadingTest : SKTest
{
[SkippableTheory]
[InlineData(10, 10)]
[InlineData(100, 1000)]
public static void ImageScalingMultipleThreadsTest(int numThreads, int numIterationsPerThread)
{

Просмотреть файл

@ -13,6 +13,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HarfBuzzSharp", "..\binding
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SkiaSharp.SceneGraph", "..\binding\SkiaSharp.SceneGraph\SkiaSharp.SceneGraph.csproj", "{8CD906F8-B3E4-48E6-8B16-EAFC0C34EAE1}"
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", "{915D1D57-B059-4301-9A35-2E5EB68DED99}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SkiaSharp.HarfBuzz", "..\source\SkiaSharp.HarfBuzz\SkiaSharp.HarfBuzz\SkiaSharp.HarfBuzz.csproj", "{6F999CA5-B67F-46A3-9A94-9E99527060F6}"
@ -55,6 +57,10 @@ Global
{8CD906F8-B3E4-48E6-8B16-EAFC0C34EAE1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8CD906F8-B3E4-48E6-8B16-EAFC0C34EAE1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8CD906F8-B3E4-48E6-8B16-EAFC0C34EAE1}.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
{915D1D57-B059-4301-9A35-2E5EB68DED99}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{915D1D57-B059-4301-9A35-2E5EB68DED99}.Debug|Any CPU.Build.0 = Debug|Any CPU
{915D1D57-B059-4301-9A35-2E5EB68DED99}.Release|Any CPU.ActiveCfg = Release|Any CPU
@ -87,6 +93,7 @@ Global
{9D753C4C-D7FC-4D1B-ABF0-BF1C089B987A} = {6779122B-72B0-42ED-A1E7-5029C1C0A78D}
{D48557C5-795D-4948-84EE-A7531DDD91DC} = {6779122B-72B0-42ED-A1E7-5029C1C0A78D}
{8CD906F8-B3E4-48E6-8B16-EAFC0C34EAE1} = {6779122B-72B0-42ED-A1E7-5029C1C0A78D}
{AD2C6978-4F5E-E592-B565-26C357877B2C} = {6779122B-72B0-42ED-A1E7-5029C1C0A78D}
{915D1D57-B059-4301-9A35-2E5EB68DED99} = {6779122B-72B0-42ED-A1E7-5029C1C0A78D}
{6F999CA5-B67F-46A3-9A94-9E99527060F6} = {6779122B-72B0-42ED-A1E7-5029C1C0A78D}
{398936B0-1B68-4F2D-B91C-6880CAC9F168} = {6779122B-72B0-42ED-A1E7-5029C1C0A78D}

Просмотреть файл

@ -46,6 +46,7 @@
<ItemGroup>
<ProjectReference Include="..\..\binding\SkiaSharp\SkiaSharp.csproj" />
<ProjectReference Include="..\..\binding\SkiaSharp.SceneGraph\SkiaSharp.SceneGraph.csproj" />
<ProjectReference Include="..\..\binding\SkiaSharp.Resources\SkiaSharp.Resources.csproj" />
<ProjectReference Include="..\..\binding\SkiaSharp.Skottie\SkiaSharp.Skottie.csproj" />
<ProjectReference Include="..\..\binding\HarfBuzzSharp\HarfBuzzSharp.csproj" />
<ProjectReference Include="..\..\source\SkiaSharp.HarfBuzz\SkiaSharp.HarfBuzz\SkiaSharp.HarfBuzz.csproj" />

Просмотреть файл

@ -13,6 +13,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SkiaSharp.HarfBuzz", "..\so
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SkiaSharp.SceneGraph", "..\binding\SkiaSharp.SceneGraph\SkiaSharp.SceneGraph.csproj", "{2A777BD2-9108-4747-BBD2-0240B8D7CCC3}"
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", "{3FCCE93A-727E-4891-8449-468F13E8052A}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "source", "source", "{5C42DB9F-1771-4F1D-8247-E58AEB9D9094}"
@ -43,6 +45,10 @@ Global
{2A777BD2-9108-4747-BBD2-0240B8D7CCC3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2A777BD2-9108-4747-BBD2-0240B8D7CCC3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2A777BD2-9108-4747-BBD2-0240B8D7CCC3}.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
{3FCCE93A-727E-4891-8449-468F13E8052A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3FCCE93A-727E-4891-8449-468F13E8052A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3FCCE93A-727E-4891-8449-468F13E8052A}.Release|Any CPU.ActiveCfg = Release|Any CPU
@ -56,6 +62,7 @@ Global
{B020BCC5-FC01-4ADC-839E-18E63BC6D4C5} = {5C42DB9F-1771-4F1D-8247-E58AEB9D9094}
{6E6DF00F-30EF-479B-92FB-B07DDE6B1259} = {5C42DB9F-1771-4F1D-8247-E58AEB9D9094}
{2A777BD2-9108-4747-BBD2-0240B8D7CCC3} = {5C42DB9F-1771-4F1D-8247-E58AEB9D9094}
{AD2C6978-4F5E-E592-B565-26C357877B2C} = {5C42DB9F-1771-4F1D-8247-E58AEB9D9094}
{3FCCE93A-727E-4891-8449-468F13E8052A} = {5C42DB9F-1771-4F1D-8247-E58AEB9D9094}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution

Просмотреть файл

@ -28,6 +28,7 @@
<ItemGroup>
<ProjectReference Include="..\..\binding\SkiaSharp\SkiaSharp.csproj" />
<ProjectReference Include="..\..\binding\SkiaSharp.SceneGraph\SkiaSharp.SceneGraph.csproj" />
<ProjectReference Include="..\..\binding\SkiaSharp.Resources\SkiaSharp.Resources.csproj" />
<ProjectReference Include="..\..\binding\SkiaSharp.Skottie\SkiaSharp.Skottie.csproj" />
<ProjectReference Include="..\..\binding\HarfBuzzSharp\HarfBuzzSharp.csproj" />
<ProjectReference Include="..\..\source\SkiaSharp.HarfBuzz\SkiaSharp.HarfBuzz\SkiaSharp.HarfBuzz.csproj" />

Просмотреть файл

@ -17,6 +17,7 @@
<ItemGroup>
<ProjectReference Include="..\..\binding\HarfBuzzSharp\HarfBuzzSharp.csproj" />
<ProjectReference Include="..\..\binding\SkiaSharp.SceneGraph\SkiaSharp.SceneGraph.csproj" />
<ProjectReference Include="..\..\binding\SkiaSharp.Resources\SkiaSharp.Resources.csproj" />
<ProjectReference Include="..\..\binding\SkiaSharp.Skottie\SkiaSharp.Skottie.csproj" />
<ProjectReference Include="..\..\binding\SkiaSharp\SkiaSharp.csproj" />
<ProjectReference Include="..\..\source\SkiaSharp.HarfBuzz\SkiaSharp.HarfBuzz\SkiaSharp.HarfBuzz.csproj" />

Просмотреть файл

@ -0,0 +1,81 @@
using System;
using System.IO;
using System.Runtime.InteropServices;
using SkiaSharp.Resources;
using Xunit;
namespace SkiaSharp.Tests
{
public class ResourceProviderTest : SKTest
{
[SkippableFact]
public void FileResourceProviderCanReadFiles()
{
var fullPath = Path.Combine(PathToImages, "baboon.png");
var expectedData = SKData.Create(fullPath);
using var rp = new FileResourceProvider(PathToImages);
using var data = rp.Load("baboon.png");
Assert.Equal(expectedData.ToArray(), data.ToArray());
}
[SkippableFact]
public void ProxyProviderCanReadFiles()
{
var fullPath = Path.Combine(PathToImages, "baboon.png");
var expectedData = SKData.Create(fullPath);
using var files = new FileResourceProvider(PathToImages);
using var datauri = new DataUriResourceProvider(files);
using var caching = new CachingResourceProvider(datauri);
using var data = caching.Load("baboon.png");
Assert.Equal(expectedData.ToArray(), data.ToArray());
}
[SkippableFact]
public void CanCreateDefaultDataUri()
{
using var datauri = new DataUriResourceProvider();
Assert.NotNull(datauri);
}
[SkippableFact]
public void CanCreateNullDataUri()
{
using var datauri = new DataUriResourceProvider(null);
Assert.NotNull(datauri);
}
[SkippableFact]
public void WrappedResourceManagersAreNotCollectedPrematurely()
{
var fullPath = Path.Combine(PathToImages, "baboon.png");
var expectedData = SKData.Create(fullPath);
var (caching, weak) = CreateProvider();
CollectGarbage();
Assert.True(weak.IsAlive);
using var data = caching.Load("baboon.png");
Assert.Equal(expectedData.ToArray(), data.ToArray());
static (CachingResourceProvider, WeakReference) CreateProvider()
{
var files = new FileResourceProvider(PathToImages);
var datauri = new DataUriResourceProvider(files);
var caching = new CachingResourceProvider(datauri);
return (caching, new WeakReference(files));
}
}
}
}

Просмотреть файл

@ -6,6 +6,41 @@ namespace SkiaSharp.Tests
{
[SkippableFact]
public void CanInstantiateDrawable()
{
using (var drawable = new TestDrawable())
{
}
}
[SkippableFact]
public void CanAccessBounds()
{
using (var drawable = new TestDrawable())
{
Assert.Equal(SKRect.Create(100, 100), drawable.Bounds);
Assert.Equal(1, drawable.BoundsFireCount);
}
}
[Trait(Traits.FailingOn.Key, Traits.FailingOn.Values.macOS)] // Something with sk_sp<SkPicture> SkDrawable::onMakePictureSnapshot() is causing issues
[Trait(Traits.FailingOn.Key, Traits.FailingOn.Values.iOS)] // Something with sk_sp<SkPicture> SkDrawable::onMakePictureSnapshot() is causing issues
[Trait(Traits.FailingOn.Key, Traits.FailingOn.Values.MacCatalyst)] // Something with sk_sp<SkPicture> SkDrawable::onMakePictureSnapshot() is causing issues
[SkippableFact]
public void CanCreateSnapshot()
{
using (var drawable = new TestDrawable())
{
var picture = drawable.Snapshot();
Assert.NotNull(picture);
Assert.Equal(1, drawable.SnapshotFireCount);
}
}
[Trait(Traits.FailingOn.Key, Traits.FailingOn.Values.macOS)] // Something with sk_sp<SkPicture> SkDrawable::onMakePictureSnapshot() is causing issues
[Trait(Traits.FailingOn.Key, Traits.FailingOn.Values.iOS)] // Something with sk_sp<SkPicture> SkDrawable::onMakePictureSnapshot() is causing issues
[Trait(Traits.FailingOn.Key, Traits.FailingOn.Values.MacCatalyst)] // Something with sk_sp<SkPicture> SkDrawable::onMakePictureSnapshot() is causing issues
[SkippableFact]
public void CanUseAllMembers()
{
using (var drawable = new TestDrawable())
{

Просмотреть файл

@ -0,0 +1,141 @@
using System;
using System.IO;
using SkiaSharp.Resources;
using SkiaSharp.SceneGraph;
using SkiaSharp.Skottie;
using Xunit;
namespace SkiaSharp.Tests
{
public class AnimationBuilderTest : SKTest
{
public static TheoryData<string> DefaultLottieFiles =>
AnimationTest.DefaultLottieFiles;
public static TheoryData<string> Base64Files =>
new TheoryData<string>
{
"lottie-base64_dotnet-bot.json",
"lottie-base64_women-thinking.json",
};
[SkippableTheory]
[MemberData(nameof(DefaultLottieFiles))]
public void DefaultBuilderIsTheSameAsDefaultCreate(string filename)
{
var path = Path.Combine(PathToImages, filename);
using var data = SKData.Create(path);
var directAnimation = Animation.Create(data);
var builderAnimation = Animation.CreateBuilder().Build(data);
Assert.NotNull(builderAnimation);
Assert.NotEqual(IntPtr.Zero, builderAnimation.Handle);
Assert.Equal(directAnimation.Duration, builderAnimation.Duration);
Assert.Equal(directAnimation.Fps, builderAnimation.Fps);
Assert.Equal(directAnimation.InPoint, builderAnimation.InPoint);
Assert.Equal(directAnimation.OutPoint, builderAnimation.OutPoint);
Assert.Equal(directAnimation.Version, builderAnimation.Version);
Assert.Equal(directAnimation.Size, builderAnimation.Size);
}
[SkippableTheory]
[MemberData(nameof(DefaultLottieFiles))]
public void DefaultBuilderHasStats(string filename)
{
var path = Path.Combine(PathToImages, filename);
using var data = SKData.Create(path);
var builder = Animation.CreateBuilder();
var animation = builder.Build(data);
Assert.NotNull(animation);
var stats = builder.Stats;
Assert.True(stats.SceneParseTime >= TimeSpan.Zero);
Assert.True(stats.JsonParseTime >= TimeSpan.Zero);
Assert.True(stats.TotalLoadTime >= TimeSpan.Zero);
Assert.True(stats.JsonSize > 0);
Assert.True(stats.AnimatorCount > 0);
}
[SkippableTheory]
[MemberData(nameof(Base64Files))]
public void CanLoadBase64ImagesFromData(string filename)
{
var path = Path.Combine(PathToImages, filename);
using var data = SKData.Create(path);
var animation = Animation
.CreateBuilder()
.SetResourceProvider(new DataUriResourceProvider())
.Build(data);
Assert.NotNull(animation);
Assert.True(animation.Duration > TimeSpan.Zero);
}
[SkippableTheory]
[MemberData(nameof(Base64Files))]
public void CanLoadBase64ImagesFromFilename(string filename)
{
var path = Path.Combine(PathToImages, filename);
var animation = Animation
.CreateBuilder()
.SetResourceProvider(new DataUriResourceProvider())
.Build(path);
Assert.NotNull(animation);
Assert.True(animation.Duration > TimeSpan.Zero);
}
[SkippableTheory]
[MemberData(nameof(Base64Files))]
public void CanRenderWithBase64(string filename)
{
var animation = Animation
.CreateBuilder()
.SetResourceProvider(new DataUriResourceProvider())
.Build(Path.Combine(PathToImages, filename));
using var bmp = new SKBitmap((int)animation.Size.Width, (int)animation.Size.Height);
bmp.Erase(SKColors.Red);
var beforePixels = bmp.Pixels;
using var canvas = new SKCanvas(bmp);
animation.Seek(0.1);
animation.Render(canvas, bmp.Info.Rect);
var afterPixels = bmp.Pixels;
Assert.NotEqual(beforePixels, afterPixels);
}
[SkippableFact]
public void WrappedResourceManagersAreNotCollectedPrematurely()
{
var (builder, weak) = CreateBuilder();
CollectGarbage();
Assert.True(weak.IsAlive);
using var animation = builder.Build(Path.Combine(PathToImages, "lottie-base64_dotnet-bot.json"));
builder.Dispose();
CollectGarbage();
Assert.False(weak.IsAlive);
static (AnimationBuilder, WeakReference) CreateBuilder()
{
var provider = new DataUriResourceProvider();
var builder = Animation
.CreateBuilder()
.SetResourceProvider(provider);
return (builder, new WeakReference(provider));
}
}
}
}

Просмотреть файл

@ -177,9 +177,12 @@ namespace SkiaSharp.Tests
Assert.NotEqual(IntPtr.Zero, animation.Handle);
}
private Animation BuildDefaultAnimation()
private Animation BuildDefaultAnimation() =>
BuildAnimation("LottieLogo1.json");
private Animation BuildAnimation(string filename)
{
var path = Path.Combine(PathToImages, "LottieLogo1.json");
var path = Path.Combine(PathToImages, filename);
var result = Animation.TryCreate(path, out var animation);
Assert.True(result);
@ -307,5 +310,39 @@ namespace SkiaSharp.Tests
Assert.Equal(new SKSize(375, 667), animation.Size);
}
[SkippableFact]
public void Can_Render()
{
var animation = BuildDefaultAnimation();
using var bmp = new SKBitmap((int)animation.Size.Width, (int)animation.Size.Height);
bmp.Erase(SKColors.Red);
var beforePixels = bmp.Pixels;
using var canvas = new SKCanvas(bmp);
animation.Seek(0.1);
animation.Render(canvas, bmp.Info.Rect);
var afterPixels = bmp.Pixels;
Assert.NotEqual(beforePixels, afterPixels);
}
[SkippableFact]
public void Can_Not_Render_With_Base64()
{
var animation = BuildAnimation("lottie-base64_dotnet-bot.json");
using var bmp = new SKBitmap((int)animation.Size.Width, (int)animation.Size.Height);
bmp.Erase(SKColors.Red);
var beforePixels = bmp.Pixels;
using var canvas = new SKCanvas(bmp);
animation.Seek(0.1);
animation.Render(canvas, bmp.Info.Rect);
var afterPixels = bmp.Pixels;
Assert.Equal(beforePixels, afterPixels);
}
}
}

Просмотреть файл

@ -11,10 +11,7 @@ This is a small set of tools that help with generating the p/invoke layer from t
This can be run with:
```pwsh
dotnet run --project=utils/SkiaSharpGenerator/SkiaSharpGenerator.csproj -- generate --config binding/libSkiaSharp.json --skia externals/skia --output binding/SkiaSharp/SkiaApi.generated.cs
dotnet run --project=utils/SkiaSharpGenerator/SkiaSharpGenerator.csproj -- generate --config binding/libSkiaSharp.Skottie.json --skia externals/skia --output binding/SkiaSharp.Skottie/SkottieApi.generated.cs
dotnet run --project=utils/SkiaSharpGenerator/SkiaSharpGenerator.csproj -- generate --config binding/libSkiaSharp.SceneGraph.json --skia externals/skia --output binding/SkiaSharp.SceneGraph/SceneGraphApi.generated.cs
dotnet run --project=utils/SkiaSharpGenerator/SkiaSharpGenerator.csproj -- generate --config binding/libHarfBuzzSharp.json --skia externals/skia/third_party/externals/harfbuzz --output binding/HarfBuzzSharp/HarfBuzzApi.generated.cs
.\utils\generate.ps1
```
* `--config binding/libSkiaSharp.json`

Просмотреть файл

@ -4,10 +4,16 @@
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<RollForward>LatestMajor</RollForward>
</PropertyGroup>
<PropertyGroup>
<!-- Workaround for issue https://github.com/microsoft/ClangSharp/issues/129 -->
<RuntimeIdentifier>$(NETCoreSdkRuntimeIdentifier)</RuntimeIdentifier>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="CppAst" Version="0.8.0" />
<PackageReference Include="CppAst" Version="0.13.0" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="3.6.0" />
<PackageReference Include="Mono.Cecil" Version="0.11.2" />
<PackageReference Include="Mono.Options" Version="5.3.0.1" />

5
utils/generate.ps1 Normal file
Просмотреть файл

@ -0,0 +1,5 @@
dotnet run --project=utils/SkiaSharpGenerator/SkiaSharpGenerator.csproj -- generate --config binding/libSkiaSharp.json --skia externals/skia --output binding/SkiaSharp/SkiaApi.generated.cs
dotnet run --project=utils/SkiaSharpGenerator/SkiaSharpGenerator.csproj -- generate --config binding/libSkiaSharp.Skottie.json --skia externals/skia --output binding/SkiaSharp.Skottie/SkottieApi.generated.cs
dotnet run --project=utils/SkiaSharpGenerator/SkiaSharpGenerator.csproj -- generate --config binding/libSkiaSharp.SceneGraph.json --skia externals/skia --output binding/SkiaSharp.SceneGraph/SceneGraphApi.generated.cs
dotnet run --project=utils/SkiaSharpGenerator/SkiaSharpGenerator.csproj -- generate --config binding/libSkiaSharp.Resources.json --skia externals/skia --output binding/SkiaSharp.Resources/ResourcesApi.generated.cs
dotnet run --project=utils/SkiaSharpGenerator/SkiaSharpGenerator.csproj -- generate --config binding/libHarfBuzzSharp.json --skia externals/skia/third_party/externals/harfbuzz --output binding/HarfBuzzSharp/HarfBuzzApi.generated.cs