From 82e4ee03918a8abef4479ae67f259bfae4e6b79c Mon Sep 17 00:00:00 2001 From: Jocelyn Turcotte Date: Fri, 28 Mar 2014 15:36:55 +0100 Subject: [PATCH] Use global context sharing from QtGui instead of QSGContext This removes QSGContext::sharedOpenGLContext and replace its uses with QOpenGLContextPrivate::globalShareContext, which is also going to be used by QOpenGLWidget and QQuickWidget. Change-Id: I1e296c3e6832f717caaf31ba7d7b27c06249219b Reviewed-by: Laszlo Agocs --- src/quick/items/qquickwindow.cpp | 2 +- src/quick/scenegraph/qsgcontext.cpp | 18 ------------------ src/quick/scenegraph/qsgcontext_p.h | 3 --- src/quick/scenegraph/qsgrenderloop.cpp | 4 ++-- src/quick/scenegraph/qsgthreadedrenderloop.cpp | 4 ++-- src/quick/scenegraph/qsgwindowsrenderloop.cpp | 4 ++-- src/quickwidgets/qquickwidget.cpp | 4 ++-- tools/qmlscene/main.cpp | 4 ++-- 8 files changed, 11 insertions(+), 32 deletions(-) diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp index 6e825a89d..4592be3af 100644 --- a/src/quick/items/qquickwindow.cpp +++ b/src/quick/items/qquickwindow.cpp @@ -2977,7 +2977,7 @@ QImage QQuickWindow::grabWindow() QOpenGLContext context; context.setFormat(requestedFormat()); - context.setShareContext(QSGContext::sharedOpenGLContext()); + context.setShareContext(QOpenGLContextPrivate::globalShareContext()); context.create(); context.makeCurrent(this); d->context->initialize(&context); diff --git a/src/quick/scenegraph/qsgcontext.cpp b/src/quick/scenegraph/qsgcontext.cpp index 835eeb1c3..2d2b643e3 100644 --- a/src/quick/scenegraph/qsgcontext.cpp +++ b/src/quick/scenegraph/qsgcontext.cpp @@ -113,12 +113,8 @@ public: bool distanceFieldDisabled; QSGDistanceFieldGlyphNode::AntialiasingMode distanceFieldAntialiasing; bool distanceFieldAntialiasingDecided; - - static QOpenGLContext *sharedOpenGLContext; }; -QOpenGLContext *QSGContextPrivate::sharedOpenGLContext = 0; - class QSGTextureCleanupEvent : public QEvent { public: @@ -177,20 +173,6 @@ QSGRenderContext *QSGContext::createRenderContext() return new QSGRenderContext(this); } -/*! - * This function is used by the Qt WebEngine to set up context sharing - * across multiple windows. Do not use it for any other purpose. - */ -void QSGContext::setSharedOpenGLContext(QOpenGLContext *context) -{ - QSGContextPrivate::sharedOpenGLContext = context; -} - -QOpenGLContext *QSGContext::sharedOpenGLContext() -{ - return QSGContextPrivate::sharedOpenGLContext; -} - void QSGContext::renderContextInitialized(QSGRenderContext *renderContext) { Q_D(QSGContext); diff --git a/src/quick/scenegraph/qsgcontext_p.h b/src/quick/scenegraph/qsgcontext_p.h index 2ab78ce28..ac372b971 100644 --- a/src/quick/scenegraph/qsgcontext_p.h +++ b/src/quick/scenegraph/qsgcontext_p.h @@ -168,9 +168,6 @@ public: virtual QSize minimumFBOSize() const; virtual QSurfaceFormat defaultSurfaceFormat() const; - static void setSharedOpenGLContext(QOpenGLContext *context); - static QOpenGLContext *sharedOpenGLContext(); - void setDistanceFieldEnabled(bool enabled); bool isDistanceFieldEnabled() const; diff --git a/src/quick/scenegraph/qsgrenderloop.cpp b/src/quick/scenegraph/qsgrenderloop.cpp index 2ef84980a..808bf07cf 100644 --- a/src/quick/scenegraph/qsgrenderloop.cpp +++ b/src/quick/scenegraph/qsgrenderloop.cpp @@ -329,8 +329,8 @@ void QSGGuiThreadRenderLoop::renderWindow(QQuickWindow *window) if (!gl) { gl = new QOpenGLContext(); gl->setFormat(window->requestedFormat()); - if (QSGContext::sharedOpenGLContext()) - gl->setShareContext(QSGContext::sharedOpenGLContext()); + if (QOpenGLContextPrivate::globalShareContext()) + gl->setShareContext(QOpenGLContextPrivate::globalShareContext()); if (!gl->create()) { const bool isEs = gl->isES(); delete gl; diff --git a/src/quick/scenegraph/qsgthreadedrenderloop.cpp b/src/quick/scenegraph/qsgthreadedrenderloop.cpp index 9edca87d7..3ded6b8ca 100644 --- a/src/quick/scenegraph/qsgthreadedrenderloop.cpp +++ b/src/quick/scenegraph/qsgthreadedrenderloop.cpp @@ -950,8 +950,8 @@ void QSGThreadedRenderLoop::handleExposure(Window *w) if (!w->thread->gl) { w->thread->gl = new QOpenGLContext(); - if (QSGContext::sharedOpenGLContext()) - w->thread->gl->setShareContext(QSGContext::sharedOpenGLContext()); + if (QOpenGLContextPrivate::globalShareContext()) + w->thread->gl->setShareContext(QOpenGLContextPrivate::globalShareContext()); w->thread->gl->setFormat(w->window->requestedFormat()); if (!w->thread->gl->create()) { const bool isEs = w->thread->gl->isES(); diff --git a/src/quick/scenegraph/qsgwindowsrenderloop.cpp b/src/quick/scenegraph/qsgwindowsrenderloop.cpp index 9605eb8ac..531f7c755 100644 --- a/src/quick/scenegraph/qsgwindowsrenderloop.cpp +++ b/src/quick/scenegraph/qsgwindowsrenderloop.cpp @@ -179,8 +179,8 @@ void QSGWindowsRenderLoop::show(QQuickWindow *window) RLDEBUG(" - creating GL context"); m_gl = new QOpenGLContext(); m_gl->setFormat(window->requestedFormat()); - if (QSGContext::sharedOpenGLContext()) - m_gl->setShareContext(QSGContext::sharedOpenGLContext()); + if (QOpenGLContextPrivate::globalShareContext()) + m_gl->setShareContext(QOpenGLContextPrivate::globalShareContext()); bool created = m_gl->create(); if (!created) { const bool isEs = m_gl->isES(); diff --git a/src/quickwidgets/qquickwidget.cpp b/src/quickwidgets/qquickwidget.cpp index ddb212454..e71da7e7e 100644 --- a/src/quickwidgets/qquickwidget.cpp +++ b/src/quickwidgets/qquickwidget.cpp @@ -586,8 +586,8 @@ void QQuickWidgetPrivate::createContext() context = new QOpenGLContext; context->setFormat(offscreenWindow->requestedFormat()); - if (QSGContext::sharedOpenGLContext()) - context->setShareContext(QSGContext::sharedOpenGLContext()); // ??? is this correct + if (QOpenGLContextPrivate::globalShareContext()) + context->setShareContext(QOpenGLContextPrivate::globalShareContext()); if (!context->create()) { const bool isEs = context->isES(); delete context; diff --git a/tools/qmlscene/main.cpp b/tools/qmlscene/main.cpp index f128e399b..7512b5482 100644 --- a/tools/qmlscene/main.cpp +++ b/tools/qmlscene/main.cpp @@ -58,7 +58,7 @@ #include #include -#include +#include #ifdef QT_WIDGETS_LIB #include @@ -460,7 +460,7 @@ int main(int argc, char ** argv) if (options.contextSharing) { shareContext.reset(new QOpenGLContext); shareContext->create(); - QSGContext::setSharedOpenGLContext(shareContext.data()); + QOpenGLContextPrivate::setGlobalShareContext(shareContext.data()); } int exitCode = 0; -- 2.34.1