@@ -15,20 +15,28 @@ use crate::wayland::compositor::{Blocker, BlockerState};
15
15
16
16
// TODO destroy handle?
17
17
/// DRM timeline syncobj
18
- #[ derive( Clone , Debug , PartialEq , Eq ) ]
18
+ #[ derive( Clone , Debug , PartialEq ) ]
19
19
pub struct DrmTimeline {
20
+ device : DrmDeviceFd ,
20
21
syncobj : drm:: control:: syncobj:: Handle ,
21
22
}
22
23
23
24
impl DrmTimeline {
24
25
/// Import DRM timeline from file descriptor
25
26
pub fn new ( device : & DrmDeviceFd , fd : BorrowedFd < ' _ > ) -> io:: Result < Self > {
26
27
Ok ( Self {
28
+ device : device. clone ( ) ,
27
29
syncobj : device. fd_to_syncobj ( fd, false ) ?,
28
30
} )
29
31
}
30
32
}
31
33
34
+ impl Drop for DrmTimeline {
35
+ fn drop ( & mut self ) {
36
+ let _ = self . device . destroy_syncobj ( self . syncobj ) ;
37
+ }
38
+ }
39
+
32
40
/// Point on a DRM timeline syncobj
33
41
#[ derive( Clone , Debug ) ]
34
42
pub struct DrmSyncPoint {
@@ -38,27 +46,28 @@ pub struct DrmSyncPoint {
38
46
39
47
impl DrmSyncPoint {
40
48
/// Create an eventfd that will be signaled by the syncpoint
41
- pub fn eventfd ( & self , device : & DrmDeviceFd ) -> io:: Result < OwnedFd > {
49
+ pub fn eventfd ( & self ) -> io:: Result < OwnedFd > {
42
50
let fd = rustix:: event:: eventfd (
43
51
0 ,
44
52
rustix:: event:: EventfdFlags :: CLOEXEC | rustix:: event:: EventfdFlags :: NONBLOCK ,
45
53
) ?;
46
54
// TODO wait_avialable?
47
- device. syncobj_eventfd ( self . timeline . syncobj , self . point , fd. as_fd ( ) , false ) ?;
55
+ self . timeline
56
+ . device
57
+ . syncobj_eventfd ( self . timeline . syncobj , self . point , fd. as_fd ( ) , false ) ?;
48
58
Ok ( fd)
49
59
}
50
60
51
61
/// Signal the syncpoint
52
- pub fn signal ( & self , device : & DrmDeviceFd ) -> io:: Result < ( ) > {
53
- device. syncobj_timeline_signal ( & [ self . timeline . syncobj ] , & [ self . point ] )
62
+ pub fn signal ( & self ) -> io:: Result < ( ) > {
63
+ self . timeline
64
+ . device
65
+ . syncobj_timeline_signal ( & [ self . timeline . syncobj ] , & [ self . point ] )
54
66
}
55
67
56
68
/// Create an [`calloop::EventSource`] and [`crate::wayland::compositor::Blocker`] for this sync point.
57
- pub fn generate_blocker (
58
- & self ,
59
- device : & DrmDeviceFd ,
60
- ) -> io:: Result < ( DrmSyncPointBlocker , DrmSyncPointSource ) > {
61
- let fd = self . eventfd ( device) ?;
69
+ pub fn generate_blocker ( & self ) -> io:: Result < ( DrmSyncPointBlocker , DrmSyncPointSource ) > {
70
+ let fd = self . eventfd ( ) ?;
62
71
let signal = Arc :: new ( AtomicBool :: new ( false ) ) ;
63
72
let blocker = DrmSyncPointBlocker {
64
73
signal : signal. clone ( ) ,
0 commit comments