Skip to main content

spice_client_glib/
gl_scanout2.rs

1use glib::translate::*;
2
3use crate::DisplayChannel;
4
5#[derive(Debug, Clone)]
6pub struct GlScanout2(ffi::SpiceGlScanout2);
7
8impl GlScanout2 {
9    #[cfg(unix)]
10    pub fn fd(&self) -> &[std::os::unix::io::RawFd; 4] {
11        &self.0.fd
12    }
13
14    pub fn width(&self) -> u32 {
15        self.0.width
16    }
17
18    pub fn height(&self) -> u32 {
19        self.0.height
20    }
21
22    pub fn offset(&self) -> &[u32; 4] {
23        &self.0.offset
24    }
25
26    pub fn stride(&self) -> &[u32; 4] {
27        &self.0.stride
28    }
29
30    pub fn num_planes(&self) -> u32 {
31        self.0.num_planes
32    }
33
34    pub fn format(&self) -> u32 {
35        self.0.format
36    }
37
38    pub fn y0_top(&self) -> bool {
39        unsafe { from_glib(self.0.y0top) }
40    }
41
42    pub fn modifier(&self) -> u64 {
43        self.0.modifier
44    }
45}
46
47impl DisplayChannel {
48    #[cfg(feature = "v0_43")]
49    #[cfg_attr(docsrs, doc(cfg(feature = "v0_43")))]
50    #[doc(alias = "spice_display_channel_get_gl_scanout2")]
51    pub fn gl_scanout2(&self) -> Option<GlScanout2> {
52        unsafe {
53            let ptr = ffi::spice_display_channel_get_gl_scanout2(self.to_glib_none().0);
54            if ptr.is_null() {
55                None
56            } else {
57                Some(GlScanout2(*ptr))
58            }
59        }
60    }
61}