diff options
Diffstat (limited to 'src/plugins/platforms/xcb/qxcbintegration.cpp')
-rw-r--r-- | src/plugins/platforms/xcb/qxcbintegration.cpp | 75 |
1 files changed, 66 insertions, 9 deletions
diff --git a/src/plugins/platforms/xcb/qxcbintegration.cpp b/src/plugins/platforms/xcb/qxcbintegration.cpp index c9ecdceb0d..471287eb44 100644 --- a/src/plugins/platforms/xcb/qxcbintegration.cpp +++ b/src/plugins/platforms/xcb/qxcbintegration.cpp @@ -65,6 +65,11 @@ #if QT_CONFIG(xcb_xlib) #include <X11/Xlib.h> +#if QT_CONFIG(xcb_native_painting) +#include "qxcbnativepainting.h" +#include "qpixmap_x11_p.h" +#include "qbackingstore_x11_p.h" +#endif #endif #include <qpa/qplatforminputcontextfactory_p.h> @@ -83,6 +88,11 @@ #include <QtCore/QFileInfo> +#if QT_CONFIG(vulkan) +#include "qxcbvulkaninstance.h" +#include "qxcbvulkanwindow.h" +#endif + QT_BEGIN_NAMESPACE // Find out if our parent process is gdb by looking at the 'exe' symlink under /proc,. @@ -111,7 +121,7 @@ static bool runningUnderDebugger() #endif } -QXcbIntegration *QXcbIntegration::m_instance = Q_NULLPTR; +QXcbIntegration *QXcbIntegration::m_instance = nullptr; QXcbIntegration::QXcbIntegration(const QStringList ¶meters, int &argc, char **argv) : m_services(new QGenericUnixServices) @@ -166,8 +176,8 @@ QXcbIntegration::QXcbIntegration(const QStringList ¶meters, int &argc, char #if defined(QT_DEBUG) if (!noGrabArg && !doGrabArg && underDebugger) { - qDebug("Qt: gdb: -nograb added to command-line options.\n" - "\t Use the -dograb option to enforce grabbing."); + qCDebug(lcQpaXcb, "Qt: gdb: -nograb added to command-line options.\n" + "\t Use the -dograb option to enforce grabbing."); } #endif m_canGrab = (!underDebugger && !noGrabArg) || (underDebugger && doGrabArg); @@ -200,23 +210,48 @@ QXcbIntegration::QXcbIntegration(const QStringList ¶meters, int &argc, char } m_fontDatabase.reset(new QGenericUnixFontDatabase()); + +#if QT_CONFIG(xcb_native_painting) + if (nativePaintingEnabled()) { + qCDebug(lcQpaXcb, "QXCB USING NATIVE PAINTING"); + qt_xcb_native_x11_info_init(defaultConnection()); + } +#endif } QXcbIntegration::~QXcbIntegration() { qDeleteAll(m_connections); - m_instance = Q_NULLPTR; + m_instance = nullptr; +} + +QPlatformPixmap *QXcbIntegration::createPlatformPixmap(QPlatformPixmap::PixelType type) const +{ +#if QT_CONFIG(xcb_native_painting) + if (nativePaintingEnabled()) + return new QX11PlatformPixmap(type); +#endif + + return QPlatformIntegration::createPlatformPixmap(type); } QPlatformWindow *QXcbIntegration::createPlatformWindow(QWindow *window) const { QXcbScreen *screen = static_cast<QXcbScreen *>(window->screen()->handle()); QXcbGlIntegration *glIntegration = screen->connection()->glIntegration(); - if (window->type() != Qt::Desktop && window->supportsOpenGL()) { - if (glIntegration) { - QXcbWindow *xcbWindow = glIntegration->createWindow(window); + if (window->type() != Qt::Desktop) { + if (window->supportsOpenGL()) { + if (glIntegration) { + QXcbWindow *xcbWindow = glIntegration->createWindow(window); + xcbWindow->create(); + return xcbWindow; + } +#if QT_CONFIG(vulkan) + } else if (window->surfaceType() == QSurface::VulkanSurface) { + QXcbWindow *xcbWindow = new QXcbVulkanWindow(window); xcbWindow->create(); return xcbWindow; +#endif } } @@ -239,7 +274,7 @@ QPlatformOpenGLContext *QXcbIntegration::createPlatformOpenGLContext(QOpenGLCont QXcbGlIntegration *glIntegration = screen->connection()->glIntegration(); if (!glIntegration) { qWarning("QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled"); - return Q_NULLPTR; + return nullptr; } return glIntegration->createPlatformOpenGLContext(context); } @@ -247,6 +282,11 @@ QPlatformOpenGLContext *QXcbIntegration::createPlatformOpenGLContext(QOpenGLCont QPlatformBackingStore *QXcbIntegration::createPlatformBackingStore(QWindow *window) const { +#if QT_CONFIG(xcb_native_painting) + if (nativePaintingEnabled()) + return new QXcbNativeBackingStore(window); +#endif + return new QXcbBackingStore(window); } @@ -256,7 +296,7 @@ QPlatformOffscreenSurface *QXcbIntegration::createPlatformOffscreenSurface(QOffs QXcbGlIntegration *glIntegration = screen->connection()->glIntegration(); if (!glIntegration) { qWarning("QXcbIntegration: Cannot create platform offscreen surface, neither GLX nor EGL are enabled"); - return Q_NULLPTR; + return nullptr; } return glIntegration->createPlatformOffscreenSurface(surface); } @@ -498,4 +538,21 @@ void QXcbIntegration::beep() const xcb_bell(connection, 0); } +bool QXcbIntegration::nativePaintingEnabled() const +{ +#if QT_CONFIG(xcb_native_painting) + static bool enabled = qEnvironmentVariableIsSet("QT_XCB_NATIVE_PAINTING"); + return enabled; +#else + return false; +#endif +} + +#if QT_CONFIG(vulkan) +QPlatformVulkanInstance *QXcbIntegration::createPlatformVulkanInstance(QVulkanInstance *instance) const +{ + return new QXcbVulkanInstance(instance); +} +#endif + QT_END_NAMESPACE |