-
Notifications
You must be signed in to change notification settings - Fork 537
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
1 parent
b651807
commit cda59a8
Showing
27 changed files
with
15,671 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule skia
updated
10 files
+1 −0 | BUILD.gn | |
+2 −0 | gn/core.gni | |
+17 −0 | include/c/sk_types.h | |
+48 −0 | include/c/skottie_animation.h | |
+28 −0 | include/c/sksg_invalidation_controller.h | |
+4 −0 | src/c/sk_enums.cpp | |
+42 −29 | src/c/sk_types_priv.h | |
+89 −0 | src/c/skottie_animation.cpp | |
+35 −0 | src/c/sksg_invalidation_controller.cpp | |
+10 −0 | src/xamarin/SkiaKeeper.c |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,8 @@ libSkiaSharp { | |
global: | ||
sk_*; | ||
gr_*; | ||
skottie_*; | ||
sksg_*; | ||
local: | ||
*; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.