glsl_stage.rs 3.28 KB
Newer Older
1 2 3 4 5 6 7 8 9
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT

use Error;
use GLContext;
use GLSLProfile;
use GLSLVersion;
use ffi;
10
use glib::GString;
11
use glib::object::IsA;
12 13 14 15 16
use glib::translate::*;
use gst;
use std::ptr;

glib_wrapper! {
17
    pub struct GLSLStage(Object<ffi::GstGLSLStage, ffi::GstGLSLStageClass, GLSLStageClass>) @extends gst::Object;
18 19 20 21 22 23 24

    match fn {
        get_type => || ffi::gst_glsl_stage_get_type(),
    }
}

impl GLSLStage {
25
    pub fn new<P: IsA<GLContext>>(context: &P, type_: u32) -> GLSLStage {
26 27
        skip_assert_initialized!();
        unsafe {
28
            from_glib_none(ffi::gst_glsl_stage_new(context.as_ref().to_glib_none().0, type_))
29 30 31
        }
    }

32
    pub fn new_default_fragment<P: IsA<GLContext>>(context: &P) -> GLSLStage {
33 34
        skip_assert_initialized!();
        unsafe {
35
            from_glib_none(ffi::gst_glsl_stage_new_default_fragment(context.as_ref().to_glib_none().0))
36 37 38
        }
    }

39
    pub fn new_default_vertex<P: IsA<GLContext>>(context: &P) -> GLSLStage {
40 41
        skip_assert_initialized!();
        unsafe {
42
            from_glib_none(ffi::gst_glsl_stage_new_default_vertex(context.as_ref().to_glib_none().0))
43 44 45
        }
    }

46
    pub fn new_with_string<P: IsA<GLContext>>(context: &P, type_: u32, version: GLSLVersion, profile: GLSLProfile, str: &str) -> GLSLStage {
47 48
        skip_assert_initialized!();
        unsafe {
49
            from_glib_none(ffi::gst_glsl_stage_new_with_string(context.as_ref().to_glib_none().0, type_, version.to_glib(), profile.to_glib(), str.to_glib_none().0))
50 51 52
        }
    }

53
    pub fn new_with_strings<P: IsA<GLContext>>(context: &P, type_: u32, version: GLSLVersion, profile: GLSLProfile, str: &[&str]) -> GLSLStage {
54 55 56
        skip_assert_initialized!();
        let n_strings = str.len() as i32;
        unsafe {
57
            from_glib_none(ffi::gst_glsl_stage_new_with_strings(context.as_ref().to_glib_none().0, type_, version.to_glib(), profile.to_glib(), n_strings, str.to_glib_none().0))
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
        }
    }

    pub fn compile(&self) -> Result<(), Error> {
        unsafe {
            let mut error = ptr::null_mut();
            let _ = ffi::gst_glsl_stage_compile(self.to_glib_none().0, &mut error);
            if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
        }
    }

    pub fn get_handle(&self) -> u32 {
        unsafe {
            ffi::gst_glsl_stage_get_handle(self.to_glib_none().0)
        }
    }

    pub fn get_profile(&self) -> GLSLProfile {
        unsafe {
            from_glib(ffi::gst_glsl_stage_get_profile(self.to_glib_none().0))
        }
    }

    pub fn get_shader_type(&self) -> u32 {
        unsafe {
            ffi::gst_glsl_stage_get_shader_type(self.to_glib_none().0)
        }
    }

    pub fn get_version(&self) -> GLSLVersion {
        unsafe {
            from_glib(ffi::gst_glsl_stage_get_version(self.to_glib_none().0))
        }
    }

    pub fn set_strings(&self, version: GLSLVersion, profile: GLSLProfile, str: &[&str]) -> bool {
        let n_strings = str.len() as i32;
        unsafe {
            from_glib(ffi::gst_glsl_stage_set_strings(self.to_glib_none().0, version.to_glib(), profile.to_glib(), n_strings, str.to_glib_none().0))
        }
    }
}

unsafe impl Send for GLSLStage {}
unsafe impl Sync for GLSLStage {}