mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-06-02 21:39:24 +00:00
360 lines
11 KiB
Rust
360 lines
11 KiB
Rust
// 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 crate::GLDisplay;
|
|
use crate::GLPlatform;
|
|
use crate::GLSLProfile;
|
|
use crate::GLSLVersion;
|
|
use crate::GLWindow;
|
|
use crate::GLAPI;
|
|
use glib::object::IsA;
|
|
use glib::translate::*;
|
|
use std::mem;
|
|
use std::ptr;
|
|
|
|
glib::wrapper! {
|
|
pub struct GLContext(Object<ffi::GstGLContext, ffi::GstGLContextClass>) @extends gst::Object;
|
|
|
|
match fn {
|
|
get_type => || ffi::gst_gl_context_get_type(),
|
|
}
|
|
}
|
|
|
|
impl GLContext {
|
|
#[doc(alias = "gst_gl_context_new")]
|
|
pub fn new<P: IsA<GLDisplay>>(display: &P) -> GLContext {
|
|
skip_assert_initialized!();
|
|
unsafe { from_glib_none(ffi::gst_gl_context_new(display.as_ref().to_glib_none().0)) }
|
|
}
|
|
|
|
#[doc(alias = "gst_gl_context_get_current")]
|
|
pub fn get_current() -> Option<GLContext> {
|
|
assert_initialized_main_thread!();
|
|
unsafe { from_glib_none(ffi::gst_gl_context_get_current()) }
|
|
}
|
|
|
|
#[doc(alias = "gst_gl_context_get_current_gl_api")]
|
|
pub fn get_current_gl_api(platform: GLPlatform) -> (GLAPI, u32, u32) {
|
|
assert_initialized_main_thread!();
|
|
unsafe {
|
|
let mut major = mem::MaybeUninit::uninit();
|
|
let mut minor = mem::MaybeUninit::uninit();
|
|
let ret = from_glib(ffi::gst_gl_context_get_current_gl_api(
|
|
platform.to_glib(),
|
|
major.as_mut_ptr(),
|
|
minor.as_mut_ptr(),
|
|
));
|
|
let major = major.assume_init();
|
|
let minor = minor.assume_init();
|
|
(ret, major, minor)
|
|
}
|
|
}
|
|
}
|
|
|
|
unsafe impl Send for GLContext {}
|
|
unsafe impl Sync for GLContext {}
|
|
|
|
pub const NONE_GL_CONTEXT: Option<&GLContext> = None;
|
|
|
|
pub trait GLContextExt: 'static {
|
|
#[doc(alias = "gst_gl_context_activate")]
|
|
fn activate(&self, activate: bool) -> Result<(), glib::error::BoolError>;
|
|
|
|
#[doc(alias = "gst_gl_context_can_share")]
|
|
fn can_share<P: IsA<GLContext>>(&self, other_context: &P) -> bool;
|
|
|
|
#[doc(alias = "gst_gl_context_check_feature")]
|
|
fn check_feature(&self, feature: &str) -> bool;
|
|
|
|
#[doc(alias = "gst_gl_context_check_framebuffer_status")]
|
|
fn check_framebuffer_status(&self, fbo_target: u32) -> bool;
|
|
|
|
#[doc(alias = "gst_gl_context_check_gl_version")]
|
|
fn check_gl_version(&self, api: GLAPI, maj: i32, min: i32) -> bool;
|
|
|
|
#[doc(alias = "gst_gl_context_clear_framebuffer")]
|
|
fn clear_framebuffer(&self);
|
|
|
|
#[doc(alias = "gst_gl_context_clear_shader")]
|
|
fn clear_shader(&self);
|
|
|
|
#[doc(alias = "gst_gl_context_create")]
|
|
fn create<P: IsA<GLContext>>(&self, other_context: Option<&P>) -> Result<(), glib::Error>;
|
|
|
|
#[doc(alias = "gst_gl_context_destroy")]
|
|
fn destroy(&self);
|
|
|
|
#[doc(alias = "gst_gl_context_fill_info")]
|
|
fn fill_info(&self) -> Result<(), glib::Error>;
|
|
|
|
#[doc(alias = "gst_gl_context_get_display")]
|
|
fn get_display(&self) -> GLDisplay;
|
|
|
|
#[doc(alias = "gst_gl_context_get_gl_api")]
|
|
fn get_gl_api(&self) -> GLAPI;
|
|
|
|
#[doc(alias = "gst_gl_context_get_gl_platform")]
|
|
fn get_gl_platform(&self) -> GLPlatform;
|
|
|
|
#[doc(alias = "gst_gl_context_get_gl_platform_version")]
|
|
fn get_gl_platform_version(&self) -> (i32, i32);
|
|
|
|
#[doc(alias = "gst_gl_context_get_gl_version")]
|
|
fn get_gl_version(&self) -> (i32, i32);
|
|
|
|
#[doc(alias = "gst_gl_context_get_window")]
|
|
fn get_window(&self) -> Option<GLWindow>;
|
|
|
|
#[doc(alias = "gst_gl_context_is_shared")]
|
|
fn is_shared(&self) -> bool;
|
|
|
|
#[doc(alias = "gst_gl_context_set_shared_with")]
|
|
fn set_shared_with<P: IsA<GLContext>>(&self, share: &P);
|
|
|
|
#[doc(alias = "gst_gl_context_set_window")]
|
|
fn set_window<P: IsA<GLWindow>>(&self, window: &P) -> Result<(), glib::error::BoolError>;
|
|
|
|
#[doc(alias = "gst_gl_context_supports_glsl_profile_version")]
|
|
fn supports_glsl_profile_version(&self, version: GLSLVersion, profile: GLSLProfile) -> bool;
|
|
|
|
#[cfg(any(feature = "v1_16", feature = "dox"))]
|
|
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_16")))]
|
|
#[doc(alias = "gst_gl_context_supports_precision")]
|
|
fn supports_precision(&self, version: GLSLVersion, profile: GLSLProfile) -> bool;
|
|
|
|
#[cfg(any(feature = "v1_16", feature = "dox"))]
|
|
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_16")))]
|
|
#[doc(alias = "gst_gl_context_supports_precision_highp")]
|
|
fn supports_precision_highp(&self, version: GLSLVersion, profile: GLSLProfile) -> bool;
|
|
|
|
#[doc(alias = "gst_gl_context_swap_buffers")]
|
|
fn swap_buffers(&self);
|
|
}
|
|
|
|
impl<O: IsA<GLContext>> GLContextExt for O {
|
|
fn activate(&self, activate: bool) -> Result<(), glib::error::BoolError> {
|
|
unsafe {
|
|
glib::result_from_gboolean!(
|
|
ffi::gst_gl_context_activate(self.as_ref().to_glib_none().0, activate.to_glib()),
|
|
"Failed to activate OpenGL context"
|
|
)
|
|
}
|
|
}
|
|
|
|
fn can_share<P: IsA<GLContext>>(&self, other_context: &P) -> bool {
|
|
unsafe {
|
|
from_glib(ffi::gst_gl_context_can_share(
|
|
self.as_ref().to_glib_none().0,
|
|
other_context.as_ref().to_glib_none().0,
|
|
))
|
|
}
|
|
}
|
|
|
|
fn check_feature(&self, feature: &str) -> bool {
|
|
unsafe {
|
|
from_glib(ffi::gst_gl_context_check_feature(
|
|
self.as_ref().to_glib_none().0,
|
|
feature.to_glib_none().0,
|
|
))
|
|
}
|
|
}
|
|
|
|
fn check_framebuffer_status(&self, fbo_target: u32) -> bool {
|
|
unsafe {
|
|
from_glib(ffi::gst_gl_context_check_framebuffer_status(
|
|
self.as_ref().to_glib_none().0,
|
|
fbo_target,
|
|
))
|
|
}
|
|
}
|
|
|
|
fn check_gl_version(&self, api: GLAPI, maj: i32, min: i32) -> bool {
|
|
unsafe {
|
|
from_glib(ffi::gst_gl_context_check_gl_version(
|
|
self.as_ref().to_glib_none().0,
|
|
api.to_glib(),
|
|
maj,
|
|
min,
|
|
))
|
|
}
|
|
}
|
|
|
|
fn clear_framebuffer(&self) {
|
|
unsafe {
|
|
ffi::gst_gl_context_clear_framebuffer(self.as_ref().to_glib_none().0);
|
|
}
|
|
}
|
|
|
|
fn clear_shader(&self) {
|
|
unsafe {
|
|
ffi::gst_gl_context_clear_shader(self.as_ref().to_glib_none().0);
|
|
}
|
|
}
|
|
|
|
fn create<P: IsA<GLContext>>(&self, other_context: Option<&P>) -> Result<(), glib::Error> {
|
|
unsafe {
|
|
let mut error = ptr::null_mut();
|
|
let _ = ffi::gst_gl_context_create(
|
|
self.as_ref().to_glib_none().0,
|
|
other_context.map(|p| p.as_ref()).to_glib_none().0,
|
|
&mut error,
|
|
);
|
|
if error.is_null() {
|
|
Ok(())
|
|
} else {
|
|
Err(from_glib_full(error))
|
|
}
|
|
}
|
|
}
|
|
|
|
fn destroy(&self) {
|
|
unsafe {
|
|
ffi::gst_gl_context_destroy(self.as_ref().to_glib_none().0);
|
|
}
|
|
}
|
|
|
|
fn fill_info(&self) -> Result<(), glib::Error> {
|
|
unsafe {
|
|
let mut error = ptr::null_mut();
|
|
let _ = ffi::gst_gl_context_fill_info(self.as_ref().to_glib_none().0, &mut error);
|
|
if error.is_null() {
|
|
Ok(())
|
|
} else {
|
|
Err(from_glib_full(error))
|
|
}
|
|
}
|
|
}
|
|
|
|
fn get_display(&self) -> GLDisplay {
|
|
unsafe {
|
|
from_glib_full(ffi::gst_gl_context_get_display(
|
|
self.as_ref().to_glib_none().0,
|
|
))
|
|
}
|
|
}
|
|
|
|
fn get_gl_api(&self) -> GLAPI {
|
|
unsafe {
|
|
from_glib(ffi::gst_gl_context_get_gl_api(
|
|
self.as_ref().to_glib_none().0,
|
|
))
|
|
}
|
|
}
|
|
|
|
fn get_gl_platform(&self) -> GLPlatform {
|
|
unsafe {
|
|
from_glib(ffi::gst_gl_context_get_gl_platform(
|
|
self.as_ref().to_glib_none().0,
|
|
))
|
|
}
|
|
}
|
|
|
|
fn get_gl_platform_version(&self) -> (i32, i32) {
|
|
unsafe {
|
|
let mut major = mem::MaybeUninit::uninit();
|
|
let mut minor = mem::MaybeUninit::uninit();
|
|
ffi::gst_gl_context_get_gl_platform_version(
|
|
self.as_ref().to_glib_none().0,
|
|
major.as_mut_ptr(),
|
|
minor.as_mut_ptr(),
|
|
);
|
|
let major = major.assume_init();
|
|
let minor = minor.assume_init();
|
|
(major, minor)
|
|
}
|
|
}
|
|
|
|
fn get_gl_version(&self) -> (i32, i32) {
|
|
unsafe {
|
|
let mut maj = mem::MaybeUninit::uninit();
|
|
let mut min = mem::MaybeUninit::uninit();
|
|
ffi::gst_gl_context_get_gl_version(
|
|
self.as_ref().to_glib_none().0,
|
|
maj.as_mut_ptr(),
|
|
min.as_mut_ptr(),
|
|
);
|
|
let maj = maj.assume_init();
|
|
let min = min.assume_init();
|
|
(maj, min)
|
|
}
|
|
}
|
|
|
|
fn get_window(&self) -> Option<GLWindow> {
|
|
unsafe {
|
|
from_glib_full(ffi::gst_gl_context_get_window(
|
|
self.as_ref().to_glib_none().0,
|
|
))
|
|
}
|
|
}
|
|
|
|
fn is_shared(&self) -> bool {
|
|
unsafe {
|
|
from_glib(ffi::gst_gl_context_is_shared(
|
|
self.as_ref().to_glib_none().0,
|
|
))
|
|
}
|
|
}
|
|
|
|
fn set_shared_with<P: IsA<GLContext>>(&self, share: &P) {
|
|
unsafe {
|
|
ffi::gst_gl_context_set_shared_with(
|
|
self.as_ref().to_glib_none().0,
|
|
share.as_ref().to_glib_none().0,
|
|
);
|
|
}
|
|
}
|
|
|
|
fn set_window<P: IsA<GLWindow>>(&self, window: &P) -> Result<(), glib::error::BoolError> {
|
|
unsafe {
|
|
glib::result_from_gboolean!(
|
|
ffi::gst_gl_context_set_window(
|
|
self.as_ref().to_glib_none().0,
|
|
window.as_ref().to_glib_full()
|
|
),
|
|
"Failed to set window"
|
|
)
|
|
}
|
|
}
|
|
|
|
fn supports_glsl_profile_version(&self, version: GLSLVersion, profile: GLSLProfile) -> bool {
|
|
unsafe {
|
|
from_glib(ffi::gst_gl_context_supports_glsl_profile_version(
|
|
self.as_ref().to_glib_none().0,
|
|
version.to_glib(),
|
|
profile.to_glib(),
|
|
))
|
|
}
|
|
}
|
|
|
|
#[cfg(any(feature = "v1_16", feature = "dox"))]
|
|
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_16")))]
|
|
fn supports_precision(&self, version: GLSLVersion, profile: GLSLProfile) -> bool {
|
|
unsafe {
|
|
from_glib(ffi::gst_gl_context_supports_precision(
|
|
self.as_ref().to_glib_none().0,
|
|
version.to_glib(),
|
|
profile.to_glib(),
|
|
))
|
|
}
|
|
}
|
|
|
|
#[cfg(any(feature = "v1_16", feature = "dox"))]
|
|
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_16")))]
|
|
fn supports_precision_highp(&self, version: GLSLVersion, profile: GLSLProfile) -> bool {
|
|
unsafe {
|
|
from_glib(ffi::gst_gl_context_supports_precision_highp(
|
|
self.as_ref().to_glib_none().0,
|
|
version.to_glib(),
|
|
profile.to_glib(),
|
|
))
|
|
}
|
|
}
|
|
|
|
fn swap_buffers(&self) {
|
|
unsafe {
|
|
ffi::gst_gl_context_swap_buffers(self.as_ref().to_glib_none().0);
|
|
}
|
|
}
|
|
}
|