diff --git a/include/c/sk_types.h b/include/c/sk_types.h index fb35a9d3cfd9..cc71e89489e0 100644 --- a/include/c/sk_types.h +++ b/include/c/sk_types.h @@ -1092,6 +1092,10 @@ typedef struct { size_t fAnimatorCount; } skottie_animation_builder_stats_t; +typedef struct skresources_image_asset_t skresources_image_asset_t; +typedef struct skresources_multi_frame_image_asset_t skresources_multi_frame_image_asset_t; +typedef struct skresources_external_track_asset_t skresources_external_track_asset_t; + typedef struct skresources_resource_provider_t skresources_resource_provider_t; SK_C_PLUS_PLUS_END_GUARD diff --git a/include/c/skresources_resource_provider.h b/include/c/skresources_resource_provider.h index aa36bab936de..31f738a07999 100644 --- a/include/c/skresources_resource_provider.h +++ b/include/c/skresources_resource_provider.h @@ -18,7 +18,12 @@ SK_C_API void skresources_resource_provider_ref(skresources_resource_provider_t* 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 skresources_resource_provider_t* skresources_file_resource_provider_make(const char* base_dir, size_t length, bool predecode); +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); diff --git a/src/c/sk_types_priv.h b/src/c/sk_types_priv.h index 6c24f258a6a4..fc51e3fbf4d8 100644 --- a/src/c/sk_types_priv.h +++ b/src/c/sk_types_priv.h @@ -391,6 +391,9 @@ DEF_CLASS_MAP_WITH_NS(sksg, InvalidationController, sksg_invalidation_controller #include "modules/skresources/include/SkResources.h" DEF_CLASS_MAP_WITH_NS(skresources, ResourceProvider, skresources_resource_provider_t, SkResourcesResourceProvider) +DEF_CLASS_MAP_WITH_NS(skresources, ImageAsset, skresources_image_asset_t, SkResourcesImageAsset) +DEF_CLASS_MAP_WITH_NS(skresources, MultiFrameImageAsset, skresources_multi_frame_image_asset_t, SkResourcesMultiFrameImageAsset) +DEF_CLASS_MAP_WITH_NS(skresources, ExternalTrackAsset, skresources_external_track_asset_t, SkResourcesExternalTrackAsset) #if defined(SK_GANESH) // GPU specific diff --git a/src/c/skresources_resource_provider.cpp b/src/c/skresources_resource_provider.cpp index 422296536227..005100615747 100644 --- a/src/c/skresources_resource_provider.cpp +++ b/src/c/skresources_resource_provider.cpp @@ -13,8 +13,21 @@ void skresources_resource_provider_delete(skresources_resource_provider_t *insta delete AsSkResourcesResourceProvider(instance); } -skresources_resource_provider_t* skresources_file_resource_provider_make(const char* base_dir, size_t length, bool predecode){ - return ToSkResourcesResourceProvider(skresources::FileResourceProvider::Make(SkString(base_dir, length), predecode).release()); +sk_data_t* skresources_resource_provider_load(skresources_resource_provider_t *instance, const char* path, const char* name) { + return ToData(AsSkResourcesResourceProvider(instance)->load(path, name).release()); +} +skresources_image_asset_t* skresources_resource_provider_load_image_asset(skresources_resource_provider_t *instance, const char* path, const char* name, const char* id) { + return ToSkResourcesImageAsset(AsSkResourcesResourceProvider(instance)->loadImageAsset(path, name, id).release()); +} +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) { + return ToSkResourcesExternalTrackAsset(AsSkResourcesResourceProvider(instance)->loadAudioAsset(path, name, id).release()); +} +sk_typeface_t* skresources_resource_provider_load_typeface(skresources_resource_provider_t *instance, const char* name, const char* url) { + return ToTypeface(AsSkResourcesResourceProvider(instance)->loadTypeface(name, url).release()); +} + +skresources_resource_provider_t* skresources_file_resource_provider_make(sk_string_t* base_dir, bool predecode){ + return ToSkResourcesResourceProvider(skresources::FileResourceProvider::Make(AsString(*base_dir), predecode).release()); } skresources_resource_provider_t* skresources_caching_resource_provider_proxy_make(skresources_resource_provider_t* rp) { return ToSkResourcesResourceProvider(skresources::CachingResourceProvider::Make(sk_ref_sp(AsSkResourcesResourceProvider(rp))).release());