diff options
author | Samuel Rødal <samuel.rodal@digia.com> | 2012-11-05 15:55:49 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2012-11-08 22:47:42 +0100 |
commit | e24c8d1266fcf42292b48a7dc119dd5f3a217989 (patch) | |
tree | 374d65b34750473a0a6061207e86501b20f0cd32 /src/gui/kernel/qopenglcontext.cpp | |
parent | 5f915d0b91bbc3d8c8c31e99f4f6b9e7b341cd90 (diff) |
Return appropriate currentContext() in platform's makeCurrent().
This way the platform plugin can use convenience classes such as
QOpenGLFramebufferObject in the makeCurrent() implementation.
Change-Id: I1fb5f6b8ec094ff39454adbeca9eb0d1a8f43ee6
Reviewed-by: Paul Olav Tvete <paul.tvete@digia.com>
Diffstat (limited to 'src/gui/kernel/qopenglcontext.cpp')
-rw-r--r-- | src/gui/kernel/qopenglcontext.cpp | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/src/gui/kernel/qopenglcontext.cpp b/src/gui/kernel/qopenglcontext.cpp index e8aa44def7..d2de6aa125 100644 --- a/src/gui/kernel/qopenglcontext.cpp +++ b/src/gui/kernel/qopenglcontext.cpp @@ -62,6 +62,10 @@ QT_BEGIN_NAMESPACE class QGuiGLThreadContext { public: + QGuiGLThreadContext() + : context(0) + { + } ~QGuiGLThreadContext() { if (context) context->doneCurrent(); @@ -151,18 +155,25 @@ QMutex QOpenGLContextPrivate::makeCurrentTrackerMutex; \sa QOpenGLFunctions, QOpenGLBuffer, QOpenGLShaderProgram, QOpenGLFramebufferObject */ -void QOpenGLContextPrivate::setCurrentContext(QOpenGLContext *context) +/*! + \internal + + Set the current context. Returns the previously current context. +*/ +QOpenGLContext *QOpenGLContextPrivate::setCurrentContext(QOpenGLContext *context) { QGuiGLThreadContext *threadContext = qwindow_context_storage.localData(); if (!threadContext) { if (!QThread::currentThread()) { qWarning("No QTLS available. currentContext wont work"); - return; + return 0; } threadContext = new QGuiGLThreadContext; qwindow_context_storage.setLocalData(threadContext); } + QOpenGLContext *previous = threadContext->context; threadContext->context = context; + return previous; } int QOpenGLContextPrivate::maxTextureSize() @@ -505,9 +516,9 @@ bool QOpenGLContext::makeCurrent(QSurface *surface) return false; } + QOpenGLContext *previous = QOpenGLContextPrivate::setCurrentContext(this); if (d->platformGLContext->makeCurrent(surface->surfaceHandle())) { - QOpenGLContextPrivate::setCurrentContext(this); d->surface = surface; d->shareGroup->d_func()->deletePendingResources(this); @@ -519,6 +530,8 @@ bool QOpenGLContext::makeCurrent(QSurface *surface) return true; } + QOpenGLContextPrivate::setCurrentContext(previous); + return false; } |