Skip to main content

get_registry/common/protocols/wayland/
wl_shm.rs

1//! shared memory support
2//!
3//! A singleton global object that provides support for shared
4//! memory.
5//!
6//! Clients can create wl_shm_pool objects using the create_pool
7//! request.
8//!
9//! On binding the wl_shm object one or more format events
10//! are emitted to inform clients about the valid pixel formats
11//! that can be used for buffers.
12
13use super::super::all_types::*;
14use ::wl_client::builder::prelude::*;
15
16static INTERFACE: wl_interface = wl_interface {
17    name: c"wl_shm".as_ptr(),
18    version: 2,
19    method_count: 2,
20    methods: {
21        static MESSAGES: [wl_message; 2] = [
22            wl_message {
23                name: c"create_pool".as_ptr(),
24                signature: c"nhi".as_ptr(),
25                types: {
26                    static TYPES: [Option<&'static wl_interface>; 3] =
27                        [Some(WlShmPool::WL_INTERFACE), None, None];
28                    TYPES.as_ptr().cast()
29                },
30            },
31            wl_message {
32                name: c"release".as_ptr(),
33                signature: c"".as_ptr(),
34                types: {
35                    static TYPES: [Option<&'static wl_interface>; 0] = [];
36                    TYPES.as_ptr().cast()
37                },
38            },
39        ];
40        MESSAGES.as_ptr()
41    },
42    event_count: 1,
43    events: {
44        static MESSAGES: [wl_message; 1] = [wl_message {
45            name: c"format".as_ptr(),
46            signature: c"u".as_ptr(),
47            types: {
48                static TYPES: [Option<&'static wl_interface>; 1] = [None];
49                TYPES.as_ptr().cast()
50            },
51        }];
52        MESSAGES.as_ptr()
53    },
54};
55
56/// An owned wl_shm proxy.
57///
58/// See the documentation of [the module][self] for the interface description.
59#[derive(Clone, Eq, PartialEq)]
60#[repr(transparent)]
61pub struct WlShm {
62    /// This proxy has the interface INTERFACE.
63    proxy: UntypedOwnedProxy,
64}
65
66/// A borrowed wl_shm proxy.
67///
68/// See the documentation of [the module][self] for the interface description.
69#[derive(Eq, PartialEq)]
70#[repr(transparent)]
71pub struct WlShmRef {
72    /// This proxy has the interface INTERFACE.
73    proxy: UntypedBorrowedProxy,
74}
75
76// SAFETY: WlShm is a transparent wrapper around UntypedOwnedProxy
77unsafe impl UntypedOwnedProxyWrapper for WlShm {}
78
79// SAFETY: - INTERFACE is a valid wl_interface
80//         - The only invariant is that self.proxy has a compatible interface
81unsafe impl OwnedProxy for WlShm {
82    const INTERFACE: &'static str = "wl_shm";
83    const WL_INTERFACE: &'static wl_interface = &INTERFACE;
84    const NO_OP_EVENT_HANDLER: Self::NoOpEventHandler =
85        private::EventHandler(private::NoOpEventHandler);
86    const MAX_VERSION: u32 = 2;
87
88    type Borrowed = WlShmRef;
89    type Api = private::ProxyApi;
90    type NoOpEventHandler = private::EventHandler<private::NoOpEventHandler>;
91}
92
93// SAFETY: WlShmRef is a transparent wrapper around UntypedBorrowedProxy
94unsafe impl UntypedBorrowedProxyWrapper for WlShmRef {}
95
96// SAFETY: - The only invariant is that self.proxy has a compatible interface
97unsafe impl BorrowedProxy for WlShmRef {
98    type Owned = WlShm;
99}
100
101impl Deref for WlShm {
102    type Target = WlShmRef;
103
104    fn deref(&self) -> &Self::Target {
105        proxy::low_level::deref(self)
106    }
107}
108
109mod private {
110    pub struct ProxyApi;
111
112    #[allow(dead_code)]
113    pub struct EventHandler<H>(pub(super) H);
114
115    #[allow(dead_code)]
116    pub struct NoOpEventHandler;
117}
118
119impl Debug for WlShm {
120    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
121        write!(f, "wl_shm#{}", self.proxy.id())
122    }
123}
124
125impl Debug for WlShmRef {
126    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
127        write!(f, "wl_shm#{}", self.proxy.id())
128    }
129}
130
131impl PartialEq<WlShmRef> for WlShm {
132    fn eq(&self, other: &WlShmRef) -> bool {
133        self.proxy == other.proxy
134    }
135}
136
137impl PartialEq<WlShm> for WlShmRef {
138    fn eq(&self, other: &WlShm) -> bool {
139        self.proxy == other.proxy
140    }
141}
142
143#[allow(dead_code)]
144impl WlShm {
145    /// Since when the create_pool request is available.
146    #[allow(dead_code)]
147    pub const REQ__CREATE_POOL__SINCE: u32 = 1;
148
149    /// Since when the release request is available.
150    #[allow(dead_code)]
151    pub const REQ__RELEASE__SINCE: u32 = 2;
152}
153
154#[allow(dead_code)]
155impl WlShm {
156    /// create a shm pool
157    ///
158    /// Create a new wl_shm_pool object.
159    ///
160    /// The pool can be used to create shared memory based buffer
161    /// objects.  The server will mmap size bytes of the passed file
162    /// descriptor, to use as backing memory for the pool.
163    ///
164    /// # Arguments
165    ///
166    /// - `fd`: file descriptor for the pool
167    /// - `size`: pool size, in bytes
168    #[inline]
169    pub fn create_pool(&self, fd: BorrowedFd<'_>, size: i32) -> WlShmPool {
170        let (arg1, arg2) = (fd, size);
171        let mut args = [
172            wl_argument { n: 0 },
173            wl_argument {
174                h: arg1.as_raw_fd(),
175            },
176            wl_argument { i: arg2 },
177        ];
178        // SAFETY: - self.proxy has the interface INTERFACE
179        //         - 0 < INTERFACE.method_count = 2
180        //         - the request signature is `nhi`
181        //         - OwnedProxy::WL_INTERFACE is always a valid interface
182        let data = unsafe {
183            self.proxy
184                .send_constructor::<false>(0, &mut args, WlShmPool::WL_INTERFACE, None)
185        };
186        // SAFETY: data has the interface WlShmPool::WL_INTERFACE
187        unsafe { proxy::low_level::from_untyped_owned(data) }
188    }
189
190    /// release the shm object
191    ///
192    /// Using this request a client can tell the server that it is not going to
193    /// use the shm object anymore.
194    ///
195    /// Objects created via this interface remain unaffected.
196    #[inline]
197    pub fn release(&self) {
198        let mut args = [];
199        // SAFETY: - self.proxy has the interface INTERFACE
200        //         - 1 < INTERFACE.method_count = 2
201        //         - the request signature is ``
202        unsafe {
203            self.proxy.send_destructor(1, &mut args);
204        }
205    }
206}
207
208#[allow(dead_code)]
209impl WlShmRef {
210    /// create a shm pool
211    ///
212    /// Create a new wl_shm_pool object.
213    ///
214    /// The pool can be used to create shared memory based buffer
215    /// objects.  The server will mmap size bytes of the passed file
216    /// descriptor, to use as backing memory for the pool.
217    ///
218    /// # Arguments
219    ///
220    /// - `_queue`: The queue that the returned proxy is assigned to.
221    /// - `fd`: file descriptor for the pool
222    /// - `size`: pool size, in bytes
223    #[inline]
224    pub fn create_pool(&self, _queue: &Queue, fd: BorrowedFd<'_>, size: i32) -> WlShmPool {
225        let (arg1, arg2) = (fd, size);
226        let mut args = [
227            wl_argument { n: 0 },
228            wl_argument {
229                h: arg1.as_raw_fd(),
230            },
231            wl_argument { i: arg2 },
232        ];
233        // SAFETY: - self.proxy has the interface INTERFACE
234        //         - 0 < INTERFACE.method_count = 2
235        //         - the request signature is `nhi`
236        //         - OwnedProxy::WL_INTERFACE is always a valid interface
237        let data = unsafe {
238            self.proxy
239                .send_constructor(_queue, 0, &mut args, WlShmPool::WL_INTERFACE, None)
240        };
241        // SAFETY: data has the interface WlShmPool::WL_INTERFACE
242        unsafe { proxy::low_level::from_untyped_owned(data) }
243    }
244}
245
246impl WlShm {
247    /// Since when the format event is available.
248    #[allow(dead_code)]
249    pub const EVT__FORMAT__SINCE: u32 = 1;
250}
251
252/// An event handler for [WlShm] proxies.
253#[allow(dead_code)]
254pub trait WlShmEventHandler {
255    /// pixel format description
256    ///
257    /// Informs the client about a valid pixel format that
258    /// can be used for buffers. Known formats include
259    /// argb8888 and xrgb8888.
260    ///
261    /// # Arguments
262    ///
263    /// - `format`: buffer pixel format
264    #[inline]
265    fn format(&self, _slf: &WlShmRef, format: WlShmFormat) {
266        let _ = format;
267    }
268}
269
270impl WlShmEventHandler for private::NoOpEventHandler {}
271
272// SAFETY: - INTERFACE is a valid wl_interface
273unsafe impl<H> EventHandler for private::EventHandler<H>
274where
275    H: WlShmEventHandler,
276{
277    const WL_INTERFACE: &'static wl_interface = &INTERFACE;
278
279    #[allow(unused_variables)]
280    unsafe fn handle_event(
281        &self,
282        queue: &Queue,
283        data: *mut u8,
284        slf: &UntypedBorrowedProxy,
285        opcode: u32,
286        args: *mut wl_argument,
287    ) {
288        // SAFETY: This function requires that slf has the interface INTERFACE
289        let slf = unsafe { proxy::low_level::from_untyped_borrowed::<WlShmRef>(slf) };
290        match opcode {
291            0 => {
292                // SAFETY: INTERFACE requires that there are 1 arguments
293                let args = unsafe { &*args.cast::<[wl_argument; 1]>() };
294                // SAFETY: - INTERFACE requires that args[0] contains a uint
295                let arg0 = unsafe { WlShmFormat(args[0].u) };
296                self.0.format(slf, arg0);
297            }
298            _ => {
299                invalid_opcode("wl_shm", opcode);
300            }
301        }
302    }
303}
304
305impl<H> CreateEventHandler<H> for private::ProxyApi
306where
307    H: WlShmEventHandler,
308{
309    type EventHandler = private::EventHandler<H>;
310
311    #[inline]
312    fn create_event_handler(handler: H) -> Self::EventHandler {
313        private::EventHandler(handler)
314    }
315}
316
317impl WlShm {
318    /// Since when the error.invalid_format enum variant is available.
319    #[allow(dead_code)]
320    pub const ENM__ERROR_INVALID_FORMAT__SINCE: u32 = 1;
321    /// Since when the error.invalid_stride enum variant is available.
322    #[allow(dead_code)]
323    pub const ENM__ERROR_INVALID_STRIDE__SINCE: u32 = 1;
324    /// Since when the error.invalid_fd enum variant is available.
325    #[allow(dead_code)]
326    pub const ENM__ERROR_INVALID_FD__SINCE: u32 = 1;
327
328    /// Since when the format.argb8888 enum variant is available.
329    #[allow(dead_code)]
330    pub const ENM__FORMAT_ARGB8888__SINCE: u32 = 1;
331    /// Since when the format.xrgb8888 enum variant is available.
332    #[allow(dead_code)]
333    pub const ENM__FORMAT_XRGB8888__SINCE: u32 = 1;
334    /// Since when the format.c8 enum variant is available.
335    #[allow(dead_code)]
336    pub const ENM__FORMAT_C8__SINCE: u32 = 1;
337    /// Since when the format.rgb332 enum variant is available.
338    #[allow(dead_code)]
339    pub const ENM__FORMAT_RGB332__SINCE: u32 = 1;
340    /// Since when the format.bgr233 enum variant is available.
341    #[allow(dead_code)]
342    pub const ENM__FORMAT_BGR233__SINCE: u32 = 1;
343    /// Since when the format.xrgb4444 enum variant is available.
344    #[allow(dead_code)]
345    pub const ENM__FORMAT_XRGB4444__SINCE: u32 = 1;
346    /// Since when the format.xbgr4444 enum variant is available.
347    #[allow(dead_code)]
348    pub const ENM__FORMAT_XBGR4444__SINCE: u32 = 1;
349    /// Since when the format.rgbx4444 enum variant is available.
350    #[allow(dead_code)]
351    pub const ENM__FORMAT_RGBX4444__SINCE: u32 = 1;
352    /// Since when the format.bgrx4444 enum variant is available.
353    #[allow(dead_code)]
354    pub const ENM__FORMAT_BGRX4444__SINCE: u32 = 1;
355    /// Since when the format.argb4444 enum variant is available.
356    #[allow(dead_code)]
357    pub const ENM__FORMAT_ARGB4444__SINCE: u32 = 1;
358    /// Since when the format.abgr4444 enum variant is available.
359    #[allow(dead_code)]
360    pub const ENM__FORMAT_ABGR4444__SINCE: u32 = 1;
361    /// Since when the format.rgba4444 enum variant is available.
362    #[allow(dead_code)]
363    pub const ENM__FORMAT_RGBA4444__SINCE: u32 = 1;
364    /// Since when the format.bgra4444 enum variant is available.
365    #[allow(dead_code)]
366    pub const ENM__FORMAT_BGRA4444__SINCE: u32 = 1;
367    /// Since when the format.xrgb1555 enum variant is available.
368    #[allow(dead_code)]
369    pub const ENM__FORMAT_XRGB1555__SINCE: u32 = 1;
370    /// Since when the format.xbgr1555 enum variant is available.
371    #[allow(dead_code)]
372    pub const ENM__FORMAT_XBGR1555__SINCE: u32 = 1;
373    /// Since when the format.rgbx5551 enum variant is available.
374    #[allow(dead_code)]
375    pub const ENM__FORMAT_RGBX5551__SINCE: u32 = 1;
376    /// Since when the format.bgrx5551 enum variant is available.
377    #[allow(dead_code)]
378    pub const ENM__FORMAT_BGRX5551__SINCE: u32 = 1;
379    /// Since when the format.argb1555 enum variant is available.
380    #[allow(dead_code)]
381    pub const ENM__FORMAT_ARGB1555__SINCE: u32 = 1;
382    /// Since when the format.abgr1555 enum variant is available.
383    #[allow(dead_code)]
384    pub const ENM__FORMAT_ABGR1555__SINCE: u32 = 1;
385    /// Since when the format.rgba5551 enum variant is available.
386    #[allow(dead_code)]
387    pub const ENM__FORMAT_RGBA5551__SINCE: u32 = 1;
388    /// Since when the format.bgra5551 enum variant is available.
389    #[allow(dead_code)]
390    pub const ENM__FORMAT_BGRA5551__SINCE: u32 = 1;
391    /// Since when the format.rgb565 enum variant is available.
392    #[allow(dead_code)]
393    pub const ENM__FORMAT_RGB565__SINCE: u32 = 1;
394    /// Since when the format.bgr565 enum variant is available.
395    #[allow(dead_code)]
396    pub const ENM__FORMAT_BGR565__SINCE: u32 = 1;
397    /// Since when the format.rgb888 enum variant is available.
398    #[allow(dead_code)]
399    pub const ENM__FORMAT_RGB888__SINCE: u32 = 1;
400    /// Since when the format.bgr888 enum variant is available.
401    #[allow(dead_code)]
402    pub const ENM__FORMAT_BGR888__SINCE: u32 = 1;
403    /// Since when the format.xbgr8888 enum variant is available.
404    #[allow(dead_code)]
405    pub const ENM__FORMAT_XBGR8888__SINCE: u32 = 1;
406    /// Since when the format.rgbx8888 enum variant is available.
407    #[allow(dead_code)]
408    pub const ENM__FORMAT_RGBX8888__SINCE: u32 = 1;
409    /// Since when the format.bgrx8888 enum variant is available.
410    #[allow(dead_code)]
411    pub const ENM__FORMAT_BGRX8888__SINCE: u32 = 1;
412    /// Since when the format.abgr8888 enum variant is available.
413    #[allow(dead_code)]
414    pub const ENM__FORMAT_ABGR8888__SINCE: u32 = 1;
415    /// Since when the format.rgba8888 enum variant is available.
416    #[allow(dead_code)]
417    pub const ENM__FORMAT_RGBA8888__SINCE: u32 = 1;
418    /// Since when the format.bgra8888 enum variant is available.
419    #[allow(dead_code)]
420    pub const ENM__FORMAT_BGRA8888__SINCE: u32 = 1;
421    /// Since when the format.xrgb2101010 enum variant is available.
422    #[allow(dead_code)]
423    pub const ENM__FORMAT_XRGB2101010__SINCE: u32 = 1;
424    /// Since when the format.xbgr2101010 enum variant is available.
425    #[allow(dead_code)]
426    pub const ENM__FORMAT_XBGR2101010__SINCE: u32 = 1;
427    /// Since when the format.rgbx1010102 enum variant is available.
428    #[allow(dead_code)]
429    pub const ENM__FORMAT_RGBX1010102__SINCE: u32 = 1;
430    /// Since when the format.bgrx1010102 enum variant is available.
431    #[allow(dead_code)]
432    pub const ENM__FORMAT_BGRX1010102__SINCE: u32 = 1;
433    /// Since when the format.argb2101010 enum variant is available.
434    #[allow(dead_code)]
435    pub const ENM__FORMAT_ARGB2101010__SINCE: u32 = 1;
436    /// Since when the format.abgr2101010 enum variant is available.
437    #[allow(dead_code)]
438    pub const ENM__FORMAT_ABGR2101010__SINCE: u32 = 1;
439    /// Since when the format.rgba1010102 enum variant is available.
440    #[allow(dead_code)]
441    pub const ENM__FORMAT_RGBA1010102__SINCE: u32 = 1;
442    /// Since when the format.bgra1010102 enum variant is available.
443    #[allow(dead_code)]
444    pub const ENM__FORMAT_BGRA1010102__SINCE: u32 = 1;
445    /// Since when the format.yuyv enum variant is available.
446    #[allow(dead_code)]
447    pub const ENM__FORMAT_YUYV__SINCE: u32 = 1;
448    /// Since when the format.yvyu enum variant is available.
449    #[allow(dead_code)]
450    pub const ENM__FORMAT_YVYU__SINCE: u32 = 1;
451    /// Since when the format.uyvy enum variant is available.
452    #[allow(dead_code)]
453    pub const ENM__FORMAT_UYVY__SINCE: u32 = 1;
454    /// Since when the format.vyuy enum variant is available.
455    #[allow(dead_code)]
456    pub const ENM__FORMAT_VYUY__SINCE: u32 = 1;
457    /// Since when the format.ayuv enum variant is available.
458    #[allow(dead_code)]
459    pub const ENM__FORMAT_AYUV__SINCE: u32 = 1;
460    /// Since when the format.nv12 enum variant is available.
461    #[allow(dead_code)]
462    pub const ENM__FORMAT_NV12__SINCE: u32 = 1;
463    /// Since when the format.nv21 enum variant is available.
464    #[allow(dead_code)]
465    pub const ENM__FORMAT_NV21__SINCE: u32 = 1;
466    /// Since when the format.nv16 enum variant is available.
467    #[allow(dead_code)]
468    pub const ENM__FORMAT_NV16__SINCE: u32 = 1;
469    /// Since when the format.nv61 enum variant is available.
470    #[allow(dead_code)]
471    pub const ENM__FORMAT_NV61__SINCE: u32 = 1;
472    /// Since when the format.yuv410 enum variant is available.
473    #[allow(dead_code)]
474    pub const ENM__FORMAT_YUV410__SINCE: u32 = 1;
475    /// Since when the format.yvu410 enum variant is available.
476    #[allow(dead_code)]
477    pub const ENM__FORMAT_YVU410__SINCE: u32 = 1;
478    /// Since when the format.yuv411 enum variant is available.
479    #[allow(dead_code)]
480    pub const ENM__FORMAT_YUV411__SINCE: u32 = 1;
481    /// Since when the format.yvu411 enum variant is available.
482    #[allow(dead_code)]
483    pub const ENM__FORMAT_YVU411__SINCE: u32 = 1;
484    /// Since when the format.yuv420 enum variant is available.
485    #[allow(dead_code)]
486    pub const ENM__FORMAT_YUV420__SINCE: u32 = 1;
487    /// Since when the format.yvu420 enum variant is available.
488    #[allow(dead_code)]
489    pub const ENM__FORMAT_YVU420__SINCE: u32 = 1;
490    /// Since when the format.yuv422 enum variant is available.
491    #[allow(dead_code)]
492    pub const ENM__FORMAT_YUV422__SINCE: u32 = 1;
493    /// Since when the format.yvu422 enum variant is available.
494    #[allow(dead_code)]
495    pub const ENM__FORMAT_YVU422__SINCE: u32 = 1;
496    /// Since when the format.yuv444 enum variant is available.
497    #[allow(dead_code)]
498    pub const ENM__FORMAT_YUV444__SINCE: u32 = 1;
499    /// Since when the format.yvu444 enum variant is available.
500    #[allow(dead_code)]
501    pub const ENM__FORMAT_YVU444__SINCE: u32 = 1;
502    /// Since when the format.r8 enum variant is available.
503    #[allow(dead_code)]
504    pub const ENM__FORMAT_R8__SINCE: u32 = 1;
505    /// Since when the format.r16 enum variant is available.
506    #[allow(dead_code)]
507    pub const ENM__FORMAT_R16__SINCE: u32 = 1;
508    /// Since when the format.rg88 enum variant is available.
509    #[allow(dead_code)]
510    pub const ENM__FORMAT_RG88__SINCE: u32 = 1;
511    /// Since when the format.gr88 enum variant is available.
512    #[allow(dead_code)]
513    pub const ENM__FORMAT_GR88__SINCE: u32 = 1;
514    /// Since when the format.rg1616 enum variant is available.
515    #[allow(dead_code)]
516    pub const ENM__FORMAT_RG1616__SINCE: u32 = 1;
517    /// Since when the format.gr1616 enum variant is available.
518    #[allow(dead_code)]
519    pub const ENM__FORMAT_GR1616__SINCE: u32 = 1;
520    /// Since when the format.xrgb16161616f enum variant is available.
521    #[allow(dead_code)]
522    pub const ENM__FORMAT_XRGB16161616F__SINCE: u32 = 1;
523    /// Since when the format.xbgr16161616f enum variant is available.
524    #[allow(dead_code)]
525    pub const ENM__FORMAT_XBGR16161616F__SINCE: u32 = 1;
526    /// Since when the format.argb16161616f enum variant is available.
527    #[allow(dead_code)]
528    pub const ENM__FORMAT_ARGB16161616F__SINCE: u32 = 1;
529    /// Since when the format.abgr16161616f enum variant is available.
530    #[allow(dead_code)]
531    pub const ENM__FORMAT_ABGR16161616F__SINCE: u32 = 1;
532    /// Since when the format.xyuv8888 enum variant is available.
533    #[allow(dead_code)]
534    pub const ENM__FORMAT_XYUV8888__SINCE: u32 = 1;
535    /// Since when the format.vuy888 enum variant is available.
536    #[allow(dead_code)]
537    pub const ENM__FORMAT_VUY888__SINCE: u32 = 1;
538    /// Since when the format.vuy101010 enum variant is available.
539    #[allow(dead_code)]
540    pub const ENM__FORMAT_VUY101010__SINCE: u32 = 1;
541    /// Since when the format.y210 enum variant is available.
542    #[allow(dead_code)]
543    pub const ENM__FORMAT_Y210__SINCE: u32 = 1;
544    /// Since when the format.y212 enum variant is available.
545    #[allow(dead_code)]
546    pub const ENM__FORMAT_Y212__SINCE: u32 = 1;
547    /// Since when the format.y216 enum variant is available.
548    #[allow(dead_code)]
549    pub const ENM__FORMAT_Y216__SINCE: u32 = 1;
550    /// Since when the format.y410 enum variant is available.
551    #[allow(dead_code)]
552    pub const ENM__FORMAT_Y410__SINCE: u32 = 1;
553    /// Since when the format.y412 enum variant is available.
554    #[allow(dead_code)]
555    pub const ENM__FORMAT_Y412__SINCE: u32 = 1;
556    /// Since when the format.y416 enum variant is available.
557    #[allow(dead_code)]
558    pub const ENM__FORMAT_Y416__SINCE: u32 = 1;
559    /// Since when the format.xvyu2101010 enum variant is available.
560    #[allow(dead_code)]
561    pub const ENM__FORMAT_XVYU2101010__SINCE: u32 = 1;
562    /// Since when the format.xvyu12_16161616 enum variant is available.
563    #[allow(dead_code)]
564    pub const ENM__FORMAT_XVYU12_16161616__SINCE: u32 = 1;
565    /// Since when the format.xvyu16161616 enum variant is available.
566    #[allow(dead_code)]
567    pub const ENM__FORMAT_XVYU16161616__SINCE: u32 = 1;
568    /// Since when the format.y0l0 enum variant is available.
569    #[allow(dead_code)]
570    pub const ENM__FORMAT_Y0L0__SINCE: u32 = 1;
571    /// Since when the format.x0l0 enum variant is available.
572    #[allow(dead_code)]
573    pub const ENM__FORMAT_X0L0__SINCE: u32 = 1;
574    /// Since when the format.y0l2 enum variant is available.
575    #[allow(dead_code)]
576    pub const ENM__FORMAT_Y0L2__SINCE: u32 = 1;
577    /// Since when the format.x0l2 enum variant is available.
578    #[allow(dead_code)]
579    pub const ENM__FORMAT_X0L2__SINCE: u32 = 1;
580    /// Since when the format.yuv420_8bit enum variant is available.
581    #[allow(dead_code)]
582    pub const ENM__FORMAT_YUV420_8BIT__SINCE: u32 = 1;
583    /// Since when the format.yuv420_10bit enum variant is available.
584    #[allow(dead_code)]
585    pub const ENM__FORMAT_YUV420_10BIT__SINCE: u32 = 1;
586    /// Since when the format.xrgb8888_a8 enum variant is available.
587    #[allow(dead_code)]
588    pub const ENM__FORMAT_XRGB8888_A8__SINCE: u32 = 1;
589    /// Since when the format.xbgr8888_a8 enum variant is available.
590    #[allow(dead_code)]
591    pub const ENM__FORMAT_XBGR8888_A8__SINCE: u32 = 1;
592    /// Since when the format.rgbx8888_a8 enum variant is available.
593    #[allow(dead_code)]
594    pub const ENM__FORMAT_RGBX8888_A8__SINCE: u32 = 1;
595    /// Since when the format.bgrx8888_a8 enum variant is available.
596    #[allow(dead_code)]
597    pub const ENM__FORMAT_BGRX8888_A8__SINCE: u32 = 1;
598    /// Since when the format.rgb888_a8 enum variant is available.
599    #[allow(dead_code)]
600    pub const ENM__FORMAT_RGB888_A8__SINCE: u32 = 1;
601    /// Since when the format.bgr888_a8 enum variant is available.
602    #[allow(dead_code)]
603    pub const ENM__FORMAT_BGR888_A8__SINCE: u32 = 1;
604    /// Since when the format.rgb565_a8 enum variant is available.
605    #[allow(dead_code)]
606    pub const ENM__FORMAT_RGB565_A8__SINCE: u32 = 1;
607    /// Since when the format.bgr565_a8 enum variant is available.
608    #[allow(dead_code)]
609    pub const ENM__FORMAT_BGR565_A8__SINCE: u32 = 1;
610    /// Since when the format.nv24 enum variant is available.
611    #[allow(dead_code)]
612    pub const ENM__FORMAT_NV24__SINCE: u32 = 1;
613    /// Since when the format.nv42 enum variant is available.
614    #[allow(dead_code)]
615    pub const ENM__FORMAT_NV42__SINCE: u32 = 1;
616    /// Since when the format.p210 enum variant is available.
617    #[allow(dead_code)]
618    pub const ENM__FORMAT_P210__SINCE: u32 = 1;
619    /// Since when the format.p010 enum variant is available.
620    #[allow(dead_code)]
621    pub const ENM__FORMAT_P010__SINCE: u32 = 1;
622    /// Since when the format.p012 enum variant is available.
623    #[allow(dead_code)]
624    pub const ENM__FORMAT_P012__SINCE: u32 = 1;
625    /// Since when the format.p016 enum variant is available.
626    #[allow(dead_code)]
627    pub const ENM__FORMAT_P016__SINCE: u32 = 1;
628    /// Since when the format.axbxgxrx106106106106 enum variant is available.
629    #[allow(dead_code)]
630    pub const ENM__FORMAT_AXBXGXRX106106106106__SINCE: u32 = 1;
631    /// Since when the format.nv15 enum variant is available.
632    #[allow(dead_code)]
633    pub const ENM__FORMAT_NV15__SINCE: u32 = 1;
634    /// Since when the format.q410 enum variant is available.
635    #[allow(dead_code)]
636    pub const ENM__FORMAT_Q410__SINCE: u32 = 1;
637    /// Since when the format.q401 enum variant is available.
638    #[allow(dead_code)]
639    pub const ENM__FORMAT_Q401__SINCE: u32 = 1;
640    /// Since when the format.xrgb16161616 enum variant is available.
641    #[allow(dead_code)]
642    pub const ENM__FORMAT_XRGB16161616__SINCE: u32 = 1;
643    /// Since when the format.xbgr16161616 enum variant is available.
644    #[allow(dead_code)]
645    pub const ENM__FORMAT_XBGR16161616__SINCE: u32 = 1;
646    /// Since when the format.argb16161616 enum variant is available.
647    #[allow(dead_code)]
648    pub const ENM__FORMAT_ARGB16161616__SINCE: u32 = 1;
649    /// Since when the format.abgr16161616 enum variant is available.
650    #[allow(dead_code)]
651    pub const ENM__FORMAT_ABGR16161616__SINCE: u32 = 1;
652    /// Since when the format.c1 enum variant is available.
653    #[allow(dead_code)]
654    pub const ENM__FORMAT_C1__SINCE: u32 = 1;
655    /// Since when the format.c2 enum variant is available.
656    #[allow(dead_code)]
657    pub const ENM__FORMAT_C2__SINCE: u32 = 1;
658    /// Since when the format.c4 enum variant is available.
659    #[allow(dead_code)]
660    pub const ENM__FORMAT_C4__SINCE: u32 = 1;
661    /// Since when the format.d1 enum variant is available.
662    #[allow(dead_code)]
663    pub const ENM__FORMAT_D1__SINCE: u32 = 1;
664    /// Since when the format.d2 enum variant is available.
665    #[allow(dead_code)]
666    pub const ENM__FORMAT_D2__SINCE: u32 = 1;
667    /// Since when the format.d4 enum variant is available.
668    #[allow(dead_code)]
669    pub const ENM__FORMAT_D4__SINCE: u32 = 1;
670    /// Since when the format.d8 enum variant is available.
671    #[allow(dead_code)]
672    pub const ENM__FORMAT_D8__SINCE: u32 = 1;
673    /// Since when the format.r1 enum variant is available.
674    #[allow(dead_code)]
675    pub const ENM__FORMAT_R1__SINCE: u32 = 1;
676    /// Since when the format.r2 enum variant is available.
677    #[allow(dead_code)]
678    pub const ENM__FORMAT_R2__SINCE: u32 = 1;
679    /// Since when the format.r4 enum variant is available.
680    #[allow(dead_code)]
681    pub const ENM__FORMAT_R4__SINCE: u32 = 1;
682    /// Since when the format.r10 enum variant is available.
683    #[allow(dead_code)]
684    pub const ENM__FORMAT_R10__SINCE: u32 = 1;
685    /// Since when the format.r12 enum variant is available.
686    #[allow(dead_code)]
687    pub const ENM__FORMAT_R12__SINCE: u32 = 1;
688    /// Since when the format.avuy8888 enum variant is available.
689    #[allow(dead_code)]
690    pub const ENM__FORMAT_AVUY8888__SINCE: u32 = 1;
691    /// Since when the format.xvuy8888 enum variant is available.
692    #[allow(dead_code)]
693    pub const ENM__FORMAT_XVUY8888__SINCE: u32 = 1;
694    /// Since when the format.p030 enum variant is available.
695    #[allow(dead_code)]
696    pub const ENM__FORMAT_P030__SINCE: u32 = 1;
697}
698
699/// wl_shm error values
700///
701/// These errors can be emitted in response to wl_shm requests.
702#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
703#[allow(dead_code)]
704pub struct WlShmError(pub u32);
705
706impl WlShmError {
707    /// buffer format is not known
708    #[allow(dead_code)]
709    pub const INVALID_FORMAT: Self = Self(0);
710
711    /// invalid size or stride during pool or buffer creation
712    #[allow(dead_code)]
713    pub const INVALID_STRIDE: Self = Self(1);
714
715    /// mmapping the file descriptor failed
716    #[allow(dead_code)]
717    pub const INVALID_FD: Self = Self(2);
718}
719
720impl Debug for WlShmError {
721    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
722        let name = match *self {
723            Self::INVALID_FORMAT => "INVALID_FORMAT",
724            Self::INVALID_STRIDE => "INVALID_STRIDE",
725            Self::INVALID_FD => "INVALID_FD",
726            _ => return Debug::fmt(&self.0, f),
727        };
728        f.write_str(name)
729    }
730}
731
732/// pixel formats
733///
734/// This describes the memory layout of an individual pixel.
735///
736/// All renderers should support argb8888 and xrgb8888 but any other
737/// formats are optional and may not be supported by the particular
738/// renderer in use.
739///
740/// The drm format codes match the macros defined in drm_fourcc.h, except
741/// argb8888 and xrgb8888. The formats actually supported by the compositor
742/// will be reported by the format event.
743///
744/// For all wl_shm formats and unless specified in another protocol
745/// extension, pre-multiplied alpha is used for pixel values.
746#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
747#[allow(dead_code)]
748pub struct WlShmFormat(pub u32);
749
750impl WlShmFormat {
751    /// 32-bit ARGB format, [31:0] A:R:G:B 8:8:8:8 little endian
752    #[allow(dead_code)]
753    pub const ARGB8888: Self = Self(0);
754
755    /// 32-bit RGB format, [31:0] x:R:G:B 8:8:8:8 little endian
756    #[allow(dead_code)]
757    pub const XRGB8888: Self = Self(1);
758
759    /// 8-bit color index format, [7:0] C
760    #[allow(dead_code)]
761    pub const C8: Self = Self(0x20203843);
762
763    /// 8-bit RGB format, [7:0] R:G:B 3:3:2
764    #[allow(dead_code)]
765    pub const RGB332: Self = Self(0x38424752);
766
767    /// 8-bit BGR format, [7:0] B:G:R 2:3:3
768    #[allow(dead_code)]
769    pub const BGR233: Self = Self(0x38524742);
770
771    /// 16-bit xRGB format, [15:0] x:R:G:B 4:4:4:4 little endian
772    #[allow(dead_code)]
773    pub const XRGB4444: Self = Self(0x32315258);
774
775    /// 16-bit xBGR format, [15:0] x:B:G:R 4:4:4:4 little endian
776    #[allow(dead_code)]
777    pub const XBGR4444: Self = Self(0x32314258);
778
779    /// 16-bit RGBx format, [15:0] R:G:B:x 4:4:4:4 little endian
780    #[allow(dead_code)]
781    pub const RGBX4444: Self = Self(0x32315852);
782
783    /// 16-bit BGRx format, [15:0] B:G:R:x 4:4:4:4 little endian
784    #[allow(dead_code)]
785    pub const BGRX4444: Self = Self(0x32315842);
786
787    /// 16-bit ARGB format, [15:0] A:R:G:B 4:4:4:4 little endian
788    #[allow(dead_code)]
789    pub const ARGB4444: Self = Self(0x32315241);
790
791    /// 16-bit ABGR format, [15:0] A:B:G:R 4:4:4:4 little endian
792    #[allow(dead_code)]
793    pub const ABGR4444: Self = Self(0x32314241);
794
795    /// 16-bit RBGA format, [15:0] R:G:B:A 4:4:4:4 little endian
796    #[allow(dead_code)]
797    pub const RGBA4444: Self = Self(0x32314152);
798
799    /// 16-bit BGRA format, [15:0] B:G:R:A 4:4:4:4 little endian
800    #[allow(dead_code)]
801    pub const BGRA4444: Self = Self(0x32314142);
802
803    /// 16-bit xRGB format, [15:0] x:R:G:B 1:5:5:5 little endian
804    #[allow(dead_code)]
805    pub const XRGB1555: Self = Self(0x35315258);
806
807    /// 16-bit xBGR 1555 format, [15:0] x:B:G:R 1:5:5:5 little endian
808    #[allow(dead_code)]
809    pub const XBGR1555: Self = Self(0x35314258);
810
811    /// 16-bit RGBx 5551 format, [15:0] R:G:B:x 5:5:5:1 little endian
812    #[allow(dead_code)]
813    pub const RGBX5551: Self = Self(0x35315852);
814
815    /// 16-bit BGRx 5551 format, [15:0] B:G:R:x 5:5:5:1 little endian
816    #[allow(dead_code)]
817    pub const BGRX5551: Self = Self(0x35315842);
818
819    /// 16-bit ARGB 1555 format, [15:0] A:R:G:B 1:5:5:5 little endian
820    #[allow(dead_code)]
821    pub const ARGB1555: Self = Self(0x35315241);
822
823    /// 16-bit ABGR 1555 format, [15:0] A:B:G:R 1:5:5:5 little endian
824    #[allow(dead_code)]
825    pub const ABGR1555: Self = Self(0x35314241);
826
827    /// 16-bit RGBA 5551 format, [15:0] R:G:B:A 5:5:5:1 little endian
828    #[allow(dead_code)]
829    pub const RGBA5551: Self = Self(0x35314152);
830
831    /// 16-bit BGRA 5551 format, [15:0] B:G:R:A 5:5:5:1 little endian
832    #[allow(dead_code)]
833    pub const BGRA5551: Self = Self(0x35314142);
834
835    /// 16-bit RGB 565 format, [15:0] R:G:B 5:6:5 little endian
836    #[allow(dead_code)]
837    pub const RGB565: Self = Self(0x36314752);
838
839    /// 16-bit BGR 565 format, [15:0] B:G:R 5:6:5 little endian
840    #[allow(dead_code)]
841    pub const BGR565: Self = Self(0x36314742);
842
843    /// 24-bit RGB format, [23:0] R:G:B little endian
844    #[allow(dead_code)]
845    pub const RGB888: Self = Self(0x34324752);
846
847    /// 24-bit BGR format, [23:0] B:G:R little endian
848    #[allow(dead_code)]
849    pub const BGR888: Self = Self(0x34324742);
850
851    /// 32-bit xBGR format, [31:0] x:B:G:R 8:8:8:8 little endian
852    #[allow(dead_code)]
853    pub const XBGR8888: Self = Self(0x34324258);
854
855    /// 32-bit RGBx format, [31:0] R:G:B:x 8:8:8:8 little endian
856    #[allow(dead_code)]
857    pub const RGBX8888: Self = Self(0x34325852);
858
859    /// 32-bit BGRx format, [31:0] B:G:R:x 8:8:8:8 little endian
860    #[allow(dead_code)]
861    pub const BGRX8888: Self = Self(0x34325842);
862
863    /// 32-bit ABGR format, [31:0] A:B:G:R 8:8:8:8 little endian
864    #[allow(dead_code)]
865    pub const ABGR8888: Self = Self(0x34324241);
866
867    /// 32-bit RGBA format, [31:0] R:G:B:A 8:8:8:8 little endian
868    #[allow(dead_code)]
869    pub const RGBA8888: Self = Self(0x34324152);
870
871    /// 32-bit BGRA format, [31:0] B:G:R:A 8:8:8:8 little endian
872    #[allow(dead_code)]
873    pub const BGRA8888: Self = Self(0x34324142);
874
875    /// 32-bit xRGB format, [31:0] x:R:G:B 2:10:10:10 little endian
876    #[allow(dead_code)]
877    pub const XRGB2101010: Self = Self(0x30335258);
878
879    /// 32-bit xBGR format, [31:0] x:B:G:R 2:10:10:10 little endian
880    #[allow(dead_code)]
881    pub const XBGR2101010: Self = Self(0x30334258);
882
883    /// 32-bit RGBx format, [31:0] R:G:B:x 10:10:10:2 little endian
884    #[allow(dead_code)]
885    pub const RGBX1010102: Self = Self(0x30335852);
886
887    /// 32-bit BGRx format, [31:0] B:G:R:x 10:10:10:2 little endian
888    #[allow(dead_code)]
889    pub const BGRX1010102: Self = Self(0x30335842);
890
891    /// 32-bit ARGB format, [31:0] A:R:G:B 2:10:10:10 little endian
892    #[allow(dead_code)]
893    pub const ARGB2101010: Self = Self(0x30335241);
894
895    /// 32-bit ABGR format, [31:0] A:B:G:R 2:10:10:10 little endian
896    #[allow(dead_code)]
897    pub const ABGR2101010: Self = Self(0x30334241);
898
899    /// 32-bit RGBA format, [31:0] R:G:B:A 10:10:10:2 little endian
900    #[allow(dead_code)]
901    pub const RGBA1010102: Self = Self(0x30334152);
902
903    /// 32-bit BGRA format, [31:0] B:G:R:A 10:10:10:2 little endian
904    #[allow(dead_code)]
905    pub const BGRA1010102: Self = Self(0x30334142);
906
907    /// packed YCbCr format, [31:0] Cr0:Y1:Cb0:Y0 8:8:8:8 little endian
908    #[allow(dead_code)]
909    pub const YUYV: Self = Self(0x56595559);
910
911    /// packed YCbCr format, [31:0] Cb0:Y1:Cr0:Y0 8:8:8:8 little endian
912    #[allow(dead_code)]
913    pub const YVYU: Self = Self(0x55595659);
914
915    /// packed YCbCr format, [31:0] Y1:Cr0:Y0:Cb0 8:8:8:8 little endian
916    #[allow(dead_code)]
917    pub const UYVY: Self = Self(0x59565955);
918
919    /// packed YCbCr format, [31:0] Y1:Cb0:Y0:Cr0 8:8:8:8 little endian
920    #[allow(dead_code)]
921    pub const VYUY: Self = Self(0x59555956);
922
923    /// packed AYCbCr format, [31:0] A:Y:Cb:Cr 8:8:8:8 little endian
924    #[allow(dead_code)]
925    pub const AYUV: Self = Self(0x56555941);
926
927    /// 2 plane YCbCr Cr:Cb format, 2x2 subsampled Cr:Cb plane
928    #[allow(dead_code)]
929    pub const NV12: Self = Self(0x3231564e);
930
931    /// 2 plane YCbCr Cb:Cr format, 2x2 subsampled Cb:Cr plane
932    #[allow(dead_code)]
933    pub const NV21: Self = Self(0x3132564e);
934
935    /// 2 plane YCbCr Cr:Cb format, 2x1 subsampled Cr:Cb plane
936    #[allow(dead_code)]
937    pub const NV16: Self = Self(0x3631564e);
938
939    /// 2 plane YCbCr Cb:Cr format, 2x1 subsampled Cb:Cr plane
940    #[allow(dead_code)]
941    pub const NV61: Self = Self(0x3136564e);
942
943    /// 3 plane YCbCr format, 4x4 subsampled Cb (1) and Cr (2) planes
944    #[allow(dead_code)]
945    pub const YUV410: Self = Self(0x39565559);
946
947    /// 3 plane YCbCr format, 4x4 subsampled Cr (1) and Cb (2) planes
948    #[allow(dead_code)]
949    pub const YVU410: Self = Self(0x39555659);
950
951    /// 3 plane YCbCr format, 4x1 subsampled Cb (1) and Cr (2) planes
952    #[allow(dead_code)]
953    pub const YUV411: Self = Self(0x31315559);
954
955    /// 3 plane YCbCr format, 4x1 subsampled Cr (1) and Cb (2) planes
956    #[allow(dead_code)]
957    pub const YVU411: Self = Self(0x31315659);
958
959    /// 3 plane YCbCr format, 2x2 subsampled Cb (1) and Cr (2) planes
960    #[allow(dead_code)]
961    pub const YUV420: Self = Self(0x32315559);
962
963    /// 3 plane YCbCr format, 2x2 subsampled Cr (1) and Cb (2) planes
964    #[allow(dead_code)]
965    pub const YVU420: Self = Self(0x32315659);
966
967    /// 3 plane YCbCr format, 2x1 subsampled Cb (1) and Cr (2) planes
968    #[allow(dead_code)]
969    pub const YUV422: Self = Self(0x36315559);
970
971    /// 3 plane YCbCr format, 2x1 subsampled Cr (1) and Cb (2) planes
972    #[allow(dead_code)]
973    pub const YVU422: Self = Self(0x36315659);
974
975    /// 3 plane YCbCr format, non-subsampled Cb (1) and Cr (2) planes
976    #[allow(dead_code)]
977    pub const YUV444: Self = Self(0x34325559);
978
979    /// 3 plane YCbCr format, non-subsampled Cr (1) and Cb (2) planes
980    #[allow(dead_code)]
981    pub const YVU444: Self = Self(0x34325659);
982
983    /// [7:0] R
984    #[allow(dead_code)]
985    pub const R8: Self = Self(0x20203852);
986
987    /// [15:0] R little endian
988    #[allow(dead_code)]
989    pub const R16: Self = Self(0x20363152);
990
991    /// [15:0] R:G 8:8 little endian
992    #[allow(dead_code)]
993    pub const RG88: Self = Self(0x38384752);
994
995    /// [15:0] G:R 8:8 little endian
996    #[allow(dead_code)]
997    pub const GR88: Self = Self(0x38385247);
998
999    /// [31:0] R:G 16:16 little endian
1000    #[allow(dead_code)]
1001    pub const RG1616: Self = Self(0x32334752);
1002
1003    /// [31:0] G:R 16:16 little endian
1004    #[allow(dead_code)]
1005    pub const GR1616: Self = Self(0x32335247);
1006
1007    /// [63:0] x:R:G:B 16:16:16:16 little endian
1008    #[allow(dead_code)]
1009    pub const XRGB16161616F: Self = Self(0x48345258);
1010
1011    /// [63:0] x:B:G:R 16:16:16:16 little endian
1012    #[allow(dead_code)]
1013    pub const XBGR16161616F: Self = Self(0x48344258);
1014
1015    /// [63:0] A:R:G:B 16:16:16:16 little endian
1016    #[allow(dead_code)]
1017    pub const ARGB16161616F: Self = Self(0x48345241);
1018
1019    /// [63:0] A:B:G:R 16:16:16:16 little endian
1020    #[allow(dead_code)]
1021    pub const ABGR16161616F: Self = Self(0x48344241);
1022
1023    /// [31:0] X:Y:Cb:Cr 8:8:8:8 little endian
1024    #[allow(dead_code)]
1025    pub const XYUV8888: Self = Self(0x56555958);
1026
1027    /// [23:0] Cr:Cb:Y 8:8:8 little endian
1028    #[allow(dead_code)]
1029    pub const VUY888: Self = Self(0x34325556);
1030
1031    /// Y followed by U then V, 10:10:10. Non-linear modifier only
1032    #[allow(dead_code)]
1033    pub const VUY101010: Self = Self(0x30335556);
1034
1035    /// [63:0] Cr0:0:Y1:0:Cb0:0:Y0:0 10:6:10:6:10:6:10:6 little endian per 2 Y pixels
1036    #[allow(dead_code)]
1037    pub const Y210: Self = Self(0x30313259);
1038
1039    /// [63:0] Cr0:0:Y1:0:Cb0:0:Y0:0 12:4:12:4:12:4:12:4 little endian per 2 Y pixels
1040    #[allow(dead_code)]
1041    pub const Y212: Self = Self(0x32313259);
1042
1043    /// [63:0] Cr0:Y1:Cb0:Y0 16:16:16:16 little endian per 2 Y pixels
1044    #[allow(dead_code)]
1045    pub const Y216: Self = Self(0x36313259);
1046
1047    /// [31:0] A:Cr:Y:Cb 2:10:10:10 little endian
1048    #[allow(dead_code)]
1049    pub const Y410: Self = Self(0x30313459);
1050
1051    /// [63:0] A:0:Cr:0:Y:0:Cb:0 12:4:12:4:12:4:12:4 little endian
1052    #[allow(dead_code)]
1053    pub const Y412: Self = Self(0x32313459);
1054
1055    /// [63:0] A:Cr:Y:Cb 16:16:16:16 little endian
1056    #[allow(dead_code)]
1057    pub const Y416: Self = Self(0x36313459);
1058
1059    /// [31:0] X:Cr:Y:Cb 2:10:10:10 little endian
1060    #[allow(dead_code)]
1061    pub const XVYU2101010: Self = Self(0x30335658);
1062
1063    /// [63:0] X:0:Cr:0:Y:0:Cb:0 12:4:12:4:12:4:12:4 little endian
1064    #[allow(dead_code)]
1065    pub const XVYU12_16161616: Self = Self(0x36335658);
1066
1067    /// [63:0] X:Cr:Y:Cb 16:16:16:16 little endian
1068    #[allow(dead_code)]
1069    pub const XVYU16161616: Self = Self(0x38345658);
1070
1071    /// [63:0]   A3:A2:Y3:0:Cr0:0:Y2:0:A1:A0:Y1:0:Cb0:0:Y0:0  1:1:8:2:8:2:8:2:1:1:8:2:8:2:8:2 little endian
1072    #[allow(dead_code)]
1073    pub const Y0L0: Self = Self(0x304c3059);
1074
1075    /// [63:0]   X3:X2:Y3:0:Cr0:0:Y2:0:X1:X0:Y1:0:Cb0:0:Y0:0  1:1:8:2:8:2:8:2:1:1:8:2:8:2:8:2 little endian
1076    #[allow(dead_code)]
1077    pub const X0L0: Self = Self(0x304c3058);
1078
1079    /// [63:0]   A3:A2:Y3:Cr0:Y2:A1:A0:Y1:Cb0:Y0  1:1:10:10:10:1:1:10:10:10 little endian
1080    #[allow(dead_code)]
1081    pub const Y0L2: Self = Self(0x324c3059);
1082
1083    /// [63:0]   X3:X2:Y3:Cr0:Y2:X1:X0:Y1:Cb0:Y0  1:1:10:10:10:1:1:10:10:10 little endian
1084    #[allow(dead_code)]
1085    pub const X0L2: Self = Self(0x324c3058);
1086
1087    #[allow(dead_code)]
1088    pub const YUV420_8BIT: Self = Self(0x38305559);
1089
1090    #[allow(dead_code)]
1091    pub const YUV420_10BIT: Self = Self(0x30315559);
1092
1093    #[allow(dead_code)]
1094    pub const XRGB8888_A8: Self = Self(0x38415258);
1095
1096    #[allow(dead_code)]
1097    pub const XBGR8888_A8: Self = Self(0x38414258);
1098
1099    #[allow(dead_code)]
1100    pub const RGBX8888_A8: Self = Self(0x38415852);
1101
1102    #[allow(dead_code)]
1103    pub const BGRX8888_A8: Self = Self(0x38415842);
1104
1105    #[allow(dead_code)]
1106    pub const RGB888_A8: Self = Self(0x38413852);
1107
1108    #[allow(dead_code)]
1109    pub const BGR888_A8: Self = Self(0x38413842);
1110
1111    #[allow(dead_code)]
1112    pub const RGB565_A8: Self = Self(0x38413552);
1113
1114    #[allow(dead_code)]
1115    pub const BGR565_A8: Self = Self(0x38413542);
1116
1117    /// non-subsampled Cr:Cb plane
1118    #[allow(dead_code)]
1119    pub const NV24: Self = Self(0x3432564e);
1120
1121    /// non-subsampled Cb:Cr plane
1122    #[allow(dead_code)]
1123    pub const NV42: Self = Self(0x3234564e);
1124
1125    /// 2x1 subsampled Cr:Cb plane, 10 bit per channel
1126    #[allow(dead_code)]
1127    pub const P210: Self = Self(0x30313250);
1128
1129    /// 2x2 subsampled Cr:Cb plane 10 bits per channel
1130    #[allow(dead_code)]
1131    pub const P010: Self = Self(0x30313050);
1132
1133    /// 2x2 subsampled Cr:Cb plane 12 bits per channel
1134    #[allow(dead_code)]
1135    pub const P012: Self = Self(0x32313050);
1136
1137    /// 2x2 subsampled Cr:Cb plane 16 bits per channel
1138    #[allow(dead_code)]
1139    pub const P016: Self = Self(0x36313050);
1140
1141    /// [63:0] A:x:B:x:G:x:R:x 10:6:10:6:10:6:10:6 little endian
1142    #[allow(dead_code)]
1143    pub const AXBXGXRX106106106106: Self = Self(0x30314241);
1144
1145    /// 2x2 subsampled Cr:Cb plane
1146    #[allow(dead_code)]
1147    pub const NV15: Self = Self(0x3531564e);
1148
1149    #[allow(dead_code)]
1150    pub const Q410: Self = Self(0x30313451);
1151
1152    #[allow(dead_code)]
1153    pub const Q401: Self = Self(0x31303451);
1154
1155    /// [63:0] x:R:G:B 16:16:16:16 little endian
1156    #[allow(dead_code)]
1157    pub const XRGB16161616: Self = Self(0x38345258);
1158
1159    /// [63:0] x:B:G:R 16:16:16:16 little endian
1160    #[allow(dead_code)]
1161    pub const XBGR16161616: Self = Self(0x38344258);
1162
1163    /// [63:0] A:R:G:B 16:16:16:16 little endian
1164    #[allow(dead_code)]
1165    pub const ARGB16161616: Self = Self(0x38345241);
1166
1167    /// [63:0] A:B:G:R 16:16:16:16 little endian
1168    #[allow(dead_code)]
1169    pub const ABGR16161616: Self = Self(0x38344241);
1170
1171    /// [7:0] C0:C1:C2:C3:C4:C5:C6:C7 1:1:1:1:1:1:1:1 eight pixels/byte
1172    #[allow(dead_code)]
1173    pub const C1: Self = Self(0x20203143);
1174
1175    /// [7:0] C0:C1:C2:C3 2:2:2:2 four pixels/byte
1176    #[allow(dead_code)]
1177    pub const C2: Self = Self(0x20203243);
1178
1179    /// [7:0] C0:C1 4:4 two pixels/byte
1180    #[allow(dead_code)]
1181    pub const C4: Self = Self(0x20203443);
1182
1183    /// [7:0] D0:D1:D2:D3:D4:D5:D6:D7 1:1:1:1:1:1:1:1 eight pixels/byte
1184    #[allow(dead_code)]
1185    pub const D1: Self = Self(0x20203144);
1186
1187    /// [7:0] D0:D1:D2:D3 2:2:2:2 four pixels/byte
1188    #[allow(dead_code)]
1189    pub const D2: Self = Self(0x20203244);
1190
1191    /// [7:0] D0:D1 4:4 two pixels/byte
1192    #[allow(dead_code)]
1193    pub const D4: Self = Self(0x20203444);
1194
1195    /// [7:0] D
1196    #[allow(dead_code)]
1197    pub const D8: Self = Self(0x20203844);
1198
1199    /// [7:0] R0:R1:R2:R3:R4:R5:R6:R7 1:1:1:1:1:1:1:1 eight pixels/byte
1200    #[allow(dead_code)]
1201    pub const R1: Self = Self(0x20203152);
1202
1203    /// [7:0] R0:R1:R2:R3 2:2:2:2 four pixels/byte
1204    #[allow(dead_code)]
1205    pub const R2: Self = Self(0x20203252);
1206
1207    /// [7:0] R0:R1 4:4 two pixels/byte
1208    #[allow(dead_code)]
1209    pub const R4: Self = Self(0x20203452);
1210
1211    /// [15:0] x:R 6:10 little endian
1212    #[allow(dead_code)]
1213    pub const R10: Self = Self(0x20303152);
1214
1215    /// [15:0] x:R 4:12 little endian
1216    #[allow(dead_code)]
1217    pub const R12: Self = Self(0x20323152);
1218
1219    /// [31:0] A:Cr:Cb:Y 8:8:8:8 little endian
1220    #[allow(dead_code)]
1221    pub const AVUY8888: Self = Self(0x59555641);
1222
1223    /// [31:0] X:Cr:Cb:Y 8:8:8:8 little endian
1224    #[allow(dead_code)]
1225    pub const XVUY8888: Self = Self(0x59555658);
1226
1227    /// 2x2 subsampled Cr:Cb plane 10 bits per channel packed
1228    #[allow(dead_code)]
1229    pub const P030: Self = Self(0x30333050);
1230}
1231
1232impl Debug for WlShmFormat {
1233    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
1234        let name = match *self {
1235            Self::ARGB8888 => "ARGB8888",
1236            Self::XRGB8888 => "XRGB8888",
1237            Self::C8 => "C8",
1238            Self::RGB332 => "RGB332",
1239            Self::BGR233 => "BGR233",
1240            Self::XRGB4444 => "XRGB4444",
1241            Self::XBGR4444 => "XBGR4444",
1242            Self::RGBX4444 => "RGBX4444",
1243            Self::BGRX4444 => "BGRX4444",
1244            Self::ARGB4444 => "ARGB4444",
1245            Self::ABGR4444 => "ABGR4444",
1246            Self::RGBA4444 => "RGBA4444",
1247            Self::BGRA4444 => "BGRA4444",
1248            Self::XRGB1555 => "XRGB1555",
1249            Self::XBGR1555 => "XBGR1555",
1250            Self::RGBX5551 => "RGBX5551",
1251            Self::BGRX5551 => "BGRX5551",
1252            Self::ARGB1555 => "ARGB1555",
1253            Self::ABGR1555 => "ABGR1555",
1254            Self::RGBA5551 => "RGBA5551",
1255            Self::BGRA5551 => "BGRA5551",
1256            Self::RGB565 => "RGB565",
1257            Self::BGR565 => "BGR565",
1258            Self::RGB888 => "RGB888",
1259            Self::BGR888 => "BGR888",
1260            Self::XBGR8888 => "XBGR8888",
1261            Self::RGBX8888 => "RGBX8888",
1262            Self::BGRX8888 => "BGRX8888",
1263            Self::ABGR8888 => "ABGR8888",
1264            Self::RGBA8888 => "RGBA8888",
1265            Self::BGRA8888 => "BGRA8888",
1266            Self::XRGB2101010 => "XRGB2101010",
1267            Self::XBGR2101010 => "XBGR2101010",
1268            Self::RGBX1010102 => "RGBX1010102",
1269            Self::BGRX1010102 => "BGRX1010102",
1270            Self::ARGB2101010 => "ARGB2101010",
1271            Self::ABGR2101010 => "ABGR2101010",
1272            Self::RGBA1010102 => "RGBA1010102",
1273            Self::BGRA1010102 => "BGRA1010102",
1274            Self::YUYV => "YUYV",
1275            Self::YVYU => "YVYU",
1276            Self::UYVY => "UYVY",
1277            Self::VYUY => "VYUY",
1278            Self::AYUV => "AYUV",
1279            Self::NV12 => "NV12",
1280            Self::NV21 => "NV21",
1281            Self::NV16 => "NV16",
1282            Self::NV61 => "NV61",
1283            Self::YUV410 => "YUV410",
1284            Self::YVU410 => "YVU410",
1285            Self::YUV411 => "YUV411",
1286            Self::YVU411 => "YVU411",
1287            Self::YUV420 => "YUV420",
1288            Self::YVU420 => "YVU420",
1289            Self::YUV422 => "YUV422",
1290            Self::YVU422 => "YVU422",
1291            Self::YUV444 => "YUV444",
1292            Self::YVU444 => "YVU444",
1293            Self::R8 => "R8",
1294            Self::R16 => "R16",
1295            Self::RG88 => "RG88",
1296            Self::GR88 => "GR88",
1297            Self::RG1616 => "RG1616",
1298            Self::GR1616 => "GR1616",
1299            Self::XRGB16161616F => "XRGB16161616F",
1300            Self::XBGR16161616F => "XBGR16161616F",
1301            Self::ARGB16161616F => "ARGB16161616F",
1302            Self::ABGR16161616F => "ABGR16161616F",
1303            Self::XYUV8888 => "XYUV8888",
1304            Self::VUY888 => "VUY888",
1305            Self::VUY101010 => "VUY101010",
1306            Self::Y210 => "Y210",
1307            Self::Y212 => "Y212",
1308            Self::Y216 => "Y216",
1309            Self::Y410 => "Y410",
1310            Self::Y412 => "Y412",
1311            Self::Y416 => "Y416",
1312            Self::XVYU2101010 => "XVYU2101010",
1313            Self::XVYU12_16161616 => "XVYU12_16161616",
1314            Self::XVYU16161616 => "XVYU16161616",
1315            Self::Y0L0 => "Y0L0",
1316            Self::X0L0 => "X0L0",
1317            Self::Y0L2 => "Y0L2",
1318            Self::X0L2 => "X0L2",
1319            Self::YUV420_8BIT => "YUV420_8BIT",
1320            Self::YUV420_10BIT => "YUV420_10BIT",
1321            Self::XRGB8888_A8 => "XRGB8888_A8",
1322            Self::XBGR8888_A8 => "XBGR8888_A8",
1323            Self::RGBX8888_A8 => "RGBX8888_A8",
1324            Self::BGRX8888_A8 => "BGRX8888_A8",
1325            Self::RGB888_A8 => "RGB888_A8",
1326            Self::BGR888_A8 => "BGR888_A8",
1327            Self::RGB565_A8 => "RGB565_A8",
1328            Self::BGR565_A8 => "BGR565_A8",
1329            Self::NV24 => "NV24",
1330            Self::NV42 => "NV42",
1331            Self::P210 => "P210",
1332            Self::P010 => "P010",
1333            Self::P012 => "P012",
1334            Self::P016 => "P016",
1335            Self::AXBXGXRX106106106106 => "AXBXGXRX106106106106",
1336            Self::NV15 => "NV15",
1337            Self::Q410 => "Q410",
1338            Self::Q401 => "Q401",
1339            Self::XRGB16161616 => "XRGB16161616",
1340            Self::XBGR16161616 => "XBGR16161616",
1341            Self::ARGB16161616 => "ARGB16161616",
1342            Self::ABGR16161616 => "ABGR16161616",
1343            Self::C1 => "C1",
1344            Self::C2 => "C2",
1345            Self::C4 => "C4",
1346            Self::D1 => "D1",
1347            Self::D2 => "D2",
1348            Self::D4 => "D4",
1349            Self::D8 => "D8",
1350            Self::R1 => "R1",
1351            Self::R2 => "R2",
1352            Self::R4 => "R4",
1353            Self::R10 => "R10",
1354            Self::R12 => "R12",
1355            Self::AVUY8888 => "AVUY8888",
1356            Self::XVUY8888 => "XVUY8888",
1357            Self::P030 => "P030",
1358            _ => return Debug::fmt(&self.0, f),
1359        };
1360        f.write_str(name)
1361    }
1362}
1363
1364/// Functional event handlers.
1365pub mod event_handlers {
1366    use super::*;
1367
1368    /// Event handler for format events.
1369    pub struct Format<F>(F);
1370    impl<F> WlShmEventHandler for Format<F>
1371    where
1372        F: Fn(&WlShmRef, WlShmFormat),
1373    {
1374        #[inline]
1375        fn format(&self, _slf: &WlShmRef, format: WlShmFormat) {
1376            self.0(_slf, format)
1377        }
1378    }
1379
1380    impl WlShm {
1381        /// Creates an event handler for format events.
1382        ///
1383        /// The event handler ignores all other events.
1384        #[allow(dead_code)]
1385        pub fn on_format<F>(f: F) -> Format<F>
1386        where
1387            F: Fn(&WlShmRef, WlShmFormat),
1388        {
1389            Format(f)
1390        }
1391    }
1392}