egl: Do not store and release WlBuffer for EGLImages
This commit is contained in:
parent
4930e7e8b2
commit
d603a9ccfb
|
@ -475,7 +475,7 @@ impl EGLBufferReader {
|
||||||
/// to render it another way.
|
/// to render it another way.
|
||||||
pub fn egl_buffer_contents(
|
pub fn egl_buffer_contents(
|
||||||
&self,
|
&self,
|
||||||
buffer: WlBuffer,
|
buffer: &WlBuffer,
|
||||||
) -> ::std::result::Result<EGLImages, BufferAccessError> {
|
) -> ::std::result::Result<EGLImages, BufferAccessError> {
|
||||||
let mut format: i32 = 0;
|
let mut format: i32 = 0;
|
||||||
let query = wrap_egl_call(|| unsafe {
|
let query = wrap_egl_call(|| unsafe {
|
||||||
|
@ -486,9 +486,9 @@ impl EGLBufferReader {
|
||||||
&mut format,
|
&mut format,
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.map_err(|source| BufferAccessError::NotManaged(buffer.clone(), source))?;
|
.map_err(BufferAccessError::NotManaged)?;
|
||||||
if query == ffi::egl::FALSE {
|
if query == ffi::egl::FALSE {
|
||||||
return Err(BufferAccessError::NotManaged(buffer, EGLError::BadParameter));
|
return Err(BufferAccessError::NotManaged(EGLError::BadParameter));
|
||||||
}
|
}
|
||||||
|
|
||||||
let format = match format {
|
let format = match format {
|
||||||
|
@ -510,7 +510,7 @@ impl EGLBufferReader {
|
||||||
&mut width,
|
&mut width,
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.map_err(|source| BufferAccessError::NotManaged(buffer.clone(), source))?;
|
.map_err(BufferAccessError::NotManaged)?;
|
||||||
|
|
||||||
let mut height: i32 = 0;
|
let mut height: i32 = 0;
|
||||||
wrap_egl_call(|| unsafe {
|
wrap_egl_call(|| unsafe {
|
||||||
|
@ -521,7 +521,7 @@ impl EGLBufferReader {
|
||||||
&mut height,
|
&mut height,
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.map_err(|source| BufferAccessError::NotManaged(buffer.clone(), source))?;
|
.map_err(BufferAccessError::NotManaged)?;
|
||||||
|
|
||||||
let mut inverted: i32 = 0;
|
let mut inverted: i32 = 0;
|
||||||
wrap_egl_call(|| unsafe {
|
wrap_egl_call(|| unsafe {
|
||||||
|
@ -532,7 +532,7 @@ impl EGLBufferReader {
|
||||||
&mut inverted,
|
&mut inverted,
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.map_err(|source| BufferAccessError::NotManaged(buffer.clone(), source))?;
|
.map_err(BufferAccessError::NotManaged)?;
|
||||||
|
|
||||||
let mut images = Vec::with_capacity(format.num_planes());
|
let mut images = Vec::with_capacity(format.num_planes());
|
||||||
for i in 0..format.num_planes() {
|
for i in 0..format.num_planes() {
|
||||||
|
@ -562,7 +562,6 @@ impl EGLBufferReader {
|
||||||
y_inverted: inverted != 0,
|
y_inverted: inverted != 0,
|
||||||
format,
|
format,
|
||||||
images,
|
images,
|
||||||
buffer,
|
|
||||||
#[cfg(feature = "renderer_gl")]
|
#[cfg(feature = "renderer_gl")]
|
||||||
gl: self.gl.clone(),
|
gl: self.gl.clone(),
|
||||||
})
|
})
|
||||||
|
|
|
@ -26,7 +26,7 @@ use crate::backend::graphics::{
|
||||||
use nix::libc::c_uint;
|
use nix::libc::c_uint;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
#[cfg(feature = "wayland_frontend")]
|
#[cfg(feature = "wayland_frontend")]
|
||||||
use wayland_server::{protocol::wl_buffer::WlBuffer, Display};
|
use wayland_server::Display;
|
||||||
|
|
||||||
pub mod context;
|
pub mod context;
|
||||||
pub use self::context::EGLContext;
|
pub use self::context::EGLContext;
|
||||||
|
@ -87,8 +87,8 @@ pub enum BufferAccessError {
|
||||||
#[error("The corresponding context was lost")]
|
#[error("The corresponding context was lost")]
|
||||||
ContextLost,
|
ContextLost,
|
||||||
/// This buffer is not managed by the EGL buffer
|
/// This buffer is not managed by the EGL buffer
|
||||||
#[error("This buffer is not managed by EGL. Err: {1:}")]
|
#[error("This buffer is not managed by EGL. Err: {0:}")]
|
||||||
NotManaged(WlBuffer, #[source] EGLError),
|
NotManaged(#[source] EGLError),
|
||||||
/// Failed to create `EGLImages` from the buffer
|
/// Failed to create `EGLImages` from the buffer
|
||||||
#[error("Failed to create EGLImages from the buffer. Err: {0:}")]
|
#[error("Failed to create EGLImages from the buffer. Err: {0:}")]
|
||||||
EGLImageCreationFailed(#[source] EGLError),
|
EGLImageCreationFailed(#[source] EGLError),
|
||||||
|
@ -102,7 +102,7 @@ impl fmt::Debug for BufferAccessError {
|
||||||
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> ::std::result::Result<(), fmt::Error> {
|
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> ::std::result::Result<(), fmt::Error> {
|
||||||
match *self {
|
match *self {
|
||||||
BufferAccessError::ContextLost => write!(formatter, "BufferAccessError::ContextLost"),
|
BufferAccessError::ContextLost => write!(formatter, "BufferAccessError::ContextLost"),
|
||||||
BufferAccessError::NotManaged(_, _) => write!(formatter, "BufferAccessError::NotManaged"),
|
BufferAccessError::NotManaged(_) => write!(formatter, "BufferAccessError::NotManaged"),
|
||||||
BufferAccessError::EGLImageCreationFailed(_) => {
|
BufferAccessError::EGLImageCreationFailed(_) => {
|
||||||
write!(formatter, "BufferAccessError::EGLImageCreationFailed")
|
write!(formatter, "BufferAccessError::EGLImageCreationFailed")
|
||||||
}
|
}
|
||||||
|
@ -265,7 +265,6 @@ 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,
|
|
||||||
#[cfg(feature = "renderer_gl")]
|
#[cfg(feature = "renderer_gl")]
|
||||||
gl: gl_ffi::Gles2,
|
gl: gl_ffi::Gles2,
|
||||||
}
|
}
|
||||||
|
@ -339,7 +338,6 @@ impl Drop for EGLImages {
|
||||||
ffi::egl::DestroyImageKHR(**self.display, image);
|
ffi::egl::DestroyImageKHR(**self.display, image);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self.buffer.release();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue