gdk4/auto/
gl_texture_builder.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5#[cfg(feature = "v4_16")]
6#[cfg_attr(docsrs, doc(cfg(feature = "v4_16")))]
7use crate::ColorState;
8use crate::{ffi, GLContext, MemoryFormat, Texture};
9use glib::translate::*;
10
11glib::wrapper! {
12    /// Constructs [`Texture`][crate::Texture] objects from GL textures.
13    ///
14    /// The operation is quite simple: Create a texture builder, set all the necessary
15    /// properties - keep in mind that the properties [`context`][struct@crate::GLTextureBuilder#context],
16    /// [`id`][struct@crate::GLTextureBuilder#id], [`width`][struct@crate::GLTextureBuilder#width], and
17    /// [`height`][struct@crate::GLTextureBuilder#height] are mandatory - and then call
18    /// [`build()`][Self::build()] to create the new texture.
19    ///
20    /// [`GLTextureBuilder`][crate::GLTextureBuilder] can be used for quick one-shot construction of
21    /// textures as well as kept around and reused to construct multiple textures.
22    ///
23    /// ## Properties
24    ///
25    ///
26    /// #### `color-state`
27    ///  The color state of the texture.
28    ///
29    /// Readable | Writeable
30    ///
31    ///
32    /// #### `context`
33    ///  The context owning the texture.
34    ///
35    /// Readable | Writeable
36    ///
37    ///
38    /// #### `format`
39    ///  The format when downloading the texture.
40    ///
41    /// Readable | Writeable
42    ///
43    ///
44    /// #### `has-mipmap`
45    ///  If the texture has a mipmap.
46    ///
47    /// Readable | Writeable
48    ///
49    ///
50    /// #### `height`
51    ///  The height of the texture.
52    ///
53    /// Readable | Writeable
54    ///
55    ///
56    /// #### `id`
57    ///  The texture ID to use.
58    ///
59    /// Readable | Writeable
60    ///
61    ///
62    /// #### `sync`
63    ///  An optional `GLSync` object.
64    ///
65    /// If this is set, GTK will wait on it before using the texture.
66    ///
67    /// Readable | Writeable
68    ///
69    ///
70    /// #### `update-region`
71    ///  The update region for [`update-texture`][struct@crate::GLTextureBuilder#update-texture].
72    ///
73    /// Readable | Writeable
74    ///
75    ///
76    /// #### `update-texture`
77    ///  The texture [`update-region`][struct@crate::GLTextureBuilder#update-region] is an update for.
78    ///
79    /// Readable | Writeable
80    ///
81    ///
82    /// #### `width`
83    ///  The width of the texture.
84    ///
85    /// Readable | Writeable
86    #[doc(alias = "GdkGLTextureBuilder")]
87    pub struct GLTextureBuilder(Object<ffi::GdkGLTextureBuilder, ffi::GdkGLTextureBuilderClass>);
88
89    match fn {
90        type_ => || ffi::gdk_gl_texture_builder_get_type(),
91    }
92}
93
94impl GLTextureBuilder {
95    /// Creates a new texture builder.
96    ///
97    /// # Returns
98    ///
99    /// the new `GdkTextureBuilder`
100    #[doc(alias = "gdk_gl_texture_builder_new")]
101    pub fn new() -> GLTextureBuilder {
102        assert_initialized_main_thread!();
103        unsafe { from_glib_full(ffi::gdk_gl_texture_builder_new()) }
104    }
105
106    /// Gets the color state previously set via gdk_gl_texture_builder_set_color_state().
107    ///
108    /// # Returns
109    ///
110    /// the color state
111    #[cfg(feature = "v4_16")]
112    #[cfg_attr(docsrs, doc(cfg(feature = "v4_16")))]
113    #[doc(alias = "gdk_gl_texture_builder_get_color_state")]
114    #[doc(alias = "get_color_state")]
115    #[doc(alias = "color-state")]
116    pub fn color_state(&self) -> ColorState {
117        unsafe {
118            from_glib_none(ffi::gdk_gl_texture_builder_get_color_state(
119                self.to_glib_none().0,
120            ))
121        }
122    }
123
124    /// Gets the context previously set via gdk_gl_texture_builder_set_context() or
125    /// [`None`] if none was set.
126    ///
127    /// # Returns
128    ///
129    /// The context
130    #[doc(alias = "gdk_gl_texture_builder_get_context")]
131    #[doc(alias = "get_context")]
132    pub fn context(&self) -> Option<GLContext> {
133        unsafe {
134            from_glib_none(ffi::gdk_gl_texture_builder_get_context(
135                self.to_glib_none().0,
136            ))
137        }
138    }
139
140    /// Gets the format previously set via gdk_gl_texture_builder_set_format().
141    ///
142    /// # Returns
143    ///
144    /// The format
145    #[doc(alias = "gdk_gl_texture_builder_get_format")]
146    #[doc(alias = "get_format")]
147    pub fn format(&self) -> MemoryFormat {
148        unsafe {
149            from_glib(ffi::gdk_gl_texture_builder_get_format(
150                self.to_glib_none().0,
151            ))
152        }
153    }
154
155    /// Gets whether the texture has a mipmap.
156    ///
157    /// # Returns
158    ///
159    /// Whether the texture has a mipmap
160    #[doc(alias = "gdk_gl_texture_builder_get_has_mipmap")]
161    #[doc(alias = "get_has_mipmap")]
162    #[doc(alias = "has-mipmap")]
163    pub fn has_mipmap(&self) -> bool {
164        unsafe {
165            from_glib(ffi::gdk_gl_texture_builder_get_has_mipmap(
166                self.to_glib_none().0,
167            ))
168        }
169    }
170
171    /// Gets the height previously set via gdk_gl_texture_builder_set_height() or
172    /// 0 if the height wasn't set.
173    ///
174    /// # Returns
175    ///
176    /// The height
177    #[doc(alias = "gdk_gl_texture_builder_get_height")]
178    #[doc(alias = "get_height")]
179    pub fn height(&self) -> i32 {
180        unsafe { ffi::gdk_gl_texture_builder_get_height(self.to_glib_none().0) }
181    }
182
183    /// Gets the texture id previously set via gdk_gl_texture_builder_set_id() or
184    /// 0 if the id wasn't set.
185    ///
186    /// # Returns
187    ///
188    /// The id
189    #[doc(alias = "gdk_gl_texture_builder_get_id")]
190    #[doc(alias = "get_id")]
191    pub fn id(&self) -> u32 {
192        unsafe { ffi::gdk_gl_texture_builder_get_id(self.to_glib_none().0) }
193    }
194
195    /// Gets the region previously set via gdk_gl_texture_builder_set_update_region() or
196    /// [`None`] if none was set.
197    ///
198    /// # Returns
199    ///
200    /// The region
201    #[doc(alias = "gdk_gl_texture_builder_get_update_region")]
202    #[doc(alias = "get_update_region")]
203    #[doc(alias = "update-region")]
204    pub fn update_region(&self) -> Option<cairo::Region> {
205        unsafe {
206            from_glib_none(ffi::gdk_gl_texture_builder_get_update_region(
207                self.to_glib_none().0,
208            ))
209        }
210    }
211
212    /// Gets the texture previously set via gdk_gl_texture_builder_set_update_texture() or
213    /// [`None`] if none was set.
214    ///
215    /// # Returns
216    ///
217    /// The texture
218    #[doc(alias = "gdk_gl_texture_builder_get_update_texture")]
219    #[doc(alias = "get_update_texture")]
220    #[doc(alias = "update-texture")]
221    pub fn update_texture(&self) -> Option<Texture> {
222        unsafe {
223            from_glib_none(ffi::gdk_gl_texture_builder_get_update_texture(
224                self.to_glib_none().0,
225            ))
226        }
227    }
228
229    /// Gets the width previously set via gdk_gl_texture_builder_set_width() or
230    /// 0 if the width wasn't set.
231    ///
232    /// # Returns
233    ///
234    /// The width
235    #[doc(alias = "gdk_gl_texture_builder_get_width")]
236    #[doc(alias = "get_width")]
237    pub fn width(&self) -> i32 {
238        unsafe { ffi::gdk_gl_texture_builder_get_width(self.to_glib_none().0) }
239    }
240}
241
242#[cfg(feature = "v4_12")]
243#[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
244impl Default for GLTextureBuilder {
245    fn default() -> Self {
246        Self::new()
247    }
248}
249
250unsafe impl Send for GLTextureBuilder {}
251unsafe impl Sync for GLTextureBuilder {}