velox-renderer
Skia rendering backends, events and HMR for the Velox UI framework.
Overview
velox-renderer owns everything between a styled VNode and pixels: backend selection, window and event loops, offscreen Skia rasterisation, hit testing and input editing, accessibility trees, viewport/DPI maths, and the HMR client. It depends on velox-core, velox-dom and velox-style, and every heavyweight dependency is behind a feature flag — with no features the crate compiles to a fast stub backend and pulls in no windowing or GPU stack at all. The feature set is the crate's real user-facing API.
Features
- Feature-flagged backends — default stub backend (no optional dependencies),
skia,svg, andskia-native(winit + skia-safe + EGL/GL) - Windowed render loop —
run_window_vnode_skia(and its HMR variant) opens a window and drives layout, paint and events - Immediate-mode paint — Skia rasterisation of a styled
VNodeevery frame - Offscreen rendering — RGBA and PNG output at an explicit DPI scale
- Event dispatch —
click/input/change, keyboard and mouse events, point-in-box hit testing, and semanticEditActiontext editing - Accessibility —
build_a11y_treewalks the laid-out tree into roles, names and rects - Viewport/DPI maths — a single rounding authority (
physical_from_logical) plus theViewporttype - HMR client — reconnecting client thread,
HmrMessageprotocol on port 31313
Installation
| Feature | What it turns on |
|---|---|
default |
Empty — the stub backend, no optional dependencies, fast to compile. |
skia |
Selects the Skia backend path: BACKEND = "skia", SelectedRenderer = skia_backend::SkiaRenderer, and a compile-only skia_backend module with no native dependencies (so the API surface builds without Skia). |
svg |
dep:resvg 0.48 — rasterisation of SVG images (<img src="*.svg">). |
skia-native |
The real backend: dep:skia-safe 0.91.1, dep:winit 0.28, dep:raw-window-handle 0.5, dep:egl 0.2, dep:glow 0.12, dep:softbuffer 0.3, plus skia and svg. Unlocks the window loops, GPU surface, offscreen PNG/RGBA rendering, and skia_backend::SkiaRenderer with a live surface. |
The always-on dependencies are velox-core, velox-dom, velox-style, log 0.4, bytemuck 1, serde 1, serde_json 1.0.
Quick start
With no features enabled the crate is a stub you can still build against:
use ;
use ;
let vnode = h;
assert_eq!;
let tree = build_a11y_tree;
println!;
With --features skia-native, run_window_vnode_skia opens a window and drives the render/event loop — a complete program using it lives in examples/counter.
Documentation
- API reference: docs.rs/velox-renderer
- Book: Renderer — backends, features and rendering
Workspace crates
Velox is a workspace of six published crates. This crate is marked (this crate).
| Crate | What it provides | Documentation |
|---|---|---|
| velox-core | Reactive primitives: signals, effects, lifecycle hooks | docs.rs |
| velox-dom | VNode types, block + flex layout, positioning, overflow |
docs.rs |
| velox-style | CSS parsing, selectors, cascade; styles applied to VNode |
docs.rs |
| velox-renderer · this crate | Rendering backends, event dispatch, hit testing | docs.rs |
| velox-sfc | Single-file component compiler (pest grammar) → Rust | docs.rs |
| veloxc | The CLI and dev server | docs.rs |
Status
Published on crates.io at 0.1.1.
Working today: Skia immediate-mode paint, event hit-testing, the skia-native windowed backend, offscreen RGBA/PNG rendering, and accessibility trees. Notes:
defaultcompiles to a stub backend with no native dependencies — opt in withskia-nativewhen you're ready. Expect a heavy first build: the Skia stack is large.- The render loop is immediate-mode: no retained tree, no previous frame to compare, no patch applier. See
docs/internal/RECONCILER.md. - Falls back to headless rendering with
VELOX_HEADLESS=1or when no compositor is available.
License
Licensed under MIT OR Apache-2.0.
Copyright © FAHIM AHMED fahimaloy@tutamail.com