mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-11-25 19:11:06 +00:00
gl: wrapper for the gst_gl_context_thread_add function
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1313>
This commit is contained in:
parent
a60cb26c27
commit
c071d8cba7
2 changed files with 24 additions and 2 deletions
|
@ -300,8 +300,7 @@ manual_traits = ["GLContextExtManual"]
|
||||||
|
|
||||||
[[object.function]]
|
[[object.function]]
|
||||||
name = "thread_add"
|
name = "thread_add"
|
||||||
# unimplemented GLContextThreadFunc
|
manual = true
|
||||||
ignore = true
|
|
||||||
|
|
||||||
[[object.function]]
|
[[object.function]]
|
||||||
name = "get_thread"
|
name = "get_thread"
|
||||||
|
|
|
@ -67,6 +67,29 @@ pub trait GLContextExtManual: sealed::Sealed + IsA<GLContext> + 'static {
|
||||||
) as uintptr_t
|
) as uintptr_t
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[doc(alias = "gst_gl_context_thread_add")]
|
||||||
|
fn thread_add<F: FnOnce(&Self) + Send>(&self, func: F) {
|
||||||
|
let mut func = std::mem::ManuallyDrop::new(func);
|
||||||
|
let user_data: *mut F = &mut *func;
|
||||||
|
|
||||||
|
unsafe extern "C" fn trampoline<O: IsA<GLContext>, F: FnOnce(&O) + Send>(
|
||||||
|
context: *mut ffi::GstGLContext,
|
||||||
|
data: glib::ffi::gpointer,
|
||||||
|
) {
|
||||||
|
let func = std::ptr::read(data as *mut F);
|
||||||
|
let context = GLContext::from_glib_borrow(context);
|
||||||
|
func(context.unsafe_cast_ref())
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe {
|
||||||
|
ffi::gst_gl_context_thread_add(
|
||||||
|
self.as_ref().to_glib_none().0,
|
||||||
|
Some(trampoline::<Self, F>),
|
||||||
|
user_data as glib::ffi::gpointer,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<O: IsA<GLContext>> GLContextExtManual for O {}
|
impl<O: IsA<GLContext>> GLContextExtManual for O {}
|
||||||
|
|
Loading…
Reference in a new issue