diff options
author | Jørgen Lind <jorgen.lind@nokia.com> | 2010-11-18 12:03:59 (GMT) |
---|---|---|
committer | Jørgen Lind <jorgen.lind@nokia.com> | 2010-11-22 13:14:08 (GMT) |
commit | 292f6a9ba1b5da049e4898525974c6f0575ccd65 (patch) | |
tree | b44bdf07f56298d7206a180a41690c2de3371fc6 /src/opengl/qgl.cpp | |
parent | a1acef227647b3043998f9ccf364ead5c29b882d (diff) | |
download | Qt-292f6a9ba1b5da049e4898525974c6f0575ccd65.zip Qt-292f6a9ba1b5da049e4898525974c6f0575ccd65.tar.gz Qt-292f6a9ba1b5da049e4898525974c6f0575ccd65.tar.bz2 |
Lighthouse: move the currentContext functionality to QPlatformGLContext
This means the threading functionality has been delegated down to
QPlatformGLContext. However, it is still possible to use
QGLContext::currentContext to retrieve the QGLContext. This so that
QGLFunctions, QGLShaderProgram etc can be used without a QGLWidget.
Reviewed-by: paul
Diffstat (limited to 'src/opengl/qgl.cpp')
-rw-r--r-- | src/opengl/qgl.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index cf45239..65d3bbe 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -79,6 +79,10 @@ #include <private/qglwindowsurface_qws_p.h> #endif +#ifdef Q_WS_QPA +#include <QtGui/QPlatformGLContext> +#endif + #include <qglpixelbuffer.h> #include <qglframebufferobject.h> @@ -117,7 +121,9 @@ struct QGLThreadContext { QGLContext *context; }; +#ifndef Q_WS_QPA static QThreadStorage<QGLThreadContext *> qgl_context_storage; +#endif Q_GLOBAL_STATIC(QGLFormat, qgl_default_format) @@ -3381,14 +3387,31 @@ void QGLContext::setInitialized(bool on) const QGLContext* QGLContext::currentContext() { +#ifdef Q_WS_QPA + if (const QPlatformGLContext *threadContext = QPlatformGLContext::currentContext()) { + if (threadContext->qGLContextHandle()) { + return (const QGLContext *)threadContext->qGLContextHandle(); + } else { + QWidget *widget = threadContext->platformWindow()->widget(); + QGLContext *context = new QGLContext(QGLFormat::fromPlatformWindowFormat(threadContext->platformWindowFormat()),widget); + context->create(); //don't know how to pass in the sharecontext. (doesn't really matter though) + return context; + } + } + return 0; +#else QGLThreadContext *threadContext = qgl_context_storage.localData(); if (threadContext) return threadContext->context; return 0; +#endif //Q_WS_QPA } void QGLContextPrivate::setCurrentContext(QGLContext *context) { +#ifdef Q_WS_QPA + Q_UNUSED(context); +#else QGLThreadContext *threadContext = qgl_context_storage.localData(); if (!threadContext) { if (!QThread::currentThread()) { @@ -3401,6 +3424,7 @@ void QGLContextPrivate::setCurrentContext(QGLContext *context) } threadContext->context = context; QGLContext::currentCtx = context; // XXX: backwards-compat, not thread-safe +#endif } /*! |