Merge pull request #279 from cmeissl/renderer/v4-fix-egl-y-invert

handle egl query with EGL_WAYLAND_Y_INVERTED_WL returning EGL_FALSE
This commit is contained in:
Victor Brekenfeld 2021-05-26 19:10:50 +02:00 committed by GitHub
commit 890a17189b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 29 additions and 11 deletions

View File

@ -734,8 +734,18 @@ impl EGLBufferReader {
}) })
.map_err(BufferAccessError::NotManaged)?; .map_err(BufferAccessError::NotManaged)?;
let y_inverted = {
let mut inverted: i32 = 0; let mut inverted: i32 = 0;
wrap_egl_call(|| unsafe {
// Query the egl buffer with EGL_WAYLAND_Y_INVERTED_WL to retrieve the
// buffer orientation.
// The call can either fail, succeed with EGL_TRUE or succeed with EGL_FALSE.
// 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.
//
// see: https://www.khronos.org/registry/EGL/extensions/WL/EGL_WL_bind_wayland_display.txt
match wrap_egl_call(|| unsafe {
ffi::egl::QueryWaylandBufferWL( ffi::egl::QueryWaylandBufferWL(
**self.display, **self.display,
buffer.as_ref().c_ptr() as _, buffer.as_ref().c_ptr() as _,
@ -743,7 +753,13 @@ impl EGLBufferReader {
&mut inverted, &mut inverted,
) )
}) })
.map_err(BufferAccessError::NotManaged)?; .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,
}) })