Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bind Skottie's Animation Builder #114

Merged
merged 3 commits into from
Feb 18, 2024
Merged

Conversation

mattleibow
Copy link

Description of Change

This PR adds a few of the essential APIs to enable loading embedded files in the Lottie animation. Currently, there is just the support for file-based and data URI-based assets.

SkiaSharp Issue

Related to mono/SkiaSharp#2173

API Changes

typedef enum {
    NONE_SKOTTIE_ANIMATION_BUILDER_FLAGS = 0,
    DEFER_IMAGE_LOADING_SKOTTIE_ANIMATION_BUILDER_FLAGS = 0x01,
    PREFER_EMBEDDED_FONTS_SKOTTIE_ANIMATION_BUILDER_FLAGS = 0x02,
} skottie_animation_builder_flags_t;

typedef struct {
    float fTotalLoadTimeMS;
    float fJsonParseTimeMS;
    float fSceneParseTimeMS;
    size_t fJsonSize;
    size_t fAnimatorCount;
} skottie_animation_builder_stats_t;

SK_C_API skottie_animation_builder_t* skottie_animation_builder_new(skottie_animation_builder_flags_t flags);
SK_C_API void skottie_animation_builder_delete(skottie_animation_builder_t *instance);
SK_C_API void skottie_animation_builder_get_stats(skottie_animation_builder_t* instance, skottie_animation_builder_stats_t* stats);
SK_C_API void skottie_animation_builder_set_resource_provider(skottie_animation_builder_t* instance, skottie_resource_provider_t* resourceProvider);
SK_C_API void skottie_animation_builder_set_font_manager(skottie_animation_builder_t* instance, sk_fontmgr_t* fontManager);
SK_C_API skottie_animation_t* skottie_animation_builder_make_from_stream(skottie_animation_builder_t* instance, sk_stream_t* stream);
SK_C_API skottie_animation_t* skottie_animation_builder_make_from_file(skottie_animation_builder_t* instance, const char* path);
SK_C_API skottie_animation_t* skottie_animation_builder_make_from_string(skottie_animation_builder_t* instance, const char* data, size_t length);
SK_C_API skottie_animation_t* skottie_animation_builder_make_from_data(skottie_animation_builder_t* instance, const char* data, size_t length);

SK_C_API void skresources_resource_provider_ref(skresources_resource_provider_t* instance);
SK_C_API void skresources_resource_provider_unref(skresources_resource_provider_t* instance);
SK_C_API void skresources_resource_provider_delete(skresources_resource_provider_t *instance);
SK_C_API sk_data_t* skresources_resource_provider_load(skresources_resource_provider_t *instance, const char* path, const char* name);
SK_C_API skresources_image_asset_t* skresources_resource_provider_load_image_asset(skresources_resource_provider_t *instance, const char* path, const char* name, const char* id);
SK_C_API 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);
SK_C_API sk_typeface_t* skresources_resource_provider_load_typeface(skresources_resource_provider_t *instance, const char* name, const char* url);
SK_C_API skresources_resource_provider_t* skresources_file_resource_provider_make(sk_string_t* base_dir, bool predecode);
SK_C_API skresources_resource_provider_t* skresources_caching_resource_provider_proxy_make(skresources_resource_provider_t* rp);
SK_C_API skresources_resource_provider_t* skresources_data_uri_resource_provider_proxy_make(skresources_resource_provider_t* rp, bool predecode);

Behavioral Changes

None.

Required SkiaSharp PR

Requires mono/SkiaSharp#2630

PR Checklist

  • Rebased on top of skiasharp at time of PR
  • Changes adhere to coding standard
  • Updated documentation

@MarkIngramUK
Copy link

@mattleibow , is this PR waiting on anything? I'm excited to see mono/SkiaSharp#2173 land.

@mattleibow mattleibow force-pushed the dev/skottie-animation-builder branch from cc032e2 to c644dff Compare February 9, 2024 21:29
@mattleibow mattleibow merged commit 53d2065 into skiasharp Feb 18, 2024
1 check passed
@mattleibow mattleibow deleted the dev/skottie-animation-builder branch February 18, 2024 10:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants