From 7621bb0f3bba69e0b2849974a335dff4742c8e95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Tue, 31 Jul 2018 12:52:02 +0200 Subject: Add debug logging operator for QPlatformSurface Change-Id: I2adecf87fa058bf973f4e4eed0a4c002f8359728 Reviewed-by: Simon Hausmann --- src/gui/kernel/qplatformsurface.cpp | 25 +++++++++++++++++++++++++ src/gui/kernel/qplatformsurface.h | 9 +++++++++ src/gui/kernel/qsurface.h | 3 +++ 3 files changed, 37 insertions(+) (limited to 'src/gui') diff --git a/src/gui/kernel/qplatformsurface.cpp b/src/gui/kernel/qplatformsurface.cpp index f091c04ebb..fdb2cf567d 100644 --- a/src/gui/kernel/qplatformsurface.cpp +++ b/src/gui/kernel/qplatformsurface.cpp @@ -38,6 +38,10 @@ ****************************************************************************/ #include "qplatformsurface.h" +#ifndef QT_NO_DEBUG_STREAM +#include +#include +#endif QT_BEGIN_NAMESPACE @@ -64,5 +68,26 @@ QPlatformSurface::QPlatformSurface(QSurface *surface) : m_surface(surface) { } +#ifndef QT_NO_DEBUG_STREAM +Q_GUI_EXPORT QDebug operator<<(QDebug debug, const QPlatformSurface *surface) +{ + QDebugStateSaver saver(debug); + debug.nospace(); + debug << "QPlatformSurface(" << (const void *)surface; + if (surface) { + QSurface *s = surface->surface(); + auto surfaceClass = s->surfaceClass(); + debug << ", class=" << surfaceClass; + debug << ", type=" << s->surfaceType(); + if (surfaceClass == QSurface::Window) + debug << ", window=" << static_cast(s); + else + debug << ", surface=" << s; + } + debug << ')'; + return debug; +} +#endif // !QT_NO_DEBUG_STREAM + QT_END_NAMESPACE diff --git a/src/gui/kernel/qplatformsurface.h b/src/gui/kernel/qplatformsurface.h index 76e8767a05..4d8854fb40 100644 --- a/src/gui/kernel/qplatformsurface.h +++ b/src/gui/kernel/qplatformsurface.h @@ -58,6 +58,10 @@ QT_BEGIN_NAMESPACE class QPlatformScreen; +#ifndef QT_NO_DEBUG_STREAM +class QDebug; +#endif + class Q_GUI_EXPORT QPlatformSurface { public: @@ -76,6 +80,11 @@ private: friend class QPlatformOffscreenSurface; }; + +#ifndef QT_NO_DEBUG_STREAM +Q_GUI_EXPORT QDebug operator<<(QDebug debug, const QPlatformSurface *surface); +#endif + QT_END_NAMESPACE #endif //QPLATFORMSURFACE_H diff --git a/src/gui/kernel/qsurface.h b/src/gui/kernel/qsurface.h index e3e5106e3a..521593ea5c 100644 --- a/src/gui/kernel/qsurface.h +++ b/src/gui/kernel/qsurface.h @@ -55,11 +55,13 @@ class QSurfacePrivate; class Q_GUI_EXPORT QSurface { + Q_GADGET public: enum SurfaceClass { Window, Offscreen }; + Q_ENUM(SurfaceClass) enum SurfaceType { RasterSurface, @@ -69,6 +71,7 @@ public: VulkanSurface, MetalSurface }; + Q_ENUM(SurfaceType) virtual ~QSurface(); -- cgit v1.2.3