1use glib::{prelude::*, translate::*};
2
3use crate::{ffi, GLFramebuffer, GLMemoryRef};
4
5mod sealed {
6 pub trait Sealed {}
7 impl<T: super::IsA<super::GLFramebuffer>> Sealed for T {}
8}
9
10pub trait GLFramebufferExtManual: sealed::Sealed + IsA<GLFramebuffer> + 'static {
11 #[doc(alias = "gst_gl_framebuffer_draw_to_texture")]
12 fn draw_to_texture<F: FnOnce()>(&self, mem: &mut GLMemoryRef, func: F) {
13 let mut func: ManuallyDrop = std::mem::ManuallyDrop::new(func);
14 let user_data: *mut F = &mut *func;
15
16 unsafe extern "C" fn trampoline<F: FnOnce()>(
17 data: glib::ffi::gpointer,
18 ) -> glib::ffi::gboolean {
19 let func: F = std::ptr::read(src:data as *mut F);
20 func();
21 glib::ffi::GTRUE
22 }
23
24 unsafe {
25 ffi::gst_gl_framebuffer_draw_to_texture(
26 self.as_ref().to_glib_none().0,
27 mem.as_mut_ptr(),
28 func:Some(trampoline::<F>),
29 user_data as glib::ffi::gpointer,
30 );
31 }
32 }
33}
34
35impl<O: IsA<GLFramebuffer>> GLFramebufferExtManual for O {}
36