Use global context sharing from QtGui instead of QSGContext
authorJocelyn Turcotte <jocelyn.turcotte@digia.com>
Fri, 28 Mar 2014 14:36:55 +0000 (15:36 +0100)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Fri, 4 Apr 2014 11:49:51 +0000 (13:49 +0200)
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 <laszlo.agocs@digia.com>
src/quick/items/qquickwindow.cpp
src/quick/scenegraph/qsgcontext.cpp
src/quick/scenegraph/qsgcontext_p.h
src/quick/scenegraph/qsgrenderloop.cpp
src/quick/scenegraph/qsgthreadedrenderloop.cpp
src/quick/scenegraph/qsgwindowsrenderloop.cpp
src/quickwidgets/qquickwidget.cpp
tools/qmlscene/main.cpp

index 6e825a89db4bbc368957b97a4508846f7f03e160..4592be3af8ce69e387b70d9d36b44ed2e34aa535 100644 (file)
@@ -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);
index 835eeb1c36c111de80abe3ac68f7c0a03ccf48eb..2d2b643e3700fbef7f100a7093c83a39c992b3aa 100644 (file)
@@ -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);
index 2ab78ce2893eeb14a5070ece4d3fcc410c60d88e..ac372b97180236f5bfcb6591e89bf0f3ece7ca68 100644 (file)
@@ -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;
 
index 2ef84980a3aca5b70cd251a04676182327a7f78b..808bf07cfc792dbf7b5fff41b7706da775571fe8 100644 (file)
@@ -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;
index 9edca87d7032a2bbb064d341a06db44596dc5be3..3ded6b8ca2d044d1401c2d07be46afca175e51d7 100644 (file)
@@ -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();
index 9605eb8accfd8d4bed09744ffed4da8746c3e32b..531f7c7551d76210a89c537106845cc6d0e5e950 100644 (file)
@@ -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();
index ddb2124542382c48ce35db3bafddf783d04b310a..e71da7e7ec0b0be731254f36207e2bb46e35f801 100644 (file)
@@ -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;
index f128e399b581d099b1c2a0efdf0f4d719c5ffbd0..7512b5482f513bfeffe1ac029319e0e3099f0077 100644 (file)
@@ -58,7 +58,7 @@
 #include <QtQuick/qquickview.h>
 
 #include <private/qabstractanimation_p.h>
-#include <private/qsgcontext_p.h>
+#include <private/qopenglcontext_p.h>
 
 #ifdef QT_WIDGETS_LIB
 #include <QtWidgets/QApplication>
@@ -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;