1use crate::ffi;
6use glib::{
7 prelude::*,
8 signal::{connect_raw, SignalHandlerId},
9 translate::*,
10};
11use std::boxed::Box as Box_;
12
13glib::wrapper! {
14 #[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 #[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_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_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 #[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_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 #[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 #[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_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 #[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_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 #[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 {}