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

Tracking issue for supporting clip-path in vello-svg? #466

Closed
Enter-tainer opened this issue Feb 26, 2024 · 3 comments
Closed

Tracking issue for supporting clip-path in vello-svg? #466

Enter-tainer opened this issue Feb 26, 2024 · 3 comments
Labels
I-SVG A problem with the SVG Integration wontfix This will not be worked on

Comments

@Enter-tainer
Copy link
Contributor

Hi! I'm the author of typst-preview. Recently I'm investigating GPU accelerated 2d vector rendering library and find it surprisingly hard. And vello seems to be the only suitable rust library i've found!

For some background, typst is a new typesetting system (written in rust) which aims to be as powerful as LaTeX but still being lightning fast. And typst-preview is a 3rd party util that compiles and render your typst source code on every keystroke. So the e2e latency is important. Typst can produce pdf/svg/png as output. When exporting to svg, typst compiles every glyph into paths and embed images into svg file using data url. Currently we use the browser to display svg, and we use a VDOM based incremental svg renderer: when updating, we only replace the changed part of the svg DOM tree. However, it still feels laggy when there is a lot of paths in document. Users with lower-end devices also complain that the browser uses too much resource.

I believe a gpu based, native application would have better performance than browser. And I'm trying to render svg produced by typst using vello_svg. Vello renders them pretty well. And the rendering speed is insane!
image

I just read the code of vello_svg and find it simply renders all paths in svg tree and ignore other things like image or clip-path. There is already a tracking issue for images in #176. I want to know is it hard to implement clip-path? I can offer help if it is not too hard.

@Enter-tainer
Copy link
Contributor Author

image

I'm trying to add basic support for clippath on my branch. I don't really understand how push/pop layer works, and currently it looks a little bit broken. Which blend mode should I choose? Could anyone give some clue of how to fix this?

Originall svg is attached here for reference.
test

@dfrg
Copy link
Collaborator

dfrg commented Feb 29, 2024

The composition mode should be SrcOver, or just pass Mix::Clip as the blend mode and it should handle that properly. Otherwise, I think your code looks about right. The base path code calls abs_transform() on the path before use… I’m not sure if you need to do the same thing for clip_path.

@simbleau simbleau added I-SVG A problem with the SVG Integration wontfix This will not be worked on labels Mar 4, 2024
@Enter-tainer Enter-tainer closed this as not planned Won't fix, can't repro, duplicate, stale Mar 21, 2024
@DJMcNab
Copy link
Member

DJMcNab commented Mar 21, 2024

For those finding this later, vello_svg has been moved to https://github.com/linebender/vello_svg

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I-SVG A problem with the SVG Integration wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

4 participants