gstreamer_gl/auto/
glsl_stage.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git)
4// DO NOT EDIT
5
6use crate::{ffi, GLContext, GLSLProfile, GLSLVersion};
7use glib::{prelude::*, translate::*};
8
9glib::wrapper! {
10    #[doc(alias = "GstGLSLStage")]
11    pub struct GLSLStage(Object<ffi::GstGLSLStage, ffi::GstGLSLStageClass>) @extends gst::Object;
12
13    match fn {
14        type_ => || ffi::gst_glsl_stage_get_type(),
15    }
16}
17
18impl GLSLStage {
19    #[doc(alias = "gst_glsl_stage_new")]
20    pub fn new(context: &impl IsA<GLContext>, type_: u32) -> GLSLStage {
21        skip_assert_initialized!();
22        unsafe {
23            from_glib_none(ffi::gst_glsl_stage_new(
24                context.as_ref().to_glib_none().0,
25                type_,
26            ))
27        }
28    }
29
30    #[doc(alias = "gst_glsl_stage_new_default_fragment")]
31    pub fn new_default_fragment(context: &impl IsA<GLContext>) -> GLSLStage {
32        skip_assert_initialized!();
33        unsafe {
34            from_glib_none(ffi::gst_glsl_stage_new_default_fragment(
35                context.as_ref().to_glib_none().0,
36            ))
37        }
38    }
39
40    #[doc(alias = "gst_glsl_stage_new_default_vertex")]
41    pub fn new_default_vertex(context: &impl IsA<GLContext>) -> GLSLStage {
42        skip_assert_initialized!();
43        unsafe {
44            from_glib_none(ffi::gst_glsl_stage_new_default_vertex(
45                context.as_ref().to_glib_none().0,
46            ))
47        }
48    }
49
50    #[doc(alias = "gst_glsl_stage_new_with_string")]
51    #[doc(alias = "new_with_string")]
52    pub fn with_string(
53        context: &impl IsA<GLContext>,
54        type_: u32,
55        version: GLSLVersion,
56        profile: GLSLProfile,
57        str: &str,
58    ) -> GLSLStage {
59        skip_assert_initialized!();
60        unsafe {
61            from_glib_none(ffi::gst_glsl_stage_new_with_string(
62                context.as_ref().to_glib_none().0,
63                type_,
64                version.into_glib(),
65                profile.into_glib(),
66                str.to_glib_none().0,
67            ))
68        }
69    }
70
71    #[doc(alias = "gst_glsl_stage_new_with_strings")]
72    #[doc(alias = "new_with_strings")]
73    pub fn with_strings(
74        context: &impl IsA<GLContext>,
75        type_: u32,
76        version: GLSLVersion,
77        profile: GLSLProfile,
78        str: &[&str],
79    ) -> GLSLStage {
80        skip_assert_initialized!();
81        let n_strings = str.len() as _;
82        unsafe {
83            from_glib_none(ffi::gst_glsl_stage_new_with_strings(
84                context.as_ref().to_glib_none().0,
85                type_,
86                version.into_glib(),
87                profile.into_glib(),
88                n_strings,
89                str.to_glib_none().0,
90            ))
91        }
92    }
93
94    #[doc(alias = "gst_glsl_stage_compile")]
95    pub fn compile(&self) -> Result<(), glib::Error> {
96        unsafe {
97            let mut error = std::ptr::null_mut();
98            let is_ok = ffi::gst_glsl_stage_compile(self.to_glib_none().0, &mut error);
99            debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
100            if error.is_null() {
101                Ok(())
102            } else {
103                Err(from_glib_full(error))
104            }
105        }
106    }
107
108    #[doc(alias = "gst_glsl_stage_get_handle")]
109    #[doc(alias = "get_handle")]
110    pub fn handle(&self) -> u32 {
111        unsafe { ffi::gst_glsl_stage_get_handle(self.to_glib_none().0) }
112    }
113
114    #[doc(alias = "gst_glsl_stage_get_profile")]
115    #[doc(alias = "get_profile")]
116    pub fn profile(&self) -> GLSLProfile {
117        unsafe { from_glib(ffi::gst_glsl_stage_get_profile(self.to_glib_none().0)) }
118    }
119
120    #[doc(alias = "gst_glsl_stage_get_shader_type")]
121    #[doc(alias = "get_shader_type")]
122    pub fn shader_type(&self) -> u32 {
123        unsafe { ffi::gst_glsl_stage_get_shader_type(self.to_glib_none().0) }
124    }
125
126    #[doc(alias = "gst_glsl_stage_get_version")]
127    #[doc(alias = "get_version")]
128    pub fn version(&self) -> GLSLVersion {
129        unsafe { from_glib(ffi::gst_glsl_stage_get_version(self.to_glib_none().0)) }
130    }
131
132    #[doc(alias = "gst_glsl_stage_set_strings")]
133    pub fn set_strings(
134        &self,
135        version: GLSLVersion,
136        profile: GLSLProfile,
137        str: &[&str],
138    ) -> Result<(), glib::error::BoolError> {
139        let n_strings = str.len() as _;
140        unsafe {
141            glib::result_from_gboolean!(
142                ffi::gst_glsl_stage_set_strings(
143                    self.to_glib_none().0,
144                    version.into_glib(),
145                    profile.into_glib(),
146                    n_strings,
147                    str.to_glib_none().0
148                ),
149                "Failed to attach stage to set strings"
150            )
151        }
152    }
153}
154
155unsafe impl Send for GLSLStage {}
156unsafe impl Sync for GLSLStage {}