summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/windows/qwindowseglcontext.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@theqtcompany.com>2015-03-16 10:31:07 +0100
committerSimon Hausmann <simon.hausmann@theqtcompany.com>2015-03-16 10:31:07 +0100
commit198606f6dbca95ba3a170fff387327d8271018cd (patch)
tree79e8c632f5277fc7f0ae30ae7fb1e1c41745c815 /src/plugins/platforms/windows/qwindowseglcontext.cpp
parent77c0c1ca6505eb66bd75b3766f9a498574822bd1 (diff)
parent0d5ffd67a4748bcbf19dc3a4b9a36ae6314e58a6 (diff)
Merge remote-tracking branch 'origin/5.5' into dev
Conflicts: src/plugins/platforms/xcb/qxcbnativeinterface.cpp src/plugins/platforms/xcb/qxcbnativeinterface.h Change-Id: I31b38ba439b9341d51a01c0fd54bea33f7410076
Diffstat (limited to 'src/plugins/platforms/windows/qwindowseglcontext.cpp')
-rw-r--r--src/plugins/platforms/windows/qwindowseglcontext.cpp33
1 files changed, 25 insertions, 8 deletions
diff --git a/src/plugins/platforms/windows/qwindowseglcontext.cpp b/src/plugins/platforms/windows/qwindowseglcontext.cpp
index 74efd49217..7db6abd8ef 100644
--- a/src/plugins/platforms/windows/qwindowseglcontext.cpp
+++ b/src/plugins/platforms/windows/qwindowseglcontext.cpp
@@ -416,12 +416,15 @@ QWindowsOpenGLContext *QWindowsEGLStaticContext::createContext(QOpenGLContext *c
return new QWindowsEGLContext(this, context->format(), context->shareHandle());
}
-void *QWindowsEGLStaticContext::createWindowSurface(void *nativeWindow, void *nativeConfig)
+void *QWindowsEGLStaticContext::createWindowSurface(void *nativeWindow, void *nativeConfig, int *err)
{
+ *err = 0;
EGLSurface surface = libEGL.eglCreateWindowSurface(m_display, (EGLConfig) nativeConfig,
(EGLNativeWindowType) nativeWindow, 0);
- if (surface == EGL_NO_SURFACE)
- qWarning("%s: Could not create the EGL window surface: 0x%x\n", Q_FUNC_INFO, libEGL.eglGetError());
+ if (surface == EGL_NO_SURFACE) {
+ *err = libEGL.eglGetError();
+ qWarning("%s: Could not create the EGL window surface: 0x%x\n", Q_FUNC_INFO, *err);
+ }
return surface;
}
@@ -578,8 +581,15 @@ bool QWindowsEGLContext::makeCurrent(QPlatformSurface *surface)
QWindowsWindow *window = static_cast<QWindowsWindow *>(surface);
window->aboutToMakeCurrent();
- EGLSurface eglSurface = static_cast<EGLSurface>(window->surface(m_eglConfig));
- Q_ASSERT(eglSurface);
+ int err = 0;
+ EGLSurface eglSurface = static_cast<EGLSurface>(window->surface(m_eglConfig, &err));
+ if (eglSurface == EGL_NO_SURFACE) {
+ if (err == EGL_CONTEXT_LOST) {
+ m_eglContext = EGL_NO_CONTEXT;
+ qCDebug(lcQpaGl) << "Got EGL context lost in createWindowSurface() for context" << this;
+ }
+ return false;
+ }
// shortcut: on some GPUs, eglMakeCurrent is not a cheap operation
if (QWindowsEGLStaticContext::libEGL.eglGetCurrentContext() == m_eglContext &&
@@ -597,7 +607,7 @@ bool QWindowsEGLContext::makeCurrent(QPlatformSurface *surface)
QWindowsEGLStaticContext::libEGL.eglSwapInterval(m_staticContext->display(), m_swapInterval);
}
} else {
- int err = QWindowsEGLStaticContext::libEGL.eglGetError();
+ err = QWindowsEGLStaticContext::libEGL.eglGetError();
// EGL_CONTEXT_LOST (loss of the D3D device) is not necessarily fatal.
// Qt Quick is able to recover for example.
if (err == EGL_CONTEXT_LOST) {
@@ -625,8 +635,15 @@ void QWindowsEGLContext::swapBuffers(QPlatformSurface *surface)
{
QWindowsEGLStaticContext::libEGL.eglBindAPI(m_api);
QWindowsWindow *window = static_cast<QWindowsWindow *>(surface);
- EGLSurface eglSurface = static_cast<EGLSurface>(window->surface(m_eglConfig));
- Q_ASSERT(eglSurface);
+ int err = 0;
+ EGLSurface eglSurface = static_cast<EGLSurface>(window->surface(m_eglConfig, &err));
+ if (eglSurface == EGL_NO_SURFACE) {
+ if (err == EGL_CONTEXT_LOST) {
+ m_eglContext = EGL_NO_CONTEXT;
+ qCDebug(lcQpaGl) << "Got EGL context lost in createWindowSurface() for context" << this;
+ }
+ return;
+ }
bool ok = QWindowsEGLStaticContext::libEGL.eglSwapBuffers(m_eglDisplay, eglSurface);
if (!ok)