diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/kernel/qplatformglcontext_qpa.cpp | 2 | ||||
-rw-r--r-- | src/gui/kernel/qplatformglcontext_qpa.h | 2 | ||||
-rw-r--r-- | src/opengl/qgl_p.h | 1 | ||||
-rw-r--r-- | src/opengl/qgl_qpa.cpp | 30 |
4 files changed, 17 insertions, 18 deletions
diff --git a/src/gui/kernel/qplatformglcontext_qpa.cpp b/src/gui/kernel/qplatformglcontext_qpa.cpp index 14bd718..1673aed 100644 --- a/src/gui/kernel/qplatformglcontext_qpa.cpp +++ b/src/gui/kernel/qplatformglcontext_qpa.cpp @@ -138,7 +138,7 @@ void QPlatformGLContext::setDefaultSharedContext(QPlatformGLContext *sharedConte Default shared context is intended to be a globally awailable pointer to a context which can be used for sharing resources when creating new contexts. Its default value is 0; */ -const QPlatformGLContext *QPlatformGLContext::defaultSharedContext() +QPlatformGLContext *QPlatformGLContext::defaultSharedContext() { return QPlatformGLContextPrivate::staticSharedContext; } diff --git a/src/gui/kernel/qplatformglcontext_qpa.h b/src/gui/kernel/qplatformglcontext_qpa.h index a70e046..807ed3d 100644 --- a/src/gui/kernel/qplatformglcontext_qpa.h +++ b/src/gui/kernel/qplatformglcontext_qpa.h @@ -69,7 +69,7 @@ public: virtual QPlatformWindowFormat platformWindowFormat() const = 0; const static QPlatformGLContext *currentContext(); - const static QPlatformGLContext *defaultSharedContext(); + static QPlatformGLContext *defaultSharedContext(); protected: diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h index ca8bc55..858a915 100644 --- a/src/opengl/qgl_p.h +++ b/src/opengl/qgl_p.h @@ -373,6 +373,7 @@ public: #if defined(Q_WS_QPA) QPlatformGLContext *platformContext; + void setupSharing(); #elif defined(Q_WS_X11) || defined(Q_WS_MAC) void* cx; #endif diff --git a/src/opengl/qgl_qpa.cpp b/src/opengl/qgl_qpa.cpp index 52eb57f..0f4b305 100644 --- a/src/opengl/qgl_qpa.cpp +++ b/src/opengl/qgl_qpa.cpp @@ -115,6 +115,16 @@ QPlatformWindowFormat QGLFormat::toPlatformWindowFormat(const QGLFormat &format) return retFormat; } +void QGLContextPrivate::setupSharing() { + Q_Q(QGLContext); + QPlatformGLContext *sharedPlatformGLContext = platformContext->platformWindowFormat().sharedGLContext(); + if (sharedPlatformGLContext) { + QGLContext *actualSharedContext = QGLContext::fromPlatformGLContext(sharedPlatformGLContext); + sharing = true; + QGLContextGroup::addShare(q,actualSharedContext); + } +} + bool QGLFormat::hasOpenGL() { return QApplicationPrivate::platformIntegration()->hasOpenGL(); @@ -151,19 +161,9 @@ bool QGLContext::chooseContext(const QGLContext* shareContext) if (d->valid) { d->platformContext->setQGLContextHandle(this,qDeleteQGLContext); } + d->setupSharing(); } - if (d->valid) { - QPlatformGLContext *sharedPlatformGLContext = d->platformContext->platformWindowFormat().sharedGLContext(); - if (sharedPlatformGLContext) { - QGLContext *actualSharedContext = QGLContext::fromPlatformGLContext(sharedPlatformGLContext); - if (actualSharedContext == shareContext) { - d->sharing = true;//Will add combination in QGLContext::create - }else { - QGLContextGroup::addShare(this,actualSharedContext); - } - } - } return d->valid; } @@ -372,6 +372,9 @@ QGLContext::QGLContext(QPlatformGLContext *platformContext) Q_D(QGLContext); d->init(0,QGLFormat::fromPlatformWindowFormat(platformContext->platformWindowFormat())); d->platformContext = platformContext; + d->platformContext->setQGLContextHandle(this,qDeleteQGLContext); + d->valid = true; + d->setupSharing(); } QGLContext *QGLContext::fromPlatformGLContext(QPlatformGLContext *platformContext) @@ -384,11 +387,6 @@ QGLContext *QGLContext::fromPlatformGLContext(QPlatformGLContext *platformContex QGLContext *glContext = new QGLContext(platformContext); //Dont call create on context. This can cause the platformFormat to be set on the widget, which //will cause the platformWindow to be recreated. - glContext->d_func()->platformContext->setQGLContextHandle(glContext,qDeleteQGLContext); - QGLFormat format = QGLFormat::fromPlatformWindowFormat(platformContext->platformWindowFormat()); - glContext->d_func()->glFormat = format; - glContext->d_func()->valid = true; - return glContext; } |