From 6c25dde36eb1e45e991f8ed0f75cb969568f3db9 Mon Sep 17 00:00:00 2001 From: Victor Brekenfeld Date: Fri, 30 Apr 2021 18:31:15 +0200 Subject: [PATCH] Fix some missing Debug implementations --- src/backend/allocator/dmabuf.rs | 5 +++-- src/backend/allocator/dumb.rs | 10 ++++++++++ src/backend/egl/display.rs | 3 ++- src/backend/egl/mod.rs | 16 +--------------- src/backend/egl/surface.rs | 16 ++++++++++++++++ src/backend/renderer/gles2/mod.rs | 21 ++++++++++++++++++++- src/backend/session/dbus/logind.rs | 2 +- src/backend/session/direct.rs | 2 +- src/backend/winit.rs | 2 +- src/wayland/seat/pointer.rs | 2 +- 10 files changed, 56 insertions(+), 23 deletions(-) diff --git a/src/backend/allocator/dmabuf.rs b/src/backend/allocator/dmabuf.rs index b025af4..1b810bc 100644 --- a/src/backend/allocator/dmabuf.rs +++ b/src/backend/allocator/dmabuf.rs @@ -6,6 +6,7 @@ use std::sync::{Arc, Weak}; const MAX_PLANES: usize = 4; +#[derive(Debug)] pub(crate) struct DmabufInternal { pub num_planes: usize, pub offsets: [u32; MAX_PLANES], @@ -16,11 +17,11 @@ pub(crate) struct DmabufInternal { pub format: Format, } -#[derive(Clone)] +#[derive(Debug, Clone)] /// Strong reference to a dmabuf handle pub struct Dmabuf(pub(crate) Arc); -#[derive(Clone)] +#[derive(Debug, Clone)] /// Weak reference to a dmabuf handle pub struct WeakDmabuf(pub(crate) Weak); diff --git a/src/backend/allocator/dumb.rs b/src/backend/allocator/dumb.rs index 42b858c..d418e3c 100644 --- a/src/backend/allocator/dumb.rs +++ b/src/backend/allocator/dumb.rs @@ -1,5 +1,6 @@ //! Module for [DumbBuffer](https://01.org/linuxgraphics/gfx-docs/drm/gpu/drm-kms.html#dumb-buffer-objects) buffers +use std::fmt; use std::os::unix::io::AsRawFd; use std::sync::Arc; @@ -16,6 +17,15 @@ pub struct DumbBuffer { format: Format, } +impl fmt::Debug for DumbBuffer { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("DumbBuffer") + .field("handle", &self.handle) + .field("format", &self.format) + .finish() + } +} + impl Allocator> for DrmDevice { type Error = drm::SystemError; diff --git a/src/backend/egl/display.rs b/src/backend/egl/display.rs index 54b2940..f99e945 100644 --- a/src/backend/egl/display.rs +++ b/src/backend/egl/display.rs @@ -1,6 +1,7 @@ //! Type safe native types for safe egl initialisation use std::collections::HashSet; +use std::fmt; use std::ffi::CStr; use std::mem::MaybeUninit; use std::ops::Deref; @@ -50,7 +51,7 @@ impl Drop for EGLDisplayHandle { } /// [`EGLDisplay`] represents an initialised EGL environment -#[derive(Clone)] +#[derive(Debug, Clone)] pub struct EGLDisplay { pub(crate) display: Arc, pub(crate) egl_version: (i32, i32), diff --git a/src/backend/egl/mod.rs b/src/backend/egl/mod.rs index 1f02640..03014c6 100644 --- a/src/backend/egl/mod.rs +++ b/src/backend/egl/mod.rs @@ -240,6 +240,7 @@ impl Format { /// Images of the EGL-based [`WlBuffer`]. #[cfg(feature = "wayland_frontend")] +#[derive(Debug)] pub struct EGLBuffer { display: Arc, /// Width in pixels @@ -253,21 +254,6 @@ pub struct EGLBuffer { images: Vec, } -// Gles2 does not implement debug, so we have to impl Debug manually -#[cfg(feature = "wayland_frontend")] -impl fmt::Debug for EGLImages { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_struct("Point") - .field("display", &self.display) - .field("width", &self.width) - .field("height", &self.height) - .field("y_inverted", &self.y_inverted) - .field("format", &self.format) - .field("images", &self.images) - .finish() - } -} - #[cfg(feature = "wayland_frontend")] impl EGLBuffer { /// Amount of planes of these `EGLImages` diff --git a/src/backend/egl/surface.rs b/src/backend/egl/surface.rs index 6008749..0c86b38 100644 --- a/src/backend/egl/surface.rs +++ b/src/backend/egl/surface.rs @@ -1,5 +1,6 @@ //! EGL surface related structs +use std::fmt; use std::sync::{ atomic::{AtomicPtr, Ordering}, Arc, @@ -24,6 +25,21 @@ pub struct EGLSurface { surface_attributes: Vec, logger: ::slog::Logger, } + +impl fmt::Debug for EGLSurface { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("EGLSurface") + .field("display", &self.display) + // native does not necessarily implement Debug + .field("surface", &self.surface) + .field("config_id", &self.config_id) + .field("pixel_format", &self.pixel_format) + .field("surface_attributes", &self.surface_attributes) + .field("logger", &self.logger) + .finish() + } +} + // safe because EGLConfig can be moved between threads // and the other types are thread-safe unsafe impl Send for EGLSurface {} diff --git a/src/backend/renderer/gles2/mod.rs b/src/backend/renderer/gles2/mod.rs index 9e93140..9548fa6 100644 --- a/src/backend/renderer/gles2/mod.rs +++ b/src/backend/renderer/gles2/mod.rs @@ -1,6 +1,7 @@ //! Implementation of the rendering traits using OpenGL ES 2 use std::collections::HashSet; +use std::fmt; use std::ffi::CStr; use std::ptr; use std::rc::Rc; @@ -38,6 +39,7 @@ struct Gles2Program { } /// A handle to a GLES2 texture +#[derive(Debug)] pub struct Gles2Texture { texture: ffi::types::GLuint, texture_kind: usize, @@ -56,7 +58,7 @@ impl Texture for Gles2Texture { } } -#[derive(Clone)] +#[derive(Debug, Clone)] struct WeakGles2Buffer { dmabuf: WeakDmabuf, image: EGLImage, @@ -64,6 +66,7 @@ struct WeakGles2Buffer { fbo: ffi::types::GLuint, } +#[derive(Debug)] struct Gles2Buffer { internal: WeakGles2Buffer, _dmabuf: Dmabuf, @@ -83,6 +86,22 @@ pub struct Gles2Renderer { _not_send: *mut (), } +impl fmt::Debug for Gles2Renderer { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("Gles2Renderer") + .field("buffers", &self.buffers) + .field("target_buffer", &self.target_buffer) + .field("target_surface", &self.target_surface) + .field("current_projection", &self.current_projection) + .field("extensions", &self.extensions) + .field("programs", &self.programs) + // ffi::Gles2 does not implement Debug + .field("egl", &self.egl) + .field("logger", &self.logger) + .finish() + } +} + /// Error returned during rendering using GL ES #[derive(thiserror::Error, Debug)] pub enum Gles2Error { diff --git a/src/backend/session/dbus/logind.rs b/src/backend/session/dbus/logind.rs index f55fd07..ac3fa23 100644 --- a/src/backend/session/dbus/logind.rs +++ b/src/backend/session/dbus/logind.rs @@ -74,7 +74,7 @@ struct LogindSessionImpl { // DBusConnection does not implement debug, so we have to impl Debug manually impl fmt::Debug for LogindSessionImpl { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_struct("LogindSessionImpl ") + f.debug_struct("LogindSessionImpl") .field("session_id", &self.session_id) .field("conn", &"...") .field("session_path", &self.session_path) diff --git a/src/backend/session/direct.rs b/src/backend/session/direct.rs index 0c2a080..d1899c3 100644 --- a/src/backend/session/direct.rs +++ b/src/backend/session/direct.rs @@ -164,7 +164,7 @@ pub struct DirectSessionNotifier { impl fmt::Debug for DirectSessionNotifier { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_struct("Point") + f.debug_struct("DirectSessionNotifier") .field("tty", &self.tty) .field("active", &self.active) .field("signaler", &self.signaler) diff --git a/src/backend/winit.rs b/src/backend/winit.rs index de4f7ec..bca9929 100644 --- a/src/backend/winit.rs +++ b/src/backend/winit.rs @@ -27,7 +27,7 @@ use winit::{ TouchPhase, WindowEvent, }, event_loop::{ControlFlow, EventLoop}, - platform::desktop::EventLoopExtDesktop, + platform::run_return::EventLoopExtRunReturn, platform::unix::WindowExtUnix, window::{Window as WinitWindow, WindowBuilder}, }; diff --git a/src/wayland/seat/pointer.rs b/src/wayland/seat/pointer.rs index d09837f..819cdb8 100644 --- a/src/wayland/seat/pointer.rs +++ b/src/wayland/seat/pointer.rs @@ -59,7 +59,7 @@ struct PointerInternal { // image_callback does not implement debug, so we have to impl Debug manually impl fmt::Debug for PointerInternal { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_struct("Point") + f.debug_struct("PointerInternal") .field("known_pointers", &self.known_pointers) .field("focus", &self.focus) .field("pending_focus", &self.pending_focus)