From 09e8d69b7a5c6f394b6a43f6c485d26f74189541 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Wed, 27 Jan 2016 11:53:25 +0100 Subject: 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 --- .../platformcompositor/qopenglcompositorbackingstore.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/platformsupport/platformcompositor/qopenglcompositorbackingstore.cpp') 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 ®ion 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; -- cgit v1.2.3