From 7727c6b2aa577f87e3d30adcf3fd96be5f62ded9 Mon Sep 17 00:00:00 2001 From: Michael Dominic K Date: Thu, 1 Jul 2010 15:19:51 +0200 Subject: Adding func prototypes for EGL_NOK_swap_region2 extension. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Merge-request: 712 Reviewed-by: Samuel Rødal --- src/gui/egl/qegl.cpp | 44 ++++++++++++++++++++++++++++++++++++++++++++ src/gui/egl/qegl_p.h | 1 + src/gui/egl/qeglcontext_p.h | 1 + 3 files changed, 46 insertions(+) diff --git a/src/gui/egl/qegl.cpp b/src/gui/egl/qegl.cpp index e6ea198..3e2049c 100644 --- a/src/gui/egl/qegl.cpp +++ b/src/gui/egl/qegl.cpp @@ -515,6 +515,31 @@ bool QEglContext::swapBuffers(EGLSurface surface) return ok; } +bool QEglContext::swapBuffersRegion2NOK(EGLSurface surface, const QRegion *region) { + QVector qrects = region->rects(); + GLint *gl_rects; + uint count; + uint i; + + count = qrects.size(); + QVarLengthArray arr(4 * count); + gl_rects = arr.data(); + for (i = 0; i < count; i++) { + QRect qrect = qrects[i]; + + gl_rects[4 * i + 0] = qrect.x(); + gl_rects[4 * i + 1] = qrect.y(); + gl_rects[4 * i + 2] = qrect.width(); + gl_rects[4 * i + 3] = qrect.height(); + } + + bool ok = QEgl::eglSwapBuffersRegion2NOK(QEgl::display(), surface, count, gl_rects); + + if (!ok) + qWarning() << "QEglContext::swapBuffersRegion2NOK():" << QEgl::errorString(); + return ok; +} + int QEglContext::configAttrib(int name) const { EGLint value; @@ -532,6 +557,9 @@ typedef EGLBoolean (EGLAPIENTRY *_eglDestroyImageKHR)(EGLDisplay, EGLImageKHR); static _eglCreateImageKHR qt_eglCreateImageKHR = 0; static _eglDestroyImageKHR qt_eglDestroyImageKHR = 0; +typedef EGLBoolean (EGLAPIENTRY *_eglSwapBuffersRegion2NOK)(EGLDisplay, EGLSurface, EGLint, const EGLint*); + +static _eglSwapBuffersRegion2NOK qt_eglSwapBuffersRegion2NOK = 0; EGLDisplay QEgl::display() { @@ -560,6 +588,10 @@ EGLDisplay QEgl::display() qt_eglDestroyImageKHR = (_eglDestroyImageKHR) eglGetProcAddress("eglDestroyImageKHR"); } #endif + + if (QEgl::hasExtension("EGL_NOK_swap_region2")) { + qt_eglSwapBuffersRegion2NOK = (_eglSwapBuffersRegion2NOK) eglGetProcAddress("eglSwapBuffersRegion2NOK"); + } } return dpy; @@ -591,6 +623,18 @@ EGLBoolean QEgl::eglDestroyImageKHR(EGLDisplay dpy, EGLImageKHR img) return 0; } +EGLBoolean QEgl::eglSwapBuffersRegion2NOK(EGLDisplay dpy, EGLSurface surface, EGLint count, const EGLint *rects) +{ + if (qt_eglSwapBuffersRegion2NOK) + return qt_eglSwapBuffersRegion2NOK(dpy, surface, count, rects); + + QEgl::display(); // Initialises function pointers + if (qt_eglSwapBuffersRegion2NOK) + return qt_eglSwapBuffersRegion2NOK(dpy, surface, count, rects); + + qWarning("QEgl::eglSwapBuffersRegion2NOK() called but EGL_NOK_swap_region2 extension not present"); + return 0; +} #ifndef Q_WS_X11 EGLSurface QEgl::createSurface(QPaintDevice *device, EGLConfig cfg, const QEglProperties *properties) diff --git a/src/gui/egl/qegl_p.h b/src/gui/egl/qegl_p.h index 4fc1338..c214e88 100644 --- a/src/gui/egl/qegl_p.h +++ b/src/gui/egl/qegl_p.h @@ -224,6 +224,7 @@ namespace QEgl { // Extension functions Q_GUI_EXPORT EGLImageKHR eglCreateImageKHR(EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list); Q_GUI_EXPORT EGLBoolean eglDestroyImageKHR(EGLDisplay dpy, EGLImageKHR img); + Q_GUI_EXPORT EGLBoolean eglSwapBuffersRegion2NOK(EGLDisplay dpy, EGLSurface surface, EGLint count, const EGLint *rects); #ifdef Q_WS_X11 Q_GUI_EXPORT VisualID getCompatibleVisualId(EGLConfig config); diff --git a/src/gui/egl/qeglcontext_p.h b/src/gui/egl/qeglcontext_p.h index ccde00d..cae8164 100644 --- a/src/gui/egl/qeglcontext_p.h +++ b/src/gui/egl/qeglcontext_p.h @@ -84,6 +84,7 @@ public: bool doneCurrent(); bool lazyDoneCurrent(); bool swapBuffers(EGLSurface surface); + bool swapBuffersRegion2NOK(EGLSurface surface, const QRegion *region); int configAttrib(int name) const; -- cgit v0.12