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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT

use crate::GLShader;
use glib::translate::*;

glib::wrapper! {
    /// An object to build the uniforms data for a [`GLShader`][crate::GLShader].
    #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
    pub struct ShaderArgsBuilder(Shared<ffi::GskShaderArgsBuilder>);

    match fn {
        ref => |ptr| ffi::gsk_shader_args_builder_ref(ptr),
        unref => |ptr| ffi::gsk_shader_args_builder_unref(ptr),
        type_ => || ffi::gsk_shader_args_builder_get_type(),
    }
}

impl ShaderArgsBuilder {
    /// Allocates a builder that can be used to construct a new uniform data
    /// chunk.
    /// ## `shader`
    /// a [`GLShader`][crate::GLShader]
    /// ## `initial_values`
    /// optional `GBytes` with initial values
    ///
    /// # Returns
    ///
    /// The newly allocated builder, free with
    ///     `Gsk::ShaderArgsBuilder::unref()`
    #[doc(alias = "gsk_shader_args_builder_new")]
    pub fn new(shader: &GLShader, initial_values: Option<&glib::Bytes>) -> ShaderArgsBuilder {
        skip_assert_initialized!();
        unsafe {
            from_glib_full(ffi::gsk_shader_args_builder_new(
                shader.to_glib_none().0,
                initial_values.to_glib_none().0,
            ))
        }
    }

    /// Sets the value of the uniform @idx.
    ///
    /// The uniform must be of bool type.
    /// ## `idx`
    /// index of the uniform
    /// ## `value`
    /// value to set the uniform to
    #[doc(alias = "gsk_shader_args_builder_set_bool")]
    pub fn set_bool(&self, idx: i32, value: bool) {
        unsafe {
            ffi::gsk_shader_args_builder_set_bool(self.to_glib_none().0, idx, value.into_glib());
        }
    }

    /// Sets the value of the uniform @idx.
    ///
    /// The uniform must be of float type.
    /// ## `idx`
    /// index of the uniform
    /// ## `value`
    /// value to set the uniform to
    #[doc(alias = "gsk_shader_args_builder_set_float")]
    pub fn set_float(&self, idx: i32, value: f32) {
        unsafe {
            ffi::gsk_shader_args_builder_set_float(self.to_glib_none().0, idx, value);
        }
    }

    /// Sets the value of the uniform @idx.
    ///
    /// The uniform must be of int type.
    /// ## `idx`
    /// index of the uniform
    /// ## `value`
    /// value to set the uniform to
    #[doc(alias = "gsk_shader_args_builder_set_int")]
    pub fn set_int(&self, idx: i32, value: i32) {
        unsafe {
            ffi::gsk_shader_args_builder_set_int(self.to_glib_none().0, idx, value);
        }
    }

    /// Sets the value of the uniform @idx.
    ///
    /// The uniform must be of uint type.
    /// ## `idx`
    /// index of the uniform
    /// ## `value`
    /// value to set the uniform to
    #[doc(alias = "gsk_shader_args_builder_set_uint")]
    pub fn set_uint(&self, idx: i32, value: u32) {
        unsafe {
            ffi::gsk_shader_args_builder_set_uint(self.to_glib_none().0, idx, value);
        }
    }

    /// Sets the value of the uniform @idx.
    ///
    /// The uniform must be of vec2 type.
    /// ## `idx`
    /// index of the uniform
    /// ## `value`
    /// value to set the uniform too
    #[doc(alias = "gsk_shader_args_builder_set_vec2")]
    pub fn set_vec2(&self, idx: i32, value: &graphene::Vec2) {
        unsafe {
            ffi::gsk_shader_args_builder_set_vec2(
                self.to_glib_none().0,
                idx,
                value.to_glib_none().0,
            );
        }
    }

    /// Sets the value of the uniform @idx.
    ///
    /// The uniform must be of vec3 type.
    /// ## `idx`
    /// index of the uniform
    /// ## `value`
    /// value to set the uniform too
    #[doc(alias = "gsk_shader_args_builder_set_vec3")]
    pub fn set_vec3(&self, idx: i32, value: &graphene::Vec3) {
        unsafe {
            ffi::gsk_shader_args_builder_set_vec3(
                self.to_glib_none().0,
                idx,
                value.to_glib_none().0,
            );
        }
    }

    /// Sets the value of the uniform @idx.
    ///
    /// The uniform must be of vec4 type.
    /// ## `idx`
    /// index of the uniform
    /// ## `value`
    /// value to set the uniform too
    #[doc(alias = "gsk_shader_args_builder_set_vec4")]
    pub fn set_vec4(&self, idx: i32, value: &graphene::Vec4) {
        unsafe {
            ffi::gsk_shader_args_builder_set_vec4(
                self.to_glib_none().0,
                idx,
                value.to_glib_none().0,
            );
        }
    }

    /// Creates a new `GBytes` args from the current state of the
    /// given @self.
    ///
    /// Any uniforms of the shader that have not been explicitly set on
    /// the @self are zero-initialized.
    ///
    /// The given [`ShaderArgsBuilder`][crate::ShaderArgsBuilder] is reset once this function returns;
    /// you cannot call this function multiple times on the same @self instance.
    ///
    /// This function is intended primarily for bindings. C code should use
    /// `Gsk::ShaderArgsBuilder::free_to_args()`.
    ///
    /// # Returns
    ///
    /// the newly allocated buffer with
    ///   all the args added to @self
    #[doc(alias = "gsk_shader_args_builder_to_args")]
    pub fn to_args(self) -> glib::Bytes {
        unsafe { from_glib_full(ffi::gsk_shader_args_builder_to_args(self.into_glib_ptr())) }
    }
}