image-copy: Prioritize ARGB/XRGB dmabuf formats
Co-authored-by: back-design <271796486+back-design@users.noreply.github.com>
This commit is contained in:
parent
e7b65b1fc8
commit
467d1fbc7f
1 changed files with 21 additions and 16 deletions
|
|
@ -454,23 +454,28 @@ fn constraints_for_renderer(
|
|||
.ok()
|
||||
.and_then(|device| device.try_get_render_node().ok().flatten())
|
||||
{
|
||||
constraints.dma = Some(DmabufConstraints {
|
||||
node,
|
||||
formats: renderer
|
||||
.egl_context()
|
||||
.dmabuf_render_formats()
|
||||
.iter()
|
||||
.fold(
|
||||
IndexMap::<Fourcc, Vec<Modifier>>::new(),
|
||||
|mut map, format| {
|
||||
map.entry(format.code).or_default().push(format.modifier);
|
||||
map
|
||||
},
|
||||
)
|
||||
.into_iter()
|
||||
.collect::<Vec<_>>(),
|
||||
});
|
||||
let mut formats = renderer
|
||||
.egl_context()
|
||||
.dmabuf_render_formats()
|
||||
.iter()
|
||||
.fold(
|
||||
IndexMap::<Fourcc, Vec<Modifier>>::new(),
|
||||
|mut map, format| {
|
||||
map.entry(format.code).or_default().push(format.modifier);
|
||||
map
|
||||
},
|
||||
)
|
||||
.into_iter()
|
||||
.collect::<Vec<_>>();
|
||||
formats.sort_by_key(|(code, _)| !is_preferred_capture_format(*code));
|
||||
constraints.dma = Some(DmabufConstraints { node, formats });
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue