gdk4_win32/auto/
d3d12_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
5use crate::ffi;
6use glib::{
7    prelude::*,
8    signal::{connect_raw, SignalHandlerId},
9    translate::*,
10};
11use std::boxed::Box as Box_;
12
13glib::wrapper! {
14    /// [`D3D12TextureBuilder`][crate::D3D12TextureBuilder] is a builder used to construct [`gdk::Texture`][crate::gdk::Texture]
15    /// objects from [ID3D12Resources](https://learn.microsoft.com/en-us/windows/win32/api/d3d12/nn-d3d12-id3d12resource).
16    ///
17    /// The operation of [`D3D12TextureBuilder`][crate::D3D12TextureBuilder] is quite simple: Create a texture builder,
18    /// set all the necessary properties, and then call `Gdk::D3d12TextureBuilder::build()`
19    /// to create the new texture.
20    ///
21    /// Not all `D3D12Resources` can be used. You have to use a texture resource for a [`gdk::Texture`][crate::gdk::Texture].
22    /// GDK will attempt to detect invalid resources and fail to create the texture in that case.
23    ///
24    /// [`D3D12TextureBuilder`][crate::D3D12TextureBuilder] can be used for quick one-shot construction of
25    /// textures as well as kept around and reused to construct multiple textures.
26    ///
27    /// ## Properties
28    ///
29    ///
30    /// #### `color-state`
31    ///  The color state of the texture.
32    ///
33    /// Readable | Writeable
34    ///
35    ///
36    /// #### `fence`
37    ///  The optional `ID3D12Fence` to wait on before using the resource.
38    ///
39    /// Readable | Writeable
40    ///
41    ///
42    /// #### `fence-wait`
43    ///  The value the fence should wait on
44    ///
45    /// Readable | Writeable
46    ///
47    ///
48    /// #### `premultiplied`
49    ///  Whether the alpha channel is premultiplied into the others.
50    ///
51    /// Only relevant if the format has alpha.
52    ///
53    /// Readable | Writeable
54    ///
55    ///
56    /// #### `resource`
57    ///  The `ID3D12Resource`
58    ///
59    /// Readable | Writeable
60    ///
61    ///
62    /// #### `update-region`
63    ///  The update region for [`update-texture`][struct@crate::Gdk::D3d12TextureBuilder#update-texture].
64    ///
65    /// Readable | Writeable
66    ///
67    ///
68    /// #### `update-texture`
69    ///  The texture [`update-region`][struct@crate::Gdk::D3d12TextureBuilder#update-region] is an update for.
70    ///
71    /// Readable | Writeable
72    #[doc(alias = "GdkD3D12TextureBuilder")]
73    pub struct D3D12TextureBuilder(Object<ffi::GdkD3D12TextureBuilder, ffi::GdkD3D12TextureBuilderClass>);
74
75    match fn {
76        type_ => || ffi::gdk_d3d12_texture_builder_get_type(),
77    }
78}
79
80impl D3D12TextureBuilder {
81    /// Creates a new texture builder.
82    ///
83    /// # Returns
84    ///
85    /// the new `GdkTextureBuilder`
86    #[doc(alias = "gdk_d3d12_texture_builder_new")]
87    pub fn new() -> D3D12TextureBuilder {
88        assert_initialized_main_thread!();
89        unsafe { from_glib_full(ffi::gdk_d3d12_texture_builder_new()) }
90    }
91
92    //#[doc(alias = "gdk_d3d12_texture_builder_build")]
93    //pub fn build(&self, data: /*Unimplemented*/Option<Basic: Pointer>) -> Result<Option<gdk::Texture>, glib::Error> {
94    //    unsafe { TODO: call ffi:gdk_d3d12_texture_builder_build() }
95    //}
96
97    /// Gets the color state previously set via gdk_d3d12_texture_builder_set_color_state().
98    ///
99    /// # Returns
100    ///
101    /// the color state
102    #[doc(alias = "gdk_d3d12_texture_builder_get_color_state")]
103    #[doc(alias = "get_color_state")]
104    #[doc(alias = "color-state")]
105    pub fn color_state(&self) -> Option<gdk::ColorState> {
106        unsafe {
107            from_glib_none(ffi::gdk_d3d12_texture_builder_get_color_state(
108                self.to_glib_none().0,
109            ))
110        }
111    }
112
113    //#[doc(alias = "gdk_d3d12_texture_builder_get_fence")]
114    //#[doc(alias = "get_fence")]
115    //pub fn fence(&self) -> /*Unimplemented*/Option<Basic: Pointer> {
116    //    unsafe { TODO: call ffi:gdk_d3d12_texture_builder_get_fence() }
117    //}
118
119    /// Returns the value that GTK should wait for on the fence
120    /// before using the resource.
121    ///
122    /// # Returns
123    ///
124    /// the fence wait value
125    #[doc(alias = "gdk_d3d12_texture_builder_get_fence_wait")]
126    #[doc(alias = "get_fence_wait")]
127    #[doc(alias = "fence-wait")]
128    pub fn fence_wait(&self) -> u64 {
129        unsafe { ffi::gdk_d3d12_texture_builder_get_fence_wait(self.to_glib_none().0) }
130    }
131
132    /// Whether the data is premultiplied.
133    ///
134    /// # Returns
135    ///
136    /// whether the data is premultiplied
137    #[doc(alias = "gdk_d3d12_texture_builder_get_premultiplied")]
138    #[doc(alias = "get_premultiplied")]
139    #[doc(alias = "premultiplied")]
140    pub fn is_premultiplied(&self) -> bool {
141        unsafe {
142            from_glib(ffi::gdk_d3d12_texture_builder_get_premultiplied(
143                self.to_glib_none().0,
144            ))
145        }
146    }
147
148    //#[doc(alias = "gdk_d3d12_texture_builder_get_resource")]
149    //#[doc(alias = "get_resource")]
150    //pub fn resource(&self) -> /*Unimplemented*/Option<Basic: Pointer> {
151    //    unsafe { TODO: call ffi:gdk_d3d12_texture_builder_get_resource() }
152    //}
153
154    /// Gets the region previously set via gdk_d3d12_texture_builder_set_update_region() or
155    /// [`None`] if none was set.
156    ///
157    /// # Returns
158    ///
159    /// The region
160    #[doc(alias = "gdk_d3d12_texture_builder_get_update_region")]
161    #[doc(alias = "get_update_region")]
162    #[doc(alias = "update-region")]
163    pub fn update_region(&self) -> Option<cairo::Region> {
164        unsafe {
165            from_glib_none(ffi::gdk_d3d12_texture_builder_get_update_region(
166                self.to_glib_none().0,
167            ))
168        }
169    }
170
171    /// Gets the texture previously set via gdk_d3d12_texture_builder_set_update_texture() or
172    /// [`None`] if none was set.
173    ///
174    /// # Returns
175    ///
176    /// The texture
177    #[doc(alias = "gdk_d3d12_texture_builder_get_update_texture")]
178    #[doc(alias = "get_update_texture")]
179    #[doc(alias = "update-texture")]
180    pub fn update_texture(&self) -> Option<gdk::Texture> {
181        unsafe {
182            from_glib_none(ffi::gdk_d3d12_texture_builder_get_update_texture(
183                self.to_glib_none().0,
184            ))
185        }
186    }
187
188    /// Sets the color state for the texture.
189    ///
190    /// By default, the colorstate is `NULL`. In that case, GTK will choose the
191    /// correct colorstate based on the format.
192    /// If you don't know what colorstates are, this is probably the right thing.
193    /// ## `color_state`
194    /// a [`gdk::ColorState`][crate::gdk::ColorState] or `NULL` to unset the colorstate.
195    #[doc(alias = "gdk_d3d12_texture_builder_set_color_state")]
196    #[doc(alias = "color-state")]
197    pub fn set_color_state(&self, color_state: Option<&gdk::ColorState>) {
198        unsafe {
199            ffi::gdk_d3d12_texture_builder_set_color_state(
200                self.to_glib_none().0,
201                color_state.to_glib_none().0,
202            );
203        }
204    }
205
206    //#[doc(alias = "gdk_d3d12_texture_builder_set_fence")]
207    //#[doc(alias = "fence")]
208    //pub fn set_fence(&self, fence: /*Unimplemented*/Basic: Pointer) {
209    //    unsafe { TODO: call ffi:gdk_d3d12_texture_builder_set_fence() }
210    //}
211
212    /// Sets the value that GTK should wait on on the given fence before using the
213    /// resource.
214    ///
215    /// When no fence is set, this value has no effect.
216    /// ## `fence_wait`
217    /// the value to wait on
218    #[doc(alias = "gdk_d3d12_texture_builder_set_fence_wait")]
219    #[doc(alias = "fence-wait")]
220    pub fn set_fence_wait(&self, fence_wait: u64) {
221        unsafe {
222            ffi::gdk_d3d12_texture_builder_set_fence_wait(self.to_glib_none().0, fence_wait);
223        }
224    }
225
226    /// Sets whether the data is premultiplied.
227    ///
228    /// Unless otherwise specified, all formats including alpha channels are assumed
229    /// to be premultiplied.
230    /// ## `premultiplied`
231    /// whether the data is premultiplied
232    #[doc(alias = "gdk_d3d12_texture_builder_set_premultiplied")]
233    #[doc(alias = "premultiplied")]
234    pub fn set_premultiplied(&self, premultiplied: bool) {
235        unsafe {
236            ffi::gdk_d3d12_texture_builder_set_premultiplied(
237                self.to_glib_none().0,
238                premultiplied.into_glib(),
239            );
240        }
241    }
242
243    //#[doc(alias = "gdk_d3d12_texture_builder_set_resource")]
244    //#[doc(alias = "resource")]
245    //pub fn set_resource(&self, resource: /*Unimplemented*/Basic: Pointer) {
246    //    unsafe { TODO: call ffi:gdk_d3d12_texture_builder_set_resource() }
247    //}
248
249    /// Sets the region to be updated by this texture. Together with
250    /// [`update-texture`][struct@crate::Gdk::D3d12TextureBuilder#update-texture] this describes an
251    /// update of a previous texture.
252    ///
253    /// When rendering animations of large textures, it is possible that
254    /// consecutive textures are only updating contents in parts of the texture.
255    /// It is then possible to describe this update via these two properties,
256    /// so that GTK can avoid rerendering parts that did not change.
257    ///
258    /// An example would be a screen recording where only the mouse pointer moves.
259    /// ## `region`
260    /// the region to update
261    #[doc(alias = "gdk_d3d12_texture_builder_set_update_region")]
262    #[doc(alias = "update-region")]
263    pub fn set_update_region(&self, region: Option<&cairo::Region>) {
264        unsafe {
265            ffi::gdk_d3d12_texture_builder_set_update_region(
266                self.to_glib_none().0,
267                mut_override(region.to_glib_none().0),
268            );
269        }
270    }
271
272    /// Sets the texture to be updated by this texture. See
273    /// `Gdk::D3d12TextureBuilder::set_update_region()` for an explanation.
274    /// ## `texture`
275    /// the texture to update
276    #[doc(alias = "gdk_d3d12_texture_builder_set_update_texture")]
277    #[doc(alias = "update-texture")]
278    pub fn set_update_texture(&self, texture: Option<&impl IsA<gdk::Texture>>) {
279        unsafe {
280            ffi::gdk_d3d12_texture_builder_set_update_texture(
281                self.to_glib_none().0,
282                texture.map(|p| p.as_ref()).to_glib_none().0,
283            );
284        }
285    }
286
287    #[cfg(feature = "v4_20")]
288    #[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
289    #[doc(alias = "color-state")]
290    pub fn connect_color_state_notify<F: Fn(&Self) + Send + Sync + 'static>(
291        &self,
292        f: F,
293    ) -> SignalHandlerId {
294        unsafe extern "C" fn notify_color_state_trampoline<
295            F: Fn(&D3D12TextureBuilder) + Send + Sync + 'static,
296        >(
297            this: *mut ffi::GdkD3D12TextureBuilder,
298            _param_spec: glib::ffi::gpointer,
299            f: glib::ffi::gpointer,
300        ) {
301            let f: &F = &*(f as *const F);
302            f(&from_glib_borrow(this))
303        }
304        unsafe {
305            let f: Box_<F> = Box_::new(f);
306            connect_raw(
307                self.as_ptr() as *mut _,
308                c"notify::color-state".as_ptr() as *const _,
309                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
310                    notify_color_state_trampoline::<F> as *const (),
311                )),
312                Box_::into_raw(f),
313            )
314        }
315    }
316
317    #[cfg(feature = "v4_20")]
318    #[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
319    #[doc(alias = "fence")]
320    pub fn connect_fence_notify<F: Fn(&Self) + Send + Sync + 'static>(
321        &self,
322        f: F,
323    ) -> SignalHandlerId {
324        unsafe extern "C" fn notify_fence_trampoline<
325            F: Fn(&D3D12TextureBuilder) + Send + Sync + 'static,
326        >(
327            this: *mut ffi::GdkD3D12TextureBuilder,
328            _param_spec: glib::ffi::gpointer,
329            f: glib::ffi::gpointer,
330        ) {
331            let f: &F = &*(f as *const F);
332            f(&from_glib_borrow(this))
333        }
334        unsafe {
335            let f: Box_<F> = Box_::new(f);
336            connect_raw(
337                self.as_ptr() as *mut _,
338                c"notify::fence".as_ptr() as *const _,
339                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
340                    notify_fence_trampoline::<F> as *const (),
341                )),
342                Box_::into_raw(f),
343            )
344        }
345    }
346
347    #[cfg(feature = "v4_20")]
348    #[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
349    #[doc(alias = "fence-wait")]
350    pub fn connect_fence_wait_notify<F: Fn(&Self) + Send + Sync + 'static>(
351        &self,
352        f: F,
353    ) -> SignalHandlerId {
354        unsafe extern "C" fn notify_fence_wait_trampoline<
355            F: Fn(&D3D12TextureBuilder) + Send + Sync + 'static,
356        >(
357            this: *mut ffi::GdkD3D12TextureBuilder,
358            _param_spec: glib::ffi::gpointer,
359            f: glib::ffi::gpointer,
360        ) {
361            let f: &F = &*(f as *const F);
362            f(&from_glib_borrow(this))
363        }
364        unsafe {
365            let f: Box_<F> = Box_::new(f);
366            connect_raw(
367                self.as_ptr() as *mut _,
368                c"notify::fence-wait".as_ptr() as *const _,
369                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
370                    notify_fence_wait_trampoline::<F> as *const (),
371                )),
372                Box_::into_raw(f),
373            )
374        }
375    }
376
377    #[cfg(feature = "v4_20")]
378    #[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
379    #[doc(alias = "premultiplied")]
380    pub fn connect_premultiplied_notify<F: Fn(&Self) + Send + Sync + 'static>(
381        &self,
382        f: F,
383    ) -> SignalHandlerId {
384        unsafe extern "C" fn notify_premultiplied_trampoline<
385            F: Fn(&D3D12TextureBuilder) + Send + Sync + 'static,
386        >(
387            this: *mut ffi::GdkD3D12TextureBuilder,
388            _param_spec: glib::ffi::gpointer,
389            f: glib::ffi::gpointer,
390        ) {
391            let f: &F = &*(f as *const F);
392            f(&from_glib_borrow(this))
393        }
394        unsafe {
395            let f: Box_<F> = Box_::new(f);
396            connect_raw(
397                self.as_ptr() as *mut _,
398                c"notify::premultiplied".as_ptr() as *const _,
399                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
400                    notify_premultiplied_trampoline::<F> as *const (),
401                )),
402                Box_::into_raw(f),
403            )
404        }
405    }
406
407    #[cfg(feature = "v4_20")]
408    #[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
409    #[doc(alias = "resource")]
410    pub fn connect_resource_notify<F: Fn(&Self) + Send + Sync + 'static>(
411        &self,
412        f: F,
413    ) -> SignalHandlerId {
414        unsafe extern "C" fn notify_resource_trampoline<
415            F: Fn(&D3D12TextureBuilder) + Send + Sync + 'static,
416        >(
417            this: *mut ffi::GdkD3D12TextureBuilder,
418            _param_spec: glib::ffi::gpointer,
419            f: glib::ffi::gpointer,
420        ) {
421            let f: &F = &*(f as *const F);
422            f(&from_glib_borrow(this))
423        }
424        unsafe {
425            let f: Box_<F> = Box_::new(f);
426            connect_raw(
427                self.as_ptr() as *mut _,
428                c"notify::resource".as_ptr() as *const _,
429                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
430                    notify_resource_trampoline::<F> as *const (),
431                )),
432                Box_::into_raw(f),
433            )
434        }
435    }
436
437    #[cfg(feature = "v4_20")]
438    #[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
439    #[doc(alias = "update-region")]
440    pub fn connect_update_region_notify<F: Fn(&Self) + Send + Sync + 'static>(
441        &self,
442        f: F,
443    ) -> SignalHandlerId {
444        unsafe extern "C" fn notify_update_region_trampoline<
445            F: Fn(&D3D12TextureBuilder) + Send + Sync + 'static,
446        >(
447            this: *mut ffi::GdkD3D12TextureBuilder,
448            _param_spec: glib::ffi::gpointer,
449            f: glib::ffi::gpointer,
450        ) {
451            let f: &F = &*(f as *const F);
452            f(&from_glib_borrow(this))
453        }
454        unsafe {
455            let f: Box_<F> = Box_::new(f);
456            connect_raw(
457                self.as_ptr() as *mut _,
458                c"notify::update-region".as_ptr() as *const _,
459                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
460                    notify_update_region_trampoline::<F> as *const (),
461                )),
462                Box_::into_raw(f),
463            )
464        }
465    }
466
467    #[cfg(feature = "v4_20")]
468    #[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
469    #[doc(alias = "update-texture")]
470    pub fn connect_update_texture_notify<F: Fn(&Self) + Send + Sync + 'static>(
471        &self,
472        f: F,
473    ) -> SignalHandlerId {
474        unsafe extern "C" fn notify_update_texture_trampoline<
475            F: Fn(&D3D12TextureBuilder) + Send + Sync + 'static,
476        >(
477            this: *mut ffi::GdkD3D12TextureBuilder,
478            _param_spec: glib::ffi::gpointer,
479            f: glib::ffi::gpointer,
480        ) {
481            let f: &F = &*(f as *const F);
482            f(&from_glib_borrow(this))
483        }
484        unsafe {
485            let f: Box_<F> = Box_::new(f);
486            connect_raw(
487                self.as_ptr() as *mut _,
488                c"notify::update-texture".as_ptr() as *const _,
489                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
490                    notify_update_texture_trampoline::<F> as *const (),
491                )),
492                Box_::into_raw(f),
493            )
494        }
495    }
496}
497
498#[cfg(feature = "v4_20")]
499#[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
500impl Default for D3D12TextureBuilder {
501    fn default() -> Self {
502        Self::new()
503    }
504}
505
506unsafe impl Send for D3D12TextureBuilder {}
507unsafe impl Sync for D3D12TextureBuilder {}