diff options
author | Michael Dominic K <mdk@codethink.co.uk> | 2010-07-01 13:19:51 (GMT) |
---|---|---|
committer | Samuel Rødal <samuel.rodal@nokia.com> | 2010-07-01 13:19:51 (GMT) |
commit | 7394aadc24bc5318fdd9498931a882f8b8533365 (patch) | |
tree | 0db9c328635475468e7263a2e1f33d08edc4494f /src | |
parent | 7727c6b2aa577f87e3d30adcf3fd96be5f62ded9 (diff) | |
download | Qt-7394aadc24bc5318fdd9498931a882f8b8533365.zip Qt-7394aadc24bc5318fdd9498931a882f8b8533365.tar.gz Qt-7394aadc24bc5318fdd9498931a882f8b8533365.tar.bz2 |
QGLWindowSurface support for partial updates via EGL_NOK_swap_region2
(if extension available).
Merge-request: 712
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/opengl/qgl.cpp | 10 | ||||
-rw-r--r-- | src/opengl/qgl_egl.cpp | 8 | ||||
-rw-r--r-- | src/opengl/qgl_p.h | 1 | ||||
-rw-r--r-- | src/opengl/qwindowsurface_gl.cpp | 24 |
4 files changed, 41 insertions, 2 deletions
diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index e05db96..72ed0c6 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -2092,6 +2092,16 @@ void QGLContextPrivate::syncGlState() } #undef ctx +#ifdef QT_NO_EGL +void QGLContextPrivate::swapRegion(const QRegion *region) +{ + static bool firstWarning = true; + if (firstWarning) { + qWarning() << "::swapRegion called but not supported!"; + firstWarning = false; + } +} +#endif /*! \overload diff --git a/src/opengl/qgl_egl.cpp b/src/opengl/qgl_egl.cpp index eafa181..3763926 100644 --- a/src/opengl/qgl_egl.cpp +++ b/src/opengl/qgl_egl.cpp @@ -274,6 +274,14 @@ EGLSurface QGLContextPrivate::eglSurfaceForDevice() const return eglSurface; } +void QGLContextPrivate::swapRegion(const QRegion *region) +{ + if (!valid || !eglContext) + return; + + eglContext->swapBuffersRegion2NOK(eglSurfaceForDevice(), region); +} + void QGLWidget::setMouseTracking(bool enable) { QWidget::setMouseTracking(enable); diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h index 34a6b7c..32feacd 100644 --- a/src/opengl/qgl_p.h +++ b/src/opengl/qgl_p.h @@ -334,6 +334,7 @@ public: void setVertexAttribArrayEnabled(int arrayIndex, bool enabled = true); void syncGlState(); // Makes sure the GL context's state is what we think it is + void swapRegion(const QRegion *region); #if defined(Q_WS_WIN) void updateFormatVersion(); diff --git a/src/opengl/qwindowsurface_gl.cpp b/src/opengl/qwindowsurface_gl.cpp index 7efa9bc..e9da452 100644 --- a/src/opengl/qwindowsurface_gl.cpp +++ b/src/opengl/qwindowsurface_gl.cpp @@ -354,8 +354,22 @@ void QGLWindowSurface::hijackWindow(QWidget *widget) ctx->create(qt_gl_share_widget()->context()); #ifndef QT_NO_EGL - if (ctx->d_func()->eglContext->configAttrib(EGL_SWAP_BEHAVIOR) != EGL_BUFFER_PRESERVED) + static bool checkedForNOKSwapRegion = false; + static bool haveNOKSwapRegion = false; + + if (!checkedForNOKSwapRegion) { + haveNOKSwapRegion = QEgl::hasExtension("EGL_NOK_swap_region2"); + checkedForNOKSwapRegion = true; + + if (haveNOKSwapRegion) + qDebug() << "Found EGL_NOK_swap_region2 extension. Using partial updates."; + } + + if (ctx->d_func()->eglContext->configAttrib(EGL_SWAP_BEHAVIOR) != EGL_BUFFER_PRESERVED && + ! haveNOKSwapRegion) setPartialUpdateSupport(false); // Force full-screen updates + else + setPartialUpdateSupport(true); #endif widgetPrivate->extraData()->glContext = ctx; @@ -480,8 +494,14 @@ void QGLWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoint & } } #endif + if (d_ptr->paintedRegion.boundingRect() != geometry()) { + // Emits warning if not supported. Should never happen unless + // setPartialUpdateSupport(true) has been called. + context()->d_func()->swapRegion(&d_ptr->paintedRegion); + } else + context()->swapBuffers(); + d_ptr->paintedRegion = QRegion(); - context()->swapBuffers(); } else { glFlush(); } |