cargo fmt

This commit is contained in:
Victor Brekenfeld 2021-05-15 22:35:44 +02:00
parent 524057418e
commit 5d6fadcea8
6 changed files with 46 additions and 28 deletions

View File

@ -410,9 +410,7 @@ impl<A: AsRawFd + 'static> DrmDevice<A> {
}); });
} }
if let Ok(1) = if let Ok(1) = self.get_driver_capability(DriverCapability::AddFB2Modifiers) {
self.get_driver_capability(DriverCapability::AddFB2Modifiers)
{
let set = self.get_properties(plane).map_err(|source| Error::Access { let set = self.get_properties(plane).map_err(|source| Error::Access {
errmsg: "Failed to query properties", errmsg: "Failed to query properties",
dev: self.dev_path(), dev: self.dev_path(),
@ -420,17 +418,20 @@ impl<A: AsRawFd + 'static> DrmDevice<A> {
})?; })?;
let (handles, _) = set.as_props_and_values(); let (handles, _) = set.as_props_and_values();
// for every handle ... // for every handle ...
let prop = handles.iter().find(|handle| { let prop = handles
// get information of that property .iter()
if let Some(info) = self.get_property(**handle).ok() { .find(|handle| {
// to find out, if we got the handle of the "IN_FORMATS" property ... // get information of that property
if info.name().to_str().map(|x| x == "IN_FORMATS").unwrap_or(false) { if let Some(info) = self.get_property(**handle).ok() {
// so we can use that to get formats // to find out, if we got the handle of the "IN_FORMATS" property ...
return true; if info.name().to_str().map(|x| x == "IN_FORMATS").unwrap_or(false) {
// so we can use that to get formats
return true;
}
} }
} false
false })
}).copied(); .copied();
if let Some(prop) = prop { if let Some(prop) = prop {
let prop_info = self.get_property(prop).map_err(|source| Error::Access { let prop_info = self.get_property(prop).map_err(|source| Error::Access {
errmsg: "Failed to query property", errmsg: "Failed to query property",
@ -505,7 +506,9 @@ impl<A: AsRawFd + 'static> DrmDevice<A> {
trace!( trace!(
self.logger, self.logger,
"Supported scan-out formats for plane ({:?}): {:?}", plane, formats "Supported scan-out formats for plane ({:?}): {:?}",
plane,
formats
); );
Ok(DrmSurface { Ok(DrmSurface {

View File

@ -4,7 +4,10 @@ use std::sync::{
Arc, Weak, Arc, Weak,
}; };
use drm::{Device as BasicDevice, control::{crtc, Device as ControlDevice}}; use drm::{
control::{crtc, Device as ControlDevice},
Device as BasicDevice,
};
use nix::libc::dev_t; use nix::libc::dev_t;
use nix::sys::stat; use nix::sys::stat;
@ -140,8 +143,8 @@ impl<A: AsRawFd + 'static> DrmSurfaceObserver<A> {
SessionSignal::ActivateSession => self.activate(None), SessionSignal::ActivateSession => self.activate(None),
SessionSignal::ActivateDevice { major, minor, new_fd } => { SessionSignal::ActivateDevice { major, minor, new_fd } => {
self.activate(Some((major, minor, new_fd))) self.activate(Some((major, minor, new_fd)))
}, }
_ => {}, _ => {}
} }
} }
@ -162,7 +165,10 @@ impl<A: AsRawFd + 'static> DrmSurfaceObserver<A> {
DrmSurfaceInternal::Atomic(surf) => surf.reset_state(fd.as_ref()), DrmSurfaceInternal::Atomic(surf) => surf.reset_state(fd.as_ref()),
DrmSurfaceInternal::Legacy(surf) => surf.reset_state(fd.as_ref()), DrmSurfaceInternal::Legacy(surf) => surf.reset_state(fd.as_ref()),
} { } {
warn!(self.logger, "Failed to reset state of surface ({:?}/{:?}): {}", self.dev_id, self.crtc, err); warn!(
self.logger,
"Failed to reset state of surface ({:?}/{:?}): {}", self.dev_id, self.crtc, err
);
} }
} }
} }

View File

@ -25,7 +25,11 @@ pub struct State {
} }
impl State { impl State {
fn current_state<A: AsRawFd + ControlDevice>(fd: &A, crtc: crtc::Handle, prop_mapping: &Mapping) -> Result<Self, Error> { fn current_state<A: AsRawFd + ControlDevice>(
fd: &A,
crtc: crtc::Handle,
prop_mapping: &Mapping,
) -> Result<Self, Error> {
let crtc_info = fd.get_crtc(crtc).map_err(|source| Error::Access { let crtc_info = fd.get_crtc(crtc).map_err(|source| Error::Access {
errmsg: "Error loading crtc info", errmsg: "Error loading crtc info",
dev: fd.dev_path(), dev: fd.dev_path(),
@ -767,8 +771,10 @@ impl<A: AsRawFd + 'static> AtomicDrmSurface<A> {
}) })
} }
pub(crate) fn reset_state<B: AsRawFd + ControlDevice + 'static>(
pub(crate) fn reset_state<B: AsRawFd + ControlDevice + 'static>(&self, fd: Option<&B>) -> Result<(), Error> { &self,
fd: Option<&B>,
) -> Result<(), Error> {
*self.state.write().unwrap() = if let Some(fd) = fd { *self.state.write().unwrap() = if let Some(fd) = fd {
State::current_state(fd, self.crtc, &self.prop_mapping)? State::current_state(fd, self.crtc, &self.prop_mapping)?
} else { } else {

View File

@ -403,7 +403,10 @@ impl<A: AsRawFd + 'static> LegacyDrmSurface<A> {
} }
} }
pub(crate) fn reset_state<B: AsRawFd + ControlDevice + 'static>(&self, fd: Option<&B>) -> Result<(), Error> { pub(crate) fn reset_state<B: AsRawFd + ControlDevice + 'static>(
&self,
fd: Option<&B>,
) -> Result<(), Error> {
*self.state.write().unwrap() = if let Some(fd) = fd { *self.state.write().unwrap() = if let Some(fd) = fd {
State::current_state(fd, self.crtc)? State::current_state(fd, self.crtc)?
} else { } else {

View File

@ -1,6 +1,7 @@
//! Implementation of the rendering traits using OpenGL ES 2 //! Implementation of the rendering traits using OpenGL ES 2
use std::cell::RefCell; use std::cell::RefCell;
use std::convert::TryFrom;
use std::ffi::CStr; use std::ffi::CStr;
use std::fmt; use std::fmt;
use std::ptr; use std::ptr;
@ -10,7 +11,6 @@ use std::sync::{
mpsc::{channel, Receiver, Sender}, mpsc::{channel, Receiver, Sender},
}; };
use std::{collections::HashSet, os::raw::c_char}; use std::{collections::HashSet, os::raw::c_char};
use std::convert::TryFrom;
use cgmath::{prelude::*, Matrix3}; use cgmath::{prelude::*, Matrix3};