summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTom Cooksey <thomas.cooksey@nokia.com>2010-04-15 10:48:56 (GMT)
committerTom Cooksey <thomas.cooksey@nokia.com>2010-04-15 10:58:43 (GMT)
commit794cbd5800a4428babc100528fd4fdba49557b6f (patch)
tree59ea1e2e422325eb20074d56ebf30f82bde26343 /src
parent4c472f1694aa9f35eda248f04decadbe0ef2dd75 (diff)
downloadQt-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')
-rw-r--r--src/gui/egl/qegl.cpp43
-rw-r--r--src/gui/egl/qegl_p.h18
-rw-r--r--src/opengl/qgl_x11egl.cpp8
-rw-r--r--src/openvg/qpixmapdata_vg.cpp12
4 files changed, 49 insertions, 32 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
diff --git a/src/opengl/qgl_x11egl.cpp b/src/opengl/qgl_x11egl.cpp
index af0100b..6f210ce 100644
--- a/src/opengl/qgl_x11egl.cpp
+++ b/src/opengl/qgl_x11egl.cpp
@@ -378,8 +378,6 @@ QGLTexture *QGLContextPrivate::bindTextureFromNativePixmap(QPixmap *pixmap, cons
// eglCreateImageKHR & eglDestroyImageKHR without support for pixmaps, so we must
// check we have the EGLImage from pixmap functionality.
if (QEgl::hasExtension("EGL_KHR_image") || QEgl::hasExtension("EGL_KHR_image_pixmap")) {
- Q_ASSERT(eglCreateImageKHR);
- Q_ASSERT(eglDestroyImageKHR);
// Being able to create an EGLImage from a native pixmap is also pretty useless
// without the ability to bind that EGLImage as a texture, which is provided by
@@ -436,15 +434,13 @@ 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,
+ eglImage = QEgl::eglCreateImageKHR(QEgl::display(), EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR,
(EGLClientBuffer)QEgl::nativePixmap(pixmap), attribs);
QGLContext* ctx = q;
@@ -457,7 +453,7 @@ QGLTexture *QGLContextPrivate::bindTextureFromNativePixmap(QPixmap *pixmap, cons
// 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);
+ QEgl::eglDestroyImageKHR(QEgl::display(), eglImage);
}
if (!textureIsBound && haveTFP) {
diff --git a/src/openvg/qpixmapdata_vg.cpp b/src/openvg/qpixmapdata_vg.cpp
index 168f06a..6258e0c 100644
--- a/src/openvg/qpixmapdata_vg.cpp
+++ b/src/openvg/qpixmapdata_vg.cpp
@@ -498,7 +498,7 @@ void QVGPixmapData::fromNativeType(void* pixmap, NativeType type)
}
const EGLint KEglImageAttribs[] = {EGL_IMAGE_PRESERVED_SYMBIAN, EGL_TRUE, EGL_NONE};
- EGLImageKHR eglImage = eglCreateImageKHR(QEgl::display(),
+ EGLImageKHR eglImage = QEgl::eglCreateImageKHR(QEgl::display(),
EGL_NO_CONTEXT,
EGL_NATIVE_PIXMAP_KHR,
(EGLClientBuffer)sgImage,
@@ -513,7 +513,7 @@ void QVGPixmapData::fromNativeType(void* pixmap, NativeType type)
vgImage = vgCreateEGLImageTargetKHR(eglImage);
if (vgGetError() != VG_NO_ERROR) {
cleanup();
- eglDestroyImageKHR(QEgl::display(), eglImage);
+ QEgl::eglDestroyImageKHR(QEgl::display(), eglImage);
driver.Close();
return;
}
@@ -527,7 +527,7 @@ void QVGPixmapData::fromNativeType(void* pixmap, NativeType type)
prevSize = QSize(w, h);
setSerialNumber(++qt_vg_pixmap_serial);
// release stuff
- eglDestroyImageKHR(QEgl::display(), eglImage);
+ QEgl::eglDestroyImageKHR(QEgl::display(), eglImage);
driver.Close();
#endif
} else if (type == QPixmapData::FbsBitmap) {
@@ -613,7 +613,7 @@ void* QVGPixmapData::toNativeType(NativeType type)
}
const EGLint KEglImageAttribs[] = {EGL_IMAGE_PRESERVED_SYMBIAN, EGL_TRUE, EGL_NONE};
- EGLImageKHR eglImage = eglCreateImageKHR(QEgl::display(),
+ EGLImageKHR eglImage = QEgl::eglCreateImageKHR(QEgl::display(),
EGL_NO_CONTEXT,
EGL_NATIVE_PIXMAP_KHR,
(EGLClientBuffer)sgImage,
@@ -626,7 +626,7 @@ void* QVGPixmapData::toNativeType(NativeType type)
VGImage dstVgImage = vgCreateEGLImageTargetKHR(eglImage);
if (vgGetError() != VG_NO_ERROR) {
- eglDestroyImageKHR(QEgl::display(), eglImage);
+ QEgl::eglDestroyImageKHR(QEgl::display(), eglImage);
sgImage->Close();
driver.Close();
return 0;
@@ -642,7 +642,7 @@ void* QVGPixmapData::toNativeType(NativeType type)
}
// release stuff
vgDestroyImage(dstVgImage);
- eglDestroyImageKHR(QEgl::display(), eglImage);
+ QEgl::eglDestroyImageKHR(QEgl::display(), eglImage);
driver.Close();
return reinterpret_cast<void*>(sgImage);
#endif