Repository navigation
plutovg, plutosvg and their ucode bindings - #163
Merged
Merged
Conversation
Software rasteriser for paths, strokes, gradients and transforms onto a 32-bit premultiplied ARGB surface, which it can create over memory the caller already owns. Needed to draw a boot splash procedurally rather than from a baked frame sequence. Links against nothing but libc, and comes to 172 KiB on aarch64. The font face cache is disabled along with the examples and tests, since nothing here renders text. Signed-off-by: Daniel Golle <[email protected]>
Parses SVG and draws it through plutovg, which lets a theme ship its artwork as text rather than as rendered bitmaps. 33 KiB on aarch64, and it needs nothing beyond plutovg and libc. freetype is disabled: it only serves OpenType SVG glyphs, and pulling it in for that would outweigh the library several times over. The bundled plutovg wrap is refused so a failed dependency check cannot stage a second copy over the packaged one. Signed-off-by: Daniel Golle <[email protected]>
Make the plutovg drawing API usable from ucode. Surfaces, canvases, paths, paints and font faces become ucode resource types with method tables, while colours, points, rectangles, matrices and gradient stops cross the boundary as plain ucode objects or arrays, so a whole scene can be built and mutated from script. Enumerations are spelled as strings rather than opaque integers. Each resource holds one plutovg reference and drops it from the type destructor; getters that return a borrowed pointer take a reference before wrapping it, so a canvas keeps its surface alive and nothing is released twice at collection time. The value conversion helpers live in a separate header installed into the staging directory because the plutosvg binding needs the same colour and rectangle marshalling. Signed-off-by: Daniel Golle <[email protected]>
Make SVG documents loadable and renderable from ucode. A document is a resource type that reports its intrinsic size, computes the extents of the whole drawing or of one element by id, and renders either onto a plutovg canvas or into a fresh surface. CSS currentColor is passed as an ordinary colour value and colour variables resolve through a ucode object or callback invoked during rendering. Script data handed to the loader is copied because the parser keeps pointers into it for the lifetime of the document; the copy is released through the destroy callback. An element id is dereferenced in the frame that owns the argument, as a short ucode string lives inside the variable holding the value. Surfaces returned by the renderer are plutovg resources, so the plutovg module is loaded on demand when it is not already present. Signed-off-by: Daniel Golle <[email protected]>
dangowrt
force-pushed
the
ucode-plutovg
branch
from
September 25, 2026 10:56
e97e213 to
26615d4
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Four packages: the plutovg rasteriser, the plutosvg renderer built on it, and a ucode binding for each.
plutovgis a software rasteriser for 2D vector graphics, MIT licensed, with no dependency beyond libc. It draws onto a 32-bit premultiplied ARGB surface that can wrap memory the caller already owns, which is what makes it usable against a buffer something else has mapped.plutosvgparses SVG documents and renders them through plutovg, built without the optional freetype support, which only serves OpenType SVG glyphs. Both are small: 89 KB and 17 KB packaged for aarch64.Both carry
--wrap-mode=nofallback. plutosvg ships asubprojects/plutovg.wrap, and without that argument meson downloads and builds a second private copy rather than using the packaged one, which also breaks a buildbot where the network is available only during the download phase.The two ucode modules expose those APIs to scripts.
ucode-mod-plutovgcovers surfaces, canvases, paths, matrices, solid, gradient and texture paints, stroking with dash patterns, clipping, compositing and text rendering, with colours, points, rectangles, matrices and gradient stops passed as plain ucode objects or arrays.ucode-mod-plutosvgcovers loading a document from memory or from a file, querying its intrinsic size and element extents, and rendering a document or a single element onto a plutovg canvas or into a fresh surface, with CSScurrentColorand colour variables resolved from a ucode object or callback.Together they let a ucode program draw vector graphics into a buffer it does not own, which is what a scripted boot splash needs: SVG stays SVG in the source tree, and nothing has to ship rendered bitmaps or pull in a rendering toolchain at build time.
Build tested for rockchip/armv8 (aarch64, musl) and run tested on a Radxa ROCK 5B.