Open redhog opened 4 years ago
Solution for communicating the placement: If an SVG document contains a group with id "#window", the full image is scaled and moved such that this group exactly overlays the window, whatever its dimensions. This way, elements can be placed outside of the window box itself (e.g. to draw border elements).
@BackOrder So I'm having this problem where reading out the coordinates of an element of an svg (see above) in the current version of librsvg (2.40.20-2) only gives integers (and for width/height for which there are float values, they're still rounded to whole numbers). The newest version of librsvg seems to maybe be able to give the raw floats, but that version depends on new versions of libcairo and basically the whole universe... Any ideas? Alternative svg implementations? Hacks for librsvg? Something else? The alternative is to wrap the svg in json or msgpack or something to send these parameters, but that is both uglier and harder to parse (remember that glass-renderer is pure C code)...
Are you using libcairo provided by the system or includes your own along InfiniteGlass? On another FOSS project, we used to provide dependencies including libcairo with the releases.
I use the system libraries for everything... And librsvg + libcairo has a pretty long list of deps, and if you ship/build one, you'll have to ship all... Dependency hell is an ugly place to be...
And at some point just wrapping the data becomes way easier... It's just too bad when svg itself does have space for the data I need... I just can't get it out.
Oh, and I thought briefly about using an xml lib to just read out the values, but the problem is, you then have to handle transforms...
Current:
Need to investigate
RE: Dependency hell
I hear you! I can probably look during the weekend. Busy week.
Nearly everything, esp OpenVG stuff, seems to be abandonware :(
I had evaluated possible replacements for Cairo and SVG libraries in the past and one of the best candidate is https://skia.org/.
Take a look and see if it would be something fit for InfiniteGlass.
So I decided to do something completely else to solve the window decorations. This will still be interesting to look into / fix later though. What I did was allow rendering extra windows with positions/sizes relative to the main window. So each button is an actual window. Might even make input handling easier. I'm not done yet, but the initial work is at https://github.com/redhog/InfiniteGlass/pull/53
I will give it a try but the pull doesn't work here.
By the way, switching Cairo/SVG to Skia would be a very good move. Cairo and libsvg are hard to deal with despite how useful they are. I would be interested in assisting you in coding and testing.
Cool! I couldn't immediately see any SVG parser in Skia, only the drawing primitives, but I didn't look very hard.
All the svg rendering is in glass-renderer/property_svg.c. It's not that much code, but there is one small tricky aspect: The SVG is zoomed and cropped while being rendered, so that you can zoom in infinitely on an SVG on the screen without losing resolution, or running out of RAM. This coordinate calculation isn't exactly obvious. Luckily I don't see why that part of the code would need to change at all :)
Maybe have a look and see if you can figure out how to port it?
Yes, I can take a look during the weekend. My understanding is that Skia is also performing better. So that would be interesting to see how it goes. Any other places Cairo or SVG is used?
Something that uses OpenGL as the back-end would be ideal from a performance point of view I guess, esp if it can render directly to an OpenGL texture...
Nope, it's all in one place. The rendering model is like this:
Each window corresponds to a single glDrawArrays() call, where window properties are mapped to uniforms, arrays and/or textures depending on their type. This is done in the property_TYPE.c modules. SVG:s are mapped to textures, in property_svg.c, in such a way that only the part of the SVG that will be visible will be rendered. To make that possible, those properties set an extra uniform with the data needed to scale and shift the texture back to the right place in the shader code.
Any complexity is handled by setting up properties and / or shader code. I'm trying to keep the C code as small and generic as possible, as that's where the hairy stuff ends up if you're not careful...
I checked property_svg.c
today. It gives me a good idea what to look for. Need to check the equivalent in Skia now.
Cool!
Some other cool features to look for:
Fantastic idea ! There are a lot of things we can do with SVG that would be too resources intensive with images.
By the way, we got a new fan. I'm 9th who starred the project and now there is a mysterious 10th! Congrats!
Yeah. The problem with doing nearly all of those things with the current implementation is that reparsing the XML of the SVG and rebuilding the DOM tree on every update is pretty slow. Example: The title search functionality (every time you press a key I update the content of a line of text in the SVG).
New fans are super cool! Would be even cooler if more people started giving feedback too! I feel like the WM is moving forward so much quicker with your input!
Btw, sorry that everything is a bit slow right now - I'm working on https://github.com/redhog/InfiniteGlass/pull/53 and it's taking quite a bit of time to get right...
No problem. A bit of slow down here too. Sick last week and work is piling up. But the dream of InfiniteGlass is still present. :)
Try out SVG-to-SDF-topixmap
RE: Skia rasterization
https://github.com/google/skia/blob/master/example/SkiaSDLExample.cpp#L248
Skia can use CPU, SDL, OpenGL and Vulkan to do the rasterization.
RE: Signed Distance Function (SDF)
Paper presented at SIGGRAPH 2007: Improved Alpha-Tested Magnification for Vector Textures and Special Effects https://steamcdn-a.akamaihd.net/apps/valve/2007/SIGGRAPH2007_AlphaTestedMagnification.pdf
RE: Accessing DOM
resvg seems to support DOM through xmlparser/roxmltree and Skia has some SkSVG and SkDOM.
Chromium Embedded Framework could work as a solution. It provides a renderer that use Skia when it comes to SVG. It obviously support the full features including SVG animation.
https://en.m.wikipedia.org/wiki/Chromium_Embedded_Framework
https://www.reddit.com/r/vulkan/comments/85xjp8/cef_ui_integration_in_vulkan/
Does it support using the OpenGL skia backend? It would be a very big performance advantage to not render the image to RAM and then copy it to a texture, but keep it in texture/gpu ram all the time...
Yes, it supports multiple backends including OpenGL and Vulkan. CEF provides the core features of a web browser but it's been trimmed down compared to Chromium. There shouldn't be bloat, memory footprint and CPU usage should be within acceptable limits.
Additional reference:
Python bindings for the Chromium Embedded Framework (CEF) at https://github.com/cztomczak/cefpython.
Goals for a new SVG rendering platform
Current platform:
Need to investigate
OpenVG stuff
Other