gdk4/auto/
dmabuf_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, Display, Texture};
9use glib::{
10    prelude::*,
11    signal::{connect_raw, SignalHandlerId},
12    translate::*,
13};
14use std::boxed::Box as Box_;
15
16glib::wrapper! {
17    /// Constructs [`Texture`][crate::Texture] objects from DMA buffers.
18    ///
19    /// DMA buffers are commonly called **_dma-bufs_**.
20    ///
21    /// DMA buffers are a feature of the Linux kernel to enable efficient buffer and
22    /// memory sharing between hardware such as codecs, GPUs, displays, cameras and the
23    /// kernel drivers controlling them. For example, a decoder may want its output to
24    /// be directly shared with the display server for rendering without a copy.
25    ///
26    /// Any device driver which participates in DMA buffer sharing, can do so as either
27    /// the exporter or importer of buffers (or both).
28    ///
29    /// The memory that is shared via DMA buffers is usually stored in non-system memory
30    /// (maybe in device's local memory or something else not directly accessible by the
31    /// CPU), and accessing this memory from the CPU may have higher-than-usual overhead.
32    ///
33    /// In particular for graphics data, it is not uncommon that data consists of multiple
34    /// separate blocks of memory, for example one block for each of the red, green and
35    /// blue channels. These blocks are called **_planes_**. DMA buffers can have up to
36    /// four planes. Even if the memory is a single block, the data can be organized in
37    /// multiple planes, by specifying offsets from the beginning of the data.
38    ///
39    /// DMA buffers are exposed to user-space as file descriptors allowing to pass them
40    /// between processes. If a DMA buffer has multiple planes, there is one file
41    /// descriptor per plane.
42    ///
43    /// The format of the data (for graphics data, essentially its colorspace) is described
44    /// by a 32-bit integer. These format identifiers are defined in the header file `drm_fourcc.h`
45    /// and commonly referred to as **_fourcc_** values, since they are identified by 4 ASCII
46    /// characters. Additionally, each DMA buffer has a **_modifier_**, which is a 64-bit integer
47    /// that describes driver-specific details of the memory layout, such as tiling or compression.
48    ///
49    /// For historical reasons, some producers of dma-bufs don't provide an explicit modifier, but
50    /// instead return `DMA_FORMAT_MOD_INVALID` to indicate that their modifier is **_implicit_**.
51    /// GTK tries to accommodate this situation by accepting `DMA_FORMAT_MOD_INVALID` as modifier.
52    ///
53    /// The operation of [`DmabufTextureBuilder`][crate::DmabufTextureBuilder] is quite simple: Create a texture builder,
54    /// set all the necessary properties, and then call [`build()`][Self::build()]
55    /// to create the new texture.
56    ///
57    /// The required properties for a dma-buf texture are
58    ///
59    ///  * The width and height in pixels
60    ///
61    ///  * The `fourcc` code and `modifier` which identify the format and memory layout of the dma-buf
62    ///
63    ///  * The file descriptor, offset and stride for each of the planes
64    ///
65    /// [`DmabufTextureBuilder`][crate::DmabufTextureBuilder] can be used for quick one-shot construction of
66    /// textures as well as kept around and reused to construct multiple textures.
67    ///
68    /// For further information, see
69    ///
70    /// * The Linux kernel [documentation](https://docs.kernel.org/driver-api/dma-buf.html)
71    ///
72    /// * The header file [drm_fourcc.h](https://gitlab.freedesktop.org/mesa/drm/-/blob/main/include/drm/drm_fourcc.h)
73    ///
74    /// ## Properties
75    ///
76    ///
77    /// #### `color-state`
78    ///  The color state of the texture.
79    ///
80    /// Readable | Writeable
81    ///
82    ///
83    /// #### `display`
84    ///  The display that this texture will be used on.
85    ///
86    /// Readable | Writeable
87    ///
88    ///
89    /// #### `fourcc`
90    ///  The format of the texture, as a fourcc value.
91    ///
92    /// Readable | Writeable
93    ///
94    ///
95    /// #### `height`
96    ///  The height of the texture.
97    ///
98    /// Readable | Writeable
99    ///
100    ///
101    /// #### `modifier`
102    ///  The modifier.
103    ///
104    /// Readable | Writeable
105    ///
106    ///
107    /// #### `n-planes`
108    ///  The number of planes of the texture.
109    ///
110    /// Note that you can set properties for other planes,
111    /// but they will be ignored when constructing the texture.
112    ///
113    /// Readable | Writeable
114    ///
115    ///
116    /// #### `premultiplied`
117    ///  Whether the alpha channel is premultiplied into the others.
118    ///
119    /// Only relevant if the format has alpha.
120    ///
121    /// Readable | Writeable
122    ///
123    ///
124    /// #### `update-region`
125    ///  The update region for [`update-texture`][struct@crate::DmabufTextureBuilder#update-texture].
126    ///
127    /// Readable | Writeable
128    ///
129    ///
130    /// #### `update-texture`
131    ///  The texture [`update-region`][struct@crate::DmabufTextureBuilder#update-region] is an update for.
132    ///
133    /// Readable | Writeable
134    ///
135    ///
136    /// #### `width`
137    ///  The width of the texture.
138    ///
139    /// Readable | Writeable
140    #[doc(alias = "GdkDmabufTextureBuilder")]
141    pub struct DmabufTextureBuilder(Object<ffi::GdkDmabufTextureBuilder, ffi::GdkDmabufTextureBuilderClass>);
142
143    match fn {
144        type_ => || ffi::gdk_dmabuf_texture_builder_get_type(),
145    }
146}
147
148impl DmabufTextureBuilder {
149    /// Creates a new texture builder.
150    ///
151    /// # Returns
152    ///
153    /// the new `GdkTextureBuilder`
154    #[doc(alias = "gdk_dmabuf_texture_builder_new")]
155    pub fn new() -> DmabufTextureBuilder {
156        assert_initialized_main_thread!();
157        unsafe { from_glib_full(ffi::gdk_dmabuf_texture_builder_new()) }
158    }
159
160    /// Gets the color state previously set via gdk_dmabuf_texture_builder_set_color_state().
161    ///
162    /// # Returns
163    ///
164    /// the color state
165    #[cfg(feature = "v4_16")]
166    #[cfg_attr(docsrs, doc(cfg(feature = "v4_16")))]
167    #[doc(alias = "gdk_dmabuf_texture_builder_get_color_state")]
168    #[doc(alias = "get_color_state")]
169    #[doc(alias = "color-state")]
170    pub fn color_state(&self) -> Option<ColorState> {
171        unsafe {
172            from_glib_none(ffi::gdk_dmabuf_texture_builder_get_color_state(
173                self.to_glib_none().0,
174            ))
175        }
176    }
177
178    /// Returns the display that this texture builder is
179    /// associated with.
180    ///
181    /// # Returns
182    ///
183    /// the display
184    #[doc(alias = "gdk_dmabuf_texture_builder_get_display")]
185    #[doc(alias = "get_display")]
186    pub fn display(&self) -> Display {
187        unsafe {
188            from_glib_none(ffi::gdk_dmabuf_texture_builder_get_display(
189                self.to_glib_none().0,
190            ))
191        }
192    }
193
194    /// Gets the file descriptor for a plane.
195    /// ## `plane`
196    /// the plane to get the fd for
197    ///
198    /// # Returns
199    ///
200    /// the file descriptor
201    #[doc(alias = "gdk_dmabuf_texture_builder_get_fd")]
202    #[doc(alias = "get_fd")]
203    pub fn fd(&self, plane: u32) -> i32 {
204        unsafe { ffi::gdk_dmabuf_texture_builder_get_fd(self.to_glib_none().0, plane) }
205    }
206
207    /// Gets the format previously set via gdk_dmabuf_texture_builder_set_fourcc()
208    /// or 0 if the format wasn't set.
209    ///
210    /// The format is specified as a fourcc code.
211    ///
212    /// # Returns
213    ///
214    /// The format
215    #[doc(alias = "gdk_dmabuf_texture_builder_get_fourcc")]
216    #[doc(alias = "get_fourcc")]
217    pub fn fourcc(&self) -> u32 {
218        unsafe { ffi::gdk_dmabuf_texture_builder_get_fourcc(self.to_glib_none().0) }
219    }
220
221    /// Gets the height previously set via gdk_dmabuf_texture_builder_set_height() or
222    /// 0 if the height wasn't set.
223    ///
224    /// # Returns
225    ///
226    /// The height
227    #[doc(alias = "gdk_dmabuf_texture_builder_get_height")]
228    #[doc(alias = "get_height")]
229    pub fn height(&self) -> u32 {
230        unsafe { ffi::gdk_dmabuf_texture_builder_get_height(self.to_glib_none().0) }
231    }
232
233    /// Gets the modifier value.
234    ///
235    /// # Returns
236    ///
237    /// the modifier
238    #[doc(alias = "gdk_dmabuf_texture_builder_get_modifier")]
239    #[doc(alias = "get_modifier")]
240    pub fn modifier(&self) -> u64 {
241        unsafe { ffi::gdk_dmabuf_texture_builder_get_modifier(self.to_glib_none().0) }
242    }
243
244    /// Gets the number of planes.
245    ///
246    /// # Returns
247    ///
248    /// The number of planes
249    #[doc(alias = "gdk_dmabuf_texture_builder_get_n_planes")]
250    #[doc(alias = "get_n_planes")]
251    #[doc(alias = "n-planes")]
252    pub fn n_planes(&self) -> u32 {
253        unsafe { ffi::gdk_dmabuf_texture_builder_get_n_planes(self.to_glib_none().0) }
254    }
255
256    /// Gets the offset value for a plane.
257    /// ## `plane`
258    /// the plane to get the offset for
259    ///
260    /// # Returns
261    ///
262    /// the offset
263    #[doc(alias = "gdk_dmabuf_texture_builder_get_offset")]
264    #[doc(alias = "get_offset")]
265    pub fn offset(&self, plane: u32) -> u32 {
266        unsafe { ffi::gdk_dmabuf_texture_builder_get_offset(self.to_glib_none().0, plane) }
267    }
268
269    /// Whether the data is premultiplied.
270    ///
271    /// # Returns
272    ///
273    /// whether the data is premultiplied
274    #[doc(alias = "gdk_dmabuf_texture_builder_get_premultiplied")]
275    #[doc(alias = "get_premultiplied")]
276    #[doc(alias = "premultiplied")]
277    pub fn is_premultiplied(&self) -> bool {
278        unsafe {
279            from_glib(ffi::gdk_dmabuf_texture_builder_get_premultiplied(
280                self.to_glib_none().0,
281            ))
282        }
283    }
284
285    /// Gets the stride value for a plane.
286    /// ## `plane`
287    /// the plane to get the stride for
288    ///
289    /// # Returns
290    ///
291    /// the stride
292    #[doc(alias = "gdk_dmabuf_texture_builder_get_stride")]
293    #[doc(alias = "get_stride")]
294    pub fn stride(&self, plane: u32) -> u32 {
295        unsafe { ffi::gdk_dmabuf_texture_builder_get_stride(self.to_glib_none().0, plane) }
296    }
297
298    /// Gets the region previously set via gdk_dmabuf_texture_builder_set_update_region() or
299    /// [`None`] if none was set.
300    ///
301    /// # Returns
302    ///
303    /// The region
304    #[doc(alias = "gdk_dmabuf_texture_builder_get_update_region")]
305    #[doc(alias = "get_update_region")]
306    #[doc(alias = "update-region")]
307    pub fn update_region(&self) -> Option<cairo::Region> {
308        unsafe {
309            from_glib_none(ffi::gdk_dmabuf_texture_builder_get_update_region(
310                self.to_glib_none().0,
311            ))
312        }
313    }
314
315    /// Gets the texture previously set via gdk_dmabuf_texture_builder_set_update_texture() or
316    /// [`None`] if none was set.
317    ///
318    /// # Returns
319    ///
320    /// The texture
321    #[doc(alias = "gdk_dmabuf_texture_builder_get_update_texture")]
322    #[doc(alias = "get_update_texture")]
323    #[doc(alias = "update-texture")]
324    pub fn update_texture(&self) -> Option<Texture> {
325        unsafe {
326            from_glib_none(ffi::gdk_dmabuf_texture_builder_get_update_texture(
327                self.to_glib_none().0,
328            ))
329        }
330    }
331
332    /// Gets the width previously set via gdk_dmabuf_texture_builder_set_width() or
333    /// 0 if the width wasn't set.
334    ///
335    /// # Returns
336    ///
337    /// The width
338    #[doc(alias = "gdk_dmabuf_texture_builder_get_width")]
339    #[doc(alias = "get_width")]
340    pub fn width(&self) -> u32 {
341        unsafe { ffi::gdk_dmabuf_texture_builder_get_width(self.to_glib_none().0) }
342    }
343
344    /// Sets the color state for the texture.
345    ///
346    /// By default, the colorstate is `NULL`. In that case, GTK will choose the
347    /// correct colorstate based on the format.
348    /// If you don't know what colorstates are, this is probably the right thing.
349    /// ## `color_state`
350    /// a [`ColorState`][crate::ColorState] or `NULL` to unset the colorstate.
351    #[cfg(feature = "v4_16")]
352    #[cfg_attr(docsrs, doc(cfg(feature = "v4_16")))]
353    #[doc(alias = "gdk_dmabuf_texture_builder_set_color_state")]
354    #[doc(alias = "color-state")]
355    pub fn set_color_state(&self, color_state: Option<&ColorState>) {
356        unsafe {
357            ffi::gdk_dmabuf_texture_builder_set_color_state(
358                self.to_glib_none().0,
359                color_state.to_glib_none().0,
360            );
361        }
362    }
363
364    /// Sets the display that this texture builder is
365    /// associated with.
366    ///
367    /// The display is used to determine the supported
368    /// dma-buf formats.
369    /// ## `display`
370    /// the display
371    #[doc(alias = "gdk_dmabuf_texture_builder_set_display")]
372    #[doc(alias = "display")]
373    pub fn set_display(&self, display: &impl IsA<Display>) {
374        unsafe {
375            ffi::gdk_dmabuf_texture_builder_set_display(
376                self.to_glib_none().0,
377                display.as_ref().to_glib_none().0,
378            );
379        }
380    }
381
382    /// Sets the file descriptor for a plane.
383    /// ## `plane`
384    /// the plane to set the fd for
385    /// ## `fd`
386    /// the file descriptor
387    #[doc(alias = "gdk_dmabuf_texture_builder_set_fd")]
388    pub fn set_fd(&self, plane: u32, fd: i32) {
389        unsafe {
390            ffi::gdk_dmabuf_texture_builder_set_fd(self.to_glib_none().0, plane, fd);
391        }
392    }
393
394    /// Sets the format of the texture.
395    ///
396    /// The format is specified as a fourcc code.
397    ///
398    /// The format must be set before calling [`build()`][Self::build()].
399    /// ## `fourcc`
400    /// the texture's format or 0 to unset
401    #[doc(alias = "gdk_dmabuf_texture_builder_set_fourcc")]
402    #[doc(alias = "fourcc")]
403    pub fn set_fourcc(&self, fourcc: u32) {
404        unsafe {
405            ffi::gdk_dmabuf_texture_builder_set_fourcc(self.to_glib_none().0, fourcc);
406        }
407    }
408
409    /// Sets the height of the texture.
410    ///
411    /// The height must be set before calling [`build()`][Self::build()].
412    /// ## `height`
413    /// the texture's height or 0 to unset
414    #[doc(alias = "gdk_dmabuf_texture_builder_set_height")]
415    #[doc(alias = "height")]
416    pub fn set_height(&self, height: u32) {
417        unsafe {
418            ffi::gdk_dmabuf_texture_builder_set_height(self.to_glib_none().0, height);
419        }
420    }
421
422    /// Sets the modifier.
423    /// ## `modifier`
424    /// the modifier value
425    #[doc(alias = "gdk_dmabuf_texture_builder_set_modifier")]
426    #[doc(alias = "modifier")]
427    pub fn set_modifier(&self, modifier: u64) {
428        unsafe {
429            ffi::gdk_dmabuf_texture_builder_set_modifier(self.to_glib_none().0, modifier);
430        }
431    }
432
433    /// Sets the number of planes of the texture.
434    /// ## `n_planes`
435    /// the number of planes
436    #[doc(alias = "gdk_dmabuf_texture_builder_set_n_planes")]
437    #[doc(alias = "n-planes")]
438    pub fn set_n_planes(&self, n_planes: u32) {
439        unsafe {
440            ffi::gdk_dmabuf_texture_builder_set_n_planes(self.to_glib_none().0, n_planes);
441        }
442    }
443
444    /// Sets the offset for a plane.
445    /// ## `plane`
446    /// the plane to set the offset for
447    /// ## `offset`
448    /// the offset value
449    #[doc(alias = "gdk_dmabuf_texture_builder_set_offset")]
450    pub fn set_offset(&self, plane: u32, offset: u32) {
451        unsafe {
452            ffi::gdk_dmabuf_texture_builder_set_offset(self.to_glib_none().0, plane, offset);
453        }
454    }
455
456    /// Sets whether the data is premultiplied.
457    ///
458    /// Unless otherwise specified, all formats including alpha channels are assumed
459    /// to be premultiplied.
460    /// ## `premultiplied`
461    /// whether the data is premultiplied
462    #[doc(alias = "gdk_dmabuf_texture_builder_set_premultiplied")]
463    #[doc(alias = "premultiplied")]
464    pub fn set_premultiplied(&self, premultiplied: bool) {
465        unsafe {
466            ffi::gdk_dmabuf_texture_builder_set_premultiplied(
467                self.to_glib_none().0,
468                premultiplied.into_glib(),
469            );
470        }
471    }
472
473    /// Sets the stride for a plane.
474    ///
475    /// The stride must be set for all planes before calling [`build()`][Self::build()].
476    /// ## `plane`
477    /// the plane to set the stride for
478    /// ## `stride`
479    /// the stride value
480    #[doc(alias = "gdk_dmabuf_texture_builder_set_stride")]
481    pub fn set_stride(&self, plane: u32, stride: u32) {
482        unsafe {
483            ffi::gdk_dmabuf_texture_builder_set_stride(self.to_glib_none().0, plane, stride);
484        }
485    }
486
487    /// Sets the region to be updated by this texture. Together with
488    /// [`update-texture`][struct@crate::DmabufTextureBuilder#update-texture] this describes an
489    /// update of a previous texture.
490    ///
491    /// When rendering animations of large textures, it is possible that
492    /// consecutive textures are only updating contents in parts of the texture.
493    /// It is then possible to describe this update via these two properties,
494    /// so that GTK can avoid rerendering parts that did not change.
495    ///
496    /// An example would be a screen recording where only the mouse pointer moves.
497    /// ## `region`
498    /// the region to update
499    #[doc(alias = "gdk_dmabuf_texture_builder_set_update_region")]
500    #[doc(alias = "update-region")]
501    pub fn set_update_region(&self, region: Option<&cairo::Region>) {
502        unsafe {
503            ffi::gdk_dmabuf_texture_builder_set_update_region(
504                self.to_glib_none().0,
505                mut_override(region.to_glib_none().0),
506            );
507        }
508    }
509
510    /// Sets the texture to be updated by this texture. See
511    /// [`set_update_region()`][Self::set_update_region()] for an explanation.
512    /// ## `texture`
513    /// the texture to update
514    #[doc(alias = "gdk_dmabuf_texture_builder_set_update_texture")]
515    #[doc(alias = "update-texture")]
516    pub fn set_update_texture(&self, texture: Option<&impl IsA<Texture>>) {
517        unsafe {
518            ffi::gdk_dmabuf_texture_builder_set_update_texture(
519                self.to_glib_none().0,
520                texture.map(|p| p.as_ref()).to_glib_none().0,
521            );
522        }
523    }
524
525    /// Sets the width of the texture.
526    ///
527    /// The width must be set before calling [`build()`][Self::build()].
528    /// ## `width`
529    /// The texture's width or 0 to unset
530    #[doc(alias = "gdk_dmabuf_texture_builder_set_width")]
531    #[doc(alias = "width")]
532    pub fn set_width(&self, width: u32) {
533        unsafe {
534            ffi::gdk_dmabuf_texture_builder_set_width(self.to_glib_none().0, width);
535        }
536    }
537
538    #[cfg(feature = "v4_16")]
539    #[cfg_attr(docsrs, doc(cfg(feature = "v4_16")))]
540    #[doc(alias = "color-state")]
541    pub fn connect_color_state_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
542        unsafe extern "C" fn notify_color_state_trampoline<
543            F: Fn(&DmabufTextureBuilder) + 'static,
544        >(
545            this: *mut ffi::GdkDmabufTextureBuilder,
546            _param_spec: glib::ffi::gpointer,
547            f: glib::ffi::gpointer,
548        ) {
549            let f: &F = &*(f as *const F);
550            f(&from_glib_borrow(this))
551        }
552        unsafe {
553            let f: Box_<F> = Box_::new(f);
554            connect_raw(
555                self.as_ptr() as *mut _,
556                c"notify::color-state".as_ptr() as *const _,
557                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
558                    notify_color_state_trampoline::<F> as *const (),
559                )),
560                Box_::into_raw(f),
561            )
562        }
563    }
564
565    #[cfg(feature = "v4_14")]
566    #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
567    #[doc(alias = "display")]
568    pub fn connect_display_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
569        unsafe extern "C" fn notify_display_trampoline<F: Fn(&DmabufTextureBuilder) + 'static>(
570            this: *mut ffi::GdkDmabufTextureBuilder,
571            _param_spec: glib::ffi::gpointer,
572            f: glib::ffi::gpointer,
573        ) {
574            let f: &F = &*(f as *const F);
575            f(&from_glib_borrow(this))
576        }
577        unsafe {
578            let f: Box_<F> = Box_::new(f);
579            connect_raw(
580                self.as_ptr() as *mut _,
581                c"notify::display".as_ptr() as *const _,
582                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
583                    notify_display_trampoline::<F> as *const (),
584                )),
585                Box_::into_raw(f),
586            )
587        }
588    }
589
590    #[cfg(feature = "v4_14")]
591    #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
592    #[doc(alias = "fourcc")]
593    pub fn connect_fourcc_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
594        unsafe extern "C" fn notify_fourcc_trampoline<F: Fn(&DmabufTextureBuilder) + 'static>(
595            this: *mut ffi::GdkDmabufTextureBuilder,
596            _param_spec: glib::ffi::gpointer,
597            f: glib::ffi::gpointer,
598        ) {
599            let f: &F = &*(f as *const F);
600            f(&from_glib_borrow(this))
601        }
602        unsafe {
603            let f: Box_<F> = Box_::new(f);
604            connect_raw(
605                self.as_ptr() as *mut _,
606                c"notify::fourcc".as_ptr() as *const _,
607                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
608                    notify_fourcc_trampoline::<F> as *const (),
609                )),
610                Box_::into_raw(f),
611            )
612        }
613    }
614
615    #[cfg(feature = "v4_14")]
616    #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
617    #[doc(alias = "height")]
618    pub fn connect_height_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
619        unsafe extern "C" fn notify_height_trampoline<F: Fn(&DmabufTextureBuilder) + 'static>(
620            this: *mut ffi::GdkDmabufTextureBuilder,
621            _param_spec: glib::ffi::gpointer,
622            f: glib::ffi::gpointer,
623        ) {
624            let f: &F = &*(f as *const F);
625            f(&from_glib_borrow(this))
626        }
627        unsafe {
628            let f: Box_<F> = Box_::new(f);
629            connect_raw(
630                self.as_ptr() as *mut _,
631                c"notify::height".as_ptr() as *const _,
632                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
633                    notify_height_trampoline::<F> as *const (),
634                )),
635                Box_::into_raw(f),
636            )
637        }
638    }
639
640    #[cfg(feature = "v4_14")]
641    #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
642    #[doc(alias = "modifier")]
643    pub fn connect_modifier_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
644        unsafe extern "C" fn notify_modifier_trampoline<F: Fn(&DmabufTextureBuilder) + 'static>(
645            this: *mut ffi::GdkDmabufTextureBuilder,
646            _param_spec: glib::ffi::gpointer,
647            f: glib::ffi::gpointer,
648        ) {
649            let f: &F = &*(f as *const F);
650            f(&from_glib_borrow(this))
651        }
652        unsafe {
653            let f: Box_<F> = Box_::new(f);
654            connect_raw(
655                self.as_ptr() as *mut _,
656                c"notify::modifier".as_ptr() as *const _,
657                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
658                    notify_modifier_trampoline::<F> as *const (),
659                )),
660                Box_::into_raw(f),
661            )
662        }
663    }
664
665    #[cfg(feature = "v4_14")]
666    #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
667    #[doc(alias = "n-planes")]
668    pub fn connect_n_planes_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
669        unsafe extern "C" fn notify_n_planes_trampoline<F: Fn(&DmabufTextureBuilder) + 'static>(
670            this: *mut ffi::GdkDmabufTextureBuilder,
671            _param_spec: glib::ffi::gpointer,
672            f: glib::ffi::gpointer,
673        ) {
674            let f: &F = &*(f as *const F);
675            f(&from_glib_borrow(this))
676        }
677        unsafe {
678            let f: Box_<F> = Box_::new(f);
679            connect_raw(
680                self.as_ptr() as *mut _,
681                c"notify::n-planes".as_ptr() as *const _,
682                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
683                    notify_n_planes_trampoline::<F> as *const (),
684                )),
685                Box_::into_raw(f),
686            )
687        }
688    }
689
690    #[cfg(feature = "v4_14")]
691    #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
692    #[doc(alias = "premultiplied")]
693    pub fn connect_premultiplied_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
694        unsafe extern "C" fn notify_premultiplied_trampoline<
695            F: Fn(&DmabufTextureBuilder) + 'static,
696        >(
697            this: *mut ffi::GdkDmabufTextureBuilder,
698            _param_spec: glib::ffi::gpointer,
699            f: glib::ffi::gpointer,
700        ) {
701            let f: &F = &*(f as *const F);
702            f(&from_glib_borrow(this))
703        }
704        unsafe {
705            let f: Box_<F> = Box_::new(f);
706            connect_raw(
707                self.as_ptr() as *mut _,
708                c"notify::premultiplied".as_ptr() as *const _,
709                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
710                    notify_premultiplied_trampoline::<F> as *const (),
711                )),
712                Box_::into_raw(f),
713            )
714        }
715    }
716
717    #[cfg(feature = "v4_14")]
718    #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
719    #[doc(alias = "update-region")]
720    pub fn connect_update_region_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
721        unsafe extern "C" fn notify_update_region_trampoline<
722            F: Fn(&DmabufTextureBuilder) + 'static,
723        >(
724            this: *mut ffi::GdkDmabufTextureBuilder,
725            _param_spec: glib::ffi::gpointer,
726            f: glib::ffi::gpointer,
727        ) {
728            let f: &F = &*(f as *const F);
729            f(&from_glib_borrow(this))
730        }
731        unsafe {
732            let f: Box_<F> = Box_::new(f);
733            connect_raw(
734                self.as_ptr() as *mut _,
735                c"notify::update-region".as_ptr() as *const _,
736                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
737                    notify_update_region_trampoline::<F> as *const (),
738                )),
739                Box_::into_raw(f),
740            )
741        }
742    }
743
744    #[cfg(feature = "v4_14")]
745    #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
746    #[doc(alias = "update-texture")]
747    pub fn connect_update_texture_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
748        unsafe extern "C" fn notify_update_texture_trampoline<
749            F: Fn(&DmabufTextureBuilder) + 'static,
750        >(
751            this: *mut ffi::GdkDmabufTextureBuilder,
752            _param_spec: glib::ffi::gpointer,
753            f: glib::ffi::gpointer,
754        ) {
755            let f: &F = &*(f as *const F);
756            f(&from_glib_borrow(this))
757        }
758        unsafe {
759            let f: Box_<F> = Box_::new(f);
760            connect_raw(
761                self.as_ptr() as *mut _,
762                c"notify::update-texture".as_ptr() as *const _,
763                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
764                    notify_update_texture_trampoline::<F> as *const (),
765                )),
766                Box_::into_raw(f),
767            )
768        }
769    }
770
771    #[cfg(feature = "v4_14")]
772    #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
773    #[doc(alias = "width")]
774    pub fn connect_width_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
775        unsafe extern "C" fn notify_width_trampoline<F: Fn(&DmabufTextureBuilder) + 'static>(
776            this: *mut ffi::GdkDmabufTextureBuilder,
777            _param_spec: glib::ffi::gpointer,
778            f: glib::ffi::gpointer,
779        ) {
780            let f: &F = &*(f as *const F);
781            f(&from_glib_borrow(this))
782        }
783        unsafe {
784            let f: Box_<F> = Box_::new(f);
785            connect_raw(
786                self.as_ptr() as *mut _,
787                c"notify::width".as_ptr() as *const _,
788                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
789                    notify_width_trampoline::<F> as *const (),
790                )),
791                Box_::into_raw(f),
792            )
793        }
794    }
795}
796
797#[cfg(feature = "v4_14")]
798#[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
799impl Default for DmabufTextureBuilder {
800    fn default() -> Self {
801        Self::new()
802    }
803}