apply cargo fmt and clippy
This commit is contained in:
parent
86716f9c9f
commit
5506c7e1c5
|
@ -44,7 +44,8 @@ impl EGLDevice {
|
||||||
|
|
||||||
// Passing 0 for max devices and a null-pointer for devices is safe because we indicate we only
|
// Passing 0 for max devices and a null-pointer for devices is safe because we indicate we only
|
||||||
// want the number of devices.
|
// want the number of devices.
|
||||||
if unsafe { ffi::egl::QueryDevicesEXT(0, ptr::null_mut(), amount.as_mut_ptr()) } == ffi::egl::FALSE
|
if unsafe { ffi::egl::QueryDevicesEXT(0, ptr::null_mut(), amount.as_mut_ptr()) }
|
||||||
|
== ffi::egl::FALSE
|
||||||
{
|
{
|
||||||
0
|
0
|
||||||
} else {
|
} else {
|
||||||
|
@ -63,7 +64,8 @@ impl EGLDevice {
|
||||||
// - Vector used as pointer is correct size.
|
// - Vector used as pointer is correct size.
|
||||||
// - Device amount will accommodate all available devices because we have checked the size earlier.
|
// - Device amount will accommodate all available devices because we have checked the size earlier.
|
||||||
ffi::egl::QueryDevicesEXT(device_amount, devices.as_mut_ptr(), &mut device_amount)
|
ffi::egl::QueryDevicesEXT(device_amount, devices.as_mut_ptr(), &mut device_amount)
|
||||||
}).map_err(Error::QueryDevices)?;
|
})
|
||||||
|
.map_err(Error::QueryDevices)?;
|
||||||
|
|
||||||
// Set the length of the vec so that rust does not think it is still empty.
|
// Set the length of the vec so that rust does not think it is still empty.
|
||||||
|
|
||||||
|
|
|
@ -325,13 +325,13 @@ impl X11Backend {
|
||||||
// We cannot fallback on the egl_init method, because there is no way for us to authenticate a primary node.
|
// We cannot fallback on the egl_init method, because there is no way for us to authenticate a primary node.
|
||||||
// dri3 does not work for closed-source drivers, but *may* give us a authenticated fd as a fallback.
|
// dri3 does not work for closed-source drivers, but *may* give us a authenticated fd as a fallback.
|
||||||
// As a result we try to use egl for a cleaner, better supported approach at first and only if that fails use dri3.
|
// As a result we try to use egl for a cleaner, better supported approach at first and only if that fails use dri3.
|
||||||
egl_init(&self).or_else(|err| {
|
egl_init(self).or_else(|err| {
|
||||||
slog::warn!(
|
slog::warn!(
|
||||||
&self.log,
|
&self.log,
|
||||||
"Failed to init X11 surface via egl, falling back to dri3: {}",
|
"Failed to init X11 surface via egl, falling back to dri3: {}",
|
||||||
err
|
err
|
||||||
);
|
);
|
||||||
dri3_init(&self)
|
dri3_init(self)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -412,8 +412,7 @@ fn dri3_init(backend: &X11Backend) -> Result<DrmNode, X11Error> {
|
||||||
.map_err(AllocateBuffersError::from)?;
|
.map_err(AllocateBuffersError::from)?;
|
||||||
let drm_node = DrmNode::from_fd(drm_device_fd).map_err(Into::<AllocateBuffersError>::into)?;
|
let drm_node = DrmNode::from_fd(drm_device_fd).map_err(Into::<AllocateBuffersError>::into)?;
|
||||||
|
|
||||||
if drm_node.ty() != NodeType::Render {
|
if drm_node.ty() != NodeType::Render && drm_node.has_render() {
|
||||||
if drm_node.has_render() {
|
|
||||||
// Try to get the render node.
|
// Try to get the render node.
|
||||||
if let Some(path) = drm_node.dev_path_with_type(NodeType::Render) {
|
if let Some(path) = drm_node.dev_path_with_type(NodeType::Render) {
|
||||||
return Ok(fcntl::open(&path, OFlag::O_RDWR | OFlag::O_CLOEXEC, Mode::empty())
|
return Ok(fcntl::open(&path, OFlag::O_RDWR | OFlag::O_CLOEXEC, Mode::empty())
|
||||||
|
@ -426,7 +425,6 @@ fn dri3_init(backend: &X11Backend) -> Result<DrmNode, X11Error> {
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
slog::warn!(
|
slog::warn!(
|
||||||
&backend.log,
|
&backend.log,
|
||||||
|
@ -598,7 +596,7 @@ impl Drop for Present<'_> {
|
||||||
|
|
||||||
match surface.current.userdata().map(Option::unwrap) {
|
match surface.current.userdata().map(Option::unwrap) {
|
||||||
Ok(dmabuf) => {
|
Ok(dmabuf) => {
|
||||||
if let Ok(pixmap) = PixmapWrapper::with_dmabuf(&*connection, &surface.window, &dmabuf) {
|
if let Ok(pixmap) = PixmapWrapper::with_dmabuf(&*connection, &surface.window, dmabuf) {
|
||||||
// Now present the current buffer
|
// Now present the current buffer
|
||||||
let _ = pixmap.present(&*connection, &surface.window);
|
let _ = pixmap.present(&*connection, &surface.window);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue