backend: take initial backend state from backend
This commit is contained in:
parent
1a9753847a
commit
d321e888be
8 changed files with 88 additions and 71 deletions
|
|
@ -141,6 +141,7 @@ pub trait Connector: Any {
|
|||
fn damage(&self);
|
||||
fn drm_dev(&self) -> Option<DrmDeviceId>;
|
||||
fn effectively_locked(&self) -> bool;
|
||||
fn state(&self) -> BackendConnectorState;
|
||||
fn caps(&self) -> ConnectorCaps {
|
||||
ConnectorCaps::none()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,8 +2,10 @@ use {
|
|||
crate::{
|
||||
async_engine::SpawnedFuture,
|
||||
backend::{
|
||||
Backend, Connector, ConnectorEvent, ConnectorId, ConnectorKernelId, DrmDeviceId,
|
||||
self, Backend, BackendConnectorState, BackendConnectorStateSerial, Connector,
|
||||
ConnectorEvent, ConnectorId, ConnectorKernelId, DrmDeviceId,
|
||||
},
|
||||
format::XRGB8888,
|
||||
video::drm::ConnectorType,
|
||||
},
|
||||
std::{error::Error, rc::Rc},
|
||||
|
|
@ -52,4 +54,25 @@ impl Connector for DummyOutput {
|
|||
fn effectively_locked(&self) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn state(&self) -> BackendConnectorState {
|
||||
let mode = backend::Mode {
|
||||
width: 0,
|
||||
height: 0,
|
||||
refresh_rate_millihz: 40_000,
|
||||
};
|
||||
BackendConnectorState {
|
||||
serial: BackendConnectorStateSerial::from_raw(0),
|
||||
enabled: true,
|
||||
active: false,
|
||||
mode,
|
||||
non_desktop_override: None,
|
||||
vrr: false,
|
||||
tearing: false,
|
||||
format: XRGB8888,
|
||||
color_space: Default::default(),
|
||||
eotf: Default::default(),
|
||||
gamma_lut: Default::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -867,6 +867,10 @@ impl Connector for MetalConnector {
|
|||
fb.locked
|
||||
}
|
||||
|
||||
fn state(&self) -> BackendConnectorState {
|
||||
self.display.borrow().persistent.state.borrow().clone()
|
||||
}
|
||||
|
||||
fn caps(&self) -> ConnectorCaps {
|
||||
CONCAP_CONNECTOR | CONCAP_MODE_SETTING | CONCAP_PHYSICAL_DISPLAY
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1113,6 +1113,10 @@ impl Connector for XOutput {
|
|||
true
|
||||
}
|
||||
|
||||
fn state(&self) -> BackendConnectorState {
|
||||
self.state.borrow().clone()
|
||||
}
|
||||
|
||||
fn transaction_type(&self) -> Box<dyn BackendConnectorTransactionTypeDyn> {
|
||||
Box::new(XTransactionType)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ use {
|
|||
crate::{
|
||||
acceptor::{Acceptor, AcceptorError},
|
||||
async_engine::{AsyncEngine, Phase, SpawnedFuture},
|
||||
backend::{self, Backend, BackendConnectorState, BackendConnectorStateSerial, Connector},
|
||||
backend::{Backend, Connector},
|
||||
backends::{
|
||||
dummy::{DummyBackend, DummyOutput},
|
||||
metal, x,
|
||||
|
|
@ -675,26 +675,9 @@ fn create_dummy_output(state: &Rc<State>) {
|
|||
serial_number: "".to_string(),
|
||||
});
|
||||
let persistent_state = Rc::new(PersistentOutputState::default());
|
||||
let mode = backend::Mode {
|
||||
width: 0,
|
||||
height: 0,
|
||||
refresh_rate_millihz: 40_000,
|
||||
};
|
||||
let backend_state = BackendConnectorState {
|
||||
serial: BackendConnectorStateSerial::from_raw(0),
|
||||
enabled: true,
|
||||
active: false,
|
||||
mode,
|
||||
non_desktop_override: None,
|
||||
vrr: false,
|
||||
tearing: false,
|
||||
format: XRGB8888,
|
||||
color_space: Default::default(),
|
||||
eotf: Default::default(),
|
||||
gamma_lut: Default::default(),
|
||||
};
|
||||
let id = state.connector_ids.next();
|
||||
let connector = Rc::new(DummyOutput { id }) as Rc<dyn Connector>;
|
||||
let backend_state = connector.state();
|
||||
let name = Rc::new("Dummy".to_string());
|
||||
let head_name = state.head_names.next();
|
||||
let head_state = HeadState {
|
||||
|
|
|
|||
|
|
@ -37,7 +37,15 @@ use {
|
|||
},
|
||||
ahash::AHashMap,
|
||||
bstr::ByteSlice,
|
||||
std::{any::Any, cell::Cell, error::Error, io, os::unix::ffi::OsStrExt, pin::Pin, rc::Rc},
|
||||
std::{
|
||||
any::Any,
|
||||
cell::{Cell, RefCell},
|
||||
error::Error,
|
||||
io,
|
||||
os::unix::ffi::OsStrExt,
|
||||
pin::Pin,
|
||||
rc::Rc,
|
||||
},
|
||||
thiserror::Error,
|
||||
uapi::c,
|
||||
};
|
||||
|
|
@ -75,6 +83,24 @@ pub struct TestBackend {
|
|||
impl TestBackend {
|
||||
pub fn new(state: &Rc<State>, future: TestFuture) -> Self {
|
||||
state.set_backend_idle(false);
|
||||
let mode = Mode {
|
||||
width: 800,
|
||||
height: 600,
|
||||
refresh_rate_millihz: 60_000,
|
||||
};
|
||||
let bcs = BackendConnectorState {
|
||||
serial: state.backend_connector_state_serials.next(),
|
||||
enabled: true,
|
||||
active: true,
|
||||
mode,
|
||||
non_desktop_override: None,
|
||||
vrr: false,
|
||||
tearing: false,
|
||||
format: XRGB8888,
|
||||
color_space: Default::default(),
|
||||
eotf: Default::default(),
|
||||
gamma_lut: Default::default(),
|
||||
};
|
||||
let default_connector = Rc::new(TestConnector {
|
||||
id: state.connector_ids.next(),
|
||||
kernel_id: ConnectorKernelId {
|
||||
|
|
@ -85,6 +111,7 @@ impl TestBackend {
|
|||
feedback: Default::default(),
|
||||
idle: Default::default(),
|
||||
damage_calls: NumCell::new(0),
|
||||
state: RefCell::new(bcs.clone()),
|
||||
});
|
||||
let default_mouse = Rc::new(TestBackendMouse {
|
||||
common: TestInputDeviceCommon {
|
||||
|
|
@ -120,11 +147,6 @@ impl TestBackend {
|
|||
state: state.clone(),
|
||||
},
|
||||
});
|
||||
let mode = Mode {
|
||||
width: 800,
|
||||
height: 600,
|
||||
refresh_rate_millihz: 60_000,
|
||||
};
|
||||
let default_monitor_info = MonitorInfo {
|
||||
modes: Some(vec![mode]),
|
||||
output_id: Rc::new(OutputId {
|
||||
|
|
@ -142,19 +164,7 @@ impl TestBackend {
|
|||
color_spaces: vec![],
|
||||
primaries: Primaries::SRGB,
|
||||
luminance: None,
|
||||
state: BackendConnectorState {
|
||||
serial: state.backend_connector_state_serials.next(),
|
||||
enabled: true,
|
||||
active: true,
|
||||
mode,
|
||||
non_desktop_override: None,
|
||||
vrr: false,
|
||||
tearing: false,
|
||||
format: XRGB8888,
|
||||
color_space: Default::default(),
|
||||
eotf: Default::default(),
|
||||
gamma_lut: Default::default(),
|
||||
},
|
||||
state: bcs,
|
||||
};
|
||||
Self {
|
||||
state: state.clone(),
|
||||
|
|
@ -325,6 +335,7 @@ pub struct TestConnector {
|
|||
pub feedback: CloneCell<Option<Rc<DrmFeedback>>>,
|
||||
pub idle: TEEH<bool>,
|
||||
pub damage_calls: NumCell<u32>,
|
||||
pub state: RefCell<BackendConnectorState>,
|
||||
}
|
||||
|
||||
impl Connector for TestConnector {
|
||||
|
|
@ -357,6 +368,10 @@ impl Connector for TestConnector {
|
|||
true
|
||||
}
|
||||
|
||||
fn state(&self) -> BackendConnectorState {
|
||||
self.state.borrow().clone()
|
||||
}
|
||||
|
||||
fn drm_feedback(&self) -> Option<Rc<DrmFeedback>> {
|
||||
self.feedback.get()
|
||||
}
|
||||
|
|
@ -404,6 +419,7 @@ impl BackendPreparedConnectorTransaction for TestBackendTransaction {
|
|||
self: Box<Self>,
|
||||
) -> Result<Box<dyn BackendAppliedConnectorTransaction>, BackendConnectorTransactionError> {
|
||||
for (c, s) in self.connectors.values() {
|
||||
*c.state.borrow_mut() = s.clone();
|
||||
c.idle.push(!s.active);
|
||||
}
|
||||
Ok(self)
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ use {
|
|||
utils::numcell::NumCell,
|
||||
video::drm::ConnectorType,
|
||||
},
|
||||
std::rc::Rc,
|
||||
std::{cell::RefCell, rc::Rc},
|
||||
};
|
||||
|
||||
testcase!();
|
||||
|
|
@ -27,6 +27,19 @@ async fn test(run: Rc<TestRun>) -> TestResult {
|
|||
bail!("no dummy output");
|
||||
};
|
||||
|
||||
let bcs = BackendConnectorState {
|
||||
serial: run.state.backend_connector_state_serials.next(),
|
||||
enabled: true,
|
||||
active: true,
|
||||
mode: Default::default(),
|
||||
non_desktop_override: None,
|
||||
vrr: false,
|
||||
tearing: false,
|
||||
format: XRGB8888,
|
||||
color_space: Default::default(),
|
||||
eotf: Default::default(),
|
||||
gamma_lut: Default::default(),
|
||||
};
|
||||
let new_connector = Rc::new(TestConnector {
|
||||
id: run.state.connector_ids.next(),
|
||||
kernel_id: ConnectorKernelId {
|
||||
|
|
@ -37,6 +50,7 @@ async fn test(run: Rc<TestRun>) -> TestResult {
|
|||
feedback: Default::default(),
|
||||
idle: Default::default(),
|
||||
damage_calls: NumCell::new(0),
|
||||
state: RefCell::new(bcs.clone()),
|
||||
});
|
||||
let new_monitor_info = MonitorInfo {
|
||||
modes: Some(vec![]),
|
||||
|
|
@ -55,19 +69,7 @@ async fn test(run: Rc<TestRun>) -> TestResult {
|
|||
color_spaces: vec![],
|
||||
primaries: Primaries::SRGB,
|
||||
luminance: None,
|
||||
state: BackendConnectorState {
|
||||
serial: run.state.backend_connector_state_serials.next(),
|
||||
enabled: true,
|
||||
active: true,
|
||||
mode: Default::default(),
|
||||
non_desktop_override: None,
|
||||
vrr: false,
|
||||
tearing: false,
|
||||
format: XRGB8888,
|
||||
color_space: Default::default(),
|
||||
eotf: Default::default(),
|
||||
gamma_lut: Default::default(),
|
||||
},
|
||||
state: bcs,
|
||||
};
|
||||
run.backend
|
||||
.state
|
||||
|
|
|
|||
|
|
@ -1,11 +1,7 @@
|
|||
use {
|
||||
crate::{
|
||||
backend::{
|
||||
BackendConnectorState, BackendConnectorStateSerial, Connector, ConnectorEvent,
|
||||
ConnectorId, MonitorInfo,
|
||||
},
|
||||
backend::{Connector, ConnectorEvent, ConnectorId, MonitorInfo},
|
||||
control_center::CCI_OUTPUTS,
|
||||
format::XRGB8888,
|
||||
globals::GlobalName,
|
||||
ifs::{
|
||||
head_management::{HeadManagers, HeadState},
|
||||
|
|
@ -35,19 +31,7 @@ pub fn handle(state: &Rc<State>, connector: &Rc<dyn Connector>) {
|
|||
_ => panic!("connector's drm device does not exist"),
|
||||
};
|
||||
}
|
||||
let backend_state = BackendConnectorState {
|
||||
serial: BackendConnectorStateSerial::from_raw(0),
|
||||
enabled: true,
|
||||
active: false,
|
||||
mode: Default::default(),
|
||||
non_desktop_override: None,
|
||||
vrr: false,
|
||||
tearing: false,
|
||||
format: XRGB8888,
|
||||
color_space: Default::default(),
|
||||
eotf: Default::default(),
|
||||
gamma_lut: None,
|
||||
};
|
||||
let backend_state = connector.state();
|
||||
let id = connector.id();
|
||||
let name = Rc::new(connector.kernel_id().to_string());
|
||||
let head_state = HeadState {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue