forked from google/skia
-
Notifications
You must be signed in to change notification settings - Fork 66
feat: Add basic Skottie C binding #84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
mattleibow
merged 9 commits into
mono:xamarin-mobile-bindings
from
unoplatform:dev/jela/skottie2
May 31, 2022
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
d82929b
feat: Add skottie C binding
jeromelaban 94c034f
chore: Adjust make from stream to support base SKStream
jeromelaban 238452a
chore: Adjust for skottie
jeromelaban 0168b55
chore: Adjust for apple build
jeromelaban d1e46a1
chore: Add keeper entries for skottie
jeromelaban 1b4be63
chore: Add tizen keepalive members
jeromelaban 7014dcf
chore: Adjust for missing deletes, enum validations
jeromelaban 1838ebf
chore: Adjust for invalid enum type
jeromelaban 753d833
chore: Add skottie_animation_ref/unref
jeromelaban File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,48 @@ | ||
| /* | ||
| * Copyright 2014 Google Inc. | ||
| * Copyright 2015 Xamarin Inc. | ||
| * Copyright 2017 Microsoft Corporation. All rights reserved. | ||
| * | ||
| * Use of this source code is governed by a BSD-style license that can be | ||
| * found in the LICENSE file. | ||
| */ | ||
|
|
||
| #ifndef skottie_DEFINED | ||
| #define skottie_DEFINED | ||
|
|
||
| #include "include/c/sk_types.h" | ||
|
|
||
| SK_C_PLUS_PLUS_BEGIN_GUARD | ||
|
|
||
| /* | ||
| * skottie::Animation | ||
| */ | ||
| SK_C_API void skottie_animation_keepalive(); | ||
|
|
||
| SK_C_API skottie_animation_t* skottie_animation_make_from_string(const char* data, size_t length); | ||
| SK_C_API skottie_animation_t* skottie_animation_make_from_stream(sk_stream_t* stream); | ||
| SK_C_API skottie_animation_t* skottie_animation_make_from_file(const char* path); | ||
|
|
||
| SK_C_API void skottie_animation_ref(skottie_animation_t* instance); | ||
| SK_C_API void skottie_animation_unref(skottie_animation_t* instance); | ||
|
|
||
| SK_C_API void skottie_animation_delete(skottie_animation_t *instance); | ||
|
|
||
| SK_C_API void skottie_animation_render(skottie_animation_t *instance, sk_canvas_t *canvas, sk_rect_t *dst); | ||
| SK_C_API void skottie_animation_render_with_flags(skottie_animation_t *instance, sk_canvas_t *canvas, sk_rect_t *dst, skottie_animation_renderflags_t flags); | ||
|
|
||
| SK_C_API void skottie_animation_seek(skottie_animation_t *instance, float t, sksg_invalidation_controller_t *ic); | ||
| SK_C_API void skottie_animation_seek_frame(skottie_animation_t *instance, float t, sksg_invalidation_controller_t *ic); | ||
| SK_C_API void skottie_animation_seek_frame_time(skottie_animation_t *instance, float t, sksg_invalidation_controller_t *ic); | ||
|
|
||
| SK_C_API double skottie_animation_get_duration(skottie_animation_t *instance); | ||
| SK_C_API double skottie_animation_get_fps(skottie_animation_t *instance); | ||
| SK_C_API double skottie_animation_get_in_point(skottie_animation_t *instance); | ||
| SK_C_API double skottie_animation_get_out_point(skottie_animation_t *instance); | ||
|
|
||
| SK_C_API void skottie_animation_get_version(skottie_animation_t *instance, sk_string_t* version); | ||
| SK_C_API void skottie_animation_get_size(skottie_animation_t *instance, sk_size_t* size); | ||
|
|
||
| SK_C_PLUS_PLUS_END_GUARD | ||
|
|
||
| #endif | ||
This file contains hidden or 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,28 @@ | ||
| /* | ||
| * Copyright 2014 Google Inc. | ||
| * Copyright 2015 Xamarin Inc. | ||
| * Copyright 2017 Microsoft Corporation. All rights reserved. | ||
| * | ||
| * Use of this source code is governed by a BSD-style license that can be | ||
| * found in the LICENSE file. | ||
| */ | ||
|
|
||
| #ifndef sksg_invalidationcontroller_DEFINED | ||
| #define sksg_invalidationcontroller_DEFINED | ||
|
|
||
| #include "include/c/sk_types.h" | ||
|
|
||
| SK_C_PLUS_PLUS_BEGIN_GUARD | ||
|
|
||
| SK_C_API sksg_invalidation_controller_t* sksg_invalidation_controller_new(); | ||
|
jeromelaban marked this conversation as resolved.
|
||
| SK_C_API void sksg_invalidation_controller_delete(sksg_invalidation_controller_t* instance); | ||
|
|
||
| SK_C_API void sksg_invalidation_controller_inval(sksg_invalidation_controller_t* instance, sk_rect_t* rect, sk_matrix_t* matrix); | ||
| SK_C_API void sksg_invalidation_controller_get_bounds(sksg_invalidation_controller_t* instance, sk_rect_t* bounds); | ||
| SK_C_API void sksg_invalidation_controller_begin(sksg_invalidation_controller_t* instance); | ||
| SK_C_API void sksg_invalidation_controller_end(sksg_invalidation_controller_t* instance); | ||
| SK_C_API void sksg_invalidation_controller_reset(sksg_invalidation_controller_t* instance); | ||
|
|
||
| SK_C_PLUS_PLUS_END_GUARD | ||
|
|
||
| #endif | ||
This file contains hidden or 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 hidden or 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 hidden or 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,89 @@ | ||
| #include "modules/skottie/include/Skottie.h" | ||
| #include "modules/skresources/include/SkResources.h" | ||
| #include "modules/sksg/include/SkSGInvalidationController.h" | ||
| #include "include/c/skottie_animation.h" | ||
|
|
||
| #include "src/c/sk_types_priv.h" | ||
|
|
||
| #include "src/utils/SkJSON.h" | ||
| #include "include/core/SkCubicMap.h" | ||
|
|
||
| void skottie_animation_keepalive() { | ||
| // This function is needed on Tizen to ensure required types are kept alive | ||
| // It is not meant to be executed. | ||
|
|
||
| skjson::ObjectValue* a; | ||
| auto r = (*a)["tmp"]; | ||
|
|
||
| SkCubicMap* b; | ||
| (*b).computeYFromX(.0f); | ||
| } | ||
|
|
||
| void skottie_animation_ref(skottie_animation_t* instance) { | ||
| SkSafeRef(AsSkottieAnimation(instance)); | ||
| } | ||
|
|
||
| void skottie_animation_unref(skottie_animation_t* instance) { | ||
| SkSafeUnref(AsSkottieAnimation(instance)); | ||
| } | ||
|
|
||
| skottie_animation_t* skottie_animation_make_from_string(const char* data, size_t length) { | ||
| auto animation = skottie::Animation::Make(data, length); | ||
| return ToSkottieAnimation(animation.release()); | ||
| } | ||
|
|
||
| skottie_animation_t* skottie_animation_make_from_stream(sk_stream_t* stream) { | ||
| return ToSkottieAnimation(skottie::Animation::Make(AsStream(stream)).release()); | ||
| } | ||
|
|
||
| skottie_animation_t* skottie_animation_make_from_file(const char* path) { | ||
| return ToSkottieAnimation(skottie::Animation::MakeFromFile(path).release()); | ||
| } | ||
|
|
||
| void skottie_animation_delete(skottie_animation_t* instance) { | ||
| delete AsSkottieAnimation(instance); | ||
| } | ||
|
|
||
| void skottie_animation_render(skottie_animation_t *instance, sk_canvas_t *canvas, sk_rect_t *dst) { | ||
| AsSkottieAnimation(instance)->render(AsCanvas(canvas), AsRect(dst)); | ||
| } | ||
|
|
||
| void skottie_animation_render_with_flags(skottie_animation_t *instance, sk_canvas_t *canvas, sk_rect_t *dst, skottie_animation_renderflags_t flags) { | ||
| AsSkottieAnimation(instance)->render(AsCanvas(canvas), AsRect(dst), (skottie::Animation::RenderFlags)(flags)); | ||
| } | ||
|
|
||
| void skottie_animation_seek(skottie_animation_t *instance, float t, sksg_invalidation_controller_t *ic) { | ||
| AsSkottieAnimation(instance)->seek(t, AsSksgInvalidationController(ic)); | ||
| } | ||
|
|
||
| void skottie_animation_seek_frame(skottie_animation_t *instance, float t, sksg_invalidation_controller_t *ic) { | ||
| AsSkottieAnimation(instance)->seekFrame(t, AsSksgInvalidationController(ic)); | ||
| } | ||
|
|
||
| void skottie_animation_seek_frame_time(skottie_animation_t *instance, float t, sksg_invalidation_controller_t *ic) { | ||
| AsSkottieAnimation(instance)->seekFrameTime(t, AsSksgInvalidationController(ic)); | ||
| } | ||
|
|
||
| double skottie_animation_get_duration(skottie_animation_t *instance) { | ||
| return AsSkottieAnimation(instance)->duration(); | ||
| } | ||
|
|
||
| double skottie_animation_get_fps(skottie_animation_t *instance) { | ||
| return AsSkottieAnimation(instance)->fps(); | ||
| } | ||
|
|
||
| double skottie_animation_get_in_point(skottie_animation_t *instance) { | ||
| return AsSkottieAnimation(instance)->inPoint(); | ||
| } | ||
|
|
||
| double skottie_animation_get_out_point(skottie_animation_t *instance) { | ||
| return AsSkottieAnimation(instance)->outPoint(); | ||
| } | ||
|
|
||
| void skottie_animation_get_version(skottie_animation_t *instance, sk_string_t* version) { | ||
| AsString(version)->set(AsSkottieAnimation(instance)->version()); | ||
| } | ||
|
|
||
| void skottie_animation_get_size(skottie_animation_t *instance, sk_size_t* size) { | ||
| *size = ToSize(AsSkottieAnimation(instance)->size()); | ||
| } |
This file contains hidden or 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,35 @@ | ||
| #include "modules/skottie/include/Skottie.h" | ||
| #include "modules/skresources/include/SkResources.h" | ||
| #include "modules/sksg/include/SkSGInvalidationController.h" | ||
| #include "include/c/skottie_animation.h" | ||
| #include "include/c/sksg_invalidation_controller.h" | ||
|
|
||
| #include "src/c/sk_types_priv.h" | ||
|
|
||
| sksg_invalidation_controller_t* sksg_invalidation_controller_new() { | ||
| return ToSksgInvalidationController(new sksg::InvalidationController()); | ||
| } | ||
|
|
||
| void sksg_invalidation_controller_delete(sksg_invalidation_controller_t* instance) { | ||
| delete AsSksgInvalidationController(instance); | ||
| } | ||
|
|
||
| void sksg_invalidation_controller_inval(sksg_invalidation_controller_t* instance, sk_rect_t* rect, sk_matrix_t* matrix) { | ||
| AsSksgInvalidationController(instance)->inval(*AsRect(rect), AsMatrix(matrix)); | ||
| } | ||
|
|
||
| void sksg_invalidation_controller_get_bounds(sksg_invalidation_controller_t* instance, sk_rect_t* bounds) { | ||
| *bounds = ToRect(AsSksgInvalidationController(instance)->bounds()); | ||
| } | ||
|
|
||
| void sksg_invalidation_controller_begin(sksg_invalidation_controller_t* instance) { | ||
| AsSksgInvalidationController(instance)->begin(); | ||
| } | ||
|
|
||
| void sksg_invalidation_controller_end(sksg_invalidation_controller_t* instance) { | ||
| AsSksgInvalidationController(instance)->end(); | ||
| } | ||
|
|
||
| void sksg_invalidation_controller_reset(sksg_invalidation_controller_t* instance) { | ||
| AsSksgInvalidationController(instance)->reset(); | ||
| } |
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.