mirror of
https://github.com/Smithay/smithay.git
synced 2024-09-28 03:21:14 +02:00
wayland: keep dmabuf formats in order
This commit is contained in:
parent
807fadb298
commit
22f44c18b6
1 changed files with 14 additions and 9 deletions
|
@ -188,7 +188,7 @@
|
|||
mod dispatch;
|
||||
|
||||
use std::{
|
||||
collections::{HashMap, HashSet},
|
||||
collections::HashMap,
|
||||
ffi::CString,
|
||||
ops::Sub,
|
||||
os::unix::io::AsFd,
|
||||
|
@ -198,7 +198,7 @@ use std::{
|
|||
},
|
||||
};
|
||||
|
||||
use indexmap::IndexSet;
|
||||
use indexmap::{IndexMap, IndexSet};
|
||||
use rustix::fs::{seek, SeekFrom};
|
||||
use wayland_protocols::wp::linux_dmabuf::zv1::server::{
|
||||
zwp_linux_buffer_params_v1::{self, ZwpLinuxBufferParamsV1},
|
||||
|
@ -596,7 +596,11 @@ impl DmabufState {
|
|||
///
|
||||
/// Note: This function will create a version 3 dmabuf global and thus not call [`DmabufHandler::new_surface_feedback`],
|
||||
/// if you want to create a version 4 global you need to call [`DmabufState::create_global_with_default_feedback`].
|
||||
pub fn create_global<D>(&mut self, display: &DisplayHandle, formats: Vec<Format>) -> DmabufGlobal
|
||||
pub fn create_global<D>(
|
||||
&mut self,
|
||||
display: &DisplayHandle,
|
||||
formats: impl IntoIterator<Item = Format>,
|
||||
) -> DmabufGlobal
|
||||
where
|
||||
D: GlobalDispatch<zwp_linux_dmabuf_v1::ZwpLinuxDmabufV1, DmabufGlobalData>
|
||||
+ BufferHandler
|
||||
|
@ -617,7 +621,7 @@ impl DmabufState {
|
|||
pub fn create_global_with_filter<D, F>(
|
||||
&mut self,
|
||||
display: &DisplayHandle,
|
||||
formats: Vec<Format>,
|
||||
formats: impl IntoIterator<Item = Format>,
|
||||
filter: F,
|
||||
) -> DmabufGlobal
|
||||
where
|
||||
|
@ -627,6 +631,7 @@ impl DmabufState {
|
|||
+ 'static,
|
||||
F: for<'c> Fn(&'c Client) -> bool + Send + Sync + 'static,
|
||||
{
|
||||
let formats = formats.into_iter().collect::<Vec<_>>();
|
||||
self.create_global_with_filter_and_optional_default_feedback::<D, _>(
|
||||
display,
|
||||
Some(formats),
|
||||
|
@ -701,12 +706,12 @@ impl DmabufState {
|
|||
.unwrap()
|
||||
.into_iter()
|
||||
.fold(
|
||||
HashMap::<Fourcc, HashSet<Modifier>>::new(),
|
||||
IndexMap::<Fourcc, IndexSet<Modifier>>::new(),
|
||||
|mut formats, format| {
|
||||
if let Some(modifiers) = formats.get_mut(&format.code) {
|
||||
modifiers.insert(format.modifier);
|
||||
} else {
|
||||
formats.insert(format.code, HashSet::from_iter(std::iter::once(format.modifier)));
|
||||
formats.insert(format.code, IndexSet::from_iter(std::iter::once(format.modifier)));
|
||||
}
|
||||
formats
|
||||
},
|
||||
|
@ -792,7 +797,7 @@ impl DmabufState {
|
|||
#[allow(missing_debug_implementations)]
|
||||
pub struct DmabufGlobalData {
|
||||
filter: Box<dyn for<'c> Fn(&'c Client) -> bool + Send + Sync>,
|
||||
formats: Arc<HashMap<Fourcc, HashSet<Modifier>>>,
|
||||
formats: Arc<IndexMap<Fourcc, IndexSet<Modifier>>>,
|
||||
default_feedback: Option<Arc<Mutex<DmabufFeedback>>>,
|
||||
known_default_feedbacks:
|
||||
Arc<Mutex<Vec<wayland_server::Weak<zwp_linux_dmabuf_feedback_v1::ZwpLinuxDmabufFeedbackV1>>>>,
|
||||
|
@ -802,7 +807,7 @@ pub struct DmabufGlobalData {
|
|||
/// Data associated with a dmabuf global protocol object.
|
||||
#[derive(Debug)]
|
||||
pub struct DmabufData {
|
||||
formats: Arc<HashMap<Fourcc, HashSet<Modifier>>>,
|
||||
formats: Arc<IndexMap<Fourcc, IndexSet<Modifier>>>,
|
||||
id: usize,
|
||||
|
||||
default_feedback: Option<Arc<Mutex<DmabufFeedback>>>,
|
||||
|
@ -827,7 +832,7 @@ pub struct DmabufParamsData {
|
|||
/// Whether the params protocol object has been used before to create a wl_buffer.
|
||||
used: AtomicBool,
|
||||
|
||||
formats: Arc<HashMap<Fourcc, HashSet<Modifier>>>,
|
||||
formats: Arc<IndexMap<Fourcc, IndexSet<Modifier>>>,
|
||||
|
||||
/// Pending planes for the params.
|
||||
modifier: Mutex<Option<Modifier>>,
|
||||
|
|
Loading…
Reference in a new issue