pub mod atlas;
pub mod compare;
pub mod display;
pub mod fonts;
pub mod ids;
pub mod parse;
pub mod proto;
pub mod render;
pub mod resolve;
pub mod shadow;
pub mod sums;
pub mod tiles;
pub mod tree;
pub mod wire;
pub mod bands;
pub mod cpu;
use std::fmt;
pub use kurbo::Rect as KRect;
pub use render::{Damage, Drawing, Renderer};
pub use resolve::{Files, Scene, Theme, resolve};
#[derive(Debug, Clone, PartialEq)]
pub struct Problem {
pub file: String,
pub pos: parse::Pos,
pub message: String,
}
impl fmt::Display for Problem {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(
f,
"{}:{}:{}: {}",
self.file, self.pos.line, self.pos.col, self.message
)
}
}
pub fn png(renderer: &mut Renderer, scene: &Scene, theme: Theme) -> Result<Vec<u8>, String> {
let drawing = renderer
.drawing(scene, theme, None)
.map_err(|e| e.message)?;
let mut png = Vec::new();
bands::png(&drawing.list, &mut png).map_err(|e| format!("encoding the PNG: {e}"))?;
Ok(png)
}
unsafe impl Send for render::Drawing {}
#[cfg(test)]
#[test]
fn the_core_names_no_adapter() {
let src = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("src");
let adapters = ["lib.rs", "cpu", "bands"];
let forbidden = [
"vello_cpu",
"vello::",
"wgpu",
"png::Encoder",
"png::Stream",
"crate::cpu",
"crate::bands",
];
let mut stack = vec![src.clone()];
while let Some(dir) = stack.pop() {
for entry in std::fs::read_dir(&dir).unwrap() {
let path = entry.unwrap().path();
let rel = path.strip_prefix(&src).unwrap();
let top = rel
.components()
.next()
.unwrap()
.as_os_str()
.to_string_lossy();
let name = path.file_name().unwrap().to_string_lossy().into_owned();
if adapters.contains(&top.trim_end_matches(".rs"))
|| adapters.contains(&top.as_ref())
|| name == "tests.rs"
|| name == "testing.rs"
|| name == "examples.rs"
{
continue;
}
if path.is_dir() {
stack.push(path);
continue;
}
let text = std::fs::read_to_string(&path).unwrap();
let text = text.split("#[cfg(test)]\nmod tests {").next().unwrap();
for word in forbidden {
assert!(!text.contains(word), "{} names {word}", rel.display());
}
}
}
}