From eaa3a0ca87cae2f257cb97d5417b8428bfe5e419 Mon Sep 17 00:00:00 2001 From: Victor Brekenfeld Date: Sun, 3 May 2020 16:51:14 +0200 Subject: [PATCH] egl: fix broken egl check --- src/backend/egl/display.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/backend/egl/display.rs b/src/backend/egl/display.rs index baf716b..62f7d7c 100644 --- a/src/backend/egl/display.rs +++ b/src/backend/egl/display.rs @@ -150,7 +150,7 @@ impl> EGLDisplay { }; info!(log, "EGL Extensions: {:?}", extensions); - if egl_version >= (1, 2) { + if egl_version <= (1, 2) { return Err(Error::OpenGlesNotSupported(None)); } wrap_egl_call(|| unsafe { ffi::egl::BindAPI(ffi::egl::OPENGL_ES_API) }) @@ -485,16 +485,17 @@ impl EGLBufferReader { buffer: WlBuffer, ) -> ::std::result::Result { let mut format: i32 = 0; - wrap_egl_call(|| unsafe { + if wrap_egl_call(|| unsafe { ffi::egl::QueryWaylandBufferWL( **self.display, buffer.as_ref().c_ptr() as _, ffi::egl::EGL_TEXTURE_FORMAT, &mut format, ) - }) - .map_err(|source| BufferAccessError::NotManaged(buffer.clone(), source))?; - + }).map_err(|source| BufferAccessError::NotManaged(buffer.clone(), source))? == ffi::egl::FALSE { + return Err(BufferAccessError::NotManaged(buffer.clone(), EGLError::BadParameter)); + } + let format = match format { x if x == ffi::egl::TEXTURE_RGB as i32 => Format::RGB, x if x == ffi::egl::TEXTURE_RGBA as i32 => Format::RGBA, @@ -502,7 +503,7 @@ impl EGLBufferReader { ffi::egl::TEXTURE_Y_UV_WL => Format::Y_UV, ffi::egl::TEXTURE_Y_U_V_WL => Format::Y_U_V, ffi::egl::TEXTURE_Y_XUXV_WL => Format::Y_XUXV, - _ => panic!("EGL returned invalid texture type"), + x => panic!("EGL returned invalid texture type: {}", x), }; let mut width: i32 = 0;