[Debug Trait] General cleanup and small fixes

This commit is contained in:
Poly 2021-02-13 00:04:45 +01:00
parent e9eb698dd0
commit de3dfacee0
9 changed files with 62 additions and 30 deletions

View File

@ -60,7 +60,7 @@ pub struct AtomicDrmDevice<A: AsRawFd + 'static> {
logger: ::slog::Logger,
}
impl<A: AsRawFd + 'static> fmt::Debug for AtomicDrmDevice<A> {
impl<A: AsRawFd + fmt::Debug + 'static> fmt::Debug for AtomicDrmDevice<A> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let mut debug = f.debug_struct("AtomicDrmDevice");
@ -68,7 +68,8 @@ impl<A: AsRawFd + 'static> fmt::Debug for AtomicDrmDevice<A> {
.field("dev", &self.dev)
.field("dev_id", &self.dev_id)
.field("active", &self.active)
.field("backends", &self.backends);
.field("backends", &self.backends)
.field("handler", &"...");
#[cfg(feature = "backend_session")]
debug.field("links", &self.links);
@ -100,9 +101,10 @@ pub(in crate::backend::drm) struct Dev<A: AsRawFd + 'static> {
logger: ::slog::Logger,
}
impl<A: AsRawFd + 'static> fmt::Debug for Dev<A> {
impl<A: AsRawFd + fmt::Debug + 'static> fmt::Debug for Dev<A> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("Dev")
.field("fd", &self.fd)
.field("privileged", &self.privileged)
.field("active", &self.active)
.field("old_state", &self.old_state)

View File

@ -48,9 +48,10 @@ pub(in crate::backend::drm) struct AtomicDrmSurfaceInternal<A: AsRawFd + 'static
pub(super) test_buffer: Mutex<Option<(DumbBuffer, framebuffer::Handle)>>,
}
impl<A: AsRawFd + 'static> fmt::Debug for AtomicDrmSurfaceInternal<A> {
impl<A: AsRawFd + fmt::Debug + 'static> fmt::Debug for AtomicDrmSurfaceInternal<A> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("AtomicDrmSurfaceInternal")
.field("dev", &self.dev)
.field("crtc", &self.crtc)
.field("cursor", &self.cursor)
.field("planse", &self.planes)

View File

@ -73,17 +73,20 @@ where
impl<B, D> fmt::Debug for EglDevice<B, D>
where
B: Backend<Surface = <D as Device>::Surface, Error = <<D as Device>::Surface as Surface>::Error>
+ fmt::Debug
+ 'static,
D: Device + NativeDisplay<B, Arguments = Arguments> + 'static,
D: Device + NativeDisplay<B, Arguments = Arguments> + fmt::Debug + 'static,
<D as Device>::Surface: NativeSurface<Error = <<D as Device>::Surface as Surface>::Error>,
{
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let mut debug = f.debug_struct("EglDevice");
debug
.field("dev", &self.dev)
.field("logger", &self.logger)
.field("default_attributes", &self.default_attributes)
.field("default_requirements", &self.default_requirements);
.field("default_requirements", &self.default_requirements)
.field("backends", &"...");
#[cfg(feature = "backend_session")]
debug.field("links", &self.links);

View File

@ -91,10 +91,15 @@ pub struct EglStreamDevice<D: RawDevice + ControlDevice + 'static> {
links: Vec<crate::signaling::SignalToken>,
}
impl<D: RawDevice + ControlDevice + 'static> fmt::Debug for EglStreamDevice<D> {
impl<D: RawDevice + ControlDevice + fmt::Debug + 'static> fmt::Debug for EglStreamDevice<D> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let mut debug = f.debug_struct("EglStreamDevice");
debug.field("dev", &self.dev).field("logger", &self.logger);
debug
.field("dev", &self.dev)
.field("raw", &self.raw)
.field("backends", &"...")
.field("logger", &self.logger);
#[cfg(feature = "backend_session")]
debug.field("links", &self.links);
debug.finish()

View File

@ -1,7 +1,6 @@
//! OpenGL rendering types
use nix::libc::c_void;
use std::fmt;
use super::{PixelFormat, SwapBuffersError};
@ -40,15 +39,6 @@ pub trait GLGraphicsBackend {
/// Returns the pixel format of the main framebuffer of the context.
fn get_pixel_format(&self) -> PixelFormat;
/// Formats the debug value using the given formatter.
fn debug_fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("GLGraphicsBackend")
.field("framebuffer_dimensions", &self.get_framebuffer_dimensions())
.field("is_current", &self.is_current())
.field("pixel_format", &self.get_pixel_format())
.finish()
}
}
/// Loads a Raw GLES Interface for a given [`GLGraphicsBackend`]

View File

@ -25,10 +25,22 @@ pub struct GliumGraphicsBackend<T: GLGraphicsBackend> {
impl<T: GLGraphicsBackend> fmt::Debug for GliumGraphicsBackend<T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let backend = &self.backend.0.borrow().debug_fmt(f);
struct BackendDebug<'a, T: GLGraphicsBackend>(&'a Rc<InternalBackend<T>>);
impl<'a, T: GLGraphicsBackend> fmt::Debug for BackendDebug<'a, T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let b = &self.0 .0.borrow();
f.debug_struct("GLGraphicsBackend")
.field("framebuffer_dimensions", &b.get_framebuffer_dimensions())
.field("is_current", &b.is_current())
.field("pixel_format", &b.get_pixel_format())
.finish()
}
}
f.debug_struct("GliumGraphicsBackend")
.field("backend", backend)
.field("context", &"...")
.field("backend", &BackendDebug(&self.backend))
.field("error_channel", &"...")
.finish()
}
}

View File

@ -430,13 +430,19 @@ pub struct LibinputSessionInterface<S: Session>(S);
#[cfg(feature = "backend_session")]
impl<S: Session> fmt::Debug for LibinputSessionInterface<S> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let sesion = &f
.debug_struct("Session")
.field("is_active", &self.0.is_active())
.field("seat", &self.0.seat())
.finish();
struct SessionDebug<'a, S: Session>(&'a S);
impl<'a, S: Session> fmt::Debug for SessionDebug<'a, S> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("Session")
.field("is_active", &self.0.is_active())
.field("seat", &self.0.seat())
.finish()
}
}
f.debug_tuple("LibinputSessionInterface").field(sesion).finish()
f.debug_tuple("LibinputSessionInterface")
.field(&SessionDebug(&self.0))
.finish()
}
}

View File

@ -75,7 +75,7 @@ impl fmt::Debug for LogindSessionImpl {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("LogindSessionImpl ")
.field("session_id", &self.session_id)
.field("conn", &"..")
.field("conn", &"...")
.field("session_path", &self.session_path)
.field("active", &self.active)
.field("signaler", &self.signaler)

View File

@ -69,10 +69,23 @@ enum Window {
impl fmt::Debug for Window {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Window::Wayland { .. } => f.debug_tuple("Window::Wayland"),
Window::X11 { .. } => f.debug_tuple("Window::X11"),
Window::Wayland { display, context, .. } => f
.debug_struct("Window::Wayland")
.field("display", &display)
.field("context", &context)
.field("surface", &"...")
.finish(),
Window::X11 {
display,
context,
surface,
} => f
.debug_struct("Window::X11")
.field("display", &display)
.field("context", &context)
.field("surface", &surface)
.finish(),
}
.finish()
}
}