@@ -8,6 +8,36 @@ use wayland_server::{
8
8
protocol:: wl_surface:: WlSurface , Client , DataInit , Dispatch , DisplayHandle , GlobalDispatch , New , Resource ,
9
9
} ;
10
10
11
+ use super :: compositor:: { with_states, Cacheable } ;
12
+
13
+ #[ derive( Clone ) ]
14
+ struct SyncPoint {
15
+ fd : Arc < OwnedFd > ,
16
+ point : u64 ,
17
+ }
18
+
19
+ #[ derive( Default ) ]
20
+ struct DrmSyncobjCachedState {
21
+ acquire_point : Option < SyncPoint > ,
22
+ release_point : Option < SyncPoint > ,
23
+ }
24
+
25
+ impl Cacheable for DrmSyncobjCachedState {
26
+ fn commit ( & mut self , _dh : & DisplayHandle ) -> Self {
27
+ Self {
28
+ acquire_point : None ,
29
+ release_point : None ,
30
+ }
31
+ }
32
+
33
+ fn merge_into ( self , into : & mut Self , _dh : & DisplayHandle ) {
34
+ // TODO need to verify that buffer, acquire point, and release point are sent together
35
+ // in one commit, or send `no_buffer`, `no_acquire_point`, `no_release_point`
36
+ into. acquire_point = self . acquire_point ;
37
+ into. release_point = self . release_point ;
38
+ }
39
+ }
40
+
11
41
pub struct DrmSyncobjState { }
12
42
13
43
impl DrmSyncobjState {
@@ -67,7 +97,7 @@ impl<D> Dispatch<WpLinuxDrmSyncobjSurfaceV1, DrmSyncobjSurfaceData, D> for DrmSy
67
97
_client : & Client ,
68
98
_resource : & WpLinuxDrmSyncobjSurfaceV1 ,
69
99
request : wp_linux_drm_syncobj_surface_v1:: Request ,
70
- _data : & DrmSyncobjSurfaceData ,
100
+ data : & DrmSyncobjSurfaceData ,
71
101
_dh : & DisplayHandle ,
72
102
data_init : & mut DataInit < ' _ , D > ,
73
103
) {
@@ -78,16 +108,28 @@ impl<D> Dispatch<WpLinuxDrmSyncobjSurfaceV1, DrmSyncobjSurfaceData, D> for DrmSy
78
108
point_hi,
79
109
point_lo,
80
110
} => {
81
- let fd = & timeline. data :: < DrmSyncobjTimelineData > ( ) . unwrap ( ) . fd ;
82
- let point = ( ( point_hi as u64 ) << 32 ) + ( point_lo as u64 ) ;
111
+ let sync_point = SyncPoint {
112
+ fd : timeline. data :: < DrmSyncobjTimelineData > ( ) . unwrap ( ) . fd . clone ( ) ,
113
+ point : ( ( point_hi as u64 ) << 32 ) + ( point_lo as u64 ) ,
114
+ } ;
115
+ with_states ( & data. surface , |states| {
116
+ let mut cached_state = states. cached_state . pending :: < DrmSyncobjCachedState > ( ) ;
117
+ cached_state. acquire_point = Some ( sync_point) ;
118
+ } ) ;
83
119
}
84
120
wp_linux_drm_syncobj_surface_v1:: Request :: SetReleasePoint {
85
121
timeline,
86
122
point_hi,
87
123
point_lo,
88
124
} => {
89
- let fd = & timeline. data :: < DrmSyncobjTimelineData > ( ) . unwrap ( ) . fd ;
90
- let point = ( ( point_hi as u64 ) << 32 ) + ( point_lo as u64 ) ;
125
+ let sync_point = SyncPoint {
126
+ fd : timeline. data :: < DrmSyncobjTimelineData > ( ) . unwrap ( ) . fd . clone ( ) ,
127
+ point : ( ( point_hi as u64 ) << 32 ) + ( point_lo as u64 ) ,
128
+ } ;
129
+ with_states ( & data. surface , |states| {
130
+ let mut cached_state = states. cached_state . pending :: < DrmSyncobjCachedState > ( ) ;
131
+ cached_state. release_point = Some ( sync_point) ;
132
+ } ) ;
91
133
}
92
134
_ => unreachable ! ( ) ,
93
135
}
0 commit comments