drm/renderer: Fixup convertion into SwapBuffersError

This commit is contained in:
Victor Brekenfeld 2021-04-25 23:29:53 +02:00
parent 0180bb6ef5
commit c107d42ced
2 changed files with 22 additions and 4 deletions

View File

@ -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<SwapBuffersError> 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<SwapBuffersError> for Error {
x => SwapBuffersError::ContextLost(Box::new(x)),
}
}
}
*/
}

View File

@ -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<Gles2Error> 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,