egl: Do not store and release WlBuffer for EGLImages

This commit is contained in:
Victor Brekenfeld 2020-06-21 14:54:58 +02:00
parent 4930e7e8b2
commit d603a9ccfb
2 changed files with 10 additions and 13 deletions

View File

@ -475,7 +475,7 @@ impl EGLBufferReader {
/// to render it another way.
pub fn egl_buffer_contents(
&self,
buffer: WlBuffer,
buffer: &WlBuffer,
) -> ::std::result::Result<EGLImages, BufferAccessError> {
let mut format: i32 = 0;
let query = wrap_egl_call(|| unsafe {
@ -486,9 +486,9 @@ impl EGLBufferReader {
&mut format,
)
})
.map_err(|source| BufferAccessError::NotManaged(buffer.clone(), source))?;
.map_err(BufferAccessError::NotManaged)?;
if query == ffi::egl::FALSE {
return Err(BufferAccessError::NotManaged(buffer, EGLError::BadParameter));
return Err(BufferAccessError::NotManaged(EGLError::BadParameter));
}
let format = match format {
@ -510,7 +510,7 @@ impl EGLBufferReader {
&mut width,
)
})
.map_err(|source| BufferAccessError::NotManaged(buffer.clone(), source))?;
.map_err(BufferAccessError::NotManaged)?;
let mut height: i32 = 0;
wrap_egl_call(|| unsafe {
@ -521,7 +521,7 @@ impl EGLBufferReader {
&mut height,
)
})
.map_err(|source| BufferAccessError::NotManaged(buffer.clone(), source))?;
.map_err(BufferAccessError::NotManaged)?;
let mut inverted: i32 = 0;
wrap_egl_call(|| unsafe {
@ -532,7 +532,7 @@ impl EGLBufferReader {
&mut inverted,
)
})
.map_err(|source| BufferAccessError::NotManaged(buffer.clone(), source))?;
.map_err(BufferAccessError::NotManaged)?;
let mut images = Vec::with_capacity(format.num_planes());
for i in 0..format.num_planes() {
@ -562,7 +562,6 @@ impl EGLBufferReader {
y_inverted: inverted != 0,
format,
images,
buffer,
#[cfg(feature = "renderer_gl")]
gl: self.gl.clone(),
})

View File

@ -26,7 +26,7 @@ use crate::backend::graphics::{
use nix::libc::c_uint;
use std::fmt;
#[cfg(feature = "wayland_frontend")]
use wayland_server::{protocol::wl_buffer::WlBuffer, Display};
use wayland_server::Display;
pub mod context;
pub use self::context::EGLContext;
@ -87,8 +87,8 @@ pub enum BufferAccessError {
#[error("The corresponding context was lost")]
ContextLost,
/// This buffer is not managed by the EGL buffer
#[error("This buffer is not managed by EGL. Err: {1:}")]
NotManaged(WlBuffer, #[source] EGLError),
#[error("This buffer is not managed by EGL. Err: {0:}")]
NotManaged(#[source] EGLError),
/// Failed to create `EGLImages` from the buffer
#[error("Failed to create EGLImages from the buffer. Err: {0:}")]
EGLImageCreationFailed(#[source] EGLError),
@ -102,7 +102,7 @@ impl fmt::Debug for BufferAccessError {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> ::std::result::Result<(), fmt::Error> {
match *self {
BufferAccessError::ContextLost => write!(formatter, "BufferAccessError::ContextLost"),
BufferAccessError::NotManaged(_, _) => write!(formatter, "BufferAccessError::NotManaged"),
BufferAccessError::NotManaged(_) => write!(formatter, "BufferAccessError::NotManaged"),
BufferAccessError::EGLImageCreationFailed(_) => {
write!(formatter, "BufferAccessError::EGLImageCreationFailed")
}
@ -265,7 +265,6 @@ pub struct EGLImages {
/// Format of these images
pub format: Format,
images: Vec<EGLImage>,
buffer: WlBuffer,
#[cfg(feature = "renderer_gl")]
gl: gl_ffi::Gles2,
}
@ -339,7 +338,6 @@ impl Drop for EGLImages {
ffi::egl::DestroyImageKHR(**self.display, image);
}
}
self.buffer.release();
}
}