SKP to SVG conversion?

262 views
Skip to first unread message

render dender

unread,
Feb 22, 2023, 9:02:00 AM2/22/23
to skia-discuss
Do you know if there's currently some kind of functionality for converting SKP files to SVG at least with some limited functionality support? I've googled some old code for that but it didn't look like something usable. 
Thought I would ask before starting to write any serialization routines/parsers :)

___
Cheers,
Denis

Florin Malita

unread,
Feb 22, 2023, 10:06:21 AM2/22/23
to skia-d...@googlegroups.com
Take a look at SkSVGCanvas.  You get a canvas that wraps an SVG stream, then you can draw the SKP into it.

DM, one of our test tools, has some conversion functionality built-in, you could try using it directly:

out/Release/dm --src skp --skps <skps_dir> --config svg -w <out_dir>


--
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 view this discussion on the web visit https://groups.google.com/d/msgid/skia-discuss/f7c7d512-a157-4383-892d-df812cae22c2n%40googlegroups.com.

render dender

unread,
Feb 27, 2023, 12:37:00 PM2/27/23
to skia-discuss
Thanks, I'll look into that.
Is there anything specific to be done with the build? Any flags or specific toolchain used? I don't have  dm  generated for some reason. 

среда, 22 февраля 2023 г. в 18:06:21 UTC+3, Florin Malita:

Florin Malita

unread,
Feb 27, 2023, 12:45:35 PM2/27/23
to skia-d...@googlegroups.com
Are you using is_official_build = true?  I think we disable all test apps in "official" builds, you may need to turn that off in order to try dm.

render dender

unread,
Feb 28, 2023, 8:47:50 AM2/28/23
to skia-discuss
Thank you. I reinstalled the toolchain and made a clear build successfully.
But I'm having an error with parsing of the .SKPs files. 
I opened it in VS, started debugging and found out my .SKPs are too old and have a version 72, while there's a range of valid versions of 82 - 95 on latest skia and the parsing fails during check in SkPicture::IsValidPictInfo(...) .
There's a reason I'm using such an old fork, it's the one from hwui.
So, my questions:
1) Was there such functionality for converting SKP to SVG at the time of version 72? If so, do you know maybe the fork I could build for that?
2) Or maybe there's something else that could be done?

I'll go look through github branches for now.
понедельник, 27 февраля 2023 г. в 20:45:35 UTC+3, Florin Malita:

Florin Malita

unread,
Feb 28, 2023, 9:32:25 AM2/28/23
to skia-d...@googlegroups.com
You can check out one of the older release branches -- `chrome/m85` seems to be the last version to support v72 SKPs.  You prolly also need to downgrade depot_tools to a version around that time frame, in order to build.

I don't think we've done much work on the SVG backend in recent years, so that may be sufficient.  You could also try to forward-port the SKPs, re-recording through several releases with overlapping version support (e.g. v72 -> [m85] -> v76 -> [m93] -> v87 -> ...), but I don't think we guarantee lossless conversion.


render dender

unread,
Mar 2, 2023, 8:07:29 AM3/2/23
to skia-discuss
Well, I spent almost 2 days trying to build it with different toolchains, with rewriting build scripts slightly/fixing dependencies but still haven't managed to build it successfully.
In the end I just used SkSVGCanvas to write SVGs locally on device within Skia Viewer built for android and then pulling them manually through adb to desktop. It works, not ideally, but does almost what I wanted.
Thanks, Florin!

вторник, 28 февраля 2023 г. в 17:32:25 UTC+3, Florin Malita:
Reply all
Reply to author
Forward
0 new messages