1use crate::ffi;
6use glib::{
7 prelude::*,
8 signal::{SignalHandlerId, connect_raw},
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 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 {}