mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-09-27 14:30:36 +00:00
4ebec84f5e
Allows us to set all the crates in the main workspace file, so changing their versions or branch is much simpler and reduce the amount of noise in the diff Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1450>
35 lines
1.1 KiB
Rust
35 lines
1.1 KiB
Rust
use glib::{prelude::*, translate::*};
|
|
|
|
use crate::{ffi, GLFramebuffer, GLMemoryRef};
|
|
|
|
mod sealed {
|
|
pub trait Sealed {}
|
|
impl<T: super::IsA<super::GLFramebuffer>> Sealed for T {}
|
|
}
|
|
|
|
pub trait GLFramebufferExtManual: sealed::Sealed + IsA<GLFramebuffer> + 'static {
|
|
#[doc(alias = "gst_gl_framebuffer_draw_to_texture")]
|
|
fn draw_to_texture<F: FnOnce()>(&self, mem: &mut GLMemoryRef, func: F) {
|
|
let mut func = std::mem::ManuallyDrop::new(func);
|
|
let user_data: *mut F = &mut *func;
|
|
|
|
unsafe extern "C" fn trampoline<F: FnOnce()>(
|
|
data: glib::ffi::gpointer,
|
|
) -> glib::ffi::gboolean {
|
|
let func = std::ptr::read(data as *mut F);
|
|
func();
|
|
glib::ffi::GTRUE
|
|
}
|
|
|
|
unsafe {
|
|
ffi::gst_gl_framebuffer_draw_to_texture(
|
|
self.as_ref().to_glib_none().0,
|
|
mem.as_mut_ptr(),
|
|
Some(trampoline::<F>),
|
|
user_data as glib::ffi::gpointer,
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
impl<O: IsA<GLFramebuffer>> GLFramebufferExtManual for O {}
|