From 6bad49308a9d943200fd48a8c9f732de20250bed Mon Sep 17 00:00:00 2001 From: Michal Klocek Date: Fri, 8 Feb 2019 14:00:42 +0100 Subject: Fix handling of glxconfig and glxcontext in offscreen plugin Return glxconfig and glxcontext, it is needed by share context in chromium. Task-number: QTBUG-63346 Change-Id: Ief15bf7170af9cf61a71453043a2629a4bcbcdc2 Reviewed-by: Laszlo Agocs --- .../offscreen/qoffscreenintegration_x11.cpp | 38 +++++++++++++++++----- 1 file changed, 29 insertions(+), 9 deletions(-) (limited to 'src/plugins/platforms/offscreen/qoffscreenintegration_x11.cpp') diff --git a/src/plugins/platforms/offscreen/qoffscreenintegration_x11.cpp b/src/plugins/platforms/offscreen/qoffscreenintegration_x11.cpp index 2e9f1eec2c..2532cedc70 100644 --- a/src/plugins/platforms/offscreen/qoffscreenintegration_x11.cpp +++ b/src/plugins/platforms/offscreen/qoffscreenintegration_x11.cpp @@ -122,11 +122,16 @@ void *QOffscreenX11Integration::nativeResourceForScreen(const QByteArray &resour #ifndef QT_NO_OPENGL void *QOffscreenX11Integration::nativeResourceForContext(const QByteArray &resource, QOpenGLContext *context) { if (resource.toLower() == QByteArrayLiteral("glxconfig") ) { - if (!m_connection) - m_connection.reset(new QOffscreenX11Connection); - QOffscreenX11Info *x11 = m_connection->x11Info(); - GLXFBConfig config = qglx_findConfig(x11->display(), x11->screenNumber(), context->format()); - return config; + if (context) { + QOffscreenX11GLXContext *glxPlatformContext = static_cast(context->handle()); + return glxPlatformContext->glxConfig(); + } + } + if (resource.toLower() == QByteArrayLiteral("glxcontext") ) { + if (context) { + QOffscreenX11GLXContext *glxPlatformContext = static_cast(context->handle()); + return glxPlatformContext->glxContext(); + } } return nullptr; } @@ -158,11 +163,12 @@ QOffscreenX11Info *QOffscreenX11Connection::x11Info() class QOffscreenX11GLXContextData { public: - QOffscreenX11Info *x11; + QOffscreenX11Info *x11 = nullptr; QSurfaceFormat format; - GLXContext context; - GLXContext shareContext; - Window window; + GLXContext context = nullptr; + GLXContext shareContext = nullptr; + GLXFBConfig config = nullptr; + Window window = 0; }; static Window createDummyWindow(QOffscreenX11Info *x11, XVisualInfo *visualInfo) @@ -173,6 +179,7 @@ static Window createDummyWindow(QOffscreenX11Info *x11, XVisualInfo *visualInfo) a.border_pixel = BlackPixel(x11->display(), x11->screenNumber()); a.colormap = cmap; + Window window = XCreateWindow(x11->display(), x11->root(), 0, 0, 100, 100, 0, visualInfo->depth, InputOutput, visualInfo->visual, @@ -194,6 +201,7 @@ static Window createDummyWindow(QOffscreenX11Info *x11, GLXFBConfig config) QOffscreenX11GLXContext::QOffscreenX11GLXContext(QOffscreenX11Info *x11, QOpenGLContext *context) : d(new QOffscreenX11GLXContextData) { + d->x11 = x11; d->format = context->format(); @@ -208,6 +216,8 @@ QOffscreenX11GLXContext::QOffscreenX11GLXContext(QOffscreenX11Info *x11, QOpenGL d->shareContext = static_cast(context->shareHandle())->d->context; GLXFBConfig config = qglx_findConfig(x11->display(), x11->screenNumber(), d->format); + d->config = config; + if (config) { d->context = glXCreateNewContext(x11->display(), config, GLX_RGBA_TYPE, d->shareContext, true); if (!d->context && d->shareContext) { @@ -291,4 +301,14 @@ bool QOffscreenX11GLXContext::isValid() const return d->context && d->window; } +void *QOffscreenX11GLXContext::glxContext() const +{ + return d->context; +} + +void *QOffscreenX11GLXContext::glxConfig() const +{ + return d->config; +} + QT_END_NAMESPACE -- cgit v1.2.3