diff options
author | Laszlo Agocs <laszlo.agocs@digia.com> | 2014-06-05 15:16:33 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-06-05 15:54:58 +0200 |
commit | 13be09c97fe235ac8f453cbee9c1f794b6815db5 (patch) | |
tree | 5eb7a244c55c22cf73867ba3df2a2a1cfa922d0c /src/quickwidgets/qquickwidget.cpp | |
parent | bcabc0ad3d25e78cd158a59fef4e894b3ec58b72 (diff) |
Fix QQuickWidget offscreen surface format and creation order
Create the QOffscreenSurface together with, and after, the QOpenGLContext.
This is essential to get a surface that is compatible with the context and
is in line with the QOffscreenSurface usage recommendation from the docs.
Otherwise, if the offscreen surface gets created first, without
knowing what _actual_ format (e.g. EGL configuration) the context
will use, the result is an incompatible surface and context on
systems that offer a different set of configurations for window and
pbuffer surfaces.
This fixes QQuickWidget on EGL implementations that offer both 16 and 24
bit pbuffer configs, but only 24 (or 32) bit window configs.
Task-number: QTBUG-39474
Change-Id: I43925d2b25e28d26d172ce9d22651c25b281b832
Reviewed-by: Paul Olav Tvete <paul.tvete@digia.com>
Diffstat (limited to 'src/quickwidgets/qquickwidget.cpp')
-rw-r--r-- | src/quickwidgets/qquickwidget.cpp | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/src/quickwidgets/qquickwidget.cpp b/src/quickwidgets/qquickwidget.cpp index 3993629672..30c35c55dd 100644 --- a/src/quickwidgets/qquickwidget.cpp +++ b/src/quickwidgets/qquickwidget.cpp @@ -89,7 +89,6 @@ void QQuickWidgetPrivate::init(QQmlEngine* e) offscreenWindow = renderControl->createOffscreenWindow(); offscreenWindow->setTitle(QString::fromLatin1("Offscreen")); // Do not call create() on offscreenWindow. - createOffscreenSurface(); if (QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::RasterGLSurface)) setRenderToTexture(); @@ -166,19 +165,9 @@ QQuickWidgetPrivate::~QQuickWidgetPrivate() delete renderControl; delete fbo; - delete offscreenSurface; destroyContext(); } -void QQuickWidgetPrivate::createOffscreenSurface() -{ - delete offscreenSurface; - offscreenSurface = 0; - offscreenSurface = new QOffscreenSurface; - offscreenSurface->setFormat(offscreenWindow->requestedFormat()); - offscreenSurface->create(); -} - void QQuickWidgetPrivate::execute() { Q_Q(QQuickWidget); @@ -641,6 +630,13 @@ void QQuickWidgetPrivate::createContext() return; } + offscreenSurface = new QOffscreenSurface; + // Pass the context's format(), which, now that the underlying platform context is created, + // contains a QSurfaceFormat representing the _actual_ format of the underlying + // configuration. This is essential to get a surface that is compatible with the context. + offscreenSurface->setFormat(context->format()); + offscreenSurface->create(); + if (context->makeCurrent(offscreenSurface)) renderControl->initialize(context); else @@ -649,6 +645,8 @@ void QQuickWidgetPrivate::createContext() void QQuickWidgetPrivate::destroyContext() { + delete offscreenSurface; + offscreenSurface = 0; delete context; context = 0; } @@ -1044,10 +1042,7 @@ void QQuickWidget::setFormat(const QSurfaceFormat &format) newFormat.setDepthBufferSize(qMax(newFormat.depthBufferSize(), currentFormat.depthBufferSize())); newFormat.setStencilBufferSize(qMax(newFormat.stencilBufferSize(), currentFormat.stencilBufferSize())); newFormat.setAlphaBufferSize(qMax(newFormat.alphaBufferSize(), currentFormat.alphaBufferSize())); - if (currentFormat != newFormat) { - d->offscreenWindow->setFormat(newFormat); - d->createOffscreenSurface(); - } + d->offscreenWindow->setFormat(newFormat); } /*! |