SVG Render example

339 views
Skip to first unread message

Joel Winarske

unread,
May 22, 2018, 8:14:03 PM5/22/18
to skia-discuss
Hi folks,

I'm new to skia, and I understand that the SVG support is experimental.

That aside I've exercised the code to write out an SVG file.

I would now like to do the reverse.  Ideally add it into SkiaSDLExample to start.

Thanks,
Joel

Florin Malita

unread,
May 22, 2018, 9:46:15 PM5/22/18
to skia-d...@googlegroups.com
The SVG front-end is already hooked in Skia's viewer app, so you should be able to open some random SVG file with

out/Release/viewer --svgs <svg_dir> -m <svg_file_name>

If you're looking for examples of using the programmatic API, a good place to start is SvgSlide.cpp from said viewer app:


--
You received this message because you are subscribed to the Google Groups "skia-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to skia-discuss...@googlegroups.com.
To post to this group, send email to skia-d...@googlegroups.com.
Visit this group at https://groups.google.com/group/skia-discuss.
For more options, visit https://groups.google.com/d/optout.

Joel Winarske

unread,
May 22, 2018, 10:15:46 PM5/22/18
to skia-discuss
Cool thanks.

I just adapted some code from nanobench, and it's working great.

Pretty slick stuff :)

李智

unread,
Jun 8, 2021, 10:52:01 AM (4 days ago) Jun 8
to skia-discuss
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
src/core/SkStrSearch.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?

Tyler Denniston

unread,
Jun 8, 2021, 2:10:03 PM (4 days ago) Jun 8
to skia-d...@googlegroups.com
Hello,

I don't think SkSVG (or other Skia modules?) currently builds in shared mode. For SVG specifically https://crbug.com/skia/11801 is tracking.

--
You received this message because you are subscribed to the Google Groups "skia-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to skia-discuss...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages