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

View File

@ -4,7 +4,10 @@ use std::sync::{
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::sys::stat;
@ -140,8 +143,8 @@ impl<A: AsRawFd + 'static> DrmSurfaceObserver<A> {
SessionSignal::ActivateSession => self.activate(None),
SessionSignal::ActivateDevice { major, minor, new_fd } => {
self.activate(Some((major, minor, new_fd)))
},
_ => {},
}
_ => {}
}
}
@ -162,8 +165,11 @@ impl<A: AsRawFd + 'static> DrmSurfaceObserver<A> {
DrmSurfaceInternal::Atomic(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 {
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 {
errmsg: "Error loading crtc info",
dev: fd.dev_path(),
@ -131,7 +135,7 @@ impl<A: AsRawFd + 'static> AtomicDrmSurface<A> {
errmsg: "Failed to create Property Blob for mode",
dev: fd.dev_path(),
source,
})?;
})?;
let pending = State {
mode,
blob,
@ -767,8 +771,10 @@ impl<A: AsRawFd + 'static> AtomicDrmSurface<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 {
State::current_state(fd, self.crtc, &self.prop_mapping)?
} else {

View File

@ -92,7 +92,7 @@ impl<A: AsRawFd + 'static> LegacyDrmSurface<A> {
"Initializing drm surface with mode {:?} and connectors {:?}", mode, connectors
);
let state = State::current_state(&*fd, crtc)?;
let state = State::current_state(&*fd, crtc)?;
let pending = State {
mode,
connectors: connectors.iter().copied().collect(),
@ -402,8 +402,11 @@ impl<A: AsRawFd + 'static> LegacyDrmSurface<A> {
Ok(false)
}
}
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 {
State::current_state(fd, self.crtc)?
} else {

View File

@ -217,7 +217,7 @@ impl<A: AsRawFd + 'static> DrmSurface<A> {
} // There is no test-commiting with the legacy interface
}
}
/// Re-evaluates the current state of the crtc.
///
/// Usually you do not need to call this, but if the state of

View File

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