Skip to main content

drmkit_present/
lib.rs

1// SPDX-FileCopyrightText: (c) 2026 Joel Winarske
2// SPDX-License-Identifier: MIT
3
4//! The present spine: getting rendered frames onto a display, repeatedly.
5//!
6//! Port of `src/present/` from drm-cxx @ `4a0b64a`, less the GPU producers.
7//!
8//! Where [`drmkit_scene`](https://docs.rs/drmkit-scene) answers "what goes on
9//! which plane this frame", this crate answers the questions around it: which
10//! buffer to draw into, how much of it needs redrawing, and whether the frame
11//! is worth submitting at all.
12//!
13//! # Why it is a separate crate
14//!
15//! A producer that renders on the GPU needs EGL or Vulkan; one that writes
16//! pixels with the CPU needs neither. Keeping the spine core-only means a
17//! GPU-less build — a kiosk, a test rig, an instrument panel — links no
18//! graphics stack at all. The producers that do live in their own crates and
19//! load their libraries at runtime.
20//!
21//! # Not here yet
22//!
23//! Being built up. [`BufferRing`], [`negotiate`] and [`FrameEconomy`] are in;
24//! `ScanoutBackend`, `DumbScanoutSink` and `DumbRingSource` follow, and the
25//! GBM, GL and Vulkan producers are separate crates after that.
26
27#[cfg(feature = "device")]
28mod armed_flip;
29#[cfg(feature = "device")]
30mod backend;
31mod buffer_ring;
32#[cfg(feature = "device")]
33mod dumb_ring;
34#[cfg(feature = "device")]
35mod dumb_sink;
36mod frame_economy;
37#[cfg(feature = "gbm")]
38mod gbm_producer;
39mod negotiate;
40#[cfg(feature = "device")]
41mod producer;
42#[cfg(feature = "device")]
43mod scanout_format;
44
45#[cfg(feature = "device")]
46pub use backend::{Config as BackendConfig, RestorePolicy, ScanoutBackend, VrrPolicy};
47pub use buffer_ring::{BufferRing, Lease, Rect, Repaint};
48#[cfg(feature = "device")]
49pub use dumb_ring::{DumbRingSource, PaintError};
50#[cfg(feature = "device")]
51pub use dumb_sink::{Config, DumbScanoutSink, PresentError};
52pub use frame_economy::{FrameAction, FrameEconomy};
53#[cfg(feature = "gbm")]
54pub use gbm_producer::GbmScanoutProducer;
55pub use negotiate::{negotiate, negotiate_for_format};
56#[cfg(feature = "device")]
57pub use producer::{ProducerError, ScanoutProducer};
58#[cfg(feature = "device")]
59pub use scanout_format::{DEFAULT_PREFERENCE, negotiate_scanout_format};
60
61#[cfg(test)]
62mod tests;