diff options
author | Jani Hautakangas <jani.hautakangas@nokia.com> | 2011-02-07 11:41:46 (GMT) |
---|---|---|
committer | Jani Hautakangas <jani.hautakangas@nokia.com> | 2011-02-08 09:56:32 (GMT) |
commit | fe68a04ed15038a9e22b66c567bcd44ee93e33d1 (patch) | |
tree | 7faef011a895516a26c0f07a36a0b13b02c6a346 /src | |
parent | bc21d7604c78cf05780bb9974911ba81e787b6f9 (diff) | |
download | Qt-fe68a04ed15038a9e22b66c567bcd44ee93e33d1.zip Qt-fe68a04ed15038a9e22b66c567bcd44ee93e33d1.tar.gz Qt-fe68a04ed15038a9e22b66c567bcd44ee93e33d1.tar.bz2 |
Recreate GL surface when native window is resized on Symbian
Symbian doesn't automatically resize EGL surface when native window
is resized.
Task-number: QTBUG-15249
Reviewed-by: Jørgen Lind
Diffstat (limited to 'src')
-rw-r--r-- | src/opengl/qwindowsurface_gl.cpp | 44 |
1 files changed, 35 insertions, 9 deletions
diff --git a/src/opengl/qwindowsurface_gl.cpp b/src/opengl/qwindowsurface_gl.cpp index 5a783ca..cdd3eb9 100644 --- a/src/opengl/qwindowsurface_gl.cpp +++ b/src/opengl/qwindowsurface_gl.cpp @@ -363,7 +363,6 @@ QGLWindowSurface::~QGLWindowSurface() *ctx = 0; } #endif - delete d_ptr->pb; delete d_ptr->fbo; delete d_ptr; @@ -812,20 +811,25 @@ void QGLWindowSurface::updateGeometry() { return; d_ptr->geometry_updated = false; -#ifdef Q_WS_QPA - QSize surfSize = size(); -#else - QSize surfSize = geometry().size(); -#endif + bool hijack(true); + QWidgetPrivate *wd = window()->d_func(); + if (wd->extraData() && wd->extraData()->glContext) + hijack = false; // we already have gl context for widget - hijackWindow(window()); - QGLContext *ctx = reinterpret_cast<QGLContext *>(window()->d_func()->extraData()->glContext); + if (hijack) + hijackWindow(window()); + + QGLContext *ctx = reinterpret_cast<QGLContext *>(wd->extraData()->glContext); #ifdef Q_WS_MAC ctx->updatePaintDevice(); #endif - const GLenum target = GL_TEXTURE_2D; +#ifdef Q_WS_QPA + QSize surfSize = size(); +#else + QSize surfSize = geometry().size(); +#endif if (surfSize.width() <= 0 || surfSize.height() <= 0) return; @@ -835,6 +839,27 @@ void QGLWindowSurface::updateGeometry() { d_ptr->size = surfSize; +#ifdef Q_OS_SYMBIAN + if (!hijack) { // Symbian needs to recreate EGL surface when native window size changes + if (ctx->d_func()->eglSurface != EGL_NO_SURFACE) { + eglDestroySurface(ctx->d_func()->eglContext->display(), + ctx->d_func()->eglSurface); + } + + ctx->d_func()->eglSurface = QEgl::createSurface(ctx->device(), + ctx->d_func()->eglContext->config()); + +#if !defined(QGL_NO_PRESERVED_SWAP) + eglGetError(); // Clear error state first. + eglSurfaceAttrib(QEgl::display(), ctx->d_func()->eglSurface, + EGL_SWAP_BEHAVIOR, EGL_BUFFER_PRESERVED); + if (eglGetError() != EGL_SUCCESS) { + qWarning("QGLWindowSurface: could not restore preserved swap behaviour"); + } +#endif + } +#endif + if (d_ptr->ctx) { #ifndef QT_OPENGL_ES_2 if (d_ptr->destructive_swap_buffers) @@ -843,6 +868,7 @@ void QGLWindowSurface::updateGeometry() { return; } + const GLenum target = GL_TEXTURE_2D; if (d_ptr->destructive_swap_buffers && (QGLExtensions::glExtensions() & QGLExtensions::FramebufferObject) && (d_ptr->fbo || !d_ptr->tried_fbo) |