summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@theqtcompany.com>2016-01-27 11:53:25 +0100
committerLaszlo Agocs <laszlo.agocs@theqtcompany.com>2016-01-29 15:51:08 +0000
commit09e8d69b7a5c6f394b6a43f6c485d26f74189541 (patch)
tree9f948f25f08bd2044cfb0dd00b9e029090159568 /src
parent6774edcef0f9f34d41d1156f6c9748f6d9a18930 (diff)
eglfs: Sanitize the widget compositor's context handling
createPlatformOpenGLContext() used to silently set the widget compositor's context as the context to share resources with. This works mostly, but is the wrong level to enforce the resource sharing. For example, QOpenGLContext::shareGroup() becomes inconsistent since from QOpenGLContext's view there was no shareContext specified. The inability to test via shareGroup() is the reason eglfs started to show warnings when exiting applications. The resource sharing was in place on EGL level but QOpenGLContext knew nothing about it. Therefore, let's switch over to the way other components, f.ex. Web Engine use: set the internal global share context pointer to the widget compositor's context. This way everything remains consistent: the widget compositor's context is stored upon creating the main QEGLFSWindow, QWidget::shareContext() picks this up then, and as a result we have sharing set up on QOpenGLContext's level instead of sneaking it in in the QPlatformOpenGLContext implementation. Task-number: QTBUG-50707 Change-Id: I5fc1dec58c69c46aa83c7b4cab1eadce6fa633ce Reviewed-by: Paul Olav Tvete <paul.tvete@theqtcompany.com>
Diffstat (limited to 'src')
-rw-r--r--src/platformsupport/platformcompositor/qopenglcompositor.cpp2
-rw-r--r--src/platformsupport/platformcompositor/qopenglcompositorbackingstore.cpp8
-rw-r--r--src/plugins/platforms/eglfs/qeglfsintegration.cpp5
-rw-r--r--src/plugins/platforms/eglfs/qeglfswindow.cpp8
4 files changed, 18 insertions, 5 deletions
diff --git a/src/platformsupport/platformcompositor/qopenglcompositor.cpp b/src/platformsupport/platformcompositor/qopenglcompositor.cpp
index 2e386532e2..7e0973040a 100644
--- a/src/platformsupport/platformcompositor/qopenglcompositor.cpp
+++ b/src/platformsupport/platformcompositor/qopenglcompositor.cpp
@@ -57,7 +57,7 @@ QT_BEGIN_NAMESPACE
It is up to the platform plugin to manage the lifetime of the
compositor (instance(), destroy()), set the correct destination
- context and window as early as possible (setTargetWindow()),
+ context and window as early as possible (setTarget()),
register the composited windows as they are shown, activated,
raised and lowered (addWindow(), moveToTop(), etc.), and to
schedule repaints (update()).
diff --git a/src/platformsupport/platformcompositor/qopenglcompositorbackingstore.cpp b/src/platformsupport/platformcompositor/qopenglcompositorbackingstore.cpp
index 07a1e77c3a..83b551557f 100644
--- a/src/platformsupport/platformcompositor/qopenglcompositorbackingstore.cpp
+++ b/src/platformsupport/platformcompositor/qopenglcompositorbackingstore.cpp
@@ -184,6 +184,8 @@ void QOpenGLCompositorBackingStore::flush(QWindow *window, const QRegion &region
QOpenGLCompositor *compositor = QOpenGLCompositor::instance();
QOpenGLContext *dstCtx = compositor->context();
+ Q_ASSERT(dstCtx);
+
QWindow *dstWin = compositor->targetWindow();
if (!dstWin)
return;
@@ -209,6 +211,12 @@ void QOpenGLCompositorBackingStore::composeAndFlush(QWindow *window, const QRegi
QOpenGLCompositor *compositor = QOpenGLCompositor::instance();
QOpenGLContext *dstCtx = compositor->context();
+ Q_ASSERT(dstCtx); // setTarget() must have been called before, e.g. from QEGLFSWindow
+
+ // The compositor's context and the context to which QOpenGLWidget/QQuickWidget
+ // textures belong are not the same. They share resources, though.
+ Q_ASSERT(context->shareGroup() == dstCtx->shareGroup());
+
QWindow *dstWin = compositor->targetWindow();
if (!dstWin)
return;
diff --git a/src/plugins/platforms/eglfs/qeglfsintegration.cpp b/src/plugins/platforms/eglfs/qeglfsintegration.cpp
index 2086ce56e2..35b27cba0b 100644
--- a/src/plugins/platforms/eglfs/qeglfsintegration.cpp
+++ b/src/plugins/platforms/eglfs/qeglfsintegration.cpp
@@ -188,11 +188,8 @@ QPlatformWindow *QEglFSIntegration::createPlatformWindow(QWindow *window) const
QPlatformOpenGLContext *QEglFSIntegration::createPlatformOpenGLContext(QOpenGLContext *context) const
{
- // If there is a "root" window into which raster and QOpenGLWidget content is
- // composited, all other contexts must share with its context.
- QOpenGLContext *compositingContext = QOpenGLCompositor::instance()->context();
EGLDisplay dpy = context->screen() ? static_cast<QEglFSScreen *>(context->screen()->handle())->display() : display();
- QPlatformOpenGLContext *share = compositingContext ? compositingContext->handle() : context->shareHandle();
+ QPlatformOpenGLContext *share = context->shareHandle();
QVariant nativeHandle = context->nativeHandle();
QEglFSContext *ctx;
diff --git a/src/plugins/platforms/eglfs/qeglfswindow.cpp b/src/plugins/platforms/eglfs/qeglfswindow.cpp
index 8301be8c17..84856831c3 100644
--- a/src/plugins/platforms/eglfs/qeglfswindow.cpp
+++ b/src/plugins/platforms/eglfs/qeglfswindow.cpp
@@ -138,6 +138,14 @@ void QEglFSWindow::create()
if (!context->create())
qFatal("EGLFS: Failed to create compositing context");
compositor->setTarget(context, window());
+ // If there is a "root" window into which raster and QOpenGLWidget content is
+ // composited, all other contexts must share with its context.
+ if (!qt_gl_global_share_context()) {
+ qt_gl_set_global_share_context(context);
+ // What we set up here is in effect equivalent to the application setting
+ // AA_ShareOpenGLContexts. Set the attribute to be fully consistent.
+ QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts);
+ }
}
}