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")]
142 pub struct DmabufTextureBuilder(Object<ffi::GdkDmabufTextureBuilder, ffi::GdkDmabufTextureBuilderClass>);
143
144 match fn {
145 type_ => || ffi::gdk_dmabuf_texture_builder_get_type(),
146 }
147}
148
149impl DmabufTextureBuilder {
150 #[doc(alias = "gdk_dmabuf_texture_builder_new")]
156 pub fn new() -> DmabufTextureBuilder {
157 assert_initialized_main_thread!();
158 unsafe { from_glib_full(ffi::gdk_dmabuf_texture_builder_new()) }
159 }
160
161 #[cfg(feature = "v4_16")]
167 #[cfg_attr(docsrs, doc(cfg(feature = "v4_16")))]
168 #[doc(alias = "gdk_dmabuf_texture_builder_get_color_state")]
169 #[doc(alias = "get_color_state")]
170 #[doc(alias = "color-state")]
171 pub fn color_state(&self) -> Option<ColorState> {
172 unsafe {
173 from_glib_none(ffi::gdk_dmabuf_texture_builder_get_color_state(
174 self.to_glib_none().0,
175 ))
176 }
177 }
178
179 #[doc(alias = "gdk_dmabuf_texture_builder_get_display")]
186 #[doc(alias = "get_display")]
187 pub fn display(&self) -> Display {
188 unsafe {
189 from_glib_none(ffi::gdk_dmabuf_texture_builder_get_display(
190 self.to_glib_none().0,
191 ))
192 }
193 }
194
195 #[doc(alias = "gdk_dmabuf_texture_builder_get_fd")]
203 #[doc(alias = "get_fd")]
204 pub fn fd(&self, plane: u32) -> i32 {
205 unsafe { ffi::gdk_dmabuf_texture_builder_get_fd(self.to_glib_none().0, plane) }
206 }
207
208 #[doc(alias = "gdk_dmabuf_texture_builder_get_fourcc")]
217 #[doc(alias = "get_fourcc")]
218 pub fn fourcc(&self) -> u32 {
219 unsafe { ffi::gdk_dmabuf_texture_builder_get_fourcc(self.to_glib_none().0) }
220 }
221
222 #[doc(alias = "gdk_dmabuf_texture_builder_get_height")]
229 #[doc(alias = "get_height")]
230 pub fn height(&self) -> u32 {
231 unsafe { ffi::gdk_dmabuf_texture_builder_get_height(self.to_glib_none().0) }
232 }
233
234 #[doc(alias = "gdk_dmabuf_texture_builder_get_modifier")]
240 #[doc(alias = "get_modifier")]
241 pub fn modifier(&self) -> u64 {
242 unsafe { ffi::gdk_dmabuf_texture_builder_get_modifier(self.to_glib_none().0) }
243 }
244
245 #[doc(alias = "gdk_dmabuf_texture_builder_get_n_planes")]
251 #[doc(alias = "get_n_planes")]
252 #[doc(alias = "n-planes")]
253 pub fn n_planes(&self) -> u32 {
254 unsafe { ffi::gdk_dmabuf_texture_builder_get_n_planes(self.to_glib_none().0) }
255 }
256
257 #[doc(alias = "gdk_dmabuf_texture_builder_get_offset")]
265 #[doc(alias = "get_offset")]
266 pub fn offset(&self, plane: u32) -> u32 {
267 unsafe { ffi::gdk_dmabuf_texture_builder_get_offset(self.to_glib_none().0, plane) }
268 }
269
270 #[doc(alias = "gdk_dmabuf_texture_builder_get_premultiplied")]
276 #[doc(alias = "get_premultiplied")]
277 #[doc(alias = "premultiplied")]
278 pub fn is_premultiplied(&self) -> bool {
279 unsafe {
280 from_glib(ffi::gdk_dmabuf_texture_builder_get_premultiplied(
281 self.to_glib_none().0,
282 ))
283 }
284 }
285
286 #[doc(alias = "gdk_dmabuf_texture_builder_get_stride")]
294 #[doc(alias = "get_stride")]
295 pub fn stride(&self, plane: u32) -> u32 {
296 unsafe { ffi::gdk_dmabuf_texture_builder_get_stride(self.to_glib_none().0, plane) }
297 }
298
299 #[doc(alias = "gdk_dmabuf_texture_builder_get_update_region")]
306 #[doc(alias = "get_update_region")]
307 #[doc(alias = "update-region")]
308 pub fn update_region(&self) -> Option<cairo::Region> {
309 unsafe {
310 from_glib_none(ffi::gdk_dmabuf_texture_builder_get_update_region(
311 self.to_glib_none().0,
312 ))
313 }
314 }
315
316 #[doc(alias = "gdk_dmabuf_texture_builder_get_update_texture")]
323 #[doc(alias = "get_update_texture")]
324 #[doc(alias = "update-texture")]
325 pub fn update_texture(&self) -> Option<Texture> {
326 unsafe {
327 from_glib_none(ffi::gdk_dmabuf_texture_builder_get_update_texture(
328 self.to_glib_none().0,
329 ))
330 }
331 }
332
333 #[doc(alias = "gdk_dmabuf_texture_builder_get_width")]
340 #[doc(alias = "get_width")]
341 pub fn width(&self) -> u32 {
342 unsafe { ffi::gdk_dmabuf_texture_builder_get_width(self.to_glib_none().0) }
343 }
344
345 #[cfg(feature = "v4_16")]
353 #[cfg_attr(docsrs, doc(cfg(feature = "v4_16")))]
354 #[doc(alias = "gdk_dmabuf_texture_builder_set_color_state")]
355 #[doc(alias = "color-state")]
356 pub fn set_color_state(&self, color_state: Option<&ColorState>) {
357 unsafe {
358 ffi::gdk_dmabuf_texture_builder_set_color_state(
359 self.to_glib_none().0,
360 color_state.to_glib_none().0,
361 );
362 }
363 }
364
365 #[doc(alias = "gdk_dmabuf_texture_builder_set_display")]
373 #[doc(alias = "display")]
374 pub fn set_display(&self, display: &impl IsA<Display>) {
375 unsafe {
376 ffi::gdk_dmabuf_texture_builder_set_display(
377 self.to_glib_none().0,
378 display.as_ref().to_glib_none().0,
379 );
380 }
381 }
382
383 #[doc(alias = "gdk_dmabuf_texture_builder_set_fd")]
389 pub fn set_fd(&self, plane: u32, fd: i32) {
390 unsafe {
391 ffi::gdk_dmabuf_texture_builder_set_fd(self.to_glib_none().0, plane, fd);
392 }
393 }
394
395 #[doc(alias = "gdk_dmabuf_texture_builder_set_fourcc")]
403 #[doc(alias = "fourcc")]
404 pub fn set_fourcc(&self, fourcc: u32) {
405 unsafe {
406 ffi::gdk_dmabuf_texture_builder_set_fourcc(self.to_glib_none().0, fourcc);
407 }
408 }
409
410 #[doc(alias = "gdk_dmabuf_texture_builder_set_height")]
416 #[doc(alias = "height")]
417 pub fn set_height(&self, height: u32) {
418 unsafe {
419 ffi::gdk_dmabuf_texture_builder_set_height(self.to_glib_none().0, height);
420 }
421 }
422
423 #[doc(alias = "gdk_dmabuf_texture_builder_set_modifier")]
427 #[doc(alias = "modifier")]
428 pub fn set_modifier(&self, modifier: u64) {
429 unsafe {
430 ffi::gdk_dmabuf_texture_builder_set_modifier(self.to_glib_none().0, modifier);
431 }
432 }
433
434 #[doc(alias = "gdk_dmabuf_texture_builder_set_n_planes")]
438 #[doc(alias = "n-planes")]
439 pub fn set_n_planes(&self, n_planes: u32) {
440 unsafe {
441 ffi::gdk_dmabuf_texture_builder_set_n_planes(self.to_glib_none().0, n_planes);
442 }
443 }
444
445 #[doc(alias = "gdk_dmabuf_texture_builder_set_offset")]
451 pub fn set_offset(&self, plane: u32, offset: u32) {
452 unsafe {
453 ffi::gdk_dmabuf_texture_builder_set_offset(self.to_glib_none().0, plane, offset);
454 }
455 }
456
457 #[doc(alias = "gdk_dmabuf_texture_builder_set_premultiplied")]
464 #[doc(alias = "premultiplied")]
465 pub fn set_premultiplied(&self, premultiplied: bool) {
466 unsafe {
467 ffi::gdk_dmabuf_texture_builder_set_premultiplied(
468 self.to_glib_none().0,
469 premultiplied.into_glib(),
470 );
471 }
472 }
473
474 #[doc(alias = "gdk_dmabuf_texture_builder_set_stride")]
482 pub fn set_stride(&self, plane: u32, stride: u32) {
483 unsafe {
484 ffi::gdk_dmabuf_texture_builder_set_stride(self.to_glib_none().0, plane, stride);
485 }
486 }
487
488 #[doc(alias = "gdk_dmabuf_texture_builder_set_update_region")]
501 #[doc(alias = "update-region")]
502 pub fn set_update_region(&self, region: Option<&cairo::Region>) {
503 unsafe {
504 ffi::gdk_dmabuf_texture_builder_set_update_region(
505 self.to_glib_none().0,
506 mut_override(region.to_glib_none().0),
507 );
508 }
509 }
510
511 #[doc(alias = "gdk_dmabuf_texture_builder_set_update_texture")]
516 #[doc(alias = "update-texture")]
517 pub fn set_update_texture(&self, texture: Option<&impl IsA<Texture>>) {
518 unsafe {
519 ffi::gdk_dmabuf_texture_builder_set_update_texture(
520 self.to_glib_none().0,
521 texture.map(|p| p.as_ref()).to_glib_none().0,
522 );
523 }
524 }
525
526 #[doc(alias = "gdk_dmabuf_texture_builder_set_width")]
532 #[doc(alias = "width")]
533 pub fn set_width(&self, width: u32) {
534 unsafe {
535 ffi::gdk_dmabuf_texture_builder_set_width(self.to_glib_none().0, width);
536 }
537 }
538
539 #[cfg(feature = "v4_16")]
540 #[cfg_attr(docsrs, doc(cfg(feature = "v4_16")))]
541 #[doc(alias = "color-state")]
542 pub fn connect_color_state_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
543 unsafe extern "C" fn notify_color_state_trampoline<
544 F: Fn(&DmabufTextureBuilder) + 'static,
545 >(
546 this: *mut ffi::GdkDmabufTextureBuilder,
547 _param_spec: glib::ffi::gpointer,
548 f: glib::ffi::gpointer,
549 ) {
550 let f: &F = &*(f as *const F);
551 f(&from_glib_borrow(this))
552 }
553 unsafe {
554 let f: Box_<F> = Box_::new(f);
555 connect_raw(
556 self.as_ptr() as *mut _,
557 b"notify::color-state\0".as_ptr() as *const _,
558 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
559 notify_color_state_trampoline::<F> as *const (),
560 )),
561 Box_::into_raw(f),
562 )
563 }
564 }
565
566 #[cfg(feature = "v4_14")]
567 #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
568 #[doc(alias = "display")]
569 pub fn connect_display_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
570 unsafe extern "C" fn notify_display_trampoline<F: Fn(&DmabufTextureBuilder) + 'static>(
571 this: *mut ffi::GdkDmabufTextureBuilder,
572 _param_spec: glib::ffi::gpointer,
573 f: glib::ffi::gpointer,
574 ) {
575 let f: &F = &*(f as *const F);
576 f(&from_glib_borrow(this))
577 }
578 unsafe {
579 let f: Box_<F> = Box_::new(f);
580 connect_raw(
581 self.as_ptr() as *mut _,
582 b"notify::display\0".as_ptr() as *const _,
583 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
584 notify_display_trampoline::<F> as *const (),
585 )),
586 Box_::into_raw(f),
587 )
588 }
589 }
590
591 #[cfg(feature = "v4_14")]
592 #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
593 #[doc(alias = "fourcc")]
594 pub fn connect_fourcc_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
595 unsafe extern "C" fn notify_fourcc_trampoline<F: Fn(&DmabufTextureBuilder) + 'static>(
596 this: *mut ffi::GdkDmabufTextureBuilder,
597 _param_spec: glib::ffi::gpointer,
598 f: glib::ffi::gpointer,
599 ) {
600 let f: &F = &*(f as *const F);
601 f(&from_glib_borrow(this))
602 }
603 unsafe {
604 let f: Box_<F> = Box_::new(f);
605 connect_raw(
606 self.as_ptr() as *mut _,
607 b"notify::fourcc\0".as_ptr() as *const _,
608 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
609 notify_fourcc_trampoline::<F> as *const (),
610 )),
611 Box_::into_raw(f),
612 )
613 }
614 }
615
616 #[cfg(feature = "v4_14")]
617 #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
618 #[doc(alias = "height")]
619 pub fn connect_height_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
620 unsafe extern "C" fn notify_height_trampoline<F: Fn(&DmabufTextureBuilder) + 'static>(
621 this: *mut ffi::GdkDmabufTextureBuilder,
622 _param_spec: glib::ffi::gpointer,
623 f: glib::ffi::gpointer,
624 ) {
625 let f: &F = &*(f as *const F);
626 f(&from_glib_borrow(this))
627 }
628 unsafe {
629 let f: Box_<F> = Box_::new(f);
630 connect_raw(
631 self.as_ptr() as *mut _,
632 b"notify::height\0".as_ptr() as *const _,
633 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
634 notify_height_trampoline::<F> as *const (),
635 )),
636 Box_::into_raw(f),
637 )
638 }
639 }
640
641 #[cfg(feature = "v4_14")]
642 #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
643 #[doc(alias = "modifier")]
644 pub fn connect_modifier_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
645 unsafe extern "C" fn notify_modifier_trampoline<F: Fn(&DmabufTextureBuilder) + 'static>(
646 this: *mut ffi::GdkDmabufTextureBuilder,
647 _param_spec: glib::ffi::gpointer,
648 f: glib::ffi::gpointer,
649 ) {
650 let f: &F = &*(f as *const F);
651 f(&from_glib_borrow(this))
652 }
653 unsafe {
654 let f: Box_<F> = Box_::new(f);
655 connect_raw(
656 self.as_ptr() as *mut _,
657 b"notify::modifier\0".as_ptr() as *const _,
658 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
659 notify_modifier_trampoline::<F> as *const (),
660 )),
661 Box_::into_raw(f),
662 )
663 }
664 }
665
666 #[cfg(feature = "v4_14")]
667 #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
668 #[doc(alias = "n-planes")]
669 pub fn connect_n_planes_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
670 unsafe extern "C" fn notify_n_planes_trampoline<F: Fn(&DmabufTextureBuilder) + 'static>(
671 this: *mut ffi::GdkDmabufTextureBuilder,
672 _param_spec: glib::ffi::gpointer,
673 f: glib::ffi::gpointer,
674 ) {
675 let f: &F = &*(f as *const F);
676 f(&from_glib_borrow(this))
677 }
678 unsafe {
679 let f: Box_<F> = Box_::new(f);
680 connect_raw(
681 self.as_ptr() as *mut _,
682 b"notify::n-planes\0".as_ptr() as *const _,
683 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
684 notify_n_planes_trampoline::<F> as *const (),
685 )),
686 Box_::into_raw(f),
687 )
688 }
689 }
690
691 #[cfg(feature = "v4_14")]
692 #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
693 #[doc(alias = "premultiplied")]
694 pub fn connect_premultiplied_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
695 unsafe extern "C" fn notify_premultiplied_trampoline<
696 F: Fn(&DmabufTextureBuilder) + 'static,
697 >(
698 this: *mut ffi::GdkDmabufTextureBuilder,
699 _param_spec: glib::ffi::gpointer,
700 f: glib::ffi::gpointer,
701 ) {
702 let f: &F = &*(f as *const F);
703 f(&from_glib_borrow(this))
704 }
705 unsafe {
706 let f: Box_<F> = Box_::new(f);
707 connect_raw(
708 self.as_ptr() as *mut _,
709 b"notify::premultiplied\0".as_ptr() as *const _,
710 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
711 notify_premultiplied_trampoline::<F> as *const (),
712 )),
713 Box_::into_raw(f),
714 )
715 }
716 }
717
718 #[cfg(feature = "v4_14")]
719 #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
720 #[doc(alias = "update-region")]
721 pub fn connect_update_region_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
722 unsafe extern "C" fn notify_update_region_trampoline<
723 F: Fn(&DmabufTextureBuilder) + 'static,
724 >(
725 this: *mut ffi::GdkDmabufTextureBuilder,
726 _param_spec: glib::ffi::gpointer,
727 f: glib::ffi::gpointer,
728 ) {
729 let f: &F = &*(f as *const F);
730 f(&from_glib_borrow(this))
731 }
732 unsafe {
733 let f: Box_<F> = Box_::new(f);
734 connect_raw(
735 self.as_ptr() as *mut _,
736 b"notify::update-region\0".as_ptr() as *const _,
737 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
738 notify_update_region_trampoline::<F> as *const (),
739 )),
740 Box_::into_raw(f),
741 )
742 }
743 }
744
745 #[cfg(feature = "v4_14")]
746 #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
747 #[doc(alias = "update-texture")]
748 pub fn connect_update_texture_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
749 unsafe extern "C" fn notify_update_texture_trampoline<
750 F: Fn(&DmabufTextureBuilder) + 'static,
751 >(
752 this: *mut ffi::GdkDmabufTextureBuilder,
753 _param_spec: glib::ffi::gpointer,
754 f: glib::ffi::gpointer,
755 ) {
756 let f: &F = &*(f as *const F);
757 f(&from_glib_borrow(this))
758 }
759 unsafe {
760 let f: Box_<F> = Box_::new(f);
761 connect_raw(
762 self.as_ptr() as *mut _,
763 b"notify::update-texture\0".as_ptr() as *const _,
764 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
765 notify_update_texture_trampoline::<F> as *const (),
766 )),
767 Box_::into_raw(f),
768 )
769 }
770 }
771
772 #[cfg(feature = "v4_14")]
773 #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
774 #[doc(alias = "width")]
775 pub fn connect_width_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
776 unsafe extern "C" fn notify_width_trampoline<F: Fn(&DmabufTextureBuilder) + 'static>(
777 this: *mut ffi::GdkDmabufTextureBuilder,
778 _param_spec: glib::ffi::gpointer,
779 f: glib::ffi::gpointer,
780 ) {
781 let f: &F = &*(f as *const F);
782 f(&from_glib_borrow(this))
783 }
784 unsafe {
785 let f: Box_<F> = Box_::new(f);
786 connect_raw(
787 self.as_ptr() as *mut _,
788 b"notify::width\0".as_ptr() as *const _,
789 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
790 notify_width_trampoline::<F> as *const (),
791 )),
792 Box_::into_raw(f),
793 )
794 }
795 }
796}
797
798#[cfg(feature = "v4_14")]
799#[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
800impl Default for DmabufTextureBuilder {
801 fn default() -> Self {
802 Self::new()
803 }
804}