1
0
Fork 0
forked from wry/wry

metal: split copy device holder

This commit is contained in:
kossLAN 2026-05-29 21:06:28 -04:00
parent 1e9ed0e568
commit 8c61a3150b
No known key found for this signature in database
2 changed files with 35 additions and 31 deletions

View file

@ -1,9 +1,11 @@
mod copy_device;
mod hardware_cursor;
mod lease;
mod properties;
#[allow(unused_imports)]
pub use {
copy_device::CopyDeviceHolder,
hardware_cursor::{MetalHardwareCursor, MetalHardwareCursorChange},
lease::{MetalLease, MetalLeaseData},
properties::{DefaultProperty, TypedProperty},
@ -99,17 +101,6 @@ pub struct MetalRenderContext {
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 backend: Rc<MetalBackend>,
@ -2447,23 +2438,3 @@ impl MetalBackend {
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()
}
}

View 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()
}
}