1#[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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}