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();