summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorTom Cooksey <thomas.cooksey@nokia.com>2010-03-22 09:48:39 (GMT)
committerTom Cooksey <thomas.cooksey@nokia.com>2010-03-26 12:32:53 (GMT)
commit75bb84ac0e6f17446d87a34ae8a644abff6009af (patch)
tree0aff2d7bd0d9f11042db103323ee72537cc41ae7 /src/gui
parentfa40e6fd8b719e2edfdbde94ac70431c68e92449 (diff)
downloadQt-75bb84ac0e6f17446d87a34ae8a644abff6009af.zip
Qt-75bb84ac0e6f17446d87a34ae8a644abff6009af.tar.gz
Qt-75bb84ac0e6f17446d87a34ae8a644abff6009af.tar.bz2
Implement Texture-From-Pixmap using EGLImage extensions on X11/EGL
There's lots of EGLImage extensions, split between EGL and client rendering APIs like OpenGL ES & OpenVG. To implement texture-from- pixmap using EGLImage, both EGL extensions and OpenGL ES extensions are needed. This patch resolves the EGL extension function pointers after the display is initialized in QEgl::display(). These are then exported from QtGui so they can be used in QtOpenGL. The OpenGL ES extension function pointers are resolved using the usual qglextensions.cpp mechanism. Using EGLImage seems to remove a fixed ~10 millisecond overhead per pixmap bind when compared to using EGLSurface. Exact results per bind for 100 QPixmaps are: 8x8 Pixmap: 12 -> 1.71 msecs (EGLSurface -> EGLImage) 64x64 Pixmap: 11.6 -> 1.83 msecs (EGLSurface -> EGLImage) 128x128 Pixmap: 12.8 -> 2.74 msecs (EGLSurface -> EGLImage) 256x256 Pixmap: 16 -> 6.20 msecs (EGLSurface -> EGLImage) Reviewed-By: Trond
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/egl/qegl.cpp9
-rw-r--r--src/gui/egl/qegl_p.h24
2 files changed, 31 insertions, 2 deletions
diff --git a/src/gui/egl/qegl.cpp b/src/gui/egl/qegl.cpp
index b870523..507fab3 100644
--- a/src/gui/egl/qegl.cpp
+++ b/src/gui/egl/qegl.cpp
@@ -528,6 +528,9 @@ QEglProperties QEglContext::configProperties() const
return QEglProperties(config());
}
+_eglCreateImageKHR eglCreateImageKHR = 0;
+_eglDestroyImageKHR eglDestroyImageKHR = 0;
+
EGLDisplay QEgl::display()
{
static EGLDisplay dpy = EGL_NO_DISPLAY;
@@ -549,6 +552,12 @@ EGLDisplay QEgl::display()
qWarning() << "QEgl::display(): Cannot initialize EGL display:" << QEgl::errorString();
return EGL_NO_DISPLAY;
}
+
+ // Resolve the egl extension function pointers:
+ if (QEgl::hasExtension("EGL_KHR_image") || QEgl::hasExtension("EGL_KHR_image_base")) {
+ eglCreateImageKHR = (_eglCreateImageKHR) eglGetProcAddress("eglCreateImageKHR");
+ eglDestroyImageKHR = (_eglDestroyImageKHR) eglGetProcAddress("eglDestroyImageKHR");
+ }
}
return dpy;
diff --git a/src/gui/egl/qegl_p.h b/src/gui/egl/qegl_p.h
index 7dad9fe..b570329 100644
--- a/src/gui/egl/qegl_p.h
+++ b/src/gui/egl/qegl_p.h
@@ -100,13 +100,34 @@ typedef NativeDisplayType EGLNativeDisplayType;
QT_END_INCLUDE_NAMESPACE
#include <QtGui/qpaintdevice.h>
-
#include <QFlags>
QT_BEGIN_NAMESPACE
#define QEGL_NO_CONFIG ((EGLConfig)-1)
+#ifndef EGLAPIENTRY
+#define EGLAPIENTRY
+#endif
+
+#if !defined(EGL_KHR_image) || !defined(EGL_KHR_image_base)
+
+typedef void *EGLImageKHR;
+#define EGL_NO_IMAGE_KHR ((EGLImageKHR)0)
+#define EGL_IMAGE_PRESERVED_KHR 0x30D2
+
+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)
+
+#if !defined(EGL_KHR_image) || !defined(EGL_KHR_image_pixmap)
+#define EGL_NATIVE_PIXMAP_KHR 0x30B0
+#endif
class QEglProperties;
@@ -132,7 +153,6 @@ namespace QEgl {
};
Q_DECLARE_FLAGS(ConfigOptions, ConfigOption);
-
// Most of the time we use the same config for things like widgets & pixmaps, so rather than
// go through the eglChooseConfig loop every time, we use defaultConfig, which will return
// the config for a particular device/api/option combo. This function assumes that once a