From 385f2c8a34a52443e78dfa272a1a483b9d6d29fc Mon Sep 17 00:00:00 2001 From: Jason Barron Date: Fri, 9 Apr 2010 13:21:32 +0200 Subject: Enable preserved swap behavior when surface is created due to resize. When the QVG_RECREATE_ON_SIZE_CHANGE macro is defined the EGL surface is recreated. However, after creating the surface, we were neglecting to set the surface attribute that enabled the preserved swapping behavior of EGL. This lead to flicker because every second frame was swapping with an empty buffer and only the dirty areas were being painted leaving the rest empty. Reviewed-by: Lars Knoll Reviewed-by: Aleksandar Sasha Babic Task-number: QT-3198 Task-number: QT-3184 Task-number: QT-3201 --- src/openvg/qwindowsurface_vgegl.cpp | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/openvg/qwindowsurface_vgegl.cpp b/src/openvg/qwindowsurface_vgegl.cpp index f46d6c2..46a905f 100644 --- a/src/openvg/qwindowsurface_vgegl.cpp +++ b/src/openvg/qwindowsurface_vgegl.cpp @@ -659,6 +659,7 @@ QEglContext *QVGEGLWindowSurfaceDirect::ensureContext(QWidget *widget) #endif windowSurface = context->createSurface(widget, &surfaceProps); isPaintingActive = false; + needToSwap = true; } #else if (context && size != newSize) { @@ -710,20 +711,21 @@ QEglContext *QVGEGLWindowSurfaceDirect::ensureContext(QWidget *widget) needToSwap = false; } #endif -#if !defined(QVG_NO_PRESERVED_SWAP) - // Try to force the surface back buffer to preserve its contents. - if (needToSwap) { - eglGetError(); // Clear error state first. - eglSurfaceAttrib(QEglContext::display(), surface, - EGL_SWAP_BEHAVIOR, EGL_BUFFER_PRESERVED); - if (eglGetError() != EGL_SUCCESS) { - qWarning("QVG: could not enable preserved swap"); - } - } -#endif windowSurface = surface; isPaintingActive = false; } + +#if !defined(QVG_NO_PRESERVED_SWAP) + // Try to force the surface back buffer to preserve its contents. + if (needToSwap) { + eglGetError(); // Clear error state first. + eglSurfaceAttrib(QEglContext::display(), windowSurface, + EGL_SWAP_BEHAVIOR, EGL_BUFFER_PRESERVED); + if (eglGetError() != EGL_SUCCESS) { + qWarning("QVG: could not enable preserved swap"); + } + } +#endif return context; } -- cgit v0.12