2018-11-27 21:52:42 +00:00
|
|
|
// Copyright (C) 2018 Víctor Jáquez <vjaquez@igalia.com>
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
|
|
|
use glib::translate::*;
|
|
|
|
use glib::IsA;
|
2019-03-19 07:58:20 +00:00
|
|
|
use gst_gl_sys;
|
2018-11-27 21:52:42 +00:00
|
|
|
use libc::uintptr_t;
|
|
|
|
use GLContext;
|
|
|
|
use GLDisplay;
|
|
|
|
use GLPlatform;
|
|
|
|
use GLAPI;
|
|
|
|
|
|
|
|
impl GLContext {
|
|
|
|
pub unsafe fn new_wrapped<T: IsA<GLDisplay>>(
|
|
|
|
display: &T,
|
|
|
|
handle: uintptr_t,
|
|
|
|
context_type: GLPlatform,
|
|
|
|
available_apis: GLAPI,
|
|
|
|
) -> Option<GLContext> {
|
2019-03-19 07:58:20 +00:00
|
|
|
from_glib_full(gst_gl_sys::gst_gl_context_new_wrapped(
|
2019-01-16 11:32:58 +00:00
|
|
|
display.as_ref().to_glib_none().0,
|
2018-11-27 21:52:42 +00:00
|
|
|
handle,
|
|
|
|
context_type.to_glib(),
|
|
|
|
available_apis.to_glib(),
|
|
|
|
))
|
|
|
|
}
|
2019-01-16 11:32:58 +00:00
|
|
|
|
|
|
|
pub fn get_current_gl_context(context_type: GLPlatform) -> uintptr_t {
|
2019-03-19 07:58:20 +00:00
|
|
|
unsafe {
|
|
|
|
gst_gl_sys::gst_gl_context_get_current_gl_context(context_type.to_glib()) as uintptr_t
|
|
|
|
}
|
2019-01-16 11:32:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn get_proc_address_with_platform(
|
|
|
|
context_type: GLPlatform,
|
|
|
|
gl_api: GLAPI,
|
|
|
|
name: &str,
|
|
|
|
) -> uintptr_t {
|
|
|
|
unsafe {
|
2019-03-19 07:58:20 +00:00
|
|
|
gst_gl_sys::gst_gl_context_get_proc_address_with_platform(
|
2019-01-16 11:32:58 +00:00
|
|
|
context_type.to_glib(),
|
|
|
|
gl_api.to_glib(),
|
|
|
|
name.to_glib_none().0,
|
|
|
|
) as uintptr_t
|
|
|
|
}
|
|
|
|
}
|
2018-11-27 21:52:42 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 09:22:42 +00:00
|
|
|
pub trait GLContextExtManual: 'static {
|
2018-11-27 21:52:42 +00:00
|
|
|
fn get_gl_context(&self) -> uintptr_t;
|
|
|
|
|
|
|
|
fn get_proc_address(&self, name: &str) -> uintptr_t;
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<O: IsA<GLContext>> GLContextExtManual for O {
|
|
|
|
fn get_gl_context(&self) -> uintptr_t {
|
2019-03-19 07:58:20 +00:00
|
|
|
unsafe {
|
|
|
|
gst_gl_sys::gst_gl_context_get_gl_context(self.as_ref().to_glib_none().0) as uintptr_t
|
|
|
|
}
|
2018-11-27 21:52:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fn get_proc_address(&self, name: &str) -> uintptr_t {
|
|
|
|
unsafe {
|
2019-03-19 07:58:20 +00:00
|
|
|
gst_gl_sys::gst_gl_context_get_proc_address(
|
2019-01-16 11:32:58 +00:00
|
|
|
self.as_ref().to_glib_none().0,
|
2018-11-27 21:52:42 +00:00
|
|
|
name.to_glib_none().0,
|
|
|
|
) as uintptr_t
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|