1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git)
// DO NOT EDIT

use crate::{GLBaseFilter, GLMemory, GLShader};
use glib::{prelude::*, translate::*};

glib::wrapper! {
    #[doc(alias = "GstGLFilter")]
    pub struct GLFilter(Object<ffi::GstGLFilter, ffi::GstGLFilterClass>) @extends GLBaseFilter, gst_base::BaseTransform, gst::Element, gst::Object;

    match fn {
        type_ => || ffi::gst_gl_filter_get_type(),
    }
}

impl GLFilter {
    pub const NONE: Option<&'static GLFilter> = None;
}

unsafe impl Send for GLFilter {}
unsafe impl Sync for GLFilter {}

mod sealed {
    pub trait Sealed {}
    impl<T: super::IsA<super::GLFilter>> Sealed for T {}
}

pub trait GLFilterExt: IsA<GLFilter> + sealed::Sealed + 'static {
    #[doc(alias = "gst_gl_filter_draw_fullscreen_quad")]
    fn draw_fullscreen_quad(&self) {
        unsafe {
            ffi::gst_gl_filter_draw_fullscreen_quad(self.as_ref().to_glib_none().0);
        }
    }

    #[doc(alias = "gst_gl_filter_filter_texture")]
    fn filter_texture(
        &self,
        input: &gst::Buffer,
        output: &gst::Buffer,
    ) -> Result<(), glib::error::BoolError> {
        unsafe {
            glib::result_from_gboolean!(
                ffi::gst_gl_filter_filter_texture(
                    self.as_ref().to_glib_none().0,
                    input.to_glib_none().0,
                    output.to_glib_none().0
                ),
                "Failed to transform texture"
            )
        }
    }

    #[doc(alias = "gst_gl_filter_render_to_target")]
    fn render_to_target<P: FnMut(&GLFilter, &GLMemory) -> bool>(
        &self,
        input: &GLMemory,
        output: &GLMemory,
        func: P,
    ) -> Result<(), glib::error::BoolError> {
        let func_data: P = func;
        unsafe extern "C" fn func_func<P: FnMut(&GLFilter, &GLMemory) -> bool>(
            filter: *mut ffi::GstGLFilter,
            in_tex: *mut ffi::GstGLMemory,
            user_data: glib::ffi::gpointer,
        ) -> glib::ffi::gboolean {
            let filter = from_glib_borrow(filter);
            let in_tex = from_glib_borrow(in_tex);
            let callback = user_data as *mut P;
            (*callback)(&filter, &in_tex).into_glib()
        }
        let func = Some(func_func::<P> as _);
        let super_callback0: &P = &func_data;
        unsafe {
            glib::result_from_gboolean!(
                ffi::gst_gl_filter_render_to_target(
                    self.as_ref().to_glib_none().0,
                    mut_override(input.to_glib_none().0),
                    mut_override(output.to_glib_none().0),
                    func,
                    super_callback0 as *const _ as *mut _
                ),
                "`func` returned `false`"
            )
        }
    }

    #[doc(alias = "gst_gl_filter_render_to_target_with_shader")]
    fn render_to_target_with_shader(&self, input: &GLMemory, output: &GLMemory, shader: &GLShader) {
        unsafe {
            ffi::gst_gl_filter_render_to_target_with_shader(
                self.as_ref().to_glib_none().0,
                mut_override(input.to_glib_none().0),
                mut_override(output.to_glib_none().0),
                shader.to_glib_none().0,
            );
        }
    }
}

impl<O: IsA<GLFilter>> GLFilterExt for O {}