diff options
author | Jørgen Lind <jorgen.lind@nokia.com> | 2010-04-21 12:22:24 (GMT) |
---|---|---|
committer | Jørgen Lind <jorgen.lind@nokia.com> | 2010-04-21 12:22:24 (GMT) |
commit | 51dca5f8afc3aa619a3bb62858db78a85cc3ecef (patch) | |
tree | dfc1fb65b6a8e5e429f1701992548f8a0425decb /src/gui/egl | |
parent | 6f5ad5dcab8e6f702894c4fa5c016d9837375626 (diff) | |
parent | c74dac2a0ef5d1b428c4da4e48fab05f9886233a (diff) | |
download | Qt-51dca5f8afc3aa619a3bb62858db78a85cc3ecef.zip Qt-51dca5f8afc3aa619a3bb62858db78a85cc3ecef.tar.gz Qt-51dca5f8afc3aa619a3bb62858db78a85cc3ecef.tar.bz2 |
Merge remote branch 'origin/4.7' into lighthouse
Conflicts:
configure
src/gui/kernel/qapplication.cpp
src/gui/painting/qbackingstore.cpp
src/opengl/qgl.cpp
src/opengl/qgl_p.h
src/plugins/plugins.pro
tests/auto/declarative/qdeclarativedom/data/importlib/sublib/qmldir
tools/tools.pro
Diffstat (limited to 'src/gui/egl')
-rw-r--r-- | src/gui/egl/qegl.cpp | 107 | ||||
-rw-r--r-- | src/gui/egl/qegl_p.h | 51 | ||||
-rw-r--r-- | src/gui/egl/qegl_x11.cpp | 85 | ||||
-rw-r--r-- | src/gui/egl/qeglcontext_p.h | 6 | ||||
-rw-r--r-- | src/gui/egl/qeglproperties.cpp | 44 | ||||
-rw-r--r-- | src/gui/egl/qeglproperties_p.h | 2 |
6 files changed, 177 insertions, 118 deletions
diff --git a/src/gui/egl/qegl.cpp b/src/gui/egl/qegl.cpp index 407b524..39d245e 100644 --- a/src/gui/egl/qegl.cpp +++ b/src/gui/egl/qegl.cpp @@ -326,10 +326,17 @@ EGLSurface QEglContext::createSurface(QPaintDevice* device, const QEglProperties bool QEglContext::createContext(QEglContext *shareContext, const QEglProperties *properties) { // We need to select the correct API before calling eglCreateContext(). +#ifdef QT_OPENGL_ES #ifdef EGL_OPENGL_ES_API if (apiType == QEgl::OpenGL) eglBindAPI(EGL_OPENGL_ES_API); #endif +#else +#ifdef EGL_OPENGL_API + if (apiType == QEgl::OpenGL) + eglBindAPI(EGL_OPENGL_API); +#endif +#endif //defined(QT_OPENGL_ES) #ifdef EGL_OPENVG_API if (apiType == QEgl::OpenVG) eglBindAPI(EGL_OPENVG_API); @@ -339,7 +346,7 @@ bool QEglContext::createContext(QEglContext *shareContext, const QEglProperties QEglProperties contextProps; if (properties) contextProps = *properties; -#if defined(QT_OPENGL_ES_2) +#ifdef QT_OPENGL_ES_2 if (apiType == QEgl::OpenGL) contextProps.setValue(EGL_CONTEXT_CLIENT_VERSION, 2); #endif @@ -477,42 +484,6 @@ bool QEglContext::swapBuffers(EGLSurface surface) return ok; } -// Wait for native rendering operations to complete before starting -// to use OpenGL/OpenVG operations. -void QEglContext::waitNative() -{ -#ifdef EGL_CORE_NATIVE_ENGINE - eglWaitNative(EGL_CORE_NATIVE_ENGINE); -#endif -} - -// Wait for client OpenGL/OpenVG operations to complete before -// using native rendering operations. -void QEglContext::waitClient() -{ -#ifdef EGL_OPENGL_ES_API - if (apiType == QEgl::OpenGL) { - eglBindAPI(EGL_OPENGL_ES_API); - eglWaitClient(); - } -#else - if (apiType == QEgl::OpenGL) - eglWaitGL(); -#endif -#ifdef EGL_OPENVG_API - if (apiType == QEgl::OpenVG) { - eglBindAPI(EGL_OPENVG_API); - eglWaitClient(); - } -#endif -} - -// Query the value of a configuration attribute. -bool QEglContext::configAttrib(int name, EGLint *value) const -{ - return eglGetConfigAttrib(QEgl::display(), cfg, name, value); -} - int QEglContext::configAttrib(int name) const { EGLint value; @@ -523,10 +494,13 @@ int QEglContext::configAttrib(int name) const return EGL_DONT_CARE; } -QEglProperties QEglContext::configProperties() const -{ - return QEglProperties(config()); -} +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() { @@ -549,11 +523,46 @@ EGLDisplay QEgl::display() qWarning() << "QEgl::display(): Cannot initialize EGL display:" << QEgl::errorString(); return EGL_NO_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")) { + qt_eglCreateImageKHR = (_eglCreateImageKHR) eglGetProcAddress("eglCreateImageKHR"); + qt_eglDestroyImageKHR = (_eglDestroyImageKHR) eglGetProcAddress("eglDestroyImageKHR"); + } +#endif } 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) { @@ -622,22 +631,6 @@ QString QEgl::errorString(EGLint code) } } -QString QEgl::errorString() -{ - return errorString(error()); -} - -void QEgl::clearError() -{ - eglGetError(); -} - -EGLint QEgl::error() -{ - return eglGetError(); -} - - // Dump all of the EGL configurations supported by the system. void QEgl::dumpAllConfigs() { diff --git a/src/gui/egl/qegl_p.h b/src/gui/egl/qegl_p.h index 7dad9fe..83bdb5e 100644 --- a/src/gui/egl/qegl_p.h +++ b/src/gui/egl/qegl_p.h @@ -100,13 +100,52 @@ 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 + +// Try to get some info to debug the symbian build failues: +#ifdef Q_OS_SYMBIAN + +#ifdef EGL_KHR_image +#warning "EGL_KHR_image is defined" +#else +#warning "EGL_KHR_image is NOT defined" +#endif + +#ifdef EGL_KHR_image_base +#warning "EGL_KHR_image_base is defined" +#else +#warning "EGL_KHR_image_base is NOT defined" +#endif + +#ifdef EGL_EGLEXT_PROTOTYPES +#warning "EGL_EGLEXT_PROTOTYPES is defined" +#else +#warning "EGL_EGLEXT_PROTOTYPES NOT not defined" +#endif + +#endif + + +// Declare/define the bits of EGL_KHR_image_base we need: +#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 +#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 class QEglProperties; @@ -132,7 +171,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 @@ -144,10 +182,7 @@ namespace QEgl { Q_GUI_EXPORT void dumpAllConfigs(); - Q_GUI_EXPORT void clearError(); - Q_GUI_EXPORT EGLint error(); - Q_GUI_EXPORT QString errorString(EGLint code); - Q_GUI_EXPORT QString errorString(); + Q_GUI_EXPORT QString errorString(EGLint code = eglGetError()); Q_GUI_EXPORT QString extensions(); Q_GUI_EXPORT bool hasExtension(const char* extensionName); @@ -158,6 +193,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/gui/egl/qegl_x11.cpp b/src/gui/egl/qegl_x11.cpp index 91423c8..cb8dcda 100644 --- a/src/gui/egl/qegl_x11.cpp +++ b/src/gui/egl/qegl_x11.cpp @@ -147,9 +147,6 @@ VisualID QEgl::getCompatibleVisualId(EGLConfig config) EGLint configAlphaSize = 0; eglGetConfigAttrib(display(), config, EGL_ALPHA_SIZE, &configAlphaSize); - eglGetConfigAttrib(display(), config, EGL_BUFFER_SIZE, &eglValue); - int configBitDepth = eglValue; - eglGetConfigAttrib(display(), config, EGL_CONFIG_ID, &eglValue); int configId = eglValue; @@ -166,27 +163,57 @@ VisualID QEgl::getCompatibleVisualId(EGLConfig config) int matchingCount = 0; chosenVisualInfo = XGetVisualInfo(X11->display, VisualIDMask, &visualInfoTemplate, &matchingCount); if (chosenVisualInfo) { - if (configBitDepth == chosenVisualInfo->depth) { + int visualRedSize = countBits(chosenVisualInfo->red_mask); + int visualGreenSize = countBits(chosenVisualInfo->green_mask); + int visualBlueSize = countBits(chosenVisualInfo->blue_mask); + int visualAlphaSize = -1; // Need XRender to tell us the alpha channel size + #if !defined(QT_NO_XRENDER) + if (X11->use_xrender) { // If we have XRender, actually check the visual supplied by EGL is ARGB - if (configAlphaSize > 0) { - XRenderPictFormat *format; - format = XRenderFindVisualFormat(X11->display, chosenVisualInfo->visual); - if (!format || (format->type != PictTypeDirect) || (!format->direct.alphaMask)) { - qWarning("Warning: EGL suggested using X visual ID %d for config %d, but this is not ARGB", - (int)visualId, configId); - visualId = 0; - } - } + XRenderPictFormat *format; + format = XRenderFindVisualFormat(X11->display, chosenVisualInfo->visual); + if (format && (format->type == PictTypeDirect)) + visualAlphaSize = countBits(format->direct.alphaMask); + } #endif - } else { - qWarning("Warning: EGL suggested using X visual ID %d (%d bpp) for config %d (%d bpp), but the depths do not match!", - (int)visualId, chosenVisualInfo->depth, configId, configBitDepth); + + bool visualMatchesConfig = false; + if ( visualRedSize == configRedSize && + visualGreenSize == configGreenSize && + visualBlueSize == configBlueSize ) + { + // We need XRender to check the alpha channel size of the visual. If we don't have + // the alpha size, we don't check it against the EGL config's alpha size. + if (visualAlphaSize >= 0) + visualMatchesConfig = visualAlphaSize == configAlphaSize; + else + visualMatchesConfig = true; + } + + if (!visualMatchesConfig) { + if (visualAlphaSize >= 0) { + qWarning("Warning: EGL suggested using X Visual ID %d (ARGB%d%d%d%d) for EGL config %d (ARGB%d%d%d%d), but this is incompatable", + (int)visualId, visualAlphaSize, visualRedSize, visualGreenSize, visualBlueSize, + configId, configAlphaSize, configRedSize, configGreenSize, configBlueSize); + } else { + qWarning("Warning: EGL suggested using X Visual ID %d (RGB%d%d%d) for EGL config %d (RGB%d%d%d), but this is incompatable", + (int)visualId, visualRedSize, visualGreenSize, visualBlueSize, + configId, configRedSize, configGreenSize, configBlueSize); + } visualId = 0; } + } else { + qWarning("Warning: EGL suggested using X Visual ID %d for EGL config %d, but that isn't a valid ID", + (int)visualId, configId); + visualId = 0; } XFree(chosenVisualInfo); } +#ifdef QT_DEBUG_X11_VISUAL_SELECTION + else + qDebug("EGL did not suggest a VisualID (EGL_NATIVE_VISUAL_ID was zero) for EGLConfig %d", configId); +#endif if (visualId) { #ifdef QT_DEBUG_X11_VISUAL_SELECTION @@ -201,17 +228,16 @@ VisualID QEgl::getCompatibleVisualId(EGLConfig config) // If EGL didn't give us a valid visual ID, try XRender #if !defined(QT_NO_XRENDER) - if (!visualId) { + if (!visualId && X11->use_xrender) { XVisualInfo visualInfoTemplate; memset(&visualInfoTemplate, 0, sizeof(XVisualInfo)); - visualInfoTemplate.depth = configBitDepth; visualInfoTemplate.c_class = TrueColor; XVisualInfo *matchingVisuals; int matchingCount = 0; matchingVisuals = XGetVisualInfo(X11->display, - VisualDepthMask|VisualClassMask, + VisualClassMask, &visualInfoTemplate, &matchingCount); @@ -242,23 +268,36 @@ VisualID QEgl::getCompatibleVisualId(EGLConfig config) # endif // QT_DEBUG_X11_VISUAL_SELECTION return visualId; } +# ifdef QT_DEBUG_X11_VISUAL_SELECTION + else + qDebug("Failed to find an XVisual which matches EGL config %d using XRender", configId); +# endif // QT_DEBUG_X11_VISUAL_SELECTION + #endif //!defined(QT_NO_XRENDER) // Finally, if XRender also failed to find a visual (or isn't present), try to - // use XGetVisualInfo and only use the bit depth to match on: + // use XGetVisualInfo and only use the bit depths to match on: if (!visualId) { XVisualInfo visualInfoTemplate; memset(&visualInfoTemplate, 0, sizeof(XVisualInfo)); - - visualInfoTemplate.depth = configBitDepth; - XVisualInfo *matchingVisuals; int matchingCount = 0; + + visualInfoTemplate.depth = configRedSize + configGreenSize + configBlueSize + configAlphaSize; matchingVisuals = XGetVisualInfo(X11->display, VisualDepthMask, &visualInfoTemplate, &matchingCount); + if (!matchingVisuals) { + // Try again without taking the alpha channel into account: + visualInfoTemplate.depth = configRedSize + configGreenSize + configBlueSize; + matchingVisuals = XGetVisualInfo(X11->display, + VisualDepthMask, + &visualInfoTemplate, + &matchingCount); + } + if (matchingVisuals) { visualId = matchingVisuals[0].visualid; XFree(matchingVisuals); diff --git a/src/gui/egl/qeglcontext_p.h b/src/gui/egl/qeglcontext_p.h index 7eec7eb..ccde00d 100644 --- a/src/gui/egl/qeglcontext_p.h +++ b/src/gui/egl/qeglcontext_p.h @@ -85,10 +85,6 @@ public: bool lazyDoneCurrent(); bool swapBuffers(EGLSurface surface); - void waitNative(); - void waitClient(); - - bool configAttrib(int name, EGLint *value) const; int configAttrib(int name) const; EGLContext context() const { return ctx; } @@ -99,8 +95,6 @@ public: EGLConfig config() const { return cfg; } void setConfig(EGLConfig config) { cfg = config; } - QEglProperties configProperties() const; - private: QEgl::API apiType; EGLContext ctx; diff --git a/src/gui/egl/qeglproperties.cpp b/src/gui/egl/qeglproperties.cpp index b5d3103..3638de5 100644 --- a/src/gui/egl/qeglproperties.cpp +++ b/src/gui/egl/qeglproperties.cpp @@ -80,19 +80,19 @@ int QEglProperties::value(int name) const case EGL_GREEN_SIZE: return 0; case EGL_BLUE_SIZE: return 0; case EGL_ALPHA_SIZE: return 0; -#if defined(EGL_LUMINANCE_SIZE) +#ifdef EGL_LUMINANCE_SIZE case EGL_LUMINANCE_SIZE: return 0; #endif -#if defined(EGL_ALPHA_MASK_SIZE) +#ifdef EGL_ALPHA_MASK_SIZE case EGL_ALPHA_MASK_SIZE: return 0; #endif -#if defined(EGL_BIND_TO_TEXTURE_RGB) +#ifdef EGL_BIND_TO_TEXTURE_RGB case EGL_BIND_TO_TEXTURE_RGB: return EGL_DONT_CARE; #endif -#if defined(EGL_BIND_TO_TEXTURE_RGBA) +#ifdef EGL_BIND_TO_TEXTURE_RGBA case EGL_BIND_TO_TEXTURE_RGBA: return EGL_DONT_CARE; #endif -#if defined(EGL_COLOR_BUFFER_TYPE) +#ifdef EGL_COLOR_BUFFER_TYPE case EGL_COLOR_BUFFER_TYPE: return EGL_RGB_BUFFER; #endif case EGL_CONFIG_CAVEAT: return EGL_DONT_CARE; @@ -103,7 +103,7 @@ int QEglProperties::value(int name) const case EGL_NATIVE_VISUAL_TYPE: return EGL_DONT_CARE; case EGL_MAX_SWAP_INTERVAL: return EGL_DONT_CARE; case EGL_MIN_SWAP_INTERVAL: return EGL_DONT_CARE; -#if defined(EGL_RENDERABLE_TYPE) +#ifdef EGL_RENDERABLE_TYPE case EGL_RENDERABLE_TYPE: return EGL_OPENGL_ES_BIT; #endif case EGL_SAMPLE_BUFFERS: return 0; @@ -115,7 +115,7 @@ int QEglProperties::value(int name) const case EGL_TRANSPARENT_GREEN_VALUE: return EGL_DONT_CARE; case EGL_TRANSPARENT_BLUE_VALUE: return EGL_DONT_CARE; -#if defined(EGL_VERSION_1_3) +#ifdef EGL_VERSION_1_3 case EGL_CONFORMANT: return 0; case EGL_MATCH_NATIVE_PIXMAP: return EGL_NONE; #endif @@ -215,15 +215,18 @@ void QEglProperties::setPixelFormat(QImage::Format pixelFormat) void QEglProperties::setRenderableType(QEgl::API api) { -#if defined(EGL_RENDERABLE_TYPE) +#ifdef EGL_RENDERABLE_TYPE #if defined(QT_OPENGL_ES_2) if (api == QEgl::OpenGL) setValue(EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT); #elif defined(QT_OPENGL_ES) if (api == QEgl::OpenGL) setValue(EGL_RENDERABLE_TYPE, EGL_OPENGL_ES_BIT); +#elif defined(EGL_OPENGL_BIT) + if (api == QEgl::OpenGL) + setValue(EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT); #endif -#if defined(EGL_OPENVG_BIT) +#ifdef EGL_OPENVG_BIT if (api == QEgl::OpenVG) setValue(EGL_RENDERABLE_TYPE, EGL_OPENVG_BIT); #endif @@ -238,6 +241,9 @@ void QEglProperties::setRenderableType(QEgl::API api) // reductions in complexity are possible. bool QEglProperties::reduceConfiguration() { + if (value(EGL_SWAP_BEHAVIOR) != EGL_DONT_CARE) + removeValue(EGL_SWAP_BEHAVIOR); + #ifdef EGL_VG_ALPHA_FORMAT_PRE_BIT // For OpenVG, we sometimes try to create a surface using a pre-multiplied format. If we can't // find a config which supports pre-multiplied formats, remove the flag on the surface type: @@ -272,7 +278,7 @@ bool QEglProperties::reduceConfiguration() return true; if (removeValue(EGL_DEPTH_SIZE)) return true; -#if defined(EGL_BIND_TO_TEXTURE_RGB) +#ifdef EGL_BIND_TO_TEXTURE_RGB if (removeValue(EGL_BIND_TO_TEXTURE_RGB)) return true; #endif @@ -289,20 +295,6 @@ static void addTag(QString& str, const QString& tag) str += tag; } -void QEglProperties::dumpAllConfigs() -{ - EGLint count = 0; - eglGetConfigs(QEgl::display(), 0, 0, &count); - if (count < 1) - return; - - EGLConfig *configs = new EGLConfig [count]; - eglGetConfigs(QEgl::display(), configs, count, &count); - for (EGLint index = 0; index < count; ++index) - qWarning() << QEglProperties(configs[index]).toString(); - delete [] configs; -} - // Convert a property list to a string suitable for debug output. QString QEglProperties::toString() const { @@ -327,6 +319,10 @@ QString QEglProperties::toString() const if ((val & EGL_OPENGL_ES2_BIT) != 0) types += QLatin1String("es2"); #endif +#ifdef EGL_OPENGL_BIT + if ((val & EGL_OPENGL_BIT) != 0) + types += QLatin1String("gl"); +#endif if ((val & EGL_OPENVG_BIT) != 0) types += QLatin1String("vg"); if ((val & ~7) != 0) diff --git a/src/gui/egl/qeglproperties_p.h b/src/gui/egl/qeglproperties_p.h index eebcf72..b1f9642 100644 --- a/src/gui/egl/qeglproperties_p.h +++ b/src/gui/egl/qeglproperties_p.h @@ -90,8 +90,6 @@ public: QString toString() const; - static void dumpAllConfigs(); - private: QVarLengthArray<int> props; }; |