Skip to main content

vello_encoding/
lib.rs

1// Copyright 2023 the Vello Authors
2// SPDX-License-Identifier: Apache-2.0 OR MIT
3
4//! Raw scene encoding.
5
6// LINEBENDER LINT SET - lib.rs - v2
7// See https://linebender.org/wiki/canonical-lints/
8// These lints aren't included in Cargo.toml because they
9// shouldn't apply to examples and tests
10#![warn(unused_crate_dependencies)]
11#![warn(clippy::print_stdout, clippy::print_stderr)]
12// Targeting e.g. 32-bit means structs containing usize can give false positives for 64-bit.
13#![cfg_attr(target_pointer_width = "64", warn(clippy::trivially_copy_pass_by_ref))]
14// END LINEBENDER LINT SET
15#![cfg_attr(docsrs, feature(doc_cfg))]
16// The following lints are part of the Linebender standard set,
17// but resolving them has been deferred for now.
18// Feel free to send a PR that solves one or more of these.
19// Need to allow instead of expect until Rust 1.83 https://github.com/rust-lang/rust/pull/130025
20#![allow(missing_docs, reason = "We have many as-yet undocumented items.")]
21#![expect(
22    missing_debug_implementations,
23    clippy::cast_possible_truncation,
24    clippy::missing_assert_message,
25    reason = "Deferred"
26)]
27#![allow(
28    unnameable_types,
29    reason = "Deferred, only apply in some feature sets so not expect"
30)]
31
32mod binning;
33mod clip;
34mod config;
35mod draw;
36mod encoding;
37#[cfg(feature = "bump_estimate")]
38mod estimate;
39mod glyph;
40mod glyph_cache;
41mod image_cache;
42mod image_delta;
43mod mask;
44pub mod math;
45mod monoid;
46mod path;
47mod ramp_cache;
48mod resolve;
49
50pub use binning::BinHeader;
51pub use clip::{Clip, ClipBbox, ClipBic, ClipElement};
52pub use config::{
53    BufferSize, BufferSizes, BumpAllocatorMemory, BumpAllocators, BumpBudget, ConfigUniform,
54    IndirectCount, RenderConfig, WorkgroupCounts, WorkgroupSize,
55};
56pub use draw::{
57    DRAW_INFO_FLAGS_FILL_RULE_BIT, DrawBbox, DrawBeginClip, DrawBlurRoundedRect, DrawColor,
58    DrawImage, DrawLinearGradient, DrawMonoid, DrawRadialGradient, DrawSweepGradient, DrawTag,
59};
60pub use encoding::{Encoding, Mark, MarkKind, Resources, StreamOffsets};
61pub use glyph::{FontEmbolden, Glyph, GlyphRun, draw_outline};
62pub use image_cache::ImageCacheStats;
63pub use image_delta::{ImageRect, image_delta, register_image_delta};
64pub use mask::{make_mask_lut, make_mask_lut_16};
65pub use math::Transform;
66pub use monoid::Monoid;
67pub use path::{
68    Cubic, LineSoup, Path, PathBbox, PathEncoder, PathMonoid, PathSegment, PathSegmentType,
69    PathTag, SegmentCount, Style, Tile,
70};
71pub use ramp_cache::Ramps;
72pub use resolve::{Layout, Patch, Resolver, resolve_solid_paths_only};
73
74#[cfg(feature = "bump_estimate")]
75pub use estimate::BumpEstimator;
76
77/// A normalized variation coordinate (for variable fonts) in 2.14 fixed point format.
78///
79/// In most cases, this can be [cast](bytemuck::cast_slice) from the
80/// normalised coords provided by your text layout library.
81///
82/// Equivalent to [`skrifa::instance::NormalizedCoord`], but defined
83/// in Vello so that Skrifa is not part of Vello's public API.
84/// This allows Vello to update its Skrifa in a patch release, and limits
85/// the need for updates only to align Skrifa versions.
86pub type NormalizedCoord = i16;
87
88#[cfg(test)]
89mod tests {
90    const _NORMALISED_COORD_SIZE_MATCHES: () = assert!(
91        size_of::<skrifa::prelude::NormalizedCoord>() == size_of::<crate::NormalizedCoord>()
92    );
93}