Using canvas->drawRect() with webgl and svg canvas differs

84 views
Skip to first unread message

Данил Буланов

unread,
Mar 10, 2024, 5:12:09 AM3/10/24
to skia-discuss
Hello, I am using webgl and svg backend in my app, and I use drawRect function. But if I use it with dash PathEffect, there is no dash in svg. here are my images
wsgwjsu4h3-image.pngrhw1abw4q8-image.png

I king of understand why it happens, in case of svg there is a <rect> element, which does not support any dashing.

So my question is is there a way to make skia use path in case of rect rendering in svg?

Данил Буланов

unread,
Mar 10, 2024, 6:12:31 AM3/10/24
to skia-discuss
I have just read the code in SkSVGDevice.cpp, and it seems that this functionality is not implemented yet. In drawRRect function (https://skia.googlesource.com/skia/+/refs/heads/main/src/svg/SkSVGDevice.cpp#932) path is used, but PathEffect is not applied properly to that path. The change seems to be easy to implement though. I took path effect handling code from drawPath function (https://skia.googlesource.com/skia/+/refs/heads/main/src/svg/SkSVGDevice.cpp#947) and it works fine.

воскресенье, 10 марта 2024 г. в 12:12:09 UTC+3, Данил Буланов:

Brian Osman

unread,
Mar 10, 2024, 8:42:29 AM3/10/24
to skia-d...@googlegroups.com
Yes, that sounds correct. In other parts of Skia, we will check if there is a path effect when handling simpler shapes. If there is, we instead construct a path and then call the generic path version. It seems like SVG device should do the same thing. Are you interested in submitting a patch?

--
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/7011997f-3f46-490c-af27-a24b4cd1f06an%40googlegroups.com.

Данил Буланов

unread,
Mar 10, 2024, 9:31:44 AM3/10/24
to skia-discuss
Yes, I am glad to send a patch

воскресенье, 10 марта 2024 г. в 15:42:29 UTC+3, brian...@google.com:

Данил Буланов

unread,
Mar 12, 2024, 6:04:07 AM3/12/24
to skia-discuss
I have created a patch here https://skia-review.googlesource.com/c/skia/+/824856
I was not sure about the reviewer, so I just found who wrote the previous code for SkSvgDevice by git blame
And I am also not sure about tests, now it just checks if path was drawn in case of PathEffect is used
воскресенье, 10 марта 2024 г. в 16:31:44 UTC+3, Данил Буланов:
Reply all
Reply to author
Forward
0 new messages