From 99c17c0efb1331f5d11260b08614c9dff9bbf2e1 Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Wed, 7 Apr 2010 17:18:04 +0200 Subject: Fix EGLImage & re-enable its use in QtOpenGL Make sure we set the EGL_KHR_image_base define when we define the reset of the extension defines. This also makes eglCreateImageKHR get defined when previously it wasn't. Reviewed-By: TrustMe --- src/gui/egl/qegl_p.h | 9 ++++++--- src/opengl/qgl_x11egl.cpp | 48 +++++++++++++++++++++++------------------------ 2 files changed, 30 insertions(+), 27 deletions(-) diff --git a/src/gui/egl/qegl_p.h b/src/gui/egl/qegl_p.h index 540cd3d..f81add6 100644 --- a/src/gui/egl/qegl_p.h +++ b/src/gui/egl/qegl_p.h @@ -139,6 +139,12 @@ QT_BEGIN_NAMESPACE typedef void *EGLImageKHR; #define EGL_NO_IMAGE_KHR ((EGLImageKHR)0) #define EGL_IMAGE_PRESERVED_KHR 0x30D2 +#define EGL_KHR_image_base +#endif + +#if !defined(EGL_KHR_image) && !defined(EGL_KHR_image_pixmap) +#define EGL_NATIVE_PIXMAP_KHR 0x30B0 +#define EGL_KHR_image_pixmap #endif // It is possible that something has included eglext.h (like Symbian 10.1's broken egl.h), in @@ -154,9 +160,6 @@ 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) -#if !defined(EGL_KHR_image) && !defined(EGL_KHR_image_pixmap) -#define EGL_NATIVE_PIXMAP_KHR 0x30B0 -#endif class QEglProperties; diff --git a/src/opengl/qgl_x11egl.cpp b/src/opengl/qgl_x11egl.cpp index 456e111..af0100b 100644 --- a/src/opengl/qgl_x11egl.cpp +++ b/src/opengl/qgl_x11egl.cpp @@ -435,30 +435,30 @@ QGLTexture *QGLContextPrivate::bindTextureFromNativePixmap(QPixmap *pixmap, cons // If the pixmap doesn't already have a valid surface, try binding it via EGLImage // first, as going through EGLImage should be faster and better supported: -// if (!textureIsBound && haveEglImageTFP) { -// Q_ASSERT(eglCreateImageKHR); -// -// EGLImageKHR eglImage; -// -// EGLint attribs[] = { -// EGL_IMAGE_PRESERVED_KHR, EGL_TRUE, -// EGL_NONE -// }; -// eglImage = eglCreateImageKHR(QEgl::display(), EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR, -// (EGLClientBuffer)QEgl::nativePixmap(pixmap), attribs); -// -// QGLContext* ctx = q; -// glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, eglImage); -// -// GLint err = glGetError(); -// if (err == GL_NO_ERROR) -// textureIsBound = true; -// -// // Once the egl image is bound, the texture becomes a new sibling image and we can safely -// // destroy the EGLImage we created for the pixmap: -// if (eglImage != EGL_NO_IMAGE_KHR) -// eglDestroyImageKHR(QEgl::display(), eglImage); -// } + if (!textureIsBound && haveEglImageTFP) { + Q_ASSERT(eglCreateImageKHR); + + EGLImageKHR eglImage; + + EGLint attribs[] = { + EGL_IMAGE_PRESERVED_KHR, EGL_TRUE, + EGL_NONE + }; + eglImage = eglCreateImageKHR(QEgl::display(), EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR, + (EGLClientBuffer)QEgl::nativePixmap(pixmap), attribs); + + QGLContext* ctx = q; + glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, eglImage); + + GLint err = glGetError(); + if (err == GL_NO_ERROR) + textureIsBound = true; + + // Once the egl image is bound, the texture becomes a new sibling image and we can safely + // destroy the EGLImage we created for the pixmap: + if (eglImage != EGL_NO_IMAGE_KHR) + eglDestroyImageKHR(QEgl::display(), eglImage); + } if (!textureIsBound && haveTFP) { // Check to see if the surface is still valid -- cgit v0.12