Skip to content

Commit

Permalink
Add some more types
Browse files Browse the repository at this point in the history
  • Loading branch information
mattleibow committed Feb 9, 2024
1 parent f0fc32b commit c644dff
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 3 deletions.
4 changes: 4 additions & 0 deletions include/c/sk_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion include/c/skresources_resource_provider.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
3 changes: 3 additions & 0 deletions src/c/sk_types_priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 15 additions & 2 deletions src/c/skresources_resource_provider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down

0 comments on commit c644dff

Please sign in to comment.