diff --git a/src/backend/drm/format_selection.rs b/src/backend/drm/format_selection.rs new file mode 100644 index 000000000000..2742d55a42a0 --- /dev/null +++ b/src/backend/drm/format_selection.rs @@ -0,0 +1,40 @@ +use drm::control::{connector, crtc, Mode}; +use drm_fourcc::{DrmFormat, DrmFourcc, DrmModifier}; + +use crate::backend::allocator::Allocator; + +use super::{exporter::ExportFramebuffer, DrmDevice, DrmSurface}; + +pub struct SurfaceDefinition<'a> { + pub crtc: crtc::Handle, + pub mode: &'a Mode, + pub connectors: &'a [connector::Handle], +} + +pub fn select_formats<'a, A: Allocator, F: ExportFramebuffer>( + device: &DrmDevice, + allocator: &mut A, + framebuffer_exporter: &F, + surfaces: impl IntoIterator>, + color_formats: impl IntoIterator, + renderer_formats: impl IntoIterator, +) -> Vec> { + let surfaces = surfaces.into_iter(); + let color_formats = color_formats.into_iter().collect::>(); + let mut surface_formats: Vec> = Vec::with_capacity(surfaces.size_hint().0); + + // TODO: Okay, so the idea is that we first check if we have a legacy device or atomic + // In case we have a legacy device we just search for supported formats and test them accepting it might just flicker like hell... + // For atomic issue test commits with: + // - All planes except the primaries for the supplied surfaces disabled + // - All crtc disabled except the passed ones + // - Format by format...with some limit and then just use Invalid + + todo!("Implement the actual format selection...") +} + +pub struct SurfaceFormat<'a> { + pub surface: &'a DrmSurface, + pub code: DrmFourcc, + pub modifiers: Vec, +} diff --git a/src/backend/drm/mod.rs b/src/backend/drm/mod.rs index 10552b5a77aa..9c03fb379f97 100644 --- a/src/backend/drm/mod.rs +++ b/src/backend/drm/mod.rs @@ -76,9 +76,10 @@ pub(crate) mod device; #[cfg(feature = "backend_drm")] pub mod dumb; mod error; +pub mod exporter; +pub mod format_selection; #[cfg(feature = "backend_gbm")] pub mod gbm; -pub mod exporter; pub mod output; mod surface;