vello_common/lib.rs
1// Copyright 2025 the Vello Authors
2// SPDX-License-Identifier: Apache-2.0 OR MIT
3
4// After you edit the crate's doc comment, run this command, then check README.md for any missing links
5// cargo rdme --workspace-project=vello_common
6
7//! This crate includes common geometry representations, tiling logic, and other fundamental components used by both [Vello CPU][vello_cpu] and Vello Hybrid.
8//!
9//! # Usage
10//!
11//! This crate should not be used on its own, and you should instead use one of the renderers which use it.
12//! At the moment, only [Vello CPU][vello_cpu] is published, and you probably want to use that.
13//!
14//! We also develop [Vello](https://crates.io/crates/vello), which makes use of the GPU for 2D rendering and has higher performance than Vello CPU.
15//! Vello CPU is being developed as part of work to address shortcomings in Vello.
16//! Vello does not use this crate.
17//!
18//! # Features
19//!
20//! - `std` (enabled by default): Get floating point functions from the standard library
21//! (likely using your target's libc).
22//! - `libm`: Use floating point implementations from [libm][].
23//! - `png` (enabled by default): Allow loading [`Pixmap`][crate::pixmap::Pixmap]s from PNG images.
24//! Also required for rendering glyphs with an embedded PNG.
25//! Implies `std`.
26//! - `text` (enabled by default): Enables glyph rendering (see the [`glyph`][] module).
27//!
28//! At least one of `std` and `libm` is required; `std` overrides `libm`.
29//!
30//! # Contents
31//!
32//! - Shared data structures for paths, tiles, and strips
33//! - Geometry processing utilities
34//! - Common logic for rendering stages
35//!
36//! This crate acts as a foundation for `vello_cpu` and `vello_hybrid`, providing essential components to minimize duplication.
37//!
38//! [vello_cpu]: https://crates.io/crates/vello_cpu
39#![cfg_attr(feature = "libm", doc = "[libm]: libm")]
40#![cfg_attr(not(feature = "libm"), doc = "[libm]: https://crates.io/crates/libm")]
41// LINEBENDER LINT SET - lib.rs - v3
42// See https://linebender.org/wiki/canonical-lints/
43// These lints shouldn't apply to examples or tests.
44#![cfg_attr(not(test), warn(unused_crate_dependencies))]
45// These lints shouldn't apply to examples.
46#![warn(clippy::print_stdout, clippy::print_stderr)]
47// Targeting e.g. 32-bit means structs containing usize can give false positives for 64-bit.
48#![cfg_attr(target_pointer_width = "64", warn(clippy::trivially_copy_pass_by_ref))]
49// END LINEBENDER LINT SET
50#![cfg_attr(docsrs, feature(doc_cfg))]
51#![forbid(unsafe_code)]
52#![expect(
53 clippy::cast_possible_truncation,
54 reason = "We temporarily ignore those because the casts\
55only break in edge cases, and some of them are also only related to conversions from f64 to f32."
56)]
57#![no_std]
58
59// Suppress the unused_crate_dependencies lint when both std and libm are specified.
60#[cfg(all(feature = "std", feature = "libm"))]
61use libm as _;
62
63extern crate alloc;
64#[cfg(feature = "std")]
65extern crate std;
66
67pub mod blurred_rounded_rect;
68pub mod clip;
69pub mod coarse;
70#[cfg(feature = "text")]
71pub mod colr;
72pub mod encode;
73pub mod filter_effects;
74pub mod flatten;
75pub(crate) mod flatten_simd;
76#[cfg(feature = "text")]
77pub mod glyph;
78pub mod mask;
79pub mod math;
80pub mod paint;
81#[doc(hidden)]
82#[cfg(feature = "pico_svg")]
83pub mod pico_svg;
84pub mod pixmap;
85pub mod recording;
86pub mod render_graph;
87pub mod simd;
88pub mod strip;
89pub mod strip_generator;
90pub mod tile;
91pub mod util;
92
93pub use fearless_simd;
94pub use peniko;
95pub use peniko::color;
96pub use peniko::kurbo;