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 | // from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git) |
4 | // DO NOT EDIT |
5 | |
6 | use crate::{ffi, GLContext, GLDisplayType, GLWindow, GLAPI}; |
7 | use glib::{ |
8 | object::ObjectType as _, |
9 | prelude::*, |
10 | signal::{connect_raw, SignalHandlerId}, |
11 | translate::*, |
12 | }; |
13 | use std::boxed::Box as Box_; |
14 | |
15 | glib::wrapper! { |
16 | #[doc (alias = "GstGLDisplay" )] |
17 | pub struct GLDisplay(Object<ffi::GstGLDisplay, ffi::GstGLDisplayClass>) @extends gst::Object; |
18 | |
19 | match fn { |
20 | type_ => || ffi::gst_gl_display_get_type(), |
21 | } |
22 | } |
23 | |
24 | impl GLDisplay { |
25 | pub const NONE: Option<&'static GLDisplay> = None; |
26 | |
27 | #[doc (alias = "gst_gl_display_new" )] |
28 | pub fn new() -> GLDisplay { |
29 | assert_initialized_main_thread!(); |
30 | unsafe { from_glib_full(ptr:ffi::gst_gl_display_new()) } |
31 | } |
32 | |
33 | #[cfg (feature = "v1_20" )] |
34 | #[cfg_attr (docsrs, doc(cfg(feature = "v1_20" )))] |
35 | #[doc (alias = "gst_gl_display_new_with_type" )] |
36 | #[doc (alias = "new_with_type" )] |
37 | pub fn with_type(type_: GLDisplayType) -> Option<GLDisplay> { |
38 | assert_initialized_main_thread!(); |
39 | unsafe { from_glib_full(ffi::gst_gl_display_new_with_type(type_.into_glib())) } |
40 | } |
41 | } |
42 | |
43 | impl Default for GLDisplay { |
44 | fn default() -> Self { |
45 | Self::new() |
46 | } |
47 | } |
48 | |
49 | unsafe impl Send for GLDisplay {} |
50 | unsafe impl Sync for GLDisplay {} |
51 | |
52 | mod sealed { |
53 | pub trait Sealed {} |
54 | impl<T: super::IsA<super::GLDisplay>> Sealed for T {} |
55 | } |
56 | |
57 | pub trait GLDisplayExt: IsA<GLDisplay> + sealed::Sealed + 'static { |
58 | #[doc (alias = "gst_gl_display_create_window" )] |
59 | fn create_window(&self) -> Result<GLWindow, glib::BoolError> { |
60 | unsafe { |
61 | Option::<_>::from_glib_full(ffi::gst_gl_display_create_window( |
62 | self.as_ref().to_glib_none().0, |
63 | )) |
64 | .ok_or_else(|| glib::bool_error!("Failed to create window" )) |
65 | } |
66 | } |
67 | |
68 | #[doc (alias = "gst_gl_display_filter_gl_api" )] |
69 | fn filter_gl_api(&self, gl_api: GLAPI) { |
70 | unsafe { |
71 | ffi::gst_gl_display_filter_gl_api(self.as_ref().to_glib_none().0, gl_api.into_glib()); |
72 | } |
73 | } |
74 | |
75 | #[doc (alias = "gst_gl_display_get_gl_api" )] |
76 | #[doc (alias = "get_gl_api" )] |
77 | fn gl_api(&self) -> GLAPI { |
78 | unsafe { |
79 | from_glib(ffi::gst_gl_display_get_gl_api( |
80 | self.as_ref().to_glib_none().0, |
81 | )) |
82 | } |
83 | } |
84 | |
85 | #[doc (alias = "gst_gl_display_get_gl_api_unlocked" )] |
86 | #[doc (alias = "get_gl_api_unlocked" )] |
87 | fn gl_api_unlocked(&self) -> GLAPI { |
88 | unsafe { |
89 | from_glib(ffi::gst_gl_display_get_gl_api_unlocked( |
90 | self.as_ref().to_glib_none().0, |
91 | )) |
92 | } |
93 | } |
94 | |
95 | #[doc (alias = "gst_gl_display_get_handle_type" )] |
96 | #[doc (alias = "get_handle_type" )] |
97 | fn handle_type(&self) -> GLDisplayType { |
98 | unsafe { |
99 | from_glib(ffi::gst_gl_display_get_handle_type( |
100 | self.as_ref().to_glib_none().0, |
101 | )) |
102 | } |
103 | } |
104 | |
105 | #[doc (alias = "gst_gl_display_remove_window" )] |
106 | fn remove_window(&self, window: &impl IsA<GLWindow>) -> Result<(), glib::error::BoolError> { |
107 | unsafe { |
108 | glib::result_from_gboolean!( |
109 | ffi::gst_gl_display_remove_window( |
110 | self.as_ref().to_glib_none().0, |
111 | window.as_ref().to_glib_none().0 |
112 | ), |
113 | "Failed to remove window" |
114 | ) |
115 | } |
116 | } |
117 | |
118 | //#[cfg(feature = "v1_18")] |
119 | //#[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))] |
120 | //#[doc(alias = "gst_gl_display_retrieve_window")] |
121 | //fn retrieve_window(&self, data: /*Unimplemented*/Option<Basic: Pointer>, compare_func: /*Unimplemented*/FnMut(/*Unimplemented*/Option<Basic: Pointer>) -> i32) -> Option<GLWindow> { |
122 | // unsafe { TODO: call ffi:gst_gl_display_retrieve_window() } |
123 | //} |
124 | |
125 | #[doc (alias = "create-context" )] |
126 | fn connect_create_context< |
127 | F: Fn(&Self, &GLContext) -> Option<GLContext> + Send + Sync + 'static, |
128 | >( |
129 | &self, |
130 | f: F, |
131 | ) -> SignalHandlerId { |
132 | unsafe extern "C" fn create_context_trampoline< |
133 | P: IsA<GLDisplay>, |
134 | F: Fn(&P, &GLContext) -> Option<GLContext> + Send + Sync + 'static, |
135 | >( |
136 | this: *mut ffi::GstGLDisplay, |
137 | context: *mut ffi::GstGLContext, |
138 | f: glib::ffi::gpointer, |
139 | ) -> *mut ffi::GstGLContext { |
140 | let f: &F = &*(f as *const F); |
141 | f( |
142 | GLDisplay::from_glib_borrow(this).unsafe_cast_ref(), |
143 | &from_glib_borrow(context), |
144 | ) |
145 | .to_glib_full() |
146 | } |
147 | unsafe { |
148 | let f: Box_<F> = Box_::new(f); |
149 | connect_raw( |
150 | self.as_ptr() as *mut _, |
151 | b"create-context \0" .as_ptr() as *const _, |
152 | Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( |
153 | create_context_trampoline::<Self, F> as *const (), |
154 | )), |
155 | Box_::into_raw(f), |
156 | ) |
157 | } |
158 | } |
159 | } |
160 | |
161 | impl<O: IsA<GLDisplay>> GLDisplayExt for O {} |
162 | |