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::{SignalHandlerId, connect_raw},
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            unsafe {
302                let f: &F = &*(f as *const F);
303                f(&from_glib_borrow(this))
304            }
305        }
306        unsafe {
307            let f: Box_<F> = Box_::new(f);
308            connect_raw(
309                self.as_ptr() as *mut _,
310                c"notify::color-state".as_ptr() as *const _,
311                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
312                    notify_color_state_trampoline::<F> as *const (),
313                )),
314                Box_::into_raw(f),
315            )
316        }
317    }
318
319    #[cfg(feature = "v4_20")]
320    #[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
321    #[doc(alias = "fence")]
322    pub fn connect_fence_notify<F: Fn(&Self) + Send + Sync + 'static>(
323        &self,
324        f: F,
325    ) -> SignalHandlerId {
326        unsafe extern "C" fn notify_fence_trampoline<
327            F: Fn(&D3D12TextureBuilder) + Send + Sync + 'static,
328        >(
329            this: *mut ffi::GdkD3D12TextureBuilder,
330            _param_spec: glib::ffi::gpointer,
331            f: glib::ffi::gpointer,
332        ) {
333            unsafe {
334                let f: &F = &*(f as *const F);
335                f(&from_glib_borrow(this))
336            }
337        }
338        unsafe {
339            let f: Box_<F> = Box_::new(f);
340            connect_raw(
341                self.as_ptr() as *mut _,
342                c"notify::fence".as_ptr() as *const _,
343                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
344                    notify_fence_trampoline::<F> as *const (),
345                )),
346                Box_::into_raw(f),
347            )
348        }
349    }
350
351    #[cfg(feature = "v4_20")]
352    #[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
353    #[doc(alias = "fence-wait")]
354    pub fn connect_fence_wait_notify<F: Fn(&Self) + Send + Sync + 'static>(
355        &self,
356        f: F,
357    ) -> SignalHandlerId {
358        unsafe extern "C" fn notify_fence_wait_trampoline<
359            F: Fn(&D3D12TextureBuilder) + Send + Sync + 'static,
360        >(
361            this: *mut ffi::GdkD3D12TextureBuilder,
362            _param_spec: glib::ffi::gpointer,
363            f: glib::ffi::gpointer,
364        ) {
365            unsafe {
366                let f: &F = &*(f as *const F);
367                f(&from_glib_borrow(this))
368            }
369        }
370        unsafe {
371            let f: Box_<F> = Box_::new(f);
372            connect_raw(
373                self.as_ptr() as *mut _,
374                c"notify::fence-wait".as_ptr() as *const _,
375                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
376                    notify_fence_wait_trampoline::<F> as *const (),
377                )),
378                Box_::into_raw(f),
379            )
380        }
381    }
382
383    #[cfg(feature = "v4_20")]
384    #[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
385    #[doc(alias = "premultiplied")]
386    pub fn connect_premultiplied_notify<F: Fn(&Self) + Send + Sync + 'static>(
387        &self,
388        f: F,
389    ) -> SignalHandlerId {
390        unsafe extern "C" fn notify_premultiplied_trampoline<
391            F: Fn(&D3D12TextureBuilder) + Send + Sync + 'static,
392        >(
393            this: *mut ffi::GdkD3D12TextureBuilder,
394            _param_spec: glib::ffi::gpointer,
395            f: glib::ffi::gpointer,
396        ) {
397            unsafe {
398                let f: &F = &*(f as *const F);
399                f(&from_glib_borrow(this))
400            }
401        }
402        unsafe {
403            let f: Box_<F> = Box_::new(f);
404            connect_raw(
405                self.as_ptr() as *mut _,
406                c"notify::premultiplied".as_ptr() as *const _,
407                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
408                    notify_premultiplied_trampoline::<F> as *const (),
409                )),
410                Box_::into_raw(f),
411            )
412        }
413    }
414
415    #[cfg(feature = "v4_20")]
416    #[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
417    #[doc(alias = "resource")]
418    pub fn connect_resource_notify<F: Fn(&Self) + Send + Sync + 'static>(
419        &self,
420        f: F,
421    ) -> SignalHandlerId {
422        unsafe extern "C" fn notify_resource_trampoline<
423            F: Fn(&D3D12TextureBuilder) + Send + Sync + 'static,
424        >(
425            this: *mut ffi::GdkD3D12TextureBuilder,
426            _param_spec: glib::ffi::gpointer,
427            f: glib::ffi::gpointer,
428        ) {
429            unsafe {
430                let f: &F = &*(f as *const F);
431                f(&from_glib_borrow(this))
432            }
433        }
434        unsafe {
435            let f: Box_<F> = Box_::new(f);
436            connect_raw(
437                self.as_ptr() as *mut _,
438                c"notify::resource".as_ptr() as *const _,
439                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
440                    notify_resource_trampoline::<F> as *const (),
441                )),
442                Box_::into_raw(f),
443            )
444        }
445    }
446
447    #[cfg(feature = "v4_20")]
448    #[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
449    #[doc(alias = "update-region")]
450    pub fn connect_update_region_notify<F: Fn(&Self) + Send + Sync + 'static>(
451        &self,
452        f: F,
453    ) -> SignalHandlerId {
454        unsafe extern "C" fn notify_update_region_trampoline<
455            F: Fn(&D3D12TextureBuilder) + Send + Sync + 'static,
456        >(
457            this: *mut ffi::GdkD3D12TextureBuilder,
458            _param_spec: glib::ffi::gpointer,
459            f: glib::ffi::gpointer,
460        ) {
461            unsafe {
462                let f: &F = &*(f as *const F);
463                f(&from_glib_borrow(this))
464            }
465        }
466        unsafe {
467            let f: Box_<F> = Box_::new(f);
468            connect_raw(
469                self.as_ptr() as *mut _,
470                c"notify::update-region".as_ptr() as *const _,
471                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
472                    notify_update_region_trampoline::<F> as *const (),
473                )),
474                Box_::into_raw(f),
475            )
476        }
477    }
478
479    #[cfg(feature = "v4_20")]
480    #[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
481    #[doc(alias = "update-texture")]
482    pub fn connect_update_texture_notify<F: Fn(&Self) + Send + Sync + 'static>(
483        &self,
484        f: F,
485    ) -> SignalHandlerId {
486        unsafe extern "C" fn notify_update_texture_trampoline<
487            F: Fn(&D3D12TextureBuilder) + Send + Sync + 'static,
488        >(
489            this: *mut ffi::GdkD3D12TextureBuilder,
490            _param_spec: glib::ffi::gpointer,
491            f: glib::ffi::gpointer,
492        ) {
493            unsafe {
494                let f: &F = &*(f as *const F);
495                f(&from_glib_borrow(this))
496            }
497        }
498        unsafe {
499            let f: Box_<F> = Box_::new(f);
500            connect_raw(
501                self.as_ptr() as *mut _,
502                c"notify::update-texture".as_ptr() as *const _,
503                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
504                    notify_update_texture_trampoline::<F> as *const (),
505                )),
506                Box_::into_raw(f),
507            )
508        }
509    }
510}
511
512#[cfg(feature = "v4_20")]
513#[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
514impl Default for D3D12TextureBuilder {
515    fn default() -> Self {
516        Self::new()
517    }
518}
519
520unsafe impl Send for D3D12TextureBuilder {}
521unsafe impl Sync for D3D12TextureBuilder {}