summaryrefslogtreecommitdiffstats
path: root/src/opengl
diff options
context:
space:
mode:
authorTom Cooksey <thomas.cooksey@nokia.com>2010-04-22 14:16:31 (GMT)
committerTom Cooksey <thomas.cooksey@nokia.com>2010-04-22 14:38:10 (GMT)
commit8f34510750bb125ae749863d0174d96c9e0aabb2 (patch)
treed1aca4ed17cc5952c594800ee943d82a4e9f651c /src/opengl
parent9f101a33b44424e22f50dcd01eeb90ac7c835f21 (diff)
downloadQt-8f34510750bb125ae749863d0174d96c9e0aabb2.zip
Qt-8f34510750bb125ae749863d0174d96c9e0aabb2.tar.gz
Qt-8f34510750bb125ae749863d0174d96c9e0aabb2.tar.bz2
Make sure recreateEglSurface creates a surface if there isn't one
If QGLWidgetPrivate::recreateEglSurface is called after a surface has been deleted, it should always create a new surface and ignore the fact that the window ID may not have changed. Reviewed-By: Trond
Diffstat (limited to 'src/opengl')
-rw-r--r--src/opengl/qgl.cpp2
-rw-r--r--src/opengl/qgl_p.h2
-rw-r--r--src/opengl/qgl_x11egl.cpp24
3 files changed, 14 insertions, 14 deletions
diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp
index 394bcbc..72ed6be 100644
--- a/src/opengl/qgl.cpp
+++ b/src/opengl/qgl.cpp
@@ -3984,7 +3984,7 @@ bool QGLWidget::event(QEvent *e)
if ((e->type() == QEvent::ParentChange) || (e->type() == QEvent::WindowStateChange)) {
// The window may have been re-created during re-parent or state change - if so, the EGL
// surface will need to be re-created.
- d->recreateEglSurface(false);
+ d->recreateEglSurface();
}
#endif
#elif defined(Q_WS_WIN)
diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h
index ee580a6..f19e394 100644
--- a/src/opengl/qgl_p.h
+++ b/src/opengl/qgl_p.h
@@ -195,7 +195,7 @@ public:
#elif defined(Q_WS_X11)
QGLOverlayWidget *olw;
#ifndef QT_NO_EGL
- void recreateEglSurface(bool force);
+ void recreateEglSurface();
WId eglSurfaceWindowId;
#endif
#elif defined(Q_WS_MAC)
diff --git a/src/opengl/qgl_x11egl.cpp b/src/opengl/qgl_x11egl.cpp
index d67a3ea..c0b1515 100644
--- a/src/opengl/qgl_x11egl.cpp
+++ b/src/opengl/qgl_x11egl.cpp
@@ -335,24 +335,24 @@ void QGLWidget::setColormap(const QGLColormap &)
{
}
-// Re-creates the EGL surface if the window ID has changed or if force is true
-void QGLWidgetPrivate::recreateEglSurface(bool force)
+// Re-creates the EGL surface if the window ID has changed or if there isn't a surface
+void QGLWidgetPrivate::recreateEglSurface()
{
Q_Q(QGLWidget);
Window currentId = q->winId();
- if ( force || (currentId != eglSurfaceWindowId) ) {
- // The window id has changed so we need to re-create the EGL surface
- QEglContext *ctx = glcx->d_func()->eglContext;
- EGLSurface surface = glcx->d_func()->eglSurface;
- if (surface != EGL_NO_SURFACE)
- ctx->destroySurface(surface); // Will force doneCurrent() if nec.
- surface = ctx->createSurface(q);
- if (surface == EGL_NO_SURFACE)
- qWarning("Error creating EGL window surface: 0x%x", eglGetError());
- glcx->d_func()->eglSurface = surface;
+ // If the window ID has changed since the surface was created, we need to delete the
+ // old surface before re-creating a new one. Note: This should not be the case as the
+ // surface should be deleted before the old window id.
+ if (glcx->d_func()->eglSurface != EGL_NO_SURFACE && (currentId != eglSurfaceWindowId)) {
+ qWarning("EGL surface for deleted window %x was not destroyed", eglSurfaceWindowId);
+ glcx->d_func()->destroyEglSurfaceForDevice();
+ }
+ if (glcx->d_func()->eglSurface == EGL_NO_SURFACE) {
+ qDebug("Re-creating the surface");
+ glcx->d_func()->eglSurface = glcx->d_func()->eglContext->createSurface(q);
eglSurfaceWindowId = currentId;
}
}