diff --git a/src/backend/drm/error.rs b/src/backend/drm/error.rs index 38eff09..1776f5c 100644 --- a/src/backend/drm/error.rs +++ b/src/backend/drm/error.rs @@ -1,6 +1,7 @@ //use crate::backend::graphics::SwapBuffersError; use drm::control::{connector, crtc, plane, Mode, RawResourceHandle}; use std::path::PathBuf; +use crate::backend::SwapBuffersError; /// Errors thrown by the [`DrmDevice`](::backend::drm::DrmDevice) /// and the [`DrmSurface`](::backend::drm::DrmSurface). @@ -59,14 +60,13 @@ pub enum Error { TestFailed(crtc::Handle), } -/* impl Into for Error { fn into(self) -> SwapBuffersError { match self { x @ Error::DeviceInactive => SwapBuffersError::TemporaryFailure(Box::new(x)), Error::Access { errmsg, dev, source, .. - } if match source.get_ref() { + } if match source { drm::SystemError::PermissionDenied => true, drm::SystemError::Unknown { errno: nix::errno::Errno::EBUSY, @@ -82,5 +82,4 @@ impl Into for Error { x => SwapBuffersError::ContextLost(Box::new(x)), } } -} -*/ \ No newline at end of file +} \ No newline at end of file diff --git a/src/backend/renderer/gles2/mod.rs b/src/backend/renderer/gles2/mod.rs index 4aa284a..71c49fb 100644 --- a/src/backend/renderer/gles2/mod.rs +++ b/src/backend/renderer/gles2/mod.rs @@ -6,6 +6,7 @@ use std::sync::Arc; use cgmath::{prelude::*, Matrix3, Vector2}; mod shaders; +use crate::backend::SwapBuffersError; use crate::backend::allocator::{dmabuf::{Dmabuf, WeakDmabuf}, Format}; use crate::backend::egl::{EGLContext, EGLSurface, ffi::egl::types::EGLImage}; use super::{Renderer, Frame, Bind, Unbind, Transform, Texture}; @@ -104,6 +105,24 @@ pub enum Gles2Error { BufferAccessError(crate::wayland::shm::BufferAccessError), } +impl From for SwapBuffersError { + fn from(err: Gles2Error) -> SwapBuffersError { + match err { + x @ Gles2Error::ShaderCompileError(_) + | x @ Gles2Error::ProgramLinkError + | x @ Gles2Error::GLFunctionLoaderError + | x @ Gles2Error::GLExtensionNotSupported(_) + => SwapBuffersError::ContextLost(Box::new(x)), + Gles2Error::ContextActivationError(err) => err.into(), + x @ Gles2Error::FramebufferBindingError + | x @ Gles2Error::BindBufferEGLError(_) + | x @ Gles2Error::UnsupportedPixelFormat(_) + | x @ Gles2Error::BufferAccessError(_) + => SwapBuffersError::TemporaryFailure(Box::new(x)), + } + } +} + extern "system" fn gl_debug_log(_source: ffi::types::GLenum, gltype: ffi::types::GLenum, _id: ffi::types::GLuint,