Add all missing Debug implementations

Fixes #258
This commit is contained in:
Victor Berger 2021-06-30 01:05:12 +02:00 committed by Victor Berger
parent b1b025992f
commit 811df39214
22 changed files with 65 additions and 5 deletions

View File

@ -124,6 +124,7 @@ impl Buffer for Dmabuf {
} }
/// Builder for Dmabufs /// Builder for Dmabufs
#[derive(Debug)]
pub struct DmabufBuilder { pub struct DmabufBuilder {
internal: DmabufInternal, internal: DmabufInternal,
} }

View File

@ -35,6 +35,7 @@ pub const SLOT_CAP: usize = 4;
/// If you have associated resources for each buffer that can be reused (e.g. framebuffer `Handle`s for a `DrmDevice`), /// If you have associated resources for each buffer that can be reused (e.g. framebuffer `Handle`s for a `DrmDevice`),
/// you can store then in the `Slot`s userdata field. If a buffer is re-used, its userdata is preserved for the next time /// you can store then in the `Slot`s userdata field. If a buffer is re-used, its userdata is preserved for the next time
/// it is returned by `acquire()`. /// it is returned by `acquire()`.
#[derive(Debug)]
pub struct Swapchain<A: Allocator<B>, B: Buffer, U: 'static> { pub struct Swapchain<A: Allocator<B>, B: Buffer, U: 'static> {
/// Allocator used by the swapchain /// Allocator used by the swapchain
pub allocator: A, pub allocator: A,
@ -52,8 +53,10 @@ pub struct Swapchain<A: Allocator<B>, B: Buffer, U: 'static> {
/// Can be cloned and passed around freely, the buffer is marked for re-use /// Can be cloned and passed around freely, the buffer is marked for re-use
/// once all copies are dropped. Holding on to this struct will block the /// once all copies are dropped. Holding on to this struct will block the
/// buffer in the swapchain. /// buffer in the swapchain.
#[derive(Debug)]
pub struct Slot<B: Buffer, U: 'static>(Arc<InternalSlot<B, U>>); pub struct Slot<B: Buffer, U: 'static>(Arc<InternalSlot<B, U>>);
#[derive(Debug)]
struct InternalSlot<B: Buffer, U: 'static> { struct InternalSlot<B: Buffer, U: 'static> {
buffer: Option<B>, buffer: Option<B>,
acquired: AtomicBool, acquired: AtomicBool,

View File

@ -29,7 +29,7 @@ pub type Mapping = (
HashMap<framebuffer::Handle, HashMap<String, property::Handle>>, HashMap<framebuffer::Handle, HashMap<String, property::Handle>>,
HashMap<plane::Handle, HashMap<String, property::Handle>>, HashMap<plane::Handle, HashMap<String, property::Handle>>,
); );
#[derive(Debug)]
pub struct AtomicDrmDevice<A: AsRawFd + 'static> { pub struct AtomicDrmDevice<A: AsRawFd + 'static> {
pub(crate) fd: Arc<FdWrapper<A>>, pub(crate) fd: Arc<FdWrapper<A>>,
pub(crate) active: Arc<AtomicBool>, pub(crate) active: Arc<AtomicBool>,

View File

@ -12,6 +12,7 @@ use crate::backend::drm::error::Error;
use slog::{error, info, o}; use slog::{error, info, o};
#[derive(Debug)]
pub struct LegacyDrmDevice<A: AsRawFd + 'static> { pub struct LegacyDrmDevice<A: AsRawFd + 'static> {
pub(crate) fd: Arc<FdWrapper<A>>, pub(crate) fd: Arc<FdWrapper<A>>,
pub(crate) active: Arc<AtomicBool>, pub(crate) active: Arc<AtomicBool>,

View File

@ -20,6 +20,7 @@ use legacy::LegacyDrmDevice;
use slog::{error, info, o, trace, warn}; use slog::{error, info, o, trace, warn};
/// An open drm device /// An open drm device
#[derive(Debug)]
pub struct DrmDevice<A: AsRawFd + 'static> { pub struct DrmDevice<A: AsRawFd + 'static> {
pub(super) dev_id: dev_t, pub(super) dev_id: dev_t,
pub(crate) internal: Arc<DrmDeviceInternal<A>>, pub(crate) internal: Arc<DrmDeviceInternal<A>>,
@ -42,6 +43,7 @@ impl<A: AsRawFd + 'static> AsRawFd for DrmDevice<A> {
impl<A: AsRawFd + 'static> BasicDevice for DrmDevice<A> {} impl<A: AsRawFd + 'static> BasicDevice for DrmDevice<A> {}
impl<A: AsRawFd + 'static> ControlDevice for DrmDevice<A> {} impl<A: AsRawFd + 'static> ControlDevice for DrmDevice<A> {}
#[derive(Debug)]
pub struct FdWrapper<A: AsRawFd + 'static> { pub struct FdWrapper<A: AsRawFd + 'static> {
fd: A, fd: A,
pub(super) privileged: bool, pub(super) privileged: bool,
@ -67,6 +69,7 @@ impl<A: AsRawFd + 'static> Drop for FdWrapper<A> {
} }
} }
#[derive(Debug)]
pub enum DrmDeviceInternal<A: AsRawFd + 'static> { pub enum DrmDeviceInternal<A: AsRawFd + 'static> {
Atomic(AtomicDrmDevice<A>), Atomic(AtomicDrmDevice<A>),
Legacy(LegacyDrmDevice<A>), Legacy(LegacyDrmDevice<A>),
@ -301,6 +304,7 @@ impl<A: AsRawFd> DevPath for A {
} }
/// Events that can be generated by a DrmDevice /// Events that can be generated by a DrmDevice
#[derive(Debug)]
pub enum DrmEvent { pub enum DrmEvent {
/// A vblank blank event on the provided crtc has happend /// A vblank blank event on the provided crtc has happend
VBlank(crtc::Handle), VBlank(crtc::Handle),

View File

@ -75,6 +75,7 @@ pub use surface::DrmSurface;
use drm::control::{crtc, plane, Device as ControlDevice, PlaneType}; use drm::control::{crtc, plane, Device as ControlDevice, PlaneType};
/// A set of planes as supported by a crtc /// A set of planes as supported by a crtc
#[derive(Debug)]
pub struct Planes { pub struct Planes {
/// The primary plane of the crtc (automatically selected for [DrmDevice::create_surface]) /// The primary plane of the crtc (automatically selected for [DrmDevice::create_surface])
pub primary: plane::Handle, pub primary: plane::Handle,

View File

@ -107,6 +107,7 @@ pub struct PlaneInfo {
h: u32, h: u32,
} }
#[derive(Debug)]
pub struct AtomicDrmSurface<A: AsRawFd + 'static> { pub struct AtomicDrmSurface<A: AsRawFd + 'static> {
pub(super) fd: Arc<DrmDeviceInternal<A>>, pub(super) fd: Arc<DrmDeviceInternal<A>>,
pub(super) active: Arc<AtomicBool>, pub(super) active: Arc<AtomicBool>,

View File

@ -29,6 +29,16 @@ pub struct GbmBufferedSurface<D: AsRawFd + 'static> {
drm: Arc<DrmSurface<D>>, drm: Arc<DrmSurface<D>>,
} }
// TODO: Replace with #[derive(Debug)] once gbm::BufferObject implements debug
impl<D: std::fmt::Debug + AsRawFd + 'static> std::fmt::Debug for GbmBufferedSurface<D> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("GbmBufferedSurface")
.field("buffers", &self.buffers)
.field("drm", &self.drm)
.finish_non_exhaustive()
}
}
impl<D> GbmBufferedSurface<D> impl<D> GbmBufferedSurface<D>
where where
D: AsRawFd + 'static, D: AsRawFd + 'static,
@ -266,6 +276,7 @@ where
} }
} }
#[derive(Debug)]
struct FbHandle<D: AsRawFd + 'static> { struct FbHandle<D: AsRawFd + 'static> {
drm: Arc<DrmSurface<D>>, drm: Arc<DrmSurface<D>>,
fb: framebuffer::Handle, fb: framebuffer::Handle,
@ -287,6 +298,15 @@ struct Buffers<D: AsRawFd + 'static> {
next_fb: Option<DmabufSlot<D>>, next_fb: Option<DmabufSlot<D>>,
} }
// TODO: Replace with #[derive(Debug)] once gbm::BufferObject implements debug
impl<D: std::fmt::Debug + AsRawFd + 'static> std::fmt::Debug for Buffers<D> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("Buffers")
.field("drm", &self.drm)
.finish_non_exhaustive()
}
}
impl<D> Buffers<D> impl<D> Buffers<D>
where where
D: AsRawFd + 'static, D: AsRawFd + 'static,

