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