kms: Cleanup now that output_elements won't panic for uninitialized outputs
This commit is contained in:
parent
db13eea91c
commit
bebd7c5c40
2 changed files with 12 additions and 25 deletions
|
|
@ -18,8 +18,9 @@ use smithay::{
|
||||||
Format, Fourcc,
|
Format, Fourcc,
|
||||||
},
|
},
|
||||||
drm::{
|
drm::{
|
||||||
compositor::FrameFlags, output::DrmOutputManager, DrmDevice, DrmDeviceFd, DrmEvent,
|
compositor::{FrameError, FrameFlags},
|
||||||
DrmNode,
|
output::DrmOutputManager,
|
||||||
|
DrmDevice, DrmDeviceFd, DrmEvent, DrmNode,
|
||||||
},
|
},
|
||||||
egl::{context::ContextPriority, EGLContext, EGLDevice, EGLDisplay},
|
egl::{context::ContextPriority, EGLContext, EGLDevice, EGLDisplay},
|
||||||
session::Session,
|
session::Session,
|
||||||
|
|
@ -620,7 +621,6 @@ impl Device {
|
||||||
renderer: &mut GlMultiRenderer,
|
renderer: &mut GlMultiRenderer,
|
||||||
clock: &Clock<Monotonic>,
|
clock: &Clock<Monotonic>,
|
||||||
shell: &Arc<RwLock<Shell>>,
|
shell: &Arc<RwLock<Shell>>,
|
||||||
startup_done: bool,
|
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
for surface in self.surfaces.values_mut() {
|
for surface in self.surfaces.values_mut() {
|
||||||
surface.allow_frame_flags(flag, flags);
|
surface.allow_frame_flags(flag, flags);
|
||||||
|
|
@ -628,16 +628,11 @@ impl Device {
|
||||||
|
|
||||||
if !flag {
|
if !flag {
|
||||||
let now = clock.now();
|
let now = clock.now();
|
||||||
|
let output_map = self
|
||||||
let mut output_map = self
|
|
||||||
.surfaces
|
.surfaces
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|(_, s)| s.is_active())
|
|
||||||
.map(|(crtc, surface)| (*crtc, surface.output.clone()))
|
.map(|(crtc, surface)| (*crtc, surface.output.clone()))
|
||||||
.collect::<HashMap<_, _>>();
|
.collect::<HashMap<_, _>>();
|
||||||
if !startup_done {
|
|
||||||
output_map.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
self.drm.with_compositors::<Result<()>>(|map| {
|
self.drm.with_compositors::<Result<()>>(|map| {
|
||||||
for (crtc, compositor) in map.iter() {
|
for (crtc, compositor) in map.iter() {
|
||||||
|
|
@ -662,7 +657,11 @@ impl Device {
|
||||||
CLEAR_COLOR,
|
CLEAR_COLOR,
|
||||||
FrameFlags::empty(),
|
FrameFlags::empty(),
|
||||||
)?;
|
)?;
|
||||||
compositor.commit_frame()?;
|
if let Err(err) = compositor.commit_frame() {
|
||||||
|
if !matches!(err, FrameError::EmptyFrame) {
|
||||||
|
return Err(err.into());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
@ -685,7 +684,6 @@ impl Device {
|
||||||
renderer,
|
renderer,
|
||||||
clock,
|
clock,
|
||||||
shell,
|
shell,
|
||||||
true,
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -695,7 +693,6 @@ impl Device {
|
||||||
renderer: &mut GlMultiRenderer,
|
renderer: &mut GlMultiRenderer,
|
||||||
clock: &Clock<Monotonic>,
|
clock: &Clock<Monotonic>,
|
||||||
shell: &Arc<RwLock<Shell>>,
|
shell: &Arc<RwLock<Shell>>,
|
||||||
startup_done: bool,
|
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
self.allow_frame_flags(
|
self.allow_frame_flags(
|
||||||
flag,
|
flag,
|
||||||
|
|
@ -703,7 +700,6 @@ impl Device {
|
||||||
renderer,
|
renderer,
|
||||||
clock,
|
clock,
|
||||||
shell,
|
shell,
|
||||||
startup_done,
|
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
self.drm.with_compositors(|comps| {
|
self.drm.with_compositors(|comps| {
|
||||||
|
|
|
||||||
|
|
@ -44,10 +44,7 @@ use std::{
|
||||||
borrow::BorrowMut,
|
borrow::BorrowMut,
|
||||||
collections::{HashMap, HashSet},
|
collections::{HashMap, HashSet},
|
||||||
path::Path,
|
path::Path,
|
||||||
sync::{
|
sync::{atomic::AtomicBool, Arc, RwLock},
|
||||||
atomic::{AtomicBool, Ordering},
|
|
||||||
Arc, RwLock,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
mod device;
|
mod device;
|
||||||
|
|
@ -649,19 +646,14 @@ impl KmsState {
|
||||||
.context("Failed to enable devices")?;
|
.context("Failed to enable devices")?;
|
||||||
}
|
}
|
||||||
|
|
||||||
let startup_done = startup_done.load(Ordering::SeqCst);
|
|
||||||
let mut all_outputs = Vec::new();
|
let mut all_outputs = Vec::new();
|
||||||
for device in self.drm_devices.values_mut() {
|
for device in self.drm_devices.values_mut() {
|
||||||
let now = clock.now();
|
let now = clock.now();
|
||||||
let mut output_map = device
|
let output_map = device
|
||||||
.surfaces
|
.surfaces
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|(_, s)| s.is_active())
|
|
||||||
.map(|(crtc, surface)| (*crtc, surface.output.clone()))
|
.map(|(crtc, surface)| (*crtc, surface.output.clone()))
|
||||||
.collect::<HashMap<_, _>>();
|
.collect::<HashMap<_, _>>();
|
||||||
if !startup_done {
|
|
||||||
output_map.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
// configure primary scanout allowance
|
// configure primary scanout allowance
|
||||||
if !device.surfaces.is_empty() {
|
if !device.surfaces.is_empty() {
|
||||||
|
|
@ -675,13 +667,12 @@ impl KmsState {
|
||||||
device
|
device
|
||||||
.surfaces
|
.surfaces
|
||||||
.values()
|
.values()
|
||||||
.filter(|s| s.output.is_enabled())
|
.filter(|s| s.output.is_enabled() && s.output.mirroring().is_none())
|
||||||
.count()
|
.count()
|
||||||
<= 1,
|
<= 1,
|
||||||
&mut renderer,
|
&mut renderer,
|
||||||
clock,
|
clock,
|
||||||
&shell,
|
&shell,
|
||||||
startup_done,
|
|
||||||
)
|
)
|
||||||
.context("Failed to switch primary-plane scanout flags")?;
|
.context("Failed to switch primary-plane scanout flags")?;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue