mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-11-22 09:31:06 +00:00
gl: wrapper for gst_gl_framebuffer_draw_to_texture
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1314>
This commit is contained in:
parent
c071d8cba7
commit
8e3994f641
3 changed files with 40 additions and 3 deletions
|
@ -415,6 +415,7 @@ status = "generate"
|
|||
[[object]]
|
||||
name = "GstGL.GLFramebuffer"
|
||||
status = "generate"
|
||||
manual_traits = ["GLFramebufferExtManual"]
|
||||
|
||||
[[object.function]]
|
||||
name = "attach"
|
||||
|
@ -423,8 +424,7 @@ status = "generate"
|
|||
|
||||
[[object.function]]
|
||||
name = "draw_to_texture"
|
||||
# needs to be manually implemented for correct types/mutability
|
||||
ignore = true
|
||||
manual = true
|
||||
|
||||
[[object]]
|
||||
name = "GstGL.GLOverlayCompositor"
|
||||
|
|
35
gstreamer-gl/src/gl_framebuffer.rs
Normal file
35
gstreamer-gl/src/gl_framebuffer.rs
Normal file
|
@ -0,0 +1,35 @@
|
|||
use glib::{prelude::*, translate::*};
|
||||
|
||||
use crate::{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 {}
|
|
@ -42,6 +42,7 @@ mod gl_base_memory;
|
|||
pub use self::gl_base_memory::*;
|
||||
mod gl_memory;
|
||||
pub use crate::gl_memory::*;
|
||||
mod gl_framebuffer;
|
||||
mod gl_memory_pbo;
|
||||
pub use crate::gl_memory_pbo::*;
|
||||
|
||||
|
@ -53,7 +54,8 @@ pub mod prelude {
|
|||
|
||||
pub use crate::{
|
||||
auto::traits::*, context::ContextGLExt, gl_context::GLContextExtManual,
|
||||
gl_display::GLDisplayExtManual, gl_video_frame::VideoFrameGLExt,
|
||||
gl_display::GLDisplayExtManual, gl_framebuffer::GLFramebufferExtManual,
|
||||
gl_video_frame::VideoFrameGLExt,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue