dotloom_render/lib.rs
1//! # dotloom-render
2//!
3//! The default Dotloom renderer, built on [wgpu]. It consumes the public scene
4//! contract ([`dotloom_scene`]) and never reads documents, so it can be replaced.
5//!
6//! * Lines are instanced, screen-constant-width capsules with analytic
7//! anti-aliasing and screen-space dash patterns.
8//! * Fills are tessellated with lyon; MSAA smooths their edges when available.
9//! * Text uses a signed-distance-field atlas of a bundled OFL font (Inter subset
10//! with Latin, Turkish, Greek, Cyrillic and technical symbols).
11//! * Items are batched into order-preserving chunks with world bounding boxes for
12//! viewport culling; meshes are cached per item and rebuilt only when the item
13//! changes, its zoom bucket changes (curves), or the glyph atlas is reset.
14//! * Only WebGL2-compatible GPU features are used, so the WebGPU and WebGL2
15//! backends run identical shaders.
16//!
17//! The browser binding lives in `dotloom-render-web`; native offscreen rendering
18//! (PNG) is behind the `png` feature.
19//!
20//! [wgpu]: https://wgpu.rs/
21
22mod cache;
23pub mod color;
24mod gpu;
25#[cfg(feature = "png")]
26mod headless;
27pub mod overlay;
28pub mod tess;
29pub mod text;
30pub mod view;
31
32pub use cache::{CHUNK_ITEMS, MAX_CHUNK_EXTENT, SceneCache};
33pub use color::Theme;
34pub use dotloom_scene as scene;
35pub use gpu::{ChunkBuffers, FrameStats, Renderer, RendererOptions};
36#[cfg(feature = "png")]
37pub use headless::{AdapterSummary, Headless, Image};
38pub use overlay::Grid;
39pub use view::View;
40pub use wgpu;
41
42/// Renderer errors.
43#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
44pub enum RenderError {
45 /// Malformed scene delta.
46 #[error("invalid scene delta: {0}")]
47 Scene(String),
48 /// Invalid camera values.
49 #[error("invalid view: {0}")]
50 InvalidView(String),
51 /// Font could not be loaded.
52 #[error("font error: {0}")]
53 Font(String),
54 /// No GPU adapter for the requested backend.
55 #[error("no GPU adapter available: {0}")]
56 NoAdapter(String),
57 /// Device creation failed.
58 #[error("GPU device request failed: {0}")]
59 Device(String),
60 /// Surface creation/configuration failed.
61 #[error("surface error: {0}")]
62 Surface(String),
63 /// Reading back pixels failed.
64 #[error("readback failed: {0}")]
65 Readback(String),
66 /// The GPU device was lost; create a new renderer.
67 #[error("GPU device lost: {0}")]
68 DeviceLost(String),
69 /// The renderer was disposed.
70 #[error("renderer disposed")]
71 Disposed,
72}