|
| 1 | +use drm::control::{connector, crtc, Mode}; |
| 2 | +use drm_fourcc::{DrmFormat, DrmFourcc, DrmModifier}; |
| 3 | + |
| 4 | +use crate::backend::allocator::Allocator; |
| 5 | + |
| 6 | +use super::{exporter::ExportFramebuffer, DrmDevice, DrmSurface}; |
| 7 | + |
| 8 | +pub struct SurfaceDefinition<'a> { |
| 9 | + pub crtc: crtc::Handle, |
| 10 | + pub mode: &'a Mode, |
| 11 | + pub connectors: &'a [connector::Handle], |
| 12 | +} |
| 13 | + |
| 14 | +pub fn select_formats<'a, A: Allocator, F: ExportFramebuffer<A::Buffer>>( |
| 15 | + device: &DrmDevice, |
| 16 | + allocator: &mut A, |
| 17 | + framebuffer_exporter: &F, |
| 18 | + surfaces: impl IntoIterator<Item = SurfaceDefinition<'a>>, |
| 19 | + color_formats: impl IntoIterator<Item = DrmFourcc>, |
| 20 | + renderer_formats: impl IntoIterator<Item = DrmFormat>, |
| 21 | +) -> Vec<SurfaceFormat<'a>> { |
| 22 | + let surfaces = surfaces.into_iter(); |
| 23 | + let color_formats = color_formats.into_iter().collect::<Vec<_>>(); |
| 24 | + let mut surface_formats: Vec<SurfaceFormat<'a>> = Vec::with_capacity(surfaces.size_hint().0); |
| 25 | + |
| 26 | + // TODO: Okay, so the idea is that we first check if we have a legacy device or atomic |
| 27 | + // In case we have a legacy device we just search for supported formats and test them accepting it might just flicker like hell... |
| 28 | + // For atomic issue test commits with: |
| 29 | + // - All planes except the primaries for the supplied surfaces disabled |
| 30 | + // - All crtc disabled except the passed ones |
| 31 | + // - Format by format...with some limit and then just use Invalid |
| 32 | + |
| 33 | + todo!("Implement the actual format selection...") |
| 34 | +} |
| 35 | + |
| 36 | +pub struct SurfaceFormat<'a> { |
| 37 | + pub surface: &'a DrmSurface, |
| 38 | + pub code: DrmFourcc, |
| 39 | + pub modifiers: Vec<DrmModifier>, |
| 40 | +} |
0 commit comments