Vello CPU is a 2D graphics rendering engine written in Rust, for devices with no or underpowered GPUs.
It is currently available as an alpha. See the Caveats section for things you need to be aware of.
We also develop Vello, which makes use of the GPU for 2D rendering and has higher performance than Vello CPU. Vello CPU is being developed as part of work to address shortcomings in Vello.
To use Vello CPU, you need to:
RenderContext
, a 2D drawing context for a fixed-size target area.set_paint
.fill_path
, stroke_path
, or glyph_run
.RenderContext::render_to_pixmap
.use vello_cpu::{RenderContext, Pixmap, RenderMode}; use vello_cpu::{color::{palette::css, PremulRgba8}, kurbo::Rect}; let width = 10; let height = 5; let mut context = RenderContext::new(width, height); context.set_paint(css::MAGENTA); context.fill_rect(&Rect::from_points((3., 1.), (7., 4.))); let mut target = Pixmap::new(width, height); context.render_to_pixmap(&mut target, RenderMode::default()); let expected_render = b"\ 0000000000\ 0001111000\ 0001111000\ 0001111000\ 0000000000"; let magenta = css::MAGENTA.premultiply().to_rgba8(); let transparent = PremulRgba8 {r: 0, g: 0, b: 0, a: 0}; let mut result = Vec::new(); for pixel in target.data() { if *pixel == magenta { result.push(b'1'); } else if *pixel == transparent { result.push(b'0'); } else { panic!("Got unexpected pixel value {pixel:?}"); } } assert_eq!(&result, expected_render);
png
(enabled by default): Allow loading Pixmap
s from PNG images. Also required for rendering glyphs with an embedded PNG.Vello CPU is an alpha for several reasons, including the following.
This API has been developed for an initial version, and has no stability guarantees. Whilst we are in the 0.0.x
release series, any release is likely to breaking. We have known plans to change the API around how image resources are used.
We have not yet put any work into documentation.
We do not perform several important optimisations, such as the use of multithreading and SIMD. Additionally, some algorithms we use aren't final, and will be replaced with higher-performance variants.
TODO: Point to documentation of sparse strips pattern.
This version of Vello CPU has been verified to compile with Rust 1.85 and later.
Future versions of Vello CPU might increase the Rust version requirement. It will not be treated as a breaking change and as such can even happen with small patch releases.
As time has passed, some of Vello CPU‘s dependencies could have released versions with a higher Rust requirement. If you encounter a compilation issue due to a dependency and don’t want to upgrade your Rust toolchain, then you could downgrade the dependency.
# Use the problematic dependency's name and version cargo update -p package_name --precise 0.1.1
Discussion of Vello CPU development happens in the Linebender Zulip, specifically the #vello channel. All public content can be read without logging in.
Contributions are welcome by pull request. The Rust code of conduct applies.
Licensed under either of
at your option.