gstreamer-rs/gstreamer-gl/src/auto/gl_context.rs

338 lines
11 KiB
Rust
Raw Normal View History

2018-11-27 21:52:42 +00:00
// 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)
2018-11-27 21:52:42 +00:00
// DO NOT EDIT
use crate::{GLDisplay, GLPlatform, GLSLProfile, GLSLVersion, GLWindow, GLAPI};
use glib::{prelude::*, translate::*};
use std::{mem, ptr};
2018-11-27 21:52:42 +00:00
2020-12-17 22:34:53 +00:00
glib::wrapper! {
#[doc(alias = "GstGLContext")]
2020-11-22 10:20:20 +00:00
pub struct GLContext(Object<ffi::GstGLContext, ffi::GstGLContextClass>) @extends gst::Object;
2018-11-27 21:52:42 +00:00
match fn {
type_ => || ffi::gst_gl_context_get_type(),
2018-11-27 21:52:42 +00:00
}
}
impl GLContext {
2021-11-16 14:02:58 +00:00
pub const NONE: Option<&'static GLContext> = None;
2020-12-08 13:00:17 +00:00
#[doc(alias = "gst_gl_context_new")]
pub fn new(display: &impl IsA<GLDisplay>) -> GLContext {
2018-11-27 21:52:42 +00:00
skip_assert_initialized!();
2020-11-22 10:20:20 +00:00
unsafe { from_glib_none(ffi::gst_gl_context_new(display.as_ref().to_glib_none().0)) }
2018-11-27 21:52:42 +00:00
}
2020-12-08 13:00:17 +00:00
#[doc(alias = "gst_gl_context_get_current")]
#[doc(alias = "get_current")]
2021-04-19 20:13:58 +00:00
pub fn current() -> Option<GLContext> {
2018-11-27 21:52:42 +00:00
assert_initialized_main_thread!();
2020-11-22 10:20:20 +00:00
unsafe { from_glib_none(ffi::gst_gl_context_get_current()) }
2018-11-27 21:52:42 +00:00
}
2020-12-08 13:00:17 +00:00
#[doc(alias = "gst_gl_context_get_current_gl_api")]
#[doc(alias = "get_current_gl_api")]
2021-04-19 20:13:58 +00:00
pub fn current_gl_api(platform: GLPlatform) -> (GLAPI, u32, u32) {
2018-11-27 21:52:42 +00:00
assert_initialized_main_thread!();
unsafe {
2019-07-10 08:21:28 +00:00
let mut major = mem::MaybeUninit::uninit();
let mut minor = mem::MaybeUninit::uninit();
2020-11-22 10:20:20 +00:00
let ret = from_glib(ffi::gst_gl_context_get_current_gl_api(
platform.into_glib(),
2019-07-10 08:21:28 +00:00
major.as_mut_ptr(),
minor.as_mut_ptr(),
));
2022-05-18 20:27:53 +00:00
(ret, major.assume_init(), minor.assume_init())
2018-11-27 21:52:42 +00:00
}
}
}
unsafe impl Send for GLContext {}
unsafe impl Sync for GLContext {}
mod sealed {
pub trait Sealed {}
impl<T: super::IsA<super::GLContext>> Sealed for T {}
2018-11-27 21:52:42 +00:00
}
pub trait GLContextExt: IsA<GLContext> + sealed::Sealed + 'static {
#[doc(alias = "gst_gl_context_activate")]
2018-11-27 21:52:42 +00:00
fn activate(&self, activate: bool) -> Result<(), glib::error::BoolError> {
unsafe {
2020-12-17 22:34:53 +00:00
glib::result_from_gboolean!(
ffi::gst_gl_context_activate(self.as_ref().to_glib_none().0, activate.into_glib()),
"Failed to activate OpenGL context"
)
2018-11-27 21:52:42 +00:00
}
}
#[doc(alias = "gst_gl_context_can_share")]
fn can_share(&self, other_context: &impl IsA<GLContext>) -> bool {
2018-11-27 21:52:42 +00:00
unsafe {
2020-11-22 10:20:20 +00:00
from_glib(ffi::gst_gl_context_can_share(
self.as_ref().to_glib_none().0,
other_context.as_ref().to_glib_none().0,
))
2018-11-27 21:52:42 +00:00
}
}
#[doc(alias = "gst_gl_context_check_feature")]
2018-11-27 21:52:42 +00:00
fn check_feature(&self, feature: &str) -> bool {
unsafe {
2020-11-22 10:20:20 +00:00
from_glib(ffi::gst_gl_context_check_feature(
self.as_ref().to_glib_none().0,
feature.to_glib_none().0,
))
2018-11-27 21:52:42 +00:00
}
}
#[doc(alias = "gst_gl_context_check_framebuffer_status")]
2018-11-27 21:52:42 +00:00
fn check_framebuffer_status(&self, fbo_target: u32) -> bool {
unsafe {
2020-11-22 10:20:20 +00:00
from_glib(ffi::gst_gl_context_check_framebuffer_status(
self.as_ref().to_glib_none().0,
fbo_target,
))
2018-11-27 21:52:42 +00:00
}
}
#[doc(alias = "gst_gl_context_check_gl_version")]
2018-11-27 21:52:42 +00:00
fn check_gl_version(&self, api: GLAPI, maj: i32, min: i32) -> bool {
unsafe {
2020-11-22 10:20:20 +00:00
from_glib(ffi::gst_gl_context_check_gl_version(
self.as_ref().to_glib_none().0,
api.into_glib(),
maj,
min,
))
2018-11-27 21:52:42 +00:00
}
}
#[doc(alias = "gst_gl_context_clear_framebuffer")]
2018-11-27 21:52:42 +00:00
fn clear_framebuffer(&self) {
unsafe {
2020-11-22 10:20:20 +00:00
ffi::gst_gl_context_clear_framebuffer(self.as_ref().to_glib_none().0);
2018-11-27 21:52:42 +00:00
}
}
#[doc(alias = "gst_gl_context_clear_shader")]
2018-11-27 21:52:42 +00:00
fn clear_shader(&self) {
unsafe {
2020-11-22 10:20:20 +00:00
ffi::gst_gl_context_clear_shader(self.as_ref().to_glib_none().0);
2018-11-27 21:52:42 +00:00
}
}
#[doc(alias = "gst_gl_context_create")]
fn create(&self, other_context: Option<&impl IsA<GLContext>>) -> Result<(), glib::Error> {
2018-11-27 21:52:42 +00:00
unsafe {
let mut error = ptr::null_mut();
let is_ok = 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,
);
debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
if error.is_null() {
Ok(())
} else {
Err(from_glib_full(error))
}
2018-11-27 21:52:42 +00:00
}
}
#[doc(alias = "gst_gl_context_destroy")]
2018-11-27 21:52:42 +00:00
fn destroy(&self) {
unsafe {
2020-11-22 10:20:20 +00:00
ffi::gst_gl_context_destroy(self.as_ref().to_glib_none().0);
2018-11-27 21:52:42 +00:00
}
}
#[doc(alias = "gst_gl_context_fill_info")]
2019-11-10 16:55:02 +00:00
fn fill_info(&self) -> Result<(), glib::Error> {
2018-11-27 21:52:42 +00:00
unsafe {
let mut error = ptr::null_mut();
let is_ok = ffi::gst_gl_context_fill_info(self.as_ref().to_glib_none().0, &mut error);
debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
if error.is_null() {
Ok(())
} else {
Err(from_glib_full(error))
}
2018-11-27 21:52:42 +00:00
}
}
#[cfg(feature = "v1_20")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
#[doc(alias = "gst_gl_context_get_config")]
#[doc(alias = "get_config")]
2021-04-17 10:11:52 +00:00
fn config(&self) -> Option<gst::Structure> {
unsafe {
from_glib_full(ffi::gst_gl_context_get_config(
self.as_ref().to_glib_none().0,
))
}
}
#[doc(alias = "gst_gl_context_get_display")]
#[doc(alias = "get_display")]
2021-04-11 19:38:18 +00:00
fn display(&self) -> GLDisplay {
2018-11-27 21:52:42 +00:00
unsafe {
2020-11-22 10:20:20 +00:00
from_glib_full(ffi::gst_gl_context_get_display(
self.as_ref().to_glib_none().0,
))
2018-11-27 21:52:42 +00:00
}
}
#[doc(alias = "gst_gl_context_get_gl_api")]
#[doc(alias = "get_gl_api")]
2021-04-11 19:38:18 +00:00
fn gl_api(&self) -> GLAPI {
2018-11-27 21:52:42 +00:00
unsafe {
2020-11-22 10:20:20 +00:00
from_glib(ffi::gst_gl_context_get_gl_api(
self.as_ref().to_glib_none().0,
))
2018-11-27 21:52:42 +00:00
}
}
#[doc(alias = "gst_gl_context_get_gl_platform")]
#[doc(alias = "get_gl_platform")]
2021-04-11 19:38:18 +00:00
fn gl_platform(&self) -> GLPlatform {
2018-11-27 21:52:42 +00:00
unsafe {
2020-11-22 10:20:20 +00:00
from_glib(ffi::gst_gl_context_get_gl_platform(
self.as_ref().to_glib_none().0,
))
2018-11-27 21:52:42 +00:00
}
}
#[doc(alias = "gst_gl_context_get_gl_platform_version")]
#[doc(alias = "get_gl_platform_version")]
2021-04-11 19:38:18 +00:00
fn gl_platform_version(&self) -> (i32, i32) {
2018-11-27 21:52:42 +00:00
unsafe {
2019-07-10 08:21:28 +00:00
let mut major = mem::MaybeUninit::uninit();
let mut minor = mem::MaybeUninit::uninit();
2020-11-22 10:20:20 +00:00
ffi::gst_gl_context_get_gl_platform_version(
self.as_ref().to_glib_none().0,
2019-07-10 08:21:28 +00:00
major.as_mut_ptr(),
minor.as_mut_ptr(),
);
2022-05-18 20:27:53 +00:00
(major.assume_init(), minor.assume_init())
2018-11-27 21:52:42 +00:00
}
}
#[doc(alias = "gst_gl_context_get_gl_version")]
#[doc(alias = "get_gl_version")]
2021-04-11 19:38:18 +00:00
fn gl_version(&self) -> (i32, i32) {
2018-11-27 21:52:42 +00:00
unsafe {
2019-07-10 08:21:28 +00:00
let mut maj = mem::MaybeUninit::uninit();
let mut min = mem::MaybeUninit::uninit();
2020-11-22 10:20:20 +00:00
ffi::gst_gl_context_get_gl_version(
self.as_ref().to_glib_none().0,
2019-07-10 08:21:28 +00:00
maj.as_mut_ptr(),
min.as_mut_ptr(),
);
2022-05-18 20:27:53 +00:00
(maj.assume_init(), min.assume_init())
2018-11-27 21:52:42 +00:00
}
}
#[doc(alias = "gst_gl_context_get_window")]
#[doc(alias = "get_window")]
2021-04-11 19:38:18 +00:00
fn window(&self) -> Option<GLWindow> {
2018-11-27 21:52:42 +00:00
unsafe {
2020-11-22 10:20:20 +00:00
from_glib_full(ffi::gst_gl_context_get_window(
self.as_ref().to_glib_none().0,
))
2018-11-27 21:52:42 +00:00
}
}
#[doc(alias = "gst_gl_context_is_shared")]
2018-11-27 21:52:42 +00:00
fn is_shared(&self) -> bool {
unsafe {
2020-11-22 10:20:20 +00:00
from_glib(ffi::gst_gl_context_is_shared(
self.as_ref().to_glib_none().0,
2021-04-17 10:11:52 +00:00
))
}
}
#[cfg(feature = "v1_20")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
#[doc(alias = "gst_gl_context_request_config")]
fn request_config(&self, gl_config: Option<gst::Structure>) -> bool {
2021-04-17 10:11:52 +00:00
unsafe {
from_glib(ffi::gst_gl_context_request_config(
self.as_ref().to_glib_none().0,
gl_config.into_glib_ptr(),
))
2018-11-27 21:52:42 +00:00
}
}
#[doc(alias = "gst_gl_context_set_shared_with")]
fn set_shared_with(&self, share: &impl IsA<GLContext>) {
2018-11-27 21:52:42 +00:00
unsafe {
2020-11-22 10:20:20 +00:00
ffi::gst_gl_context_set_shared_with(
self.as_ref().to_glib_none().0,
share.as_ref().to_glib_none().0,
);
2018-11-27 21:52:42 +00:00
}
}
#[doc(alias = "gst_gl_context_set_window")]
fn set_window(&self, window: impl IsA<GLWindow>) -> Result<(), glib::error::BoolError> {
2018-11-27 21:52:42 +00:00
unsafe {
2020-12-17 22:34:53 +00:00
glib::result_from_gboolean!(
2020-11-22 10:20:20 +00:00
ffi::gst_gl_context_set_window(
self.as_ref().to_glib_none().0,
window.upcast().into_glib_ptr()
),
"Failed to set window"
)
2018-11-27 21:52:42 +00:00
}
}
#[doc(alias = "gst_gl_context_supports_glsl_profile_version")]
2018-11-27 21:52:42 +00:00
fn supports_glsl_profile_version(&self, version: GLSLVersion, profile: GLSLProfile) -> bool {
unsafe {
2020-11-22 10:20:20 +00:00
from_glib(ffi::gst_gl_context_supports_glsl_profile_version(
self.as_ref().to_glib_none().0,
version.into_glib(),
profile.into_glib(),
))
2018-11-27 21:52:42 +00:00
}
}
#[cfg(feature = "v1_16")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
#[doc(alias = "gst_gl_context_supports_precision")]
2019-04-23 14:32:09 +00:00
fn supports_precision(&self, version: GLSLVersion, profile: GLSLProfile) -> bool {
unsafe {
2020-11-22 10:20:20 +00:00
from_glib(ffi::gst_gl_context_supports_precision(
self.as_ref().to_glib_none().0,
version.into_glib(),
profile.into_glib(),
))
2019-04-23 14:32:09 +00:00
}
}
#[cfg(feature = "v1_16")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
#[doc(alias = "gst_gl_context_supports_precision_highp")]
2019-04-23 14:32:09 +00:00
fn supports_precision_highp(&self, version: GLSLVersion, profile: GLSLProfile) -> bool {
unsafe {
2020-11-22 10:20:20 +00:00
from_glib(ffi::gst_gl_context_supports_precision_highp(
self.as_ref().to_glib_none().0,
version.into_glib(),
profile.into_glib(),
))
2019-04-23 14:32:09 +00:00
}
}
#[doc(alias = "gst_gl_context_swap_buffers")]
2018-11-27 21:52:42 +00:00
fn swap_buffers(&self) {
unsafe {
2020-11-22 10:20:20 +00:00
ffi::gst_gl_context_swap_buffers(self.as_ref().to_glib_none().0);
2018-11-27 21:52:42 +00:00
}
}
}
impl<O: IsA<GLContext>> GLContextExt for O {}