feat: Add basic Skottie support (#1987)

* feat: Add basic Skottie support
* chore: Adjust skottie SKStream support
* ci: Adjust apple targets
* chore: Adjust apple targets
* chore: Adjust tizen targets
* chore: Adjust APIs, add tests, align with new memory management functions
* chore: Adjust for updated API name in sample
* chore: Adjust test values
* chore: Adjust AnimationRenderFlags generation
* chore: Fix linux skottie export map
* ci: Update skia submodule
This commit is contained in:
Jérôme Laban 2022-05-31 16:40:16 -04:00 коммит произвёл GitHub
Родитель b651807a72
Коммит cda59a8fb3
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
27 изменённых файлов: 15671 добавлений и 12 удалений

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

@ -0,0 +1,54 @@
using System;
using System.ComponentModel;
using System.IO;
using System.Runtime.InteropServices;
namespace SkiaSharp.SceneGraph
{
public unsafe class InvalidationController : SKObject, ISKSkipObjectRegistration
{
public InvalidationController ()
: this (SkiaApi.sksg_invalidation_controller_new (), true)
{
}
internal InvalidationController (IntPtr handle, bool owns)
: base (handle, owns)
{
}
protected override void DisposeNative ()
{
SkiaApi.sksg_invalidation_controller_delete (Handle);
}
public unsafe void Invalidate(SKRect rect, SKMatrix matrix)
{
SkiaApi.sksg_invalidation_controller_inval (Handle, &rect, &matrix);
}
public unsafe SKRect Bounds
{
get {
SKRect rect;
SkiaApi.sksg_invalidation_controller_get_bounds (Handle, &rect);
return rect;
}
}
public unsafe void Begin ()
{
SkiaApi.sksg_invalidation_controller_begin (Handle);
}
public unsafe void End ()
{
SkiaApi.sksg_invalidation_controller_end (Handle);
}
public unsafe void Reset ()
{
SkiaApi.sksg_invalidation_controller_reset (Handle);
}
}
}

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

@ -3,6 +3,8 @@ using System.Runtime.InteropServices;
#region Namespaces
using SkiaSharp.SceneGraph;
using SkiaSharp.Skottie;
#endregion
@ -84,6 +86,13 @@ using sk_wstream_managedstream_t = System.IntPtr;
using sk_wstream_t = System.IntPtr;
using sk_xmlstreamwriter_t = System.IntPtr;
using sk_xmlwriter_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 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;
@ -13003,6 +13012,364 @@ namespace SkiaSharp
#endregion
#region skottie_animation.h
// void skottie_animation_delete(skottie_animation_t* instance)
#if !USE_DELEGATES
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
internal static extern void skottie_animation_delete (skottie_animation_t instance);
#else
private partial class Delegates {
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
internal delegate void skottie_animation_delete (skottie_animation_t instance);
}
private static Delegates.skottie_animation_delete skottie_animation_delete_delegate;
internal static void skottie_animation_delete (skottie_animation_t instance) =>
(skottie_animation_delete_delegate ??= GetSymbol<Delegates.skottie_animation_delete> ("skottie_animation_delete")).Invoke (instance);
#endif
// double skottie_animation_get_duration(skottie_animation_t* instance)
#if !USE_DELEGATES
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
internal static extern Double skottie_animation_get_duration (skottie_animation_t instance);
#else
private partial class Delegates {
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
internal delegate Double skottie_animation_get_duration (skottie_animation_t instance);
}
private static Delegates.skottie_animation_get_duration skottie_animation_get_duration_delegate;
internal static Double skottie_animation_get_duration (skottie_animation_t instance) =>
(skottie_animation_get_duration_delegate ??= GetSymbol<Delegates.skottie_animation_get_duration> ("skottie_animation_get_duration")).Invoke (instance);
#endif
// double skottie_animation_get_fps(skottie_animation_t* instance)
#if !USE_DELEGATES
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
internal static extern Double skottie_animation_get_fps (skottie_animation_t instance);
#else
private partial class Delegates {
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
internal delegate Double skottie_animation_get_fps (skottie_animation_t instance);
}
private static Delegates.skottie_animation_get_fps skottie_animation_get_fps_delegate;
internal static Double skottie_animation_get_fps (skottie_animation_t instance) =>
(skottie_animation_get_fps_delegate ??= GetSymbol<Delegates.skottie_animation_get_fps> ("skottie_animation_get_fps")).Invoke (instance);
#endif
// double skottie_animation_get_in_point(skottie_animation_t* instance)
#if !USE_DELEGATES
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
internal static extern Double skottie_animation_get_in_point (skottie_animation_t instance);
#else
private partial class Delegates {
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
internal delegate Double skottie_animation_get_in_point (skottie_animation_t instance);
}
private static Delegates.skottie_animation_get_in_point skottie_animation_get_in_point_delegate;
internal static Double skottie_animation_get_in_point (skottie_animation_t instance) =>
(skottie_animation_get_in_point_delegate ??= GetSymbol<Delegates.skottie_animation_get_in_point> ("skottie_animation_get_in_point")).Invoke (instance);
#endif
// double skottie_animation_get_out_point(skottie_animation_t* instance)
#if !USE_DELEGATES
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
internal static extern Double skottie_animation_get_out_point (skottie_animation_t instance);
#else
private partial class Delegates {
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
internal delegate Double skottie_animation_get_out_point (skottie_animation_t instance);
}
private static Delegates.skottie_animation_get_out_point skottie_animation_get_out_point_delegate;
internal static Double skottie_animation_get_out_point (skottie_animation_t instance) =>
(skottie_animation_get_out_point_delegate ??= GetSymbol<Delegates.skottie_animation_get_out_point> ("skottie_animation_get_out_point")).Invoke (instance);
#endif
// void skottie_animation_get_size(skottie_animation_t* instance, sk_size_t* size)
#if !USE_DELEGATES
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
internal static extern void skottie_animation_get_size (skottie_animation_t instance, SKSize* size);
#else
private partial class Delegates {
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
internal delegate void skottie_animation_get_size (skottie_animation_t instance, SKSize* size);
}
private static Delegates.skottie_animation_get_size skottie_animation_get_size_delegate;
internal static void skottie_animation_get_size (skottie_animation_t instance, SKSize* size) =>
(skottie_animation_get_size_delegate ??= GetSymbol<Delegates.skottie_animation_get_size> ("skottie_animation_get_size")).Invoke (instance, size);
#endif
// void skottie_animation_get_version(skottie_animation_t* instance, sk_string_t* version)
#if !USE_DELEGATES
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
internal static extern void skottie_animation_get_version (skottie_animation_t instance, sk_string_t version);
#else
private partial class Delegates {
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
internal delegate void skottie_animation_get_version (skottie_animation_t instance, sk_string_t version);
}
private static Delegates.skottie_animation_get_version skottie_animation_get_version_delegate;
internal static void skottie_animation_get_version (skottie_animation_t instance, sk_string_t version) =>
(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_file(const char* path)
#if !USE_DELEGATES
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
internal static extern skottie_animation_t skottie_animation_make_from_file ([MarshalAs (UnmanagedType.LPStr)] String path);
#else
private partial class Delegates {
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
internal delegate skottie_animation_t skottie_animation_make_from_file ([MarshalAs (UnmanagedType.LPStr)] String path);
}
private static Delegates.skottie_animation_make_from_file skottie_animation_make_from_file_delegate;
internal static skottie_animation_t skottie_animation_make_from_file ([MarshalAs (UnmanagedType.LPStr)] String path) =>
(skottie_animation_make_from_file_delegate ??= GetSymbol<Delegates.skottie_animation_make_from_file> ("skottie_animation_make_from_file")).Invoke (path);
#endif
// skottie_animation_t* skottie_animation_make_from_stream(sk_stream_t* stream)
#if !USE_DELEGATES
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
internal static extern skottie_animation_t skottie_animation_make_from_stream (sk_stream_t stream);
#else
private partial class Delegates {
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
internal delegate skottie_animation_t skottie_animation_make_from_stream (sk_stream_t stream);
}
private static Delegates.skottie_animation_make_from_stream skottie_animation_make_from_stream_delegate;
internal static skottie_animation_t skottie_animation_make_from_stream (sk_stream_t stream) =>
(skottie_animation_make_from_stream_delegate ??= GetSymbol<Delegates.skottie_animation_make_from_stream> ("skottie_animation_make_from_stream")).Invoke (stream);
#endif
// skottie_animation_t* skottie_animation_make_from_string(const char* data, size_t length)
#if !USE_DELEGATES
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
internal static extern skottie_animation_t skottie_animation_make_from_string ([MarshalAs (UnmanagedType.LPStr)] String data, int length);
#else
private partial class Delegates {
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
internal delegate skottie_animation_t skottie_animation_make_from_string ([MarshalAs (UnmanagedType.LPStr)] String data, int length);
}
private static Delegates.skottie_animation_make_from_string skottie_animation_make_from_string_delegate;
internal static skottie_animation_t skottie_animation_make_from_string ([MarshalAs (UnmanagedType.LPStr)] String data, int length) =>
(skottie_animation_make_from_string_delegate ??= GetSymbol<Delegates.skottie_animation_make_from_string> ("skottie_animation_make_from_string")).Invoke (data, length);
#endif
// void skottie_animation_ref(skottie_animation_t* instance)
#if !USE_DELEGATES
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
internal static extern void skottie_animation_ref (skottie_animation_t instance);
#else
private partial class Delegates {
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
internal delegate void skottie_animation_ref (skottie_animation_t instance);
}
private static Delegates.skottie_animation_ref skottie_animation_ref_delegate;
internal static void skottie_animation_ref (skottie_animation_t instance) =>
(skottie_animation_ref_delegate ??= GetSymbol<Delegates.skottie_animation_ref> ("skottie_animation_ref")).Invoke (instance);
#endif
// void skottie_animation_render(skottie_animation_t* instance, sk_canvas_t* canvas, sk_rect_t* dst)
#if !USE_DELEGATES
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
internal static extern void skottie_animation_render (skottie_animation_t instance, sk_canvas_t canvas, SKRect* dst);
#else
private partial class Delegates {
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
internal delegate void skottie_animation_render (skottie_animation_t instance, sk_canvas_t canvas, SKRect* dst);
}
private static Delegates.skottie_animation_render skottie_animation_render_delegate;
internal static void skottie_animation_render (skottie_animation_t instance, sk_canvas_t canvas, SKRect* dst) =>
(skottie_animation_render_delegate ??= GetSymbol<Delegates.skottie_animation_render> ("skottie_animation_render")).Invoke (instance, canvas, dst);
#endif
// void skottie_animation_render_with_flags(skottie_animation_t* instance, sk_canvas_t* canvas, sk_rect_t* dst, skottie_animation_renderflags_t flags)
#if !USE_DELEGATES
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
internal static extern void skottie_animation_render_with_flags (skottie_animation_t instance, sk_canvas_t canvas, SKRect* dst, AnimationRenderFlags flags);
#else
private partial class Delegates {
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
internal delegate void skottie_animation_render_with_flags (skottie_animation_t instance, sk_canvas_t canvas, SKRect* dst, AnimationRenderFlags flags);
}
private static Delegates.skottie_animation_render_with_flags skottie_animation_render_with_flags_delegate;
internal static void skottie_animation_render_with_flags (skottie_animation_t instance, sk_canvas_t canvas, SKRect* dst, AnimationRenderFlags flags) =>
(skottie_animation_render_with_flags_delegate ??= GetSymbol<Delegates.skottie_animation_render_with_flags> ("skottie_animation_render_with_flags")).Invoke (instance, canvas, dst, flags);
#endif
// void skottie_animation_seek(skottie_animation_t* instance, float t, sksg_invalidation_controller_t* ic)
#if !USE_DELEGATES
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
internal static extern void skottie_animation_seek (skottie_animation_t instance, Single t, sksg_invalidation_controller_t ic);
#else
private partial class Delegates {
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
internal delegate void skottie_animation_seek (skottie_animation_t instance, Single t, sksg_invalidation_controller_t ic);
}
private static Delegates.skottie_animation_seek skottie_animation_seek_delegate;
internal static void skottie_animation_seek (skottie_animation_t instance, Single t, sksg_invalidation_controller_t ic) =>
(skottie_animation_seek_delegate ??= GetSymbol<Delegates.skottie_animation_seek> ("skottie_animation_seek")).Invoke (instance, t, ic);
#endif
// void skottie_animation_seek_frame(skottie_animation_t* instance, float t, sksg_invalidation_controller_t* ic)
#if !USE_DELEGATES
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
internal static extern void skottie_animation_seek_frame (skottie_animation_t instance, Single t, sksg_invalidation_controller_t ic);
#else
private partial class Delegates {
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
internal delegate void skottie_animation_seek_frame (skottie_animation_t instance, Single t, sksg_invalidation_controller_t ic);
}
private static Delegates.skottie_animation_seek_frame skottie_animation_seek_frame_delegate;
internal static void skottie_animation_seek_frame (skottie_animation_t instance, Single t, sksg_invalidation_controller_t ic) =>
(skottie_animation_seek_frame_delegate ??= GetSymbol<Delegates.skottie_animation_seek_frame> ("skottie_animation_seek_frame")).Invoke (instance, t, ic);
#endif
// void skottie_animation_seek_frame_time(skottie_animation_t* instance, float t, sksg_invalidation_controller_t* ic)
#if !USE_DELEGATES
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
internal static extern void skottie_animation_seek_frame_time (skottie_animation_t instance, Single t, sksg_invalidation_controller_t ic);
#else
private partial class Delegates {
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
internal delegate void skottie_animation_seek_frame_time (skottie_animation_t instance, Single t, sksg_invalidation_controller_t ic);
}
private static Delegates.skottie_animation_seek_frame_time skottie_animation_seek_frame_time_delegate;
internal static void skottie_animation_seek_frame_time (skottie_animation_t instance, Single t, sksg_invalidation_controller_t ic) =>
(skottie_animation_seek_frame_time_delegate ??= GetSymbol<Delegates.skottie_animation_seek_frame_time> ("skottie_animation_seek_frame_time")).Invoke (instance, t, ic);
#endif
// void skottie_animation_unref(skottie_animation_t* instance)
#if !USE_DELEGATES
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
internal static extern void skottie_animation_unref (skottie_animation_t instance);
#else
private partial class Delegates {
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
internal delegate void skottie_animation_unref (skottie_animation_t instance);
}
private static Delegates.skottie_animation_unref skottie_animation_unref_delegate;
internal static void skottie_animation_unref (skottie_animation_t instance) =>
(skottie_animation_unref_delegate ??= GetSymbol<Delegates.skottie_animation_unref> ("skottie_animation_unref")).Invoke (instance);
#endif
#endregion
#region sksg_invalidation_controller.h
// void sksg_invalidation_controller_begin(sksg_invalidation_controller_t* instance)
#if !USE_DELEGATES
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
internal static extern void sksg_invalidation_controller_begin (sksg_invalidation_controller_t instance);
#else
private partial class Delegates {
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
internal delegate void sksg_invalidation_controller_begin (sksg_invalidation_controller_t instance);
}
private static Delegates.sksg_invalidation_controller_begin sksg_invalidation_controller_begin_delegate;
internal static void sksg_invalidation_controller_begin (sksg_invalidation_controller_t instance) =>
(sksg_invalidation_controller_begin_delegate ??= GetSymbol<Delegates.sksg_invalidation_controller_begin> ("sksg_invalidation_controller_begin")).Invoke (instance);
#endif
// void sksg_invalidation_controller_delete(sksg_invalidation_controller_t* instance)
#if !USE_DELEGATES
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
internal static extern void sksg_invalidation_controller_delete (sksg_invalidation_controller_t instance);
#else
private partial class Delegates {
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
internal delegate void sksg_invalidation_controller_delete (sksg_invalidation_controller_t instance);
}
private static Delegates.sksg_invalidation_controller_delete sksg_invalidation_controller_delete_delegate;
internal static void sksg_invalidation_controller_delete (sksg_invalidation_controller_t instance) =>
(sksg_invalidation_controller_delete_delegate ??= GetSymbol<Delegates.sksg_invalidation_controller_delete> ("sksg_invalidation_controller_delete")).Invoke (instance);
#endif
// void sksg_invalidation_controller_end(sksg_invalidation_controller_t* instance)
#if !USE_DELEGATES
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
internal static extern void sksg_invalidation_controller_end (sksg_invalidation_controller_t instance);
#else
private partial class Delegates {
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
internal delegate void sksg_invalidation_controller_end (sksg_invalidation_controller_t instance);
}
private static Delegates.sksg_invalidation_controller_end sksg_invalidation_controller_end_delegate;
internal static void sksg_invalidation_controller_end (sksg_invalidation_controller_t instance) =>
(sksg_invalidation_controller_end_delegate ??= GetSymbol<Delegates.sksg_invalidation_controller_end> ("sksg_invalidation_controller_end")).Invoke (instance);
#endif
// void sksg_invalidation_controller_get_bounds(sksg_invalidation_controller_t* instance, sk_rect_t* bounds)
#if !USE_DELEGATES
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
internal static extern void sksg_invalidation_controller_get_bounds (sksg_invalidation_controller_t instance, SKRect* bounds);
#else
private partial class Delegates {
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
internal delegate void sksg_invalidation_controller_get_bounds (sksg_invalidation_controller_t instance, SKRect* bounds);
}
private static Delegates.sksg_invalidation_controller_get_bounds sksg_invalidation_controller_get_bounds_delegate;
internal static void sksg_invalidation_controller_get_bounds (sksg_invalidation_controller_t instance, SKRect* bounds) =>
(sksg_invalidation_controller_get_bounds_delegate ??= GetSymbol<Delegates.sksg_invalidation_controller_get_bounds> ("sksg_invalidation_controller_get_bounds")).Invoke (instance, bounds);
#endif
// void sksg_invalidation_controller_inval(sksg_invalidation_controller_t* instance, sk_rect_t* rect, sk_matrix_t* matrix)
#if !USE_DELEGATES
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
internal static extern void sksg_invalidation_controller_inval (sksg_invalidation_controller_t instance, SKRect* rect, SKMatrix* matrix);
#else
private partial class Delegates {
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
internal delegate void sksg_invalidation_controller_inval (sksg_invalidation_controller_t instance, SKRect* rect, SKMatrix* matrix);
}
private static Delegates.sksg_invalidation_controller_inval sksg_invalidation_controller_inval_delegate;
internal static void sksg_invalidation_controller_inval (sksg_invalidation_controller_t instance, SKRect* rect, SKMatrix* matrix) =>
(sksg_invalidation_controller_inval_delegate ??= GetSymbol<Delegates.sksg_invalidation_controller_inval> ("sksg_invalidation_controller_inval")).Invoke (instance, rect, matrix);
#endif
// sksg_invalidation_controller_t* sksg_invalidation_controller_new()
#if !USE_DELEGATES
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
internal static extern sksg_invalidation_controller_t sksg_invalidation_controller_new ();
#else
private partial class Delegates {
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
internal delegate sksg_invalidation_controller_t sksg_invalidation_controller_new ();
}
private static Delegates.sksg_invalidation_controller_new sksg_invalidation_controller_new_delegate;
internal static sksg_invalidation_controller_t sksg_invalidation_controller_new () =>
(sksg_invalidation_controller_new_delegate ??= GetSymbol<Delegates.sksg_invalidation_controller_new> ("sksg_invalidation_controller_new")).Invoke ();
#endif
// void sksg_invalidation_controller_reset(sksg_invalidation_controller_t* instance)
#if !USE_DELEGATES
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
internal static extern void sksg_invalidation_controller_reset (sksg_invalidation_controller_t instance);
#else
private partial class Delegates {
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
internal delegate void sksg_invalidation_controller_reset (sksg_invalidation_controller_t instance);
}
private static Delegates.sksg_invalidation_controller_reset sksg_invalidation_controller_reset_delegate;
internal static void sksg_invalidation_controller_reset (sksg_invalidation_controller_t instance) =>
(sksg_invalidation_controller_reset_delegate ??= GetSymbol<Delegates.sksg_invalidation_controller_reset> ("sksg_invalidation_controller_reset")).Invoke (instance);
#endif
#endregion
#region sk_compatpaint.h
// sk_compatpaint_t* sk_compatpaint_clone(const sk_compatpaint_t* paint)
@ -16315,4 +16682,16 @@ namespace SkiaSharp {
}
}
namespace SkiaSharp.Skottie {
// skottie_animation_renderflags_t
[Flags]
public enum AnimationRenderFlags {
// SKIP_TOP_LEVEL_ISOLATION = 0x01
SkipTopLevelIsolation = 1,
// DISABLE_TOP_LEVEL_CLIPPING = 0x02
DisableTopLevelClipping = 2,
}
}
#endregion

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

@ -0,0 +1,98 @@
using System;
using System.ComponentModel;
using System.IO;
using System.Runtime.InteropServices;
using SkiaSharp.SceneGraph;
namespace SkiaSharp.Skottie
{
public unsafe class Animation : SKObject, ISKNonVirtualReferenceCounted, ISKSkipObjectRegistration
{
internal Animation (IntPtr handle, bool owns)
: base (handle, owns)
{
}
void ISKNonVirtualReferenceCounted.ReferenceNative ()
=> SkiaApi.skottie_animation_ref (Handle);
void ISKNonVirtualReferenceCounted.UnreferenceNative ()
=> SkiaApi.skottie_animation_unref (Handle);
protected override void DisposeNative ()
=> SkiaApi.skottie_animation_delete (Handle);
public static bool TryParse (string data, out Animation animation)
{
animation = GetObject (SkiaApi.skottie_animation_make_from_string (data, data.Length));
return animation != null;
}
public static bool TryCreate (Stream stream, out Animation animation)
{
using (var managed = new SKManagedStream (stream)) {
return TryCreate (managed, out animation);
}
}
public static bool TryCreate (SKStream stream, out Animation animation)
{
animation = GetObject (SkiaApi.skottie_animation_make_from_stream (stream.Handle));
return animation != null;
}
public static bool TryCreate (string path, out Animation animation)
{
animation = GetObject (SkiaApi.skottie_animation_make_from_file (path));
return animation != null;
}
public unsafe void Render(SKCanvas canvas, SKRect dst)
=> SkiaApi.skottie_animation_render (Handle, canvas.Handle, &dst);
public void Render (SKCanvas canvas, SKRect dst, AnimationRenderFlags flags)
=> SkiaApi.skottie_animation_render_with_flags (Handle, canvas.Handle, &dst, flags);
public void Seek (double t, InvalidationController ic = null)
=> SkiaApi.skottie_animation_seek (Handle, (float)t, ic?.Handle ?? IntPtr.Zero);
public void SeekFrame(double t, InvalidationController ic = null)
=> SkiaApi.skottie_animation_seek_frame (Handle, (float)t, ic?.Handle ?? IntPtr.Zero);
public void SeekFrameTime(double t, InvalidationController ic = null)
=> SkiaApi.skottie_animation_seek_frame_time (Handle, (float)t, ic?.Handle ?? IntPtr.Zero);
public double Duration
=> SkiaApi.skottie_animation_get_duration (Handle);
public double Fps
=> SkiaApi.skottie_animation_get_fps (Handle);
public double InPoint
=> SkiaApi.skottie_animation_get_in_point (Handle);
public double OutPoint
=> SkiaApi.skottie_animation_get_out_point (Handle);
public string Version {
get {
using var str = new SKString ();
SkiaApi.skottie_animation_get_version (Handle, str.Handle);
return str.ToString();
}
}
public unsafe SKSize Size {
get {
SKSize size;
SkiaApi.skottie_animation_get_size (Handle, &size);
return size;
}
}
internal static Animation GetObject (IntPtr handle) =>
handle == IntPtr.Zero ? null : new Animation (handle, true);
}
}

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

@ -11,6 +11,14 @@
},
"gr_": {
"prefix": "GR"
},
"sksg_": {
"cs": "SceneGraph",
"prefix": ""
},
"skottie_": {
"cs": "Skottie",
"prefix": ""
}
},
"className": "SkiaApi",
@ -18,11 +26,11 @@
"."
],
"headers": {
"include/c": [ "sk_*", "gr_*" ],
"include/c": [ "sk_*", "gr_*", "skottie*", "sksg_*" ],
"include/xamarin": [ "sk_*" ]
},
"source": {
"src/c": [ "sk_*", "gr_*" ],
"src/c": [ "sk_*", "gr_*", "skottie*", "sksg_*" ],
"src/xamarin": [ "sk_*" ]
},
"mappings": {
@ -366,6 +374,10 @@
"sk_lattice_t": {
"cs": "SKLatticeInternal",
"internal": true
},
"skottie_animation_renderflags_t": {
"cs": "AnimationRenderFlags",
"flags": true
}
},
"functions": {
@ -444,6 +456,18 @@
"parameters": {
"1": "[MarshalAs (UnmanagedType.LPStr)] String"
}
},
"skottie_animation_make_from_string": {
"parameters": {
"0": "[MarshalAs (UnmanagedType.LPStr)] String",
"1": "int"
}
},
"skottie_animation_make_from_file": {
"parameters": {
"0": "[MarshalAs (UnmanagedType.LPStr)] String"
}
}
}
}

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

