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

SkSVGDOM bindings #2689

Open
1 task done
lol768 opened this issue Jan 4, 2024 · 2 comments
Open
1 task done

SkSVGDOM bindings #2689

lol768 opened this issue Jan 4, 2024 · 2 comments

Comments

@lol768
Copy link

lol768 commented Jan 4, 2024

Is your feature request related to a problem?

Skia's own frontend support for the SVG format is no longer experimental. Please expose an API around SkSVGDOM::Builder() with the ability to load SVG from file/string and render to a canvas.

Describe the solution you would like

For "inspiration", rust-skia re-exports via a C interface:

extern "C" SkSVGDOM* C_SkSVGDOM_MakeFromStream(SkStream& stream, loadSkData loadCb, loadSkTypeface loadTfCb, void* loadContext) {
    auto provider = sk_make_sp<ImageResourceProvider>(loadCb, loadTfCb, loadContext);
    auto builder = SkSVGDOM::Builder();
    builder.setResourceProvider(provider);
    return builder.make(stream).release();
}

and then exposes in its crate.

SkiaSharp should do the same.

Describe alternatives you have considered

Svg.Skia (which is based on SVG.Net). For reasons I don't fully understand, I found this to generate very large, inefficient PDFs (which used hundreds of /Patterns and produced PDF files hundreds of times larger than required) when importing a specific SVG to an SkPicture and then rendering to a PDF canvas. Generally I would expect the built-in native code in C++ to be a bit more performant too.

When I tried using the native C++ SkSVGCanvas stuff myself, the commands generated in the SkPicture were much more sensible.

Additional context

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@HinTak
Copy link

HinTak commented Jul 13, 2024

FWIW, skia-python had SkSVGDOM::MakeFromStream 4 years ago, in m87,
https://github.com/kyamagu/skia-python/blob/e0b030c14e33f70880cfcc502eaeed898a77fc3c/src/skia/SVGDOM.cpp#L13 before it became non-experimental in m88.

@fcallejon
Copy link

Hi @mattleibow is this branch supposed to cover this feature ?
If anyone can guide me I can try to add SkSVGDOM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants