diff options
author | Jani Hautakangas <jani.hautakangas@nokia.com> | 2011-03-22 09:03:13 (GMT) |
---|---|---|
committer | Jani Hautakangas <jani.hautakangas@nokia.com> | 2011-03-22 09:46:25 (GMT) |
commit | 48c5a020c6ad6ee5ef1721d422f10bbc40dd1557 (patch) | |
tree | 2efc4cf4ab3fb56cc5f989aa65167f60cdf35798 /src/opengl | |
parent | de4bd221124e0a133858839b4b824165a9eb7dff (diff) | |
download | Qt-48c5a020c6ad6ee5ef1721d422f10bbc40dd1557.zip Qt-48c5a020c6ad6ee5ef1721d422f10bbc40dd1557.tar.gz Qt-48c5a020c6ad6ee5ef1721d422f10bbc40dd1557.tar.bz2 |
Change Symbian to use destroyed swap behaviour in GL
Destroyed swap behaviour is a little bit faster than
preserved swap with heavily animated UIs like QML.
Task-number: QTBUG-18270
Reviewed-by: Samuel Rødal
Diffstat (limited to 'src/opengl')
-rw-r--r-- | src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp | 4 | ||||
-rw-r--r-- | src/opengl/opengl.pro | 2 | ||||
-rw-r--r-- | src/opengl/qgl_symbian.cpp | 21 | ||||
-rw-r--r-- | src/opengl/qgltexturepool.cpp | 7 | ||||
-rw-r--r-- | src/opengl/qwindowsurface_gl.cpp | 40 |
5 files changed, 51 insertions, 23 deletions
diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index c8786fb..5c8d2b6 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -90,10 +90,6 @@ QT_BEGIN_NAMESPACE -#if defined(Q_OS_SYMBIAN) -#define QT_GL_NO_SCISSOR_TEST -#endif - #if defined(Q_WS_WIN) extern Q_GUI_EXPORT bool qt_cleartype_enabled; #endif diff --git a/src/opengl/opengl.pro b/src/opengl/opengl.pro index 6bbf99b..6d79584 100644 --- a/src/opengl/opengl.pro +++ b/src/opengl/opengl.pro @@ -148,7 +148,7 @@ embedded { } symbian { - DEFINES += QGL_USE_TEXTURE_POOL + DEFINES += QGL_USE_TEXTURE_POOL QGL_NO_PRESERVED_SWAP SOURCES -= qpixmapdata_gl.cpp SOURCES += qgl_symbian.cpp \ qpixmapdata_poolgl.cpp \ diff --git a/src/opengl/qgl_symbian.cpp b/src/opengl/qgl_symbian.cpp index 78624a2..7caaabd 100644 --- a/src/opengl/qgl_symbian.cpp +++ b/src/opengl/qgl_symbian.cpp @@ -228,13 +228,20 @@ bool QGLContext::chooseContext(const QGLContext* shareContext) // almost same as d->eglSurface = QEgl::createSurface(device(), d->eglContext->config()); -#if !defined(QGL_NO_PRESERVED_SWAP) - eglGetError(); // Clear error state first. - eglSurfaceAttrib(QEgl::display(), d->eglSurface, - EGL_SWAP_BEHAVIOR, EGL_BUFFER_PRESERVED); - if (eglGetError() != EGL_SUCCESS) { - qWarning("QGLContext: could not enable preserved swap"); - } + eglGetError(); // Clear error state first. + +#ifdef QGL_NO_PRESERVED_SWAP + eglSurfaceAttrib(QEgl::display(), d->eglSurface, + EGL_SWAP_BEHAVIOR, EGL_BUFFER_DESTROYED); + + if (eglGetError() != EGL_SUCCESS) + qWarning("QGLContext: could not enable destroyed swap behaviour"); +#else + eglSurfaceAttrib(QEgl::display(), d->eglSurface, + EGL_SWAP_BEHAVIOR, EGL_BUFFER_PRESERVED); + + if (eglGetError() != EGL_SUCCESS) + qWarning("QGLContext: could not enable preserved swap behaviour"); #endif setWindowCreated(true); diff --git a/src/opengl/qgltexturepool.cpp b/src/opengl/qgltexturepool.cpp index 61a88c3..a5472ec 100644 --- a/src/opengl/qgltexturepool.cpp +++ b/src/opengl/qgltexturepool.cpp @@ -135,8 +135,11 @@ void QGLTexturePool::releaseTexture(QGLPixmapData *data, GLuint texture) if (data) removeFromLRU(data); - QGLShareContextScope ctx(qt_gl_share_widget()->context()); - glDeleteTextures(1, &texture); + QGLWidget *shareWidget = qt_gl_share_widget(); + if (shareWidget) { + QGLShareContextScope ctx(shareWidget->context()); + glDeleteTextures(1, &texture); + } } void QGLTexturePool::useTexture(QGLPixmapData *data) diff --git a/src/opengl/qwindowsurface_gl.cpp b/src/opengl/qwindowsurface_gl.cpp index 11a9eb0..ed541ce 100644 --- a/src/opengl/qwindowsurface_gl.cpp +++ b/src/opengl/qwindowsurface_gl.cpp @@ -371,6 +371,10 @@ QGLWindowSurface::QGLWindowSurface(QWidget *window) d_ptr->q_ptr = this; d_ptr->geometry_updated = false; d_ptr->did_paint = false; + +#ifdef QGL_NO_PRESERVED_SWAP + setPartialUpdateSupport(false); +#endif } QGLWindowSurface::~QGLWindowSurface() @@ -467,8 +471,16 @@ void QGLWindowSurface::hijackWindow(QWidget *widget) if (haveNOKSwapRegion) qDebug() << "Found EGL_NOK_swap_region2 extension. Using partial updates."; } - bool swapBehaviourPreserved = (ctx->d_func()->eglContext->configAttrib(EGL_SWAP_BEHAVIOR) - || (ctx->d_func()->eglContext->configAttrib(EGL_SURFACE_TYPE)&EGL_SWAP_BEHAVIOR_PRESERVED_BIT)); + + bool swapBehaviourPreserved = ctx->d_func()->eglContext->configAttrib(EGL_SWAP_BEHAVIOR); + if (ctx->d_func()->eglContext->configAttrib(EGL_SURFACE_TYPE)&EGL_SWAP_BEHAVIOR_PRESERVED_BIT) { + EGLint swapBehavior; + if (eglQuerySurface(ctx->d_func()->eglContext->display(), ctx->d_func()->eglSurface + , EGL_SWAP_BEHAVIOR, &swapBehavior)) { + swapBehaviourPreserved = (swapBehavior == EGL_BUFFER_PRESERVED); + } + } + if (!swapBehaviourPreserved && !haveNOKSwapRegion) setPartialUpdateSupport(false); // Force full-screen updates else @@ -514,6 +526,8 @@ static void drawTexture(const QRectF &rect, GLuint tex_id, const QSize &texSize, void QGLWindowSurface::beginPaint(const QRegion &) { + updateGeometry(); + if (!context()) return; @@ -874,14 +888,22 @@ void QGLWindowSurface::updateGeometry() { 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"); + eglGetError(); // Clear error state. + if (hasPartialUpdateSupport()) { + eglSurfaceAttrib(ctx->d_func()->eglContext->display(), + ctx->d_func()->eglSurface, + EGL_SWAP_BEHAVIOR, EGL_BUFFER_PRESERVED); + + if (eglGetError() != EGL_SUCCESS) + qWarning("QGLWindowSurface: could not enable preserved swap behaviour"); + } else { + eglSurfaceAttrib(ctx->d_func()->eglContext->display(), + ctx->d_func()->eglSurface, + EGL_SWAP_BEHAVIOR, EGL_BUFFER_DESTROYED); + + if (eglGetError() != EGL_SUCCESS) + qWarning("QGLWindowSurface: could not enable destroyed swap behaviour"); } -#endif } #endif |