example/glupload: Update to separated GL windowing crates

This commit is contained in:
Marijn Suijten 2020-11-26 23:46:15 +01:00
parent 55badab13d
commit 75bcc8402d
2 changed files with 27 additions and 24 deletions

View file

@ -9,6 +9,9 @@ edition = "2018"
glib = { git = "https://github.com/gtk-rs/gtk-rs" }
gst = { package = "gstreamer", path = "../gstreamer" }
gst-gl = { package = "gstreamer-gl", path = "../gstreamer-gl", optional = true }
gst-gl-egl = { package = "gstreamer-gl-egl", path = "../gstreamer-gl/egl", optional = true }
gst-gl-wayland = { package = "gstreamer-gl-wayland", path = "../gstreamer-gl/wayland", optional = true }
gst-gl-x11 = { package = "gstreamer-gl-x11", path = "../gstreamer-gl/x11", optional = true }
gst-app = { package = "gstreamer-app", path = "../gstreamer-app" }
gst-audio = { package = "gstreamer-audio", path = "../gstreamer-audio" }
gst-base = { package = "gstreamer-base", path = "../gstreamer-base" }
@ -23,6 +26,7 @@ gtk = { git = "https://github.com/gtk-rs/gtk-rs", optional = true }
gdk = { git = "https://github.com/gtk-rs/gtk-rs", optional = true }
gio = { git = "https://github.com/gtk-rs/gtk-rs", optional = true }
anyhow = "1.0"
cfg-if = "1.0"
derive_more = "0.99.5"
futures = "0.3"
byte-slice-cast = "1"
@ -50,9 +54,6 @@ v1_14 = ["gst/v1_14"]
pango-cairo = ["pango", "pangocairo", "cairo-rs"]
overlay-composition = ["pango", "pangocairo", "cairo-rs"]
gl = ["gst-gl", "gl_generator", "glutin"]
gl-egl = ["gst-gl/egl"]
gl-x11 = ["gst-gl/x11"]
gl-wayland = ["gst-gl/wayland"]
[[bin]]
name = "appsink"
@ -161,7 +162,7 @@ required-features = ["ges"]
[[bin]]
name = "glupload"
required-features = ["gl"]
features = ["gl-egl", "gl-x11", "gl-wayland"]
features = ["gst-gl-egl", "gst-gl-wayland", "gst-gl-x11"]
[[bin]]
name = "subclass"

View file

@ -340,13 +340,13 @@ impl App {
let windowed_context = unsafe { windowed_context.make_current().map_err(|(_, err)| err)? };
#[cfg(any(feature = "gl-x11", feature = "gl-wayland"))]
#[cfg(any(feature = "gst-gl-x11", feature = "gst-gl-wayland"))]
let inner_window = windowed_context.window();
let shared_context: gst_gl::GLContext;
if cfg!(target_os = "linux") {
use glutin::os::unix::RawHandle;
#[cfg(any(feature = "gl-x11", feature = "gl-wayland"))]
#[cfg(any(feature = "gst-gl-x11", feature = "gst-gl-wayland"))]
use glutin::os::unix::WindowExt;
use glutin::os::ContextTraitExt;
@ -354,23 +354,25 @@ impl App {
let (gl_context, gl_display, platform) = match unsafe { windowed_context.raw_handle() }
{
#[cfg(any(feature = "gl-egl", feature = "gl-wayland"))]
#[cfg(any(feature = "gst-gl-egl", feature = "gst-gl-wayland"))]
RawHandle::Egl(egl_context) => {
#[cfg(feature = "gl-egl")]
let gl_display = if let Some(display) =
unsafe { windowed_context.get_egl_display() }
{
unsafe { gst_gl::GLDisplayEGL::with_egl_display(display as usize) }.unwrap()
} else {
panic!("EGL context without EGL display");
};
#[cfg(not(feature = "gl-egl"))]
let gl_display = if let Some(display) = inner_window.get_wayland_display() {
unsafe { gst_gl::GLDisplayWayland::with_display(display as usize) }.unwrap()
} else {
panic!("Wayland window without Wayland display");
};
cfg_if::cfg_if! {
if #[cfg(feature = "gst-gl-egl")] {
let gl_display = if let Some(display) =
unsafe { windowed_context.get_egl_display() }
{
unsafe { gst_gl_egl::GLDisplayEGL::with_egl_display(display as usize) }.unwrap()
} else {
panic!("EGL context without EGL display");
};
} else if #[cfg(feature = "gst-gl-wayland")] {
let gl_display = if let Some(display) = inner_window.get_wayland_display() {
unsafe { gst_gl_wayland::GLDisplayWayland::with_display(display as usize) }.unwrap()
} else {
panic!("Wayland window without Wayland display");
};
}
}
(
egl_context as usize,
@ -378,10 +380,10 @@ impl App {
gst_gl::GLPlatform::EGL,
)
}
#[cfg(feature = "gl-x11")]
#[cfg(feature = "gst-gl-x11")]
RawHandle::Glx(glx_context) => {
let gl_display = if let Some(display) = inner_window.get_xlib_display() {
unsafe { gst_gl::GLDisplayX11::with_display(display as usize) }.unwrap()
unsafe { gst_gl_x11::GLDisplayX11::with_display(display as usize) }.unwrap()
} else {
panic!("X11 window without X Display");
};