hello,guys, as svg is moved out of experimental dir in skia 91.
in my case, i want to use skia's svg component to render svg files in android .
1. generate ninja
bin/gn gen out/arm64 --args='ndk="pathto/android-ndk-r19c" target_cpu="arm64" is_component_build=true is_debug=false skia_use_lua=false skia_use_zlib=false skia_use_libheif=false skia_enable_pdf=false skia_enable_tools=false skia_use_icu=false skia_enable_svg=true ndk_api=21'
2. compile libsvg.so and libskia.so
ninja -C out/arm64
3. Codes and CMakeList like following
Code:
....
System.loadLibrary("myLibLinkedWith_svg_and_skia");
....
drawSvg(const void *data, size_t size, SkCanvas* canvas){
auto data_wrap = SkData::MakeWithCopy(data, size);
sk_sp<SkSVGDOM> svg_document_;
if (data_wrap) {
std::unique_ptr<SkStream> svg_stream = SkMemoryStream::Make(data_wrap);
svg_document_ = SkSVGDOM::MakeFromStream(*svg_stream);
svg_document_->render(canvas);
}
}
CMakeList:
......
add_library(libskia SHARED IMPORTED )
set_target_properties(libskia PROPERTIES IMPORTED_LOCATION "${SKIA_DIR}/android/${ANDROID_ABI}/libskia.so")
add_library(libsvg SHARED IMPORTED)
set_target_properties(libsvg PROPERTIES IMPORTED_LOCATION "${DEMO_CORE_DIR}/third_party/skia/android/${ANDROID_ABI}/libsvg.so")
add_library(libshape SHARED IMPORTED)
set_target_properties(libshape PROPERTIES IMPORTED_LOCATION "${DEMO_CORE_DIR}/third_party/skia/android/${ANDROID_ABI}/libskshaper.so")
add_library( # Sets the name of the library.
myLibLinkedWith_svg_and_skia
SHARED
${my-source}
)
target_link_libraries( # Specifies the target library.
myLibLinkedWith_svg_and_skia
libskia
libshape
libsvg
...
)
Problem
as show above, my compiled shared_library will compile across.
But when load the library. because libsvg.so depnds on a lot symbols which is not SK_API of skia, these symbols are not exported in libskia.so, so there is a lot error of "dlopen failed: cannot locate symbol...." refercenced by libsvg.so when i try to System.load it.
these symbols includes but not limited to
src/xml/SkDOM.h
src/utils/SkOSPath.h
......
I'm wondering if there is some options for me to config when compile to avoid modify skia sourcecode to add SK_API for the relevant symbols used by libsvg.so in libskia.so?