View File

@ -70,6 +70,7 @@ impl State {
} }
} }
#[derive(Debug)]
pub struct LegacyDrmSurface<A: AsRawFd + 'static> { pub struct LegacyDrmSurface<A: AsRawFd + 'static> {
pub(super) fd: Arc<DrmDeviceInternal<A>>, pub(super) fd: Arc<DrmDeviceInternal<A>>,
pub(super) active: Arc<AtomicBool>, pub(super) active: Arc<AtomicBool>,

View File

@ -22,6 +22,7 @@ use legacy::LegacyDrmSurface;
use slog::trace; use slog::trace;
/// An open crtc + plane combination that can be used for scan-out /// An open crtc + plane combination that can be used for scan-out
#[derive(Debug)]
pub struct DrmSurface<A: AsRawFd + 'static> { pub struct DrmSurface<A: AsRawFd + 'static> {
// This field is only read when 'backend_session' is enabled // This field is only read when 'backend_session' is enabled
#[allow(dead_code)] #[allow(dead_code)]
@ -34,6 +35,7 @@ pub struct DrmSurface<A: AsRawFd + 'static> {
pub(super) links: RefCell<Vec<crate::signaling::SignalToken>>, pub(super) links: RefCell<Vec<crate::signaling::SignalToken>>,
} }
#[derive(Debug)]
pub enum DrmSurfaceInternal<A: AsRawFd + 'static> { pub enum DrmSurfaceInternal<A: AsRawFd + 'static> {
Atomic(AtomicDrmSurface<A>), Atomic(AtomicDrmSurface<A>),
Legacy(LegacyDrmSurface<A>), Legacy(LegacyDrmSurface<A>),

View File

@ -42,7 +42,7 @@ pub fn make_sure_egl_is_loaded() {
}); });
} }
#[allow(clippy::all)] #[allow(clippy::all, missing_debug_implementations)]
pub mod egl { pub mod egl {
use super::*; use super::*;
use libloading::Library; use libloading::Library;

View File

@ -227,6 +227,7 @@ pub unsafe trait EGLNativeSurface: Send + Sync {
#[cfg(feature = "backend_winit")] #[cfg(feature = "backend_winit")]
/// Typed Xlib window for the `X11` backend /// Typed Xlib window for the `X11` backend
#[derive(Debug)]
pub struct XlibWindow(pub raw::c_ulong); pub struct XlibWindow(pub raw::c_ulong);
#[cfg(feature = "backend_winit")] #[cfg(feature = "backend_winit")]

View File

@ -40,7 +40,7 @@ use wayland_server::protocol::{wl_buffer, wl_shm};
use slog::{debug, error, info, o, trace, warn}; use slog::{debug, error, info, o, trace, warn};
#[allow(clippy::all, missing_docs)] #[allow(clippy::all, missing_docs, missing_debug_implementations)]
pub mod ffi { pub mod ffi {
include!(concat!(env!("OUT_DIR"), "/gl_bindings.rs")); include!(concat!(env!("OUT_DIR"), "/gl_bindings.rs"));
} }
@ -172,6 +172,15 @@ pub struct Gles2Frame {
programs: [Gles2Program; shaders::FRAGMENT_COUNT], programs: [Gles2Program; shaders::FRAGMENT_COUNT],
} }
impl fmt::Debug for Gles2Frame {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("Gles2Frame")
.field("current_projection", &self.current_projection)
.field("programs", &self.programs)
.finish_non_exhaustive()
}
}
impl fmt::Debug for Gles2Renderer { impl fmt::Debug for Gles2Renderer {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("Gles2Renderer") f.debug_struct("Gles2Renderer")

View File

@ -453,6 +453,7 @@ impl<R: Renderer + ImportShm + ImportDma> ImportAll for R {
#[cfg(feature = "wayland_frontend")] #[cfg(feature = "wayland_frontend")]
#[non_exhaustive] #[non_exhaustive]
/// Buffer type of a given wl_buffer, if managed by smithay /// Buffer type of a given wl_buffer, if managed by smithay
#[derive(Debug)]
pub enum BufferType { pub enum BufferType {
/// Buffer is managed by the [`crate::wayland::shm`] global /// Buffer is managed by the [`crate::wayland::shm`] global
Shm, Shm,

View File

@ -270,7 +270,7 @@ impl WinitGraphicsBackend {
} }
/// Virtual input device used by the backend to associate input events /// Virtual input device used by the backend to associate input events
#[derive(PartialEq, Eq, Hash)] #[derive(PartialEq, Eq, Hash, Debug)]
pub struct WinitVirtualDevice; pub struct WinitVirtualDevice;
impl Device for WinitVirtualDevice { impl Device for WinitVirtualDevice {

View File

@ -1,4 +1,4 @@
#![warn(missing_docs, rust_2018_idioms)] #![warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]
// Allow acronyms like EGL // Allow acronyms like EGL
#![allow(clippy::upper_case_acronyms)] #![allow(clippy::upper_case_acronyms)]

View File

@ -136,6 +136,12 @@ pub struct MultiCache {
caches: appendlist::AppendList<Box<dyn Cache + Send>>, caches: appendlist::AppendList<Box<dyn Cache + Send>>,
} }
impl std::fmt::Debug for MultiCache {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("MultiCache").finish_non_exhaustive()
}
}
impl MultiCache { impl MultiCache {
pub(crate) fn new() -> MultiCache { pub(crate) fn new() -> MultiCache {
MultiCache { MultiCache {

View File

@ -277,6 +277,7 @@ pub(crate) fn implement_subcompositor(
*/ */
/// The cached state associated with a subsurface /// The cached state associated with a subsurface
#[derive(Debug)]
pub struct SubsurfaceCachedState { pub struct SubsurfaceCachedState {
/// Location of the top-left corner of this subsurface /// Location of the top-left corner of this subsurface
/// relative to its parent coordinate space /// relative to its parent coordinate space

View File

@ -133,6 +133,7 @@ struct Marker<R> {
/// ///
/// By default, all surfaces have a [`SurfaceAttributes`] cached state, /// By default, all surfaces have a [`SurfaceAttributes`] cached state,
/// and subsurface also have a [`SubsurfaceCachedState`] state as well. /// and subsurface also have a [`SubsurfaceCachedState`] state as well.
#[derive(Debug)]
pub struct SurfaceData { pub struct SurfaceData {
/// The current role of the surface. /// The current role of the surface.
/// ///

View File

@ -197,6 +197,7 @@ xdg_role!(
/// xdg_surface description). /// xdg_surface description).
/// ///
/// Attaching a null buffer to a toplevel unmaps the surface. /// Attaching a null buffer to a toplevel unmaps the surface.
#[derive(Debug)]
XdgToplevelSurfaceRoleAttributes { XdgToplevelSurfaceRoleAttributes {
/// The parent field of a toplevel should be used /// The parent field of a toplevel should be used
/// by the compositor to determine which toplevel /// by the compositor to determine which toplevel
@ -272,6 +273,7 @@ xdg_role!(
/// ///
/// The client must call wl_surface.commit on the corresponding wl_surface /// The client must call wl_surface.commit on the corresponding wl_surface
/// for the xdg_popup state to take effect. /// for the xdg_popup state to take effect.
#[derive(Debug)]
XdgPopupSurfaceRoleAttributes { XdgPopupSurfaceRoleAttributes {
/// Holds the parent for the xdg_popup. /// Holds the parent for the xdg_popup.
/// ///

View File

@ -26,6 +26,7 @@ pub(crate) fn prepare_x11_sockets(log: ::slog::Logger) -> Result<(X11Lock, [Unix
)) ))
} }
#[derive(Debug)]
pub(crate) struct X11Lock { pub(crate) struct X11Lock {
display: u32, display: u32,
log: ::slog::Logger, log: ::slog::Logger,

View File

@ -68,6 +68,7 @@ use wayland_server::{Client, Display, Filter};
use super::x11_sockets::{prepare_x11_sockets, X11Lock}; use super::x11_sockets::{prepare_x11_sockets, X11Lock};
/// The XWayland handle /// The XWayland handle
#[derive(Debug)]
pub struct XWayland<Data> { pub struct XWayland<Data> {
inner: Rc<RefCell<Inner<Data>>>, inner: Rc<RefCell<Inner<Data>>>,
} }
@ -143,6 +144,7 @@ impl<Data> Drop for XWayland<Data> {
} }
} }
#[derive(Debug)]
struct XWaylandInstance { struct XWaylandInstance {
display_lock: X11Lock, display_lock: X11Lock,
wayland_client: Option<Client>, wayland_client: Option<Client>,
@ -151,6 +153,7 @@ struct XWaylandInstance {
} }
// Inner implementation of the XWayland manager // Inner implementation of the XWayland manager
#[derive(Debug)]
struct Inner<Data> { struct Inner<Data> {
sender: SyncSender<XWaylandEvent>, sender: SyncSender<XWaylandEvent>,
handle: LoopHandle<'static, Data>, handle: LoopHandle<'static, Data>,
@ -227,6 +230,7 @@ fn launch<Data: Any>(inner: &Rc<RefCell<Inner<Data>>>) -> std::io::Result<()> {
Ok(()) Ok(())
} }
#[derive(Debug)]
pub struct XWaylandSource { pub struct XWaylandSource {
channel: Channel<XWaylandEvent>, channel: Channel<XWaylandEvent>,
} }