diff options
author | Tom Cooksey <thomas.cooksey@nokia.com> | 2010-04-15 10:48:56 (GMT) |
---|---|---|
committer | Tom Cooksey <thomas.cooksey@nokia.com> | 2010-04-15 10:58:43 (GMT) |
commit | 794cbd5800a4428babc100528fd4fdba49557b6f (patch) | |
tree | 59ea1e2e422325eb20074d56ebf30f82bde26343 /src/gui | |
parent | 4c472f1694aa9f35eda248f04decadbe0ef2dd75 (diff) | |
download | Qt-794cbd5800a4428babc100528fd4fdba49557b6f.zip Qt-794cbd5800a4428babc100528fd4fdba49557b6f.tar.gz Qt-794cbd5800a4428babc100528fd4fdba49557b6f.tar.bz2 |
Wrap EGL image function pointers and move into QEgl namespace
QtGui exporting a symbol called eglCreateImageKHR seems a pretty
silly idea. Much better to have them in the QEgl namespace.
Reviewed-By: Iain
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/egl/qegl.cpp | 43 | ||||
-rw-r--r-- | src/gui/egl/qegl_p.h | 18 |
2 files changed, 41 insertions, 20 deletions
diff --git a/src/gui/egl/qegl.cpp b/src/gui/egl/qegl.cpp index 3b007d7..0fe5cbe 100644 --- a/src/gui/egl/qegl.cpp +++ b/src/gui/egl/qegl.cpp @@ -535,10 +535,14 @@ QEglProperties QEglContext::configProperties() const return QEglProperties(config()); } -#if (defined(EGL_KHR_image) || defined(EGL_KHR_image_base)) && !defined(EGL_EGLEXT_PROTOTYPES) -_eglCreateImageKHR eglCreateImageKHR = 0; -_eglDestroyImageKHR eglDestroyImageKHR = 0; -#endif + +typedef EGLImageKHR (EGLAPIENTRY *_eglCreateImageKHR)(EGLDisplay, EGLContext, EGLenum, EGLClientBuffer, const EGLint*); +typedef EGLBoolean (EGLAPIENTRY *_eglDestroyImageKHR)(EGLDisplay, EGLImageKHR); + +// Defined in qegl.cpp: +static _eglCreateImageKHR qt_eglCreateImageKHR = 0; +static _eglDestroyImageKHR qt_eglDestroyImageKHR = 0; + EGLDisplay QEgl::display() { @@ -565,8 +569,8 @@ EGLDisplay QEgl::display() // Resolve the egl extension function pointers: #if (defined(EGL_KHR_image) || defined(EGL_KHR_image_base)) && !defined(EGL_EGLEXT_PROTOTYPES) if (QEgl::hasExtension("EGL_KHR_image") || QEgl::hasExtension("EGL_KHR_image_base")) { - eglCreateImageKHR = (_eglCreateImageKHR) eglGetProcAddress("eglCreateImageKHR"); - eglDestroyImageKHR = (_eglDestroyImageKHR) eglGetProcAddress("eglDestroyImageKHR"); + qt_eglCreateImageKHR = (_eglCreateImageKHR) eglGetProcAddress("eglCreateImageKHR"); + qt_eglDestroyImageKHR = (_eglDestroyImageKHR) eglGetProcAddress("eglDestroyImageKHR"); } #endif } @@ -574,6 +578,33 @@ EGLDisplay QEgl::display() return dpy; } +EGLImageKHR QEgl::eglCreateImageKHR(EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list) +{ + if (qt_eglCreateImageKHR) + return qt_eglCreateImageKHR(dpy, ctx, target, buffer, attrib_list); + + QEgl::display(); // Initialises function pointers + if (qt_eglCreateImageKHR) + return qt_eglCreateImageKHR(dpy, ctx, target, buffer, attrib_list); + + qWarning("QEgl::eglCreateImageKHR() called but EGL_KHR_image(_base) extension not present"); + return 0; +} + +EGLBoolean QEgl::eglDestroyImageKHR(EGLDisplay dpy, EGLImageKHR img) +{ + if (qt_eglDestroyImageKHR) + return qt_eglDestroyImageKHR(dpy, img); + + QEgl::display(); // Initialises function pointers + if (qt_eglDestroyImageKHR) + return qt_eglDestroyImageKHR(dpy, img); + + qWarning("QEgl::eglDestroyImageKHR() called but EGL_KHR_image(_base) 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 f81add6..6345d5d 100644 --- a/src/gui/egl/qegl_p.h +++ b/src/gui/egl/qegl_p.h @@ -147,20 +147,6 @@ typedef void *EGLImageKHR; #define EGL_KHR_image_pixmap #endif -// It is possible that something has included eglext.h (like Symbian 10.1's broken egl.h), in -// which case, EGL_KHR_image/EGL_KHR_image_base will be defined. They may have also defined -// the actual function prototypes, but generally EGL_EGLEXT_PROTOTYPES will be defined in that -// case and we shouldn't re-define them here. -#if (defined(EGL_KHR_image) || defined(EGL_KHR_image_base)) && !defined(EGL_EGLEXT_PROTOTYPES) -typedef EGLImageKHR (EGLAPIENTRY *_eglCreateImageKHR)(EGLDisplay, EGLContext, EGLenum, EGLClientBuffer, EGLint*); -typedef EGLBoolean (EGLAPIENTRY *_eglDestroyImageKHR)(EGLDisplay, EGLImageKHR); - -// Defined in qegl.cpp: -extern Q_GUI_EXPORT _eglCreateImageKHR eglCreateImageKHR; -extern Q_GUI_EXPORT _eglDestroyImageKHR eglDestroyImageKHR; -#endif // (defined(EGL_KHR_image) || defined(EGL_KHR_image_base)) && !defined(EGL_EGLEXT_PROTOTYPES) - - class QEglProperties; @@ -210,6 +196,10 @@ namespace QEgl { Q_GUI_EXPORT EGLNativeWindowType nativeWindow(QWidget*); Q_GUI_EXPORT EGLNativePixmapType nativePixmap(QPixmap*); + // 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); + #ifdef Q_WS_X11 Q_GUI_EXPORT VisualID getCompatibleVisualId(EGLConfig config); #endif |