summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorSamuel Rødal <samuel.rodal@nokia.com>2011-12-06 12:55:41 +0100
committerQt by Nokia <qt-info@nokia.com>2011-12-07 11:15:28 +0100
commitbab5329437e6e80da7e9f30d6422ac53f4f33f6d (patch)
tree4003aab018d087c5c7862ba1c6f6e831bf0b4435 /src/gui
parent77fb1c71bf9bb576cfb3d7f5bf887325841ebd75 (diff)
Better handling of GLX / EGL errors.
If context creation fails, try again without a shared context. Added QPlatformOpenGLContext::isSharing() and QPlatformOpenGLContext::isValid() to propagate whether the platform context was successfully created with or without sharing. Change-Id: I37080b645f531fd207946441057be6d3f6be3f6e Reviewed-by: Jørgen Lind <jorgen.lind@nokia.com>
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/kernel/qopenglcontext.cpp10
-rw-r--r--src/gui/kernel/qplatformopenglcontext_qpa.h3
2 files changed, 9 insertions, 4 deletions
diff --git a/src/gui/kernel/qopenglcontext.cpp b/src/gui/kernel/qopenglcontext.cpp
index 3549f647b5..6a9cb43028 100644
--- a/src/gui/kernel/qopenglcontext.cpp
+++ b/src/gui/kernel/qopenglcontext.cpp
@@ -164,6 +164,8 @@ bool QOpenGLContext::create()
Q_D(QOpenGLContext);
d->platformGLContext = QGuiApplicationPrivate::platformIntegration()->createPlatformOpenGLContext(this);
d->platformGLContext->setContext(this);
+ if (!d->platformGLContext->isSharing())
+ d->shareContext = 0;
d->shareGroup = d->shareContext ? d->shareContext->shareGroup() : new QOpenGLContextGroup;
d->shareGroup->d_func()->addContext(this);
return d->platformGLContext;
@@ -197,7 +199,7 @@ QOpenGLContext::~QOpenGLContext()
bool QOpenGLContext::isValid() const
{
Q_D(const QOpenGLContext);
- return d->platformGLContext != 0;
+ return d->platformGLContext && d->platformGLContext->isValid();
}
/*!
@@ -225,7 +227,7 @@ QOpenGLFunctions *QOpenGLContext::functions() const
bool QOpenGLContext::makeCurrent(QSurface *surface)
{
Q_D(QOpenGLContext);
- if (!d->platformGLContext)
+ if (!isValid())
return false;
if (thread() != QThread::currentThread())
@@ -257,7 +259,7 @@ bool QOpenGLContext::makeCurrent(QSurface *surface)
void QOpenGLContext::doneCurrent()
{
Q_D(QOpenGLContext);
- if (!d->platformGLContext)
+ if (!isValid())
return;
if (QOpenGLContext::currentContext() == this)
@@ -282,7 +284,7 @@ QSurface *QOpenGLContext::surface() const
void QOpenGLContext::swapBuffers(QSurface *surface)
{
Q_D(QOpenGLContext);
- if (!d->platformGLContext)
+ if (!isValid())
return;
if (!surface) {
diff --git a/src/gui/kernel/qplatformopenglcontext_qpa.h b/src/gui/kernel/qplatformopenglcontext_qpa.h
index fc1b404b91..1b3bfc9a34 100644
--- a/src/gui/kernel/qplatformopenglcontext_qpa.h
+++ b/src/gui/kernel/qplatformopenglcontext_qpa.h
@@ -68,6 +68,9 @@ public:
virtual bool makeCurrent(QPlatformSurface *surface) = 0;
virtual void doneCurrent() = 0;
+ virtual bool isSharing() const { return false; }
+ virtual bool isValid() const { return true; }
+
virtual QFunctionPointer getProcAddress(const QByteArray &procName) = 0;
QOpenGLContext *context() const;