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>
This commit is contained in:
parent
5f915d0b91
commit
e24c8d1266
@ -62,6 +62,10 @@ QT_BEGIN_NAMESPACE
|
|||||||
class QGuiGLThreadContext
|
class QGuiGLThreadContext
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
QGuiGLThreadContext()
|
||||||
|
: context(0)
|
||||||
|
{
|
||||||
|
}
|
||||||
~QGuiGLThreadContext() {
|
~QGuiGLThreadContext() {
|
||||||
if (context)
|
if (context)
|
||||||
context->doneCurrent();
|
context->doneCurrent();
|
||||||
@ -151,18 +155,25 @@ QMutex QOpenGLContextPrivate::makeCurrentTrackerMutex;
|
|||||||
\sa QOpenGLFunctions, QOpenGLBuffer, QOpenGLShaderProgram, QOpenGLFramebufferObject
|
\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();
|
QGuiGLThreadContext *threadContext = qwindow_context_storage.localData();
|
||||||
if (!threadContext) {
|
if (!threadContext) {
|
||||||
if (!QThread::currentThread()) {
|
if (!QThread::currentThread()) {
|
||||||
qWarning("No QTLS available. currentContext wont work");
|
qWarning("No QTLS available. currentContext wont work");
|
||||||
return;
|
return 0;
|
||||||
}
|
}
|
||||||
threadContext = new QGuiGLThreadContext;
|
threadContext = new QGuiGLThreadContext;
|
||||||
qwindow_context_storage.setLocalData(threadContext);
|
qwindow_context_storage.setLocalData(threadContext);
|
||||||
}
|
}
|
||||||
|
QOpenGLContext *previous = threadContext->context;
|
||||||
threadContext->context = context;
|
threadContext->context = context;
|
||||||
|
return previous;
|
||||||
}
|
}
|
||||||
|
|
||||||
int QOpenGLContextPrivate::maxTextureSize()
|
int QOpenGLContextPrivate::maxTextureSize()
|
||||||
@ -505,9 +516,9 @@ bool QOpenGLContext::makeCurrent(QSurface *surface)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QOpenGLContext *previous = QOpenGLContextPrivate::setCurrentContext(this);
|
||||||
|
|
||||||
if (d->platformGLContext->makeCurrent(surface->surfaceHandle())) {
|
if (d->platformGLContext->makeCurrent(surface->surfaceHandle())) {
|
||||||
QOpenGLContextPrivate::setCurrentContext(this);
|
|
||||||
d->surface = surface;
|
d->surface = surface;
|
||||||
|
|
||||||
d->shareGroup->d_func()->deletePendingResources(this);
|
d->shareGroup->d_func()->deletePendingResources(this);
|
||||||
@ -519,6 +530,8 @@ bool QOpenGLContext::makeCurrent(QSurface *surface)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QOpenGLContextPrivate::setCurrentContext(previous);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -224,7 +224,7 @@ public:
|
|||||||
|
|
||||||
QPaintEngineEx *active_engine;
|
QPaintEngineEx *active_engine;
|
||||||
|
|
||||||
static void setCurrentContext(QOpenGLContext *context);
|
static QOpenGLContext *setCurrentContext(QOpenGLContext *context);
|
||||||
|
|
||||||
int maxTextureSize();
|
int maxTextureSize();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user