diff options
author | Jørgen Lind <jorgen.lind@nokia.com> | 2010-11-23 15:34:09 +0100 |
---|---|---|
committer | Jørgen Lind <jorgen.lind@nokia.com> | 2010-11-24 09:54:48 +0100 |
commit | 004cd14b84e3683cd92cf01061ee9688990f990c (patch) | |
tree | 8f879f07439b212de831c528e832d3c3ab4c6bb3 /src/opengl/qgl_qpa.cpp | |
parent | f309a20b4177572282082b8c17ec9025b75a69b1 (diff) |
Lighthouse: Fix QGLContext::currentContext for systems with limited
resources. The example plugins EGLFS uses only 1 native
context. Make sure that we only use this 1 context, and that we dont
wrap it in many different QPlatformGLContexts or QGLContexts instanses.
This change also removes the QPlatformWindow link which was made in the
initial QPlatformGLContext change. Lighthouse has to support situations
where a context isnt bound to a QPlatformWindow.
Reviewed-by: gunnar
Diffstat (limited to 'src/opengl/qgl_qpa.cpp')
-rw-r--r-- | src/opengl/qgl_qpa.cpp | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/opengl/qgl_qpa.cpp b/src/opengl/qgl_qpa.cpp index 28bea83f5b..e997704b31 100644 --- a/src/opengl/qgl_qpa.cpp +++ b/src/opengl/qgl_qpa.cpp @@ -129,7 +129,11 @@ void qDeleteQGLContext(void *handle) bool QGLContext::chooseContext(const QGLContext* shareContext) { Q_D(QGLContext); - if (!d->paintDevice || d->paintDevice->devType() != QInternal::Widget) { + if (d->platformContext && !d->platformContext->qGLContextHandle()) { + d->platformContext->setQGLContextHandle(this,qDeleteQGLContext); + d->glFormat = QGLFormat::fromPlatformWindowFormat(d->platformContext->platformWindowFormat()); + d->valid = true; + }else if(!d->paintDevice || d->paintDevice->devType() != QInternal::Widget) { d->valid = false; }else { QWidget *widget = static_cast<QWidget *>(d->paintDevice); @@ -215,10 +219,9 @@ void QGLWidget::setContext(QGLContext *context, qWarning("QGLWidget::setContext: Cannot set null context"); return; } - if (!context->deviceIsPixmap() && context->device() != this) { - qWarning("QGLWidget::setContext: Context must refer to this widget"); - return; - } + + if (context->device() == 0) // a context may refere to more than 1 window. + context->setDevice(this); //but its better to point to 1 of them than none of them. QGLContext* oldcx = d->glcx; d->glcx = context; @@ -312,11 +315,8 @@ bool QGLWidget::event(QEvent *e) { Q_D(QGLWidget); if (e->type() == QEvent::WinIdChange) { - if (d->glcx->isValid()) { - if (QGLContext::currentContext() == d->glcx) - QGLContextPrivate::setCurrentContext(0); //Its not valid anymore - setContext(new QGLContext(d->glcx->requestedFormat(), this)); - + if (platformWindow()) { + d->glcx = QGLContext::fromPlatformGLContext(platformWindow()->glContext()); } } return QWidget::event(e); |