summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJørgen Lind <jorgen.lind@nokia.com>2011-01-20 07:44:27 (GMT)
committerJørgen Lind <jorgen.lind@nokia.com>2011-01-25 18:07:35 (GMT)
commit37207d16cb51616c0b506dcc57126ff06c9073a9 (patch)
treee6079db4b9f9e1ee014d14086be79b6967adf98a
parentfd28a6ab14fc3c54c443718d405eeb9f98c7dd27 (diff)
downloadQt-37207d16cb51616c0b506dcc57126ff06c9073a9.zip
Qt-37207d16cb51616c0b506dcc57126ff06c9073a9.tar.gz
Qt-37207d16cb51616c0b506dcc57126ff06c9073a9.tar.bz2
Make QGLContext::fromPlatformGLContext show correct sharing
information. Prior to this, if a context was created with QGLWidget it would setup the sharing correct, but all sharing actually created on a QPlatformGLContext level was ignored by the QGLContext, thus indicating that it wasnt sharing with any other context.
-rw-r--r--src/gui/kernel/qplatformglcontext_qpa.cpp2
-rw-r--r--src/gui/kernel/qplatformglcontext_qpa.h2
-rw-r--r--src/opengl/qgl_p.h1
-rw-r--r--src/opengl/qgl_qpa.cpp30
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;
}