backend: store damaged state in ConnectorData
This commit is contained in:
parent
7ff7edaa8f
commit
ada4e5a5f0
7 changed files with 33 additions and 16 deletions
|
|
@ -272,6 +272,10 @@ impl MetalConnector {
|
|||
self.can_present.set(false);
|
||||
if let Some(latched) = latched {
|
||||
self.has_damage.fetch_sub(latched.damage);
|
||||
node.global
|
||||
.connector
|
||||
.damaged
|
||||
.set(self.has_damage.is_not_zero());
|
||||
}
|
||||
self.cursor_changed.set(false);
|
||||
Ok(())
|
||||
|
|
|
|||
|
|
@ -449,10 +449,19 @@ fn create_dummy_output(state: &Rc<State>) {
|
|||
let connector = Rc::new(DummyOutput {
|
||||
id: state.connector_ids.next(),
|
||||
}) as Rc<dyn Connector>;
|
||||
let connector_data = Rc::new(ConnectorData {
|
||||
connector,
|
||||
handler: Cell::new(None),
|
||||
connected: Cell::new(true),
|
||||
name: "Dummy".to_string(),
|
||||
drm_dev: None,
|
||||
async_event: Default::default(),
|
||||
damaged: Cell::new(false),
|
||||
});
|
||||
let schedule = Rc::new(OutputSchedule::new(
|
||||
&state.ring,
|
||||
&state.eng,
|
||||
&connector,
|
||||
&connector_data,
|
||||
&persistent_state,
|
||||
));
|
||||
let dummy_output = Rc::new(OutputNode {
|
||||
|
|
@ -460,14 +469,7 @@ fn create_dummy_output(state: &Rc<State>) {
|
|||
global: Rc::new(WlOutputGlobal::new(
|
||||
state.globals.name(),
|
||||
state,
|
||||
&Rc::new(ConnectorData {
|
||||
connector,
|
||||
handler: Cell::new(None),
|
||||
connected: Cell::new(true),
|
||||
name: "Dummy".to_string(),
|
||||
drm_dev: None,
|
||||
async_event: Default::default(),
|
||||
}),
|
||||
&connector_data,
|
||||
Vec::new(),
|
||||
&backend::Mode {
|
||||
width: 0,
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ pub async fn visualize_damage(state: Rc<State>) {
|
|||
fn damage_all(state: &State) {
|
||||
for connector in state.connectors.lock().values() {
|
||||
if connector.connected.get() {
|
||||
connector.connector.damage();
|
||||
connector.damage();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ impl ZwlrScreencopyFrameV1 {
|
|||
self.buffer.set(Some(buffer));
|
||||
if !with_damage {
|
||||
if let Some(global) = self.output.get() {
|
||||
global.connector.connector.damage();
|
||||
global.connector.damage();
|
||||
}
|
||||
}
|
||||
self.with_damage.set(with_damage);
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
use {
|
||||
crate::{
|
||||
async_engine::AsyncEngine,
|
||||
backend::{Connector, HardwareCursor},
|
||||
backend::HardwareCursor,
|
||||
ifs::wl_output::PersistentOutputState,
|
||||
io_uring::{IoUring, IoUringError},
|
||||
state::ConnectorData,
|
||||
utils::{
|
||||
asyncevent::AsyncEvent, cell_ext::CellExt, clonecell::CloneCell, errorfmt::ErrorFmt,
|
||||
numcell::NumCell,
|
||||
|
|
@ -18,7 +19,7 @@ pub struct OutputSchedule {
|
|||
changed: AsyncEvent,
|
||||
run: Cell<bool>,
|
||||
|
||||
connector: Rc<dyn Connector>,
|
||||
connector: Rc<ConnectorData>,
|
||||
hardware_cursor: CloneCell<Option<Rc<dyn HardwareCursor>>>,
|
||||
|
||||
persistent: Rc<PersistentOutputState>,
|
||||
|
|
@ -42,7 +43,7 @@ impl OutputSchedule {
|
|||
pub fn new(
|
||||
ring: &Rc<IoUring>,
|
||||
eng: &Rc<AsyncEngine>,
|
||||
connector: &Rc<dyn Connector>,
|
||||
connector: &Rc<ConnectorData>,
|
||||
persistent: &Rc<PersistentOutputState>,
|
||||
) -> Self {
|
||||
let slf = Self {
|
||||
|
|
|
|||
11
src/state.rs
11
src/state.rs
|
|
@ -300,6 +300,7 @@ pub struct ConnectorData {
|
|||
pub name: String,
|
||||
pub drm_dev: Option<Rc<DrmDevData>>,
|
||||
pub async_event: Rc<AsyncEvent>,
|
||||
pub damaged: Cell<bool>,
|
||||
}
|
||||
|
||||
pub struct OutputData {
|
||||
|
|
@ -321,6 +322,14 @@ pub struct DrmDevData {
|
|||
pub lease_global: Rc<WpDrmLeaseDeviceV1Global>,
|
||||
}
|
||||
|
||||
impl ConnectorData {
|
||||
pub fn damage(&self) {
|
||||
if !self.damaged.replace(true) {
|
||||
self.connector.damage();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl DrmDevData {
|
||||
pub fn make_render_device(&self) {
|
||||
log::info!(
|
||||
|
|
@ -761,7 +770,7 @@ impl State {
|
|||
if cursor && output.schedule.defer_cursor_updates() {
|
||||
output.schedule.software_cursor_changed();
|
||||
} else {
|
||||
output.global.connector.connector.damage();
|
||||
output.global.connector.damage();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ pub fn handle(state: &Rc<State>, connector: &Rc<dyn Connector>) {
|
|||
name: connector.kernel_id().to_string(),
|
||||
drm_dev: drm_dev.clone(),
|
||||
async_event: Rc::new(AsyncEvent::default()),
|
||||
damaged: Cell::new(false),
|
||||
});
|
||||
if let Some(dev) = drm_dev {
|
||||
dev.connectors.set(id, data.clone());
|
||||
|
|
@ -137,7 +138,7 @@ impl ConnectorHandler {
|
|||
let schedule = Rc::new(OutputSchedule::new(
|
||||
&self.state.ring,
|
||||
&self.state.eng,
|
||||
&self.data.connector,
|
||||
&self.data,
|
||||
&desired_state,
|
||||
));
|
||||
let _schedule = self.state.eng.spawn(schedule.clone().drive());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue