diff --git a/Cargo.toml b/Cargo.toml index 783335ada252..1ebea1a4b3b3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -37,7 +37,7 @@ drm-fourcc = "^2.2.0" drm = { version = "0.14.0", optional = true } drm-ffi = { version = "0.9.0", optional = true } errno = "0.3.5" -gbm = { version = "0.16.0", optional = true, default-features = false, features = ["drm-support"] } +gbm = { version = "0.18.0", optional = true, default-features = false, features = ["drm-support"] } glow = { version = "0.14", optional = true } input = { version = "0.9.0", default-features = false, features=["libinput_1_19"], optional = true } indexmap = "2.0" diff --git a/src/backend/allocator/gbm.rs b/src/backend/allocator/gbm.rs index fe10ff7e059a..603bbc1994d4 100644 --- a/src/backend/allocator/gbm.rs +++ b/src/backend/allocator/gbm.rs @@ -94,13 +94,13 @@ impl GbmBuffer { /// Gbm might otherwise give us the underlying or a non-sensical modifier, /// which can fail in various other apis. pub fn from_bo(bo: BufferObject<()>, implicit: bool) -> Self { - let size = (bo.width().unwrap_or(0) as i32, bo.height().unwrap_or(0) as i32).into(); + let size = (bo.width() as i32, bo.height() as i32).into(); let format = Format { - code: bo.format().unwrap_or(Fourcc::Argb8888), // we got to return something, but this should never happen anyway + code: bo.format(), modifier: if implicit { Modifier::Invalid } else { - bo.modifier().unwrap_or(Modifier::Invalid) + bo.modifier() }, }; Self { bo, size, format } @@ -242,9 +242,6 @@ impl Buffer for GbmBuffer { /// Errors during conversion to a dmabuf handle from a gbm buffer object #[derive(thiserror::Error, Debug)] pub enum GbmConvertError { - /// The gbm device was destroyed - #[error("The gbm device was destroyed")] - DeviceDestroyed(#[from] gbm::DeviceDestroyedError), /// The buffer consists out of multiple file descriptions, which is currently unsupported #[error("Buffer consists out of multiple file descriptors, which is currently unsupported")] UnsupportedBuffer, @@ -253,23 +250,13 @@ pub enum GbmConvertError { InvalidFD(#[from] gbm::InvalidFdError), } -impl From for GbmConvertError { - #[inline] - fn from(err: gbm::FdError) -> Self { - match err { - gbm::FdError::DeviceDestroyed(err) => err.into(), - gbm::FdError::InvalidFd(err) => err.into(), - } - } -} - impl AsDmabuf for GbmBuffer { type Error = GbmConvertError; #[cfg(feature = "backend_gbm_has_fd_for_plane")] #[profiling::function] fn export(&self) -> Result { - let planes = self.plane_count()? as i32; + let planes = self.plane_count() as i32; let mut builder = Dmabuf::builder_from_buffer(self, DmabufFlags::empty()); for idx in 0..planes { @@ -279,13 +266,13 @@ impl AsDmabuf for GbmBuffer { // SAFETY: `gbm_bo_get_fd_for_plane` returns a new fd owned by the caller. fd, idx as u32, - self.offset(idx)?, - self.stride_for_plane(idx)?, + self.offset(idx), + self.stride_for_plane(idx), ); } #[cfg(feature = "backend_drm")] - if let Some(node) = self.device_fd().ok().and_then(|fd| DrmNode::from_file(fd).ok()) { + if let Ok(node) = DrmNode::from_file(self.device_fd()) { builder.set_node(node); } diff --git a/src/backend/drm/compositor/mod.rs b/src/backend/drm/compositor/mod.rs index 8b2f7fe8bcdc..81b3fb69c795 100644 --- a/src/backend/drm/compositor/mod.rs +++ b/src/backend/drm/compositor/mod.rs @@ -3431,7 +3431,6 @@ where element_size, cursor_plane_size, output_transform, - &cursor_state.framebuffer_exporter, &mut cursor_buffer, ) { tracing::trace!("failed to copy element to cursor bo, skipping element on cursor plane"); @@ -3445,7 +3444,6 @@ where element_size, cursor_plane_size, output_transform, - &cursor_state.framebuffer_exporter, &mut cursor_buffer, ) { profiling::scope!("render cursor plane"); @@ -3493,8 +3491,7 @@ where }?; let ret = cursor_buffer - .map_mut::<_, _, Result<_, ::Error>>( - &cursor_state.framebuffer_exporter, + .map_mut::<_, Result<_, ::Error>>( 0, 0, cursor_buffer_size.w as u32, @@ -3538,17 +3535,10 @@ where _ = pixman_renderer.unbind(); - match ret { - Err(err) => { - debug!("{err}"); - return None; - } - Ok(Err(err)) => { - debug!("{err}"); - return None; - } - Ok(Ok(_)) => (), - }; + if let Err(err) = ret { + debug!("{err}"); + return None; + } }; let src = Rectangle::from_loc_and_size(Point::default(), cursor_buffer_size).to_f64(); @@ -4375,19 +4365,17 @@ fn apply_output_transform(transform: Transform, output_transform: Transform) -> } #[profiling::function] -fn copy_element_to_cursor_bo( +fn copy_element_to_cursor_bo( renderer: &mut R, element: &E, element_size: Size, cursor_size: Size, output_transform: Transform, - device: &GbmDevice, bo: &mut GbmBuffer, ) -> bool where R: Renderer, E: RenderElement, - T: AsFd + 'static, { // Without access to the underlying storage we can not copy anything let Some(underlying_storage) = element.underlying_storage(renderer) else { @@ -4407,15 +4395,13 @@ where } let bo_format = bo.format().code; - let Ok(bo_stride) = bo.stride() else { - return false; - }; + let bo_stride = bo.stride(); let mut copy_to_bo = |src, src_stride, src_height| { if src_stride == bo_stride as i32 { - matches!(bo.write(src), Ok(Ok(_))) + bo.write(src).is_ok() } else { - let res = bo.map_mut(device, 0, 0, cursor_size.w as u32, cursor_size.h as u32, |mbo| { + let res = bo.map_mut(0, 0, cursor_size.w as u32, cursor_size.h as u32, |mbo| { let dst = mbo.buffer_mut(); for row in 0..src_height { let src_row_start = (row * src_stride) as usize; @@ -4427,7 +4413,7 @@ where dst_row.copy_from_slice(src_row); } }); - matches!(res, Ok(Ok(_))) + res.is_ok() } }; diff --git a/src/backend/drm/gbm.rs b/src/backend/drm/gbm.rs index d9229738eb2c..e3d75236c132 100644 --- a/src/backend/drm/gbm.rs +++ b/src/backend/drm/gbm.rs @@ -344,7 +344,7 @@ where // We only support this as a fallback of last resort like xf86-video-modesetting does. warn_legacy_fb_export(); - if bo.plane_count().unwrap() > 1 { + if bo.plane_count() > 1 { return Err(AccessError { errmsg: "Failed to add framebuffer", dev: drm.dev_path(), diff --git a/src/backend/drm/surface/gbm.rs b/src/backend/drm/surface/gbm.rs index 373e62351327..604d8f899f2f 100644 --- a/src/backend/drm/surface/gbm.rs +++ b/src/backend/drm/surface/gbm.rs @@ -197,10 +197,10 @@ where }; let format = Format { code, - modifier: buffer.modifier().unwrap(), // no guarantee - // that this is stable across allocations, but - // we want to print that here for debugging proposes. - // It has no further use. + modifier: buffer.modifier(), // no guarantee + // that this is stable across allocations, but + // we want to print that here for debugging proposes. + // It has no further use. }; let use_opaque = !plane_formats.iter().any(|f| f.code == code);