handle egl query with EGL_WAYLAND_Y_INVERTED_WL...

...returning EGL_FALSE
This commit is contained in:
Christian Meissl 2021-05-25 12:28:35 +02:00
parent 73420b75bc
commit 730dbc896a
1 changed files with 29 additions and 11 deletions

View File

@ -734,16 +734,32 @@ impl EGLBufferReader {
}) })
.map_err(BufferAccessError::NotManaged)?; .map_err(BufferAccessError::NotManaged)?;
let mut inverted: i32 = 0; let y_inverted = {
wrap_egl_call(|| unsafe { let mut inverted: i32 = 0;
ffi::egl::QueryWaylandBufferWL(
**self.display, // Query the egl buffer with EGL_WAYLAND_Y_INVERTED_WL to retrieve the
buffer.as_ref().c_ptr() as _, // buffer orientation.
ffi::egl::WAYLAND_Y_INVERTED_WL, // The call can either fail, succeed with EGL_TRUE or succeed with EGL_FALSE.
&mut inverted, // The specification for eglQuery defines that unsupported attributes shall return
) // EGL_FALSE. In case of EGL_WAYLAND_Y_INVERTED_WL the specification defines that
}) // if EGL_FALSE is returned the value of inverted should be assumed as EGL_TRUE.
.map_err(BufferAccessError::NotManaged)?; //
// see: https://www.khronos.org/registry/EGL/extensions/WL/EGL_WL_bind_wayland_display.txt
match wrap_egl_call(|| unsafe {
ffi::egl::QueryWaylandBufferWL(
**self.display,
buffer.as_ref().c_ptr() as _,
ffi::egl::WAYLAND_Y_INVERTED_WL,
&mut inverted,
)
})
.map_err(BufferAccessError::NotManaged)?
{
ffi::egl::TRUE => inverted != 0,
ffi::egl::FALSE => true,
_ => unreachable!(),
}
};
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() {
@ -767,7 +783,9 @@ impl EGLBufferReader {
display: self.display.clone(), display: self.display.clone(),
width: width as u32, width: width as u32,
height: height as u32, height: height as u32,
y_inverted: inverted != 0, // y_inverted is negated here because the gles2 renderer
// already inverts the buffer during rendering.
y_inverted: !y_inverted,
format, format,
images, images,
}) })