image-copy: Prioritize ARGB/XRGB dmabuf formats

Co-authored-by: back-design <271796486+back-design@users.noreply.github.com>
This commit is contained in:
Netflate 2026-09-30 04:32:30 +01:00 • committed by Victoria Brekenfeld
parent e7b65b1fc8
commit 467d1fbc7f

View file

@ -454,9 +454,7 @@ fn constraints_for_renderer(
.ok() .ok()
.and_then(|device| device.try_get_render_node().ok().flatten()) .and_then(|device| device.try_get_render_node().ok().flatten())
{ {
constraints.dma = Some(DmabufConstraints { let mut formats = renderer
node,
formats: renderer
.egl_context() .egl_context()
.dmabuf_render_formats() .dmabuf_render_formats()
.iter() .iter()
@ -468,9 +466,16 @@ fn constraints_for_renderer(
}, },
) )
.into_iter() .into_iter()
.collect::<Vec<_>>(), .collect::<Vec<_>>();
}); formats.sort_by_key(|(code, _)| !is_preferred_capture_format(*code));
constraints.dma = Some(DmabufConstraints { node, formats });
} }
constraints constraints
} }
/// Formats most screencast consumers handle natively, offered first. WebRTC, for
/// example, swaps RGBA frames to BGRA on the CPU for every captured frame.
fn is_preferred_capture_format(code: Fourcc) -> bool {
matches!(code, Fourcc::Argb8888 | Fourcc::Xrgb8888)
}