Fix some missing Debug implementations

This commit is contained in:
Victor Brekenfeld 2021-04-30 18:31:15 +02:00
parent 7e47d648d4
commit 6c25dde36e
10 changed files with 56 additions and 23 deletions

View File

@ -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<DmabufInternal>);
#[derive(Clone)]
#[derive(Debug, Clone)]
/// Weak reference to a dmabuf handle
pub struct WeakDmabuf(pub(crate) Weak<DmabufInternal>);

View File

@ -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<A: AsRawFd + 'static> {
format: Format,
}
impl<A: AsRawFd + 'static> fmt::Debug for DumbBuffer<A> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("DumbBuffer")
.field("handle", &self.handle)
.field("format", &self.format)
.finish()
}
}
impl<A: AsRawFd + 'static> Allocator<DumbBuffer<A>> for DrmDevice<A> {
type Error = drm::SystemError;

View File

@ -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<EGLDisplayHandle>,
pub(crate) egl_version: (i32, i32),

View File

@ -240,6 +240,7 @@ impl Format {
/// Images of the EGL-based [`WlBuffer`].
#[cfg(feature = "wayland_frontend")]
#[derive(Debug)]
pub struct EGLBuffer {
display: Arc<EGLDisplayHandle>,
/// Width in pixels
@ -253,21 +254,6 @@ pub struct EGLBuffer {
images: Vec<EGLImage>,
}
// 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`

View File

@ -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<c_int>,
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 {}

View File

@ -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 {

View File

@ -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)

View File

@ -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)

View File

@ -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},
};

View File

@ -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)