@ -1 +1 @@
Subproject commit 0932353360e5fcb46a7be47a00e398ce60b7486a
Subproject commit 8e7a3aa31b76f3e16e561eead4c938a8fbbd520f

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

@ -35,6 +35,7 @@ Task("libSkiaSharp")
$"skia_use_system_libwebp=false " +
$"skia_use_system_zlib=false " +
$"skia_use_vulkan={SUPPORT_VULKAN} ".ToLower () +
$"skia_enable_skottie=true " +
$"extra_cflags=[ '-DSKIA_C_DLL', '-DHAVE_SYSCALL_GETRANDOM', '-DXML_DEV_URANDOM' ] " +
$"ndk='{ANDROID_NDK_HOME}' " +
$"ndk_api={(skiaArch == "x64" || skiaArch == "arm64" ? 21 : 16)}");

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

@ -29,7 +29,7 @@ Task("libSkiaSharp")
{
if (Skip(arch)) return;
GnNinja($"{VARIANT}/{arch}", "skia",
GnNinja($"{VARIANT}/{arch}", "skia modules/skottie",
$"target_cpu='{skiaArch}' " +
$"target_os='{VARIANT}' " +
$"skia_use_icu=false " +
@ -41,6 +41,7 @@ Task("libSkiaSharp")
$"skia_use_system_libpng=false " +
$"skia_use_system_libwebp=false " +
$"skia_use_system_zlib=false " +
$"skia_enable_skottie=true " +
$"extra_cflags=[ '-DSKIA_C_DLL', '-DHAVE_ARC4RANDOM_BUF' ] ");
RunXCodeBuild("libSkiaSharp/libSkiaSharp.xcodeproj", "libSkiaSharp", sdk, arch, platform: VARIANT);

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

@ -418,6 +418,10 @@
OTHER_LDFLAGS = (
"-all_load",
"-lskia",
"-lskottie",
"-lsksg",
"-lskshaper",
"-lskresources",
);
PRODUCT_BUNDLE_IDENTIFIER = "com.microsoft.libSkiaSharp";
PRODUCT_NAME = "$(TARGET_NAME)";
@ -444,6 +448,10 @@
OTHER_LDFLAGS = (
"-all_load",
"-lskia",
"-lskottie",
"-lsksg",
"-lskshaper",
"-lskresources",
);
PRODUCT_BUNDLE_IDENTIFIER = "com.microsoft.libSkiaSharp";
PRODUCT_NAME = "$(TARGET_NAME)";

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

@ -73,6 +73,7 @@ Task("libSkiaSharp")
$"skia_use_system_libpng=false " +
$"skia_use_system_libwebp=false " +
$"skia_use_system_zlib=false " +
$"skia_enable_skottie=true " +
$"skia_use_vulkan={SUPPORT_VULKAN} ".ToLower() +
$"extra_asmflags=[] " +
$"extra_cflags=[ '-DSKIA_C_DLL', '-DHAVE_SYSCALL_GETRANDOM', '-DXML_DEV_URANDOM' ] " +

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

@ -2,6 +2,8 @@ libSkiaSharp {
global:
sk_*;
gr_*;
skottie_*;
sksg_*;
local:
*;
};

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

@ -22,7 +22,7 @@ Task("libSkiaSharp")
? "11.0"
: "10.8";
GnNinja($"macos/{arch}", "skia",
GnNinja($"macos/{arch}", "skia modules/skottie",
$"target_os='mac' " +
$"target_cpu='{skiaArch}' " +
$"min_macos_version='{minVersion}' " +
@ -35,6 +35,7 @@ Task("libSkiaSharp")
$"skia_use_system_libpng=false " +
$"skia_use_system_libwebp=false " +
$"skia_use_system_zlib=false " +
$"skia_enable_skottie=true " +
$"extra_cflags=[ '-DSKIA_C_DLL', '-DHAVE_ARC4RANDOM_BUF', '-stdlib=libc++' ] " +
$"extra_ldflags=[ '-stdlib=libc++' ]");

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

@ -379,7 +379,13 @@
INSTALL_PATH = "@rpath";
LIBRARY_SEARCH_PATHS = "../../../externals/skia/out/macos/$(ARCHS)";
MACOSX_DEPLOYMENT_TARGET = 10.8;
OTHER_LDFLAGS = "-lskia";
OTHER_LDFLAGS = (
"-lskia",
"-lskottie",
"-lsksg",
"-lskshaper",
"-lskresources",
);
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Debug;
@ -396,7 +402,13 @@
INSTALL_PATH = "@rpath";
LIBRARY_SEARCH_PATHS = "../../../externals/skia/out/macos/$(ARCHS)";
MACOSX_DEPLOYMENT_TARGET = 10.8;
OTHER_LDFLAGS = "-lskia";
OTHER_LDFLAGS = (
"-lskia",
"-lskottie",
"-lsksg",
"-lskshaper",
"-lskresources",
);
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Release;

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

@ -21,7 +21,7 @@ Task("libSkiaSharp")
{
if (Skip(arch)) return;
GnNinja($"tizen/{arch}", "skia",
GnNinja($"tizen/{arch}", "skia modules/skottie",
$"target_os='tizen' " +
$"target_cpu='{skiaArch}' " +
$"skia_enable_gpu=true " +
@ -34,6 +34,7 @@ Task("libSkiaSharp")
$"skia_use_system_libpng=false " +
$"skia_use_system_libwebp=false " +
$"skia_use_system_zlib=true " +
$"skia_enable_skottie=true " +
$"extra_cflags=[ '-DSKIA_C_DLL', '-DXML_DEV_URANDOM', '-DSK_NO_MAKE_SHARED_PTR' ] " +
$"ncli='{TIZEN_STUDIO_HOME}' " +
$"ncli_version='4.0'");

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

@ -5,7 +5,7 @@ skia_root = $(abspath ../../../externals/skia)
USER_LIB_DIRS = $(skia_root)/out/tizen/$(BUILD_ARCH)
USER_LIBS = skia
USER_LIBS = skia skresources skottie sksg skshaper
USER_LINK_OPTS = -Wl,--gc-sections

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

@ -18,7 +18,7 @@ Task("libSkiaSharp")
{
if (Skip(arch)) return;
GnNinja($"tvos/{arch}", "skia",
GnNinja($"tvos/{arch}", "skia modules/skottie",
$"target_os='tvos' " +
$"target_cpu='{skiaArch}' " +
$"skia_use_icu=false " +
@ -30,6 +30,7 @@ Task("libSkiaSharp")
$"skia_use_system_libpng=false " +
$"skia_use_system_libwebp=false " +
$"skia_use_system_zlib=false " +
$"skia_enable_skottie=true " +
$"extra_cflags=[ '-DSKIA_C_DLL', '-DHAVE_ARC4RANDOM_BUF' ] ");
RunXCodeBuild("libSkiaSharp/libSkiaSharp.xcodeproj", "libSkiaSharp", sdk, arch);

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

@ -408,6 +408,10 @@
OTHER_LDFLAGS = (
"-all_load",
"-lskia",
"-lskottie",
"-lsksg",
"-lskshaper",
"-lskresources",
);
PRODUCT_BUNDLE_IDENTIFIER = "com.microsoft.libSkiaSharp";
PRODUCT_NAME = "$(TARGET_NAME)";
@ -432,6 +436,10 @@
OTHER_LDFLAGS = (
"-all_load",
"-lskia",
"-lskottie",
"-lsksg",
"-lskshaper",
"-lskresources",
);
PRODUCT_BUNDLE_IDENTIFIER = "com.microsoft.libSkiaSharp";
PRODUCT_NAME = "$(TARGET_NAME)";

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

@ -37,6 +37,7 @@ Task("libSkiaSharp")
$"skia_use_system_libpng=false " +
$"skia_use_system_libwebp=false " +
$"skia_use_system_zlib=false " +
$"skia_enable_skottie=true " +
win_vcvars_version +
$"extra_cflags=[ " +
$" '-DSKIA_C_DLL', '/MD{d}', '/EHsc', '/Z7', " +

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

@ -47,6 +47,7 @@ Task("libSkiaSharp")
$"skia_use_system_zlib=false " +
$"skia_use_vulkan=false " +
$"skia_use_wuffs=true " +
$"skia_enable_skottie=true " +
$"use_PIC=false " +
$"extra_cflags=[ " +
$" '-DSKIA_C_DLL', '-DXML_POOR_ENTROPY', " +

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

@ -19,7 +19,7 @@ Task("libSkiaSharp")
{
if (Skip(arch)) return;
GnNinja($"watchos/{arch}", "skia",
GnNinja($"watchos/{arch}", "skia modules/skottie",
$"target_os='watchos' " +
$"target_cpu='{skiaArch}' " +
$"skia_enable_gpu=false " +
@ -32,6 +32,7 @@ Task("libSkiaSharp")
$"skia_use_system_libpng=false " +
$"skia_use_system_libwebp=false " +
$"skia_use_system_zlib=false " +
$"skia_enable_skottie=true " +
$"extra_cflags=[ '-DSKIA_C_DLL', '-DHAVE_ARC4RANDOM_BUF' ] ");
RunXCodeBuild("libSkiaSharp/libSkiaSharp.xcodeproj", "libSkiaSharp", sdk, arch);

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

@ -409,6 +409,10 @@
OTHER_LDFLAGS = (
"-all_load",
"-lskia",
"-lskottie",
"-lsksg",
"-lskshaper",
"-lskresources",
);
PRODUCT_BUNDLE_IDENTIFIER = "xamarin.libskia-watchos";
PRODUCT_NAME = "$(TARGET_NAME)";
@ -434,6 +438,10 @@
OTHER_LDFLAGS = (
"-all_load",
"-lskia",
"-lskottie",
"-lsksg",
"-lskshaper",
"-lskresources",
);
PRODUCT_BUNDLE_IDENTIFIER = "xamarin.libskia-watchos";
PRODUCT_NAME = "$(TARGET_NAME)";

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

@ -48,6 +48,7 @@ Task("libSkiaSharp")
$"skia_use_system_libpng=false " +
$"skia_use_system_libwebp=false " +
$"skia_use_system_zlib=false " +
$"skia_enable_skottie=true " +
$"skia_use_vulkan={SUPPORT_VULKAN} ".ToLower () +
clang +
win_vcvars_version +

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -157,7 +157,9 @@ namespace SkiaSharpSample
{
await base.OnInit();
#if !__WASM__
var scheduler = TaskScheduler.FromCurrentSynchronizationContext();
#endif
cts = new CancellationTokenSource();
var loop = Task.Run(async () =>
{
@ -165,7 +167,12 @@ namespace SkiaSharpSample
{
await OnUpdate(cts.Token);
new Task(Refresh).Start(scheduler);
new Task(Refresh)
#if !__WASM__
.Start(scheduler);
#else
.Start();
#endif
}
}, cts.Token);
}

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

@ -26,6 +26,7 @@ namespace SkiaSharpSample
public static Stream LogosSvg => Embedded.Load("logos.svg");
public static Stream AnimatedHeartGif => Embedded.Load("animated-heart.gif");
public static Stream OpacitySvg => Embedded.Load("opacity.svg");
public static Stream LottieLogo => Embedded.Load("LottieLogo1.json");
}
public static class Fonts

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

@ -0,0 +1,84 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using SkiaSharp;
using SkiaSharp.Skottie;
namespace SkiaSharpSample.Samples
{
[Preserve(AllMembers = true)]
public class SkottieSample : AnimatedSampleBase
{
private readonly Animation _animation;
private Stopwatch _watch = new Stopwatch();
[Preserve]
public SkottieSample()
{
using var fileStream = new SKManagedStream(SampleMedia.Images.LottieLogo);
if (SkiaSharp.Skottie.Animation.TryCreate(fileStream, out _animation))
{
_animation.Seek(0, null);
Console.WriteLine($"SkottieSample(): Version:{_animation.Version} Duration:{_animation.Duration} Fps:{_animation.Fps} InPoint:{_animation.InPoint} OutPoint:{_animation.OutPoint}");
}
else
{
Console.WriteLine($"SkottieSample(): failed to load animation");
}
}
public override string Title => "Skottie";
public override SampleCategories Category => SampleCategories.General;
protected override async Task OnInit()
{
try
{
await base.OnInit();
_watch.Start();
}
catch (Exception e)
{
Console.WriteLine(e);
}
}
protected override async Task OnUpdate(CancellationToken token)
{
try
{
await Task.Delay(25, token);
_animation.SeekFrameTime((float)_watch.Elapsed.TotalSeconds, null);
if(_watch.Elapsed.TotalSeconds > _animation.Duration)
{
_watch.Restart();
}
}
catch(Exception e)
{
Console.WriteLine(e);
}
}
protected override void OnDrawSample(SKCanvas canvas, int width, int height)
{
try
{
_animation.Render(canvas, new SKRect(0, 0, width, height));
}
catch (Exception e)
{
Console.WriteLine(e);
}
}
}
}

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -0,0 +1,184 @@
using System;
using System.Collections.Generic;
using Xunit;
using System.IO;
using SkiaSharp.SceneGraph;
using SkiaSharp.Skottie;
namespace SkiaSharp.Tests
{
public class AnimationTest : SKTest
{
[Trait(CategoryKey, ApiCategory)]
[SkippableFact]
public void When_Default_Make()
{
var path = Path.Combine(PathToImages, "LottieLogo1.json");
var result = SkiaSharp.Skottie.Animation.TryParse(File.ReadAllText(path), out var animation);
Assert.True(result);
Assert.NotEqual(IntPtr.Zero, animation?.Handle);
}
[Trait(CategoryKey, ApiCategory)]
[SkippableFact]
public void When_Default_Make_From_SKStream()
{
var path = Path.Combine(PathToImages, "LottieLogo1.json");
using var fileStream = File.OpenRead(path);
using var managedStream = new SKManagedStream(fileStream);
var result = SkiaSharp.Skottie.Animation.TryCreate(managedStream, out var animation);
Assert.True(result);
Assert.NotEqual(IntPtr.Zero, animation?.Handle);
}
[Trait(CategoryKey, ApiCategory)]
[SkippableFact]
public void When_Default_Make_From_Stream()
{
var path = Path.Combine(PathToImages, "LottieLogo1.json");
using var fileStream = File.OpenRead(path);
var result = SkiaSharp.Skottie.Animation.TryCreate(fileStream, out var animation);
Assert.True(result);
Assert.NotEqual(IntPtr.Zero, animation?.Handle);
}
[Trait(CategoryKey, ApiCategory)]
[SkippableFact]
public void When_Seek_Without_Controller()
{
var path = Path.Combine(PathToImages, "LottieLogo1.json");
using var fileStream = File.OpenRead(path);
var result = SkiaSharp.Skottie.Animation.TryCreate(fileStream, out var animation);
Assert.True(result);
Assert.NotEqual(IntPtr.Zero, animation?.Handle);
animation.Seek(.1);
}
[Trait(CategoryKey, ApiCategory)]
[SkippableFact]
public void When_Seek_With_Controller()
{
var path = Path.Combine(PathToImages, "LottieLogo1.json");
using var fileStream = File.OpenRead(path);
var result = SkiaSharp.Skottie.Animation.TryCreate(fileStream, out var animation);
Assert.True(result);
Assert.NotEqual(IntPtr.Zero, animation?.Handle);
var controller = new InvalidationController();
animation.Seek(.1, controller);
}
private Animation BuildDefaultAnimation()
{
var path = Path.Combine(PathToImages, "LottieLogo1.json");
using var fileStream = File.OpenRead(path);
var result = SkiaSharp.Skottie.Animation.TryCreate(fileStream, out var animation);
Assert.True(result);
Assert.NotEqual(IntPtr.Zero, animation?.Handle);
return animation;
}
[Trait(CategoryKey, ApiCategory)]
[SkippableFact]
public void When_SeekFrame_Without_Controller()
{
var animation = BuildDefaultAnimation();
animation.SeekFrame(.1);
}
[Trait(CategoryKey, ApiCategory)]
[SkippableFact]
public void When_SeekFrame_With_Controller()
{
var animation = BuildDefaultAnimation();
var controller = new InvalidationController();
animation.SeekFrame(.1, controller);
}
[Trait(CategoryKey, ApiCategory)]
[SkippableFact]
public void When_SeekFrameTime_Without_Controller()
{
var animation = BuildDefaultAnimation();
animation.SeekFrameTime(.1);
}
[Trait(CategoryKey, ApiCategory)]
[SkippableFact]
public void When_SeekFrameTime_With_Controller()
{
var animation = BuildDefaultAnimation();
var controller = new InvalidationController();
animation.SeekFrameTime(.1, controller);
}
[Trait(CategoryKey, ApiCategory)]
[SkippableFact]
public void When_Duration()
{
var animation = BuildDefaultAnimation();
Assert.True(animation.Duration > 0);
}
[Trait(CategoryKey, ApiCategory)]
[SkippableFact]
public void When_Fps()
{
var animation = BuildDefaultAnimation();
Assert.True(animation.Fps == 30);
}
[Trait(CategoryKey, ApiCategory)]
[SkippableFact]
public void When_InPoint()
{
var animation = BuildDefaultAnimation();
Assert.True(animation.InPoint == 0);
}
[Trait(CategoryKey, ApiCategory)]
[SkippableFact]
public void When_OutPoint()
{
var animation = BuildDefaultAnimation();
Assert.True(animation.OutPoint > 0);
}
[Trait(CategoryKey, ApiCategory)]
[SkippableFact]
public void When_Version()
{
var animation = BuildDefaultAnimation();
Assert.True(animation.Version.Length > 0);
}
[Trait(CategoryKey, ApiCategory)]
[SkippableFact]
public void When_Size()
{
var animation = BuildDefaultAnimation();
Assert.True(animation.Size.Height > 0);
}
}
}