From 75bcc8402d2935af9d04af8b4d830966a883557c Mon Sep 17 00:00:00 2001 From: Marijn Suijten Date: Thu, 26 Nov 2020 23:46:15 +0100 Subject: [PATCH] example/glupload: Update to separated GL windowing crates --- examples/Cargo.toml | 9 ++++---- examples/src/bin/glupload.rs | 42 +++++++++++++++++++----------------- 2 files changed, 27 insertions(+), 24 deletions(-) diff --git a/examples/Cargo.toml b/examples/Cargo.toml index 37eb2ed77..a52bd3830 100644 --- a/examples/Cargo.toml +++ b/examples/Cargo.toml @@ -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" diff --git a/examples/src/bin/glupload.rs b/examples/src/bin/glupload.rs index 6a0184c8f..360dfedf3 100644 --- a/examples/src/bin/glupload.rs +++ b/examples/src/bin/glupload.rs @@ -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"); };