mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-12-23 00:26:31 +00:00
Support Wayland display on glupload example
This commit is contained in:
parent
4b3a011882
commit
2a6343a671
2 changed files with 17 additions and 5 deletions
|
@ -49,6 +49,7 @@ pango-cairo = ["pango", "pangocairo", "cairo-rs"]
|
||||||
gl = ["gl_generator", "glutin"]
|
gl = ["gl_generator", "glutin"]
|
||||||
gl-egl = ["gstreamer-gl/egl"]
|
gl-egl = ["gstreamer-gl/egl"]
|
||||||
gl-x11 = ["gstreamer-gl/x11"]
|
gl-x11 = ["gstreamer-gl/x11"]
|
||||||
|
gl-wayland = ["gstreamer-gl/wayland"]
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "appsink"
|
name = "appsink"
|
||||||
|
@ -140,4 +141,4 @@ required-features = ["ges"]
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "glupload"
|
name = "glupload"
|
||||||
required-features = ["gl"]
|
required-features = ["gl"]
|
||||||
features = ["gl-egl", "gl-x11"]
|
features = ["gl-egl", "gl-x11", "gl-wayland"]
|
||||||
|
|
|
@ -355,18 +355,23 @@ impl App {
|
||||||
|
|
||||||
let windowed_context_ = windowed_context.clone();
|
let windowed_context_ = windowed_context.clone();
|
||||||
let context = windowed_context_.context();
|
let context = windowed_context_.context();
|
||||||
|
|
||||||
|
#[cfg(any(feature = "gl-x11", feature = "gl-wayland"))]
|
||||||
let inner_window = windowed_context_.window();
|
let inner_window = windowed_context_.window();
|
||||||
|
|
||||||
let shared_context: gst_gl::GLContext;
|
let shared_context: gst_gl::GLContext;
|
||||||
if cfg!(target_os = "linux") {
|
if cfg!(target_os = "linux") {
|
||||||
use glutin::os::unix::RawHandle;
|
use glutin::os::unix::RawHandle;
|
||||||
|
#[cfg(any(feature = "gl-x11", feature = "gl-wayland"))]
|
||||||
|
use glutin::os::unix::WindowExt;
|
||||||
use glutin::os::ContextTraitExt;
|
use glutin::os::ContextTraitExt;
|
||||||
|
|
||||||
let api = App::map_gl_api(context.get_api());
|
let api = App::map_gl_api(context.get_api());
|
||||||
|
|
||||||
let (gl_context, gl_display, platform) = match unsafe { context.raw_handle() } {
|
let (gl_context, gl_display, platform) = match unsafe { context.raw_handle() } {
|
||||||
#[cfg(feature = "gl-egl")]
|
#[cfg(any(feature = "gl-egl", feature = "gl-wayland"))]
|
||||||
RawHandle::Egl(egl_context) => {
|
RawHandle::Egl(egl_context) => {
|
||||||
|
#[cfg(feature = "gl-egl")]
|
||||||
let gl_display = if let Some(display) = unsafe { context.get_egl_display() } {
|
let gl_display = if let Some(display) = unsafe { context.get_egl_display() } {
|
||||||
unsafe { gst_gl::GLDisplayEGL::new_with_egl_display(display as usize) }
|
unsafe { gst_gl::GLDisplayEGL::new_with_egl_display(display as usize) }
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
@ -374,6 +379,14 @@ impl App {
|
||||||
panic!("EGL context without EGL display");
|
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::new_with_display(display as usize) }
|
||||||
|
.unwrap()
|
||||||
|
} else {
|
||||||
|
panic!("Wayland window without Wayland display");
|
||||||
|
};
|
||||||
|
|
||||||
(
|
(
|
||||||
egl_context as usize,
|
egl_context as usize,
|
||||||
gl_display.upcast::<gst_gl::GLDisplay>(),
|
gl_display.upcast::<gst_gl::GLDisplay>(),
|
||||||
|
@ -382,8 +395,6 @@ impl App {
|
||||||
}
|
}
|
||||||
#[cfg(feature = "gl-x11")]
|
#[cfg(feature = "gl-x11")]
|
||||||
RawHandle::Glx(glx_context) => {
|
RawHandle::Glx(glx_context) => {
|
||||||
use glutin::os::unix::WindowExt;
|
|
||||||
|
|
||||||
let gl_display = if let Some(display) = inner_window.get_xlib_display() {
|
let gl_display = if let Some(display) = inner_window.get_xlib_display() {
|
||||||
unsafe { gst_gl::GLDisplayX11::new_with_display(display as usize) }.unwrap()
|
unsafe { gst_gl::GLDisplayX11::new_with_display(display as usize) }.unwrap()
|
||||||
} else {
|
} else {
|
||||||
|
@ -396,7 +407,7 @@ impl App {
|
||||||
gst_gl::GLPlatform::GLX,
|
gst_gl::GLPlatform::GLX,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
_ => panic!("Unsupported platform"),
|
handler => panic!("Unsupported platform: {:?}.", handler),
|
||||||
};
|
};
|
||||||
|
|
||||||
shared_context =
|
shared_context =
|
||||||
|
|
Loading…
Reference in a new issue