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()
|
.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,
|
.egl_context()
|
||||||
formats: renderer
|
.dmabuf_render_formats()
|
||||||
.egl_context()
|
.iter()
|
||||||
.dmabuf_render_formats()
|
.fold(
|
||||||
.iter()
|
IndexMap::<Fourcc, Vec<Modifier>>::new(),
|
||||||
.fold(
|
|mut map, format| {
|
||||||
IndexMap::<Fourcc, Vec<Modifier>>::new(),
|
map.entry(format.code).or_default().push(format.modifier);
|
||||||
|mut map, format| {
|
map
|
||||||
map.entry(format.code).or_default().push(format.modifier);
|
},
|
||||||
map
|
)
|
||||||
},
|
.into_iter()
|
||||||
)
|
.collect::<Vec<_>>();
|
||||||
.into_iter()
|
formats.sort_by_key(|(code, _)| !is_preferred_capture_format(*code));
|
||||||
.collect::<Vec<_>>(),
|
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)
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue