backend.graphics: port no-feature code to wayland-rs 0.20
This commit is contained in:
parent
cb4b783dc2
commit
f9dbabce56
|
@ -17,7 +17,7 @@ use nix::libc::c_uint;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::rc::{Rc, Weak};
|
use std::rc::{Rc, Weak};
|
||||||
use wayland_server::{Display, Resource};
|
use wayland_server::{Display, Resource};
|
||||||
use wayland_server::protocol::wl_buffer::WlBuffer;
|
use wayland_server::protocol::wl_buffer::{self, WlBuffer};
|
||||||
use wayland_sys::server::wl_display;
|
use wayland_sys::server::wl_display;
|
||||||
|
|
||||||
/// Error that can occur when accessing an EGL buffer
|
/// Error that can occur when accessing an EGL buffer
|
||||||
|
@ -25,7 +25,7 @@ pub enum BufferAccessError {
|
||||||
/// The corresponding Context is not alive anymore
|
/// The corresponding Context is not alive anymore
|
||||||
ContextLost,
|
ContextLost,
|
||||||
/// This buffer is not managed by the EGL buffer
|
/// This buffer is not managed by the EGL buffer
|
||||||
NotManaged(WlBuffer),
|
NotManaged(Resource<WlBuffer>),
|
||||||
/// Failed to create EGLImages from the buffer
|
/// Failed to create EGLImages from the buffer
|
||||||
EGLImageCreationFailed,
|
EGLImageCreationFailed,
|
||||||
/// The required EGL extension is not supported by the underlying EGL implementation
|
/// The required EGL extension is not supported by the underlying EGL implementation
|
||||||
|
@ -175,7 +175,7 @@ pub struct EGLImages {
|
||||||
/// Format of these images
|
/// Format of these images
|
||||||
pub format: Format,
|
pub format: Format,
|
||||||
images: Vec<EGLImage>,
|
images: Vec<EGLImage>,
|
||||||
buffer: WlBuffer,
|
buffer: Resource<WlBuffer>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl EGLImages {
|
impl EGLImages {
|
||||||
|
@ -225,7 +225,7 @@ impl Drop for EGLImages {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self.buffer.release();
|
self.buffer.send(wl_buffer::Event::Release);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -266,14 +266,14 @@ impl EGLDisplay {
|
||||||
/// a `BufferAccessError::NotManaged(WlBuffer)` is returned with the original buffer
|
/// a `BufferAccessError::NotManaged(WlBuffer)` is returned with the original buffer
|
||||||
/// to render it another way.
|
/// to render it another way.
|
||||||
pub fn egl_buffer_contents(
|
pub fn egl_buffer_contents(
|
||||||
&self, buffer: WlBuffer
|
&self, buffer: Resource<WlBuffer>
|
||||||
) -> ::std::result::Result<EGLImages, BufferAccessError> {
|
) -> ::std::result::Result<EGLImages, BufferAccessError> {
|
||||||
if let Some(display) = self.0.upgrade() {
|
if let Some(display) = self.0.upgrade() {
|
||||||
let mut format: i32 = 0;
|
let mut format: i32 = 0;
|
||||||
if unsafe {
|
if unsafe {
|
||||||
ffi::egl::QueryWaylandBufferWL(
|
ffi::egl::QueryWaylandBufferWL(
|
||||||
*display,
|
*display,
|
||||||
buffer.ptr() as *mut _,
|
buffer.c_ptr() as *mut _,
|
||||||
ffi::egl::EGL_TEXTURE_FORMAT,
|
ffi::egl::EGL_TEXTURE_FORMAT,
|
||||||
&mut format as *mut _,
|
&mut format as *mut _,
|
||||||
) == 0
|
) == 0
|
||||||
|
@ -294,7 +294,7 @@ impl EGLDisplay {
|
||||||
if unsafe {
|
if unsafe {
|
||||||
ffi::egl::QueryWaylandBufferWL(
|
ffi::egl::QueryWaylandBufferWL(
|
||||||
*display,
|
*display,
|
||||||
buffer.ptr() as *mut _,
|
buffer.c_ptr() as *mut _,
|
||||||
ffi::egl::WIDTH as i32,
|
ffi::egl::WIDTH as i32,
|
||||||
&mut width as *mut _,
|
&mut width as *mut _,
|
||||||
) == 0
|
) == 0
|
||||||
|
@ -306,7 +306,7 @@ impl EGLDisplay {
|
||||||
if unsafe {
|
if unsafe {
|
||||||
ffi::egl::QueryWaylandBufferWL(
|
ffi::egl::QueryWaylandBufferWL(
|
||||||
*display,
|
*display,
|
||||||
buffer.ptr() as *mut _,
|
buffer.c_ptr() as *mut _,
|
||||||
ffi::egl::HEIGHT as i32,
|
ffi::egl::HEIGHT as i32,
|
||||||
&mut height as *mut _,
|
&mut height as *mut _,
|
||||||
) == 0
|
) == 0
|
||||||
|
@ -318,7 +318,7 @@ impl EGLDisplay {
|
||||||
if unsafe {
|
if unsafe {
|
||||||
ffi::egl::QueryWaylandBufferWL(
|
ffi::egl::QueryWaylandBufferWL(
|
||||||
*display,
|
*display,
|
||||||
buffer.ptr() as *mut _,
|
buffer.c_ptr() as *mut _,
|
||||||
ffi::egl::WAYLAND_Y_INVERTED_WL,
|
ffi::egl::WAYLAND_Y_INVERTED_WL,
|
||||||
&mut inverted as *mut _,
|
&mut inverted as *mut _,
|
||||||
) != 0
|
) != 0
|
||||||
|
@ -339,7 +339,7 @@ impl EGLDisplay {
|
||||||
*display,
|
*display,
|
||||||
ffi::egl::NO_CONTEXT,
|
ffi::egl::NO_CONTEXT,
|
||||||
ffi::egl::WAYLAND_BUFFER_WL,
|
ffi::egl::WAYLAND_BUFFER_WL,
|
||||||
buffer.ptr() as *mut _,
|
buffer.c_ptr() as *mut _,
|
||||||
out.as_ptr(),
|
out.as_ptr(),
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
@ -394,10 +394,10 @@ impl<B: native::Backend, N: native::NativeDisplay<B>> EGLWaylandExtensions for E
|
||||||
if !self.egl_to_texture_support {
|
if !self.egl_to_texture_support {
|
||||||
bail!(ErrorKind::EglExtensionNotSupported(&["GL_OES_EGL_image"]));
|
bail!(ErrorKind::EglExtensionNotSupported(&["GL_OES_EGL_image"]));
|
||||||
}
|
}
|
||||||
let res = unsafe { ffi::egl::BindWaylandDisplayWL(*self.display, display.ptr() as *mut _) };
|
let res = unsafe { ffi::egl::BindWaylandDisplayWL(*self.display, display.c_ptr() as *mut _) };
|
||||||
if res == 0 {
|
if res == 0 {
|
||||||
bail!(ErrorKind::OtherEGLDisplayAlreadyBound);
|
bail!(ErrorKind::OtherEGLDisplayAlreadyBound);
|
||||||
}
|
}
|
||||||
Ok(EGLDisplay::new(self, unsafe { display.ptr() }))
|
Ok(EGLDisplay::new(self, display.c_ptr()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
//! - libinput
|
//! - libinput
|
||||||
|
|
||||||
pub mod input;
|
pub mod input;
|
||||||
//pub mod graphics;
|
pub mod graphics;
|
||||||
|
|
||||||
//#[cfg(feature = "backend_winit")]
|
//#[cfg(feature = "backend_winit")]
|
||||||
//pub mod winit;
|
//pub mod winit;
|
||||||
|
|
Loading…
Reference in New Issue