metal: split copy device holder
This commit is contained in:
parent
1e9ed0e568
commit
8c61a3150b
2 changed files with 35 additions and 31 deletions
|
|
@ -1,9 +1,11 @@
|
||||||
|
mod copy_device;
|
||||||
mod hardware_cursor;
|
mod hardware_cursor;
|
||||||
mod lease;
|
mod lease;
|
||||||
mod properties;
|
mod properties;
|
||||||
|
|
||||||
#[allow(unused_imports)]
|
#[allow(unused_imports)]
|
||||||
pub use {
|
pub use {
|
||||||
|
copy_device::CopyDeviceHolder,
|
||||||
hardware_cursor::{MetalHardwareCursor, MetalHardwareCursorChange},
|
hardware_cursor::{MetalHardwareCursor, MetalHardwareCursorChange},
|
||||||
lease::{MetalLease, MetalLeaseData},
|
lease::{MetalLease, MetalLeaseData},
|
||||||
properties::{DefaultProperty, TypedProperty},
|
properties::{DefaultProperty, TypedProperty},
|
||||||
|
|
@ -99,17 +101,6 @@ pub struct MetalRenderContext {
|
||||||
pub copy_device: Rc<CopyDeviceHolder>,
|
pub copy_device: Rc<CopyDeviceHolder>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct CopyDeviceHolder {
|
|
||||||
pub registry: Rc<CopyDeviceRegistry>,
|
|
||||||
pub devnum: dev_t,
|
|
||||||
pub dev: OnceCell<Option<Rc<CopyDevice>>>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Debug for CopyDeviceHolder {
|
|
||||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
|
||||||
f.debug_struct("CopyDeviceHolder").finish_non_exhaustive()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct MetalDrmDevice {
|
pub struct MetalDrmDevice {
|
||||||
pub backend: Rc<MetalBackend>,
|
pub backend: Rc<MetalBackend>,
|
||||||
|
|
@ -2447,23 +2438,3 @@ impl MetalBackend {
|
||||||
connector.schedule_present();
|
connector.schedule_present();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CopyDeviceHolder {
|
|
||||||
pub fn get(&self) -> Option<Rc<CopyDevice>> {
|
|
||||||
self.dev
|
|
||||||
.get_or_init(
|
|
||||||
|| match self.registry.get(self.devnum)?.create_device().map(Some) {
|
|
||||||
Ok(d) => d,
|
|
||||||
Err(e) => {
|
|
||||||
log::error!(
|
|
||||||
"Could not get copy device for {}: {}",
|
|
||||||
self.devnum,
|
|
||||||
ErrorFmt(e),
|
|
||||||
);
|
|
||||||
None
|
|
||||||
}
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.clone()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
33
src/backends/metal/video/copy_device.rs
Normal file
33
src/backends/metal/video/copy_device.rs
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
pub struct CopyDeviceHolder {
|
||||||
|
pub registry: Rc<CopyDeviceRegistry>,
|
||||||
|
pub devnum: dev_t,
|
||||||
|
pub dev: OnceCell<Option<Rc<CopyDevice>>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Debug for CopyDeviceHolder {
|
||||||
|
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||||
|
f.debug_struct("CopyDeviceHolder").finish_non_exhaustive()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl CopyDeviceHolder {
|
||||||
|
pub fn get(&self) -> Option<Rc<CopyDevice>> {
|
||||||
|
self.dev
|
||||||
|
.get_or_init(
|
||||||
|
|| match self.registry.get(self.devnum)?.create_device().map(Some) {
|
||||||
|
Ok(d) => d,
|
||||||
|
Err(e) => {
|
||||||
|
log::error!(
|
||||||
|
"Could not get copy device for {}: {}",
|
||||||
|
self.devnum,
|
||||||
|
ErrorFmt(e),
|
||||||
|
);
|
||||||
|
None
|
||||||
|
}
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.clone()
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue