1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#![allow(
    clippy::too_many_arguments,
    clippy::let_and_return,
    clippy::from_over_into
)]

use crate::Object;

use glib::translate::*;
use std::fmt;

glib_wrapper! {
    pub struct SwapChain(Object<ffi::CoglSwapChain, SwapChainClass>) @extends Object;

    match fn {
        get_type => || ffi::cogl_swap_chain_get_gtype(),
    }
}

impl SwapChain {
    pub fn new() -> SwapChain {
        unsafe { from_glib_full(ffi::cogl_swap_chain_new()) }
    }

    pub fn set_has_alpha(&self, has_alpha: bool) {
        unsafe {
            ffi::cogl_swap_chain_set_has_alpha(self.to_glib_none().0, has_alpha as i32);
        }
    }

    pub fn set_length(&self, length: i32) {
        unsafe {
            ffi::cogl_swap_chain_set_length(self.to_glib_none().0, length);
        }
    }
}

impl Default for SwapChain {
    fn default() -> Self {
        Self::new()
    }
}

impl fmt::Display for SwapChain {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(f, "SwapChain")
    }
}