diff options
author | Laszlo Agocs <laszlo.p.agocs@nokia.com> | 2011-10-06 05:26:48 (GMT) |
---|---|---|
committer | Laszlo Agocs <laszlo.p.agocs@nokia.com> | 2011-10-06 05:30:50 (GMT) |
commit | dde0a87329a9e48f82c16c383a42ce42c5422351 (patch) | |
tree | 87024f784f8096b94489521abc4b692cd1b70a8f /src | |
parent | 0ca343973a8417da2bb5bea1e5c3d8ac525f2815 (diff) | |
download | Qt-dde0a87329a9e48f82c16c383a42ce42c5422351.zip Qt-dde0a87329a9e48f82c16c383a42ce42c5422351.tar.gz Qt-dde0a87329a9e48f82c16c383a42ce42c5422351.tar.bz2 |
Do not let QGLContext get out of sync when doing mixed VG-GL rendering
The default graphics system is openvg, this means that apps using
QGLWidget (despite the official recommendation), without explicitly
setting opengl as the graphics system will use both the openvg and
opengl modules to perform rendering. This presents some problems
because QtOpenGL's comes with its own wrapper over QEglContext,
and making a foreign QEglContext (e.g. from VG) current will cause
its state to get out of sync, resulting in various drawing issues
due to skipped makeCurrent and similar calls.
The patch works this around by querying the current context from
EGL in QGLContext::currentContext() and returning null if the
EGLContext does not match. This somewhat ugly workaround ensures
that at least QGLContext::currentContext() will not lie: It will
not return a valid pointer when the underlying QEglContext's
underlying EGLContext is not actually the current context. This
will allow e.g. QGLPaintDevice::beginPaint to correctly recognize
the need for making the GL widget's context current and thus
avoid various rendering issues in certain games.
Task-number: QTTH-1553
Reviewed-by: Jani Hautakangas
Diffstat (limited to 'src')
-rw-r--r-- | src/opengl/qgl.cpp | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 161e099..ca16cca 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -95,9 +95,9 @@ #ifdef Q_OS_SYMBIAN #include <private/qgltexturepool_p.h> +#include <private/qeglcontext_p.h> #endif - QT_BEGIN_NAMESPACE #if defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN) @@ -3426,8 +3426,25 @@ void QGLContext::setInitialized(bool on) const QGLContext* QGLContext::currentContext() { QGLThreadContext *threadContext = qgl_context_storage.localData(); - if (threadContext) + if (threadContext) { +#ifdef Q_OS_SYMBIAN + // Query the current context and return null if it is different. + // This is needed to support mixed VG-GL rendering. + // QtOpenVG is free to make a QEglContext current at any time and + // QGLContext gets no notification that its underlying QEglContext is + // not current anymore. We query directly from EGL to be thread-safe. + // QEglContext does not store all the contexts per-thread. + if (threadContext->context) { + QEglContext *eglcontext = threadContext->context->d_func()->eglContext; + if (eglcontext) { + EGLContext ctx = eglcontext->context(); + if (ctx != eglGetCurrentContext()) + return 0; + } + } +#endif return threadContext->context; + } return 0; } |