aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Edmundson <davidedmundson@kde.org>2019-08-27 17:55:45 +0100
committerDavid Edmundson <davidedmundson@kde.org>2019-10-08 20:48:35 +0000
commitadc268574ccfd602bd5fccba6bea00f3f8a58e26 (patch)
tree36bdf1f9d70e73be48c3514b9bb7210e81572d13
parent8ea33db63505cbdbad3d298908211d78a4812519 (diff)
Handle context loss in the basic render loop
In the event of a graphics context loss, we need to reset the scenegraph and the GL context. As all windows share a graphics context a loss detected in one window needs to reset the scenegraph on all windows. Change-Id: I3ff1a93d5a08fa21366a6a56e94bd2185aebb2d5 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
-rw-r--r--src/quick/scenegraph/qsgrenderloop.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/quick/scenegraph/qsgrenderloop.cpp b/src/quick/scenegraph/qsgrenderloop.cpp
index ba231f8159..f609055677 100644
--- a/src/quick/scenegraph/qsgrenderloop.cpp
+++ b/src/quick/scenegraph/qsgrenderloop.cpp
@@ -619,6 +619,24 @@ void QSGGuiThreadRenderLoop::renderWindow(QQuickWindow *window)
i++;
}
+ // Check for context loss.
+ if (!current && !rhi && !gl->isValid()) {
+ for (auto it = m_windows.constBegin() ; it != m_windows.constEnd(); it++) {
+ QQuickWindowPrivate *windowPrivate = QQuickWindowPrivate::get(it.key());
+ windowPrivate->cleanupNodesOnShutdown();
+ }
+ rc->invalidate();
+ current = gl->create() && gl->makeCurrent(window);
+ if (current) {
+ QSGDefaultRenderContext::InitParams rcParams;
+ rcParams.sampleCount = qMax(1, gl->format().samples());
+ rcParams.openGLContext = gl;
+ rcParams.initialSurfacePixelSize = window->size() * window->effectiveDevicePixelRatio();
+ rcParams.maybeSurface = window;
+ rc->initialize(&rcParams);
+ }
+ }
+
if (!current)
return;