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 GL and Vulkan
7//! producers.
8//!
9//! Where [`drmkit_scene`](https://docs.rs/drmkit-scene) answers "what goes on
10//! which plane this frame", this crate answers the questions around it: which
11//! buffer to draw into, how much of it needs redrawing, and whether the frame
12//! is worth submitting at all.
13//!
14//! # Why it is a separate crate
15//!
16//! A producer that renders on the GPU needs EGL or Vulkan; one that writes
17//! pixels with the CPU needs neither. Keeping the spine core-only means a
18//! GPU-less build — a kiosk, a test rig, an instrument panel — links no
19//! graphics stack at all. The device-facing half sits behind the `device`
20//! feature, and the GBM producer behind `gbm`, which opens libgbm.
21//!
22//! # Not here yet
23//!
24//! The GL and Vulkan producers. They will live in their own crates and load
25//! their libraries at runtime, plugging into `ScanoutBackend` through the
26//! `ScanoutProducer` trait the way the GBM producer does.
27
28#[cfg(feature = "device")]
29mod armed_flip;
30#[cfg(feature = "device")]
31mod backend;
32mod buffer_ring;
33#[cfg(feature = "device")]
34mod dumb_ring;
35#[cfg(feature = "device")]
36mod dumb_sink;
37mod frame_economy;
38#[cfg(feature = "gbm")]
39mod gbm_producer;
40mod negotiate;
41#[cfg(feature = "device")]
42mod producer;
43#[cfg(feature = "device")]
44mod scanout_format;
45
46#[cfg(feature = "device")]
47pub use backend::{Config as BackendConfig, RestorePolicy, ScanoutBackend, VrrPolicy};
48pub use buffer_ring::{BufferRing, Lease, Rect, Repaint};
49#[cfg(feature = "device")]
50pub use dumb_ring::{DumbRingSource, PaintError};
51#[cfg(feature = "device")]
52pub use dumb_sink::{Config, DumbScanoutSink, PresentError};
53pub use frame_economy::{FrameAction, FrameEconomy};
54#[cfg(feature = "gbm")]
55pub use gbm_producer::GbmScanoutProducer;
56pub use negotiate::{negotiate, negotiate_for_format};
57#[cfg(feature = "device")]
58pub use producer::{ProducerError, ScanoutProducer};
59#[cfg(feature = "device")]
60pub use scanout_format::{DEFAULT_PREFERENCE, negotiate_scanout_format};
61
62#[cfg(test)]
63mod tests;