diff options
author | Tom Cooksey <thomas.cooksey@nokia.com> | 2010-03-01 15:53:17 (GMT) |
---|---|---|
committer | Tom Cooksey <thomas.cooksey@nokia.com> | 2010-03-02 08:24:26 (GMT) |
commit | 9c1ff07b427765beb71755e964b017d8258b834e (patch) | |
tree | 6d29345397572b5f72d849d833d9f91e21af92a3 /src/gui/egl | |
parent | b2cbb880273ae6516d68be5b5f3f9b614c31ca79 (diff) | |
download | Qt-9c1ff07b427765beb71755e964b017d8258b834e.zip Qt-9c1ff07b427765beb71755e964b017d8258b834e.tar.gz Qt-9c1ff07b427765beb71755e964b017d8258b834e.tar.bz2 |
Make bindTextureFromNativePixmap use new QEgl APIs
The old qt_chooseEGLConfigForPixmap & qt_createEGLSurfaceForPixmap
code will remain until QX11GLPixmapData can be re-written properly.
Reviewed-By: TrustMe
Diffstat (limited to 'src/gui/egl')
-rw-r--r-- | src/gui/egl/qegl.cpp | 8 | ||||
-rw-r--r-- | src/gui/egl/qegl_p.h | 6 | ||||
-rw-r--r-- | src/gui/egl/qegl_x11.cpp | 23 |
3 files changed, 25 insertions, 12 deletions
diff --git a/src/gui/egl/qegl.cpp b/src/gui/egl/qegl.cpp index e2002ed..1bfba10 100644 --- a/src/gui/egl/qegl.cpp +++ b/src/gui/egl/qegl.cpp @@ -88,10 +88,8 @@ bool QEglContext::isCurrent() const return current; } -EGLConfig QEgl::defaultConfig(QPaintDevice* device, API api, ConfigOptions options) +EGLConfig QEgl::defaultConfig(int devType, API api, ConfigOptions options) { - int devType = device->devType(); - if ( (devType != QInternal::Pixmap) && ((options & Renderable) == 0)) qWarning("QEgl::defaultConfig() - Only configs for pixmaps make sense to be read-only!"); @@ -243,8 +241,8 @@ EGLConfig QEgl::defaultConfig(QPaintDevice* device, API api, ConfigOptions optio #endif } - // Finally, set the color format based on the device: - configAttribs.setPaintDeviceFormat(device); + if (options & Translucent) + configAttribs.setValue(EGL_ALPHA_SIZE, 1); *targetConfig = chooseConfig(&configAttribs, QEgl::BestPixelFormat); return *targetConfig; diff --git a/src/gui/egl/qegl_p.h b/src/gui/egl/qegl_p.h index 7f753d0..aa89772 100644 --- a/src/gui/egl/qegl_p.h +++ b/src/gui/egl/qegl_p.h @@ -116,10 +116,8 @@ namespace QEgl { enum ConfigOptions { - Opaque = 0x00, + NoOptions = 0, Translucent = 0x01, - - ReadOnly = 0x00, Renderable = 0x02 // Config will be compatable with the paint engines (VG or GL) }; @@ -127,7 +125,7 @@ namespace QEgl { // 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 // config is chosen for a particular combo, it's safe to always use that combo. - Q_GUI_EXPORT EGLConfig defaultConfig(QPaintDevice* device, API api, ConfigOptions options); + Q_GUI_EXPORT EGLConfig defaultConfig(int devType, API api, ConfigOptions options); Q_GUI_EXPORT EGLConfig chooseConfig(const QEglProperties* configAttribs, QEgl::PixelFormatMatch match = QEgl::ExactPixelFormat); Q_GUI_EXPORT EGLSurface createSurface(QPaintDevice *device, EGLConfig cfg, const QEglProperties *surfaceAttribs = 0); diff --git a/src/gui/egl/qegl_x11.cpp b/src/gui/egl/qegl_x11.cpp index b710889..a4bfcac 100644 --- a/src/gui/egl/qegl_x11.cpp +++ b/src/gui/egl/qegl_x11.cpp @@ -361,9 +361,26 @@ EGLSurface QEgl::createSurface(QPaintDevice *device, EGLConfig config, const QEg } if (x11PixmapData) { - VisualID currentVisualId = XVisualIDFromVisual((Visual*)qt_x11Info(device)->visual()); - if (visualId != currentVisualId) - qWarning("Error: The QPixmap's visual does not match the EGLConfig's visual!"); + // X11 Pixmaps are only created with a depth, so that's all we need to check + EGLint configDepth; + eglGetConfigAttrib(QEgl::display(), config, EGL_BUFFER_SIZE , &configDepth); + if (x11PixmapData->depth() != configDepth) { + // The bit depths are wrong which means the EGLConfig isn't compatable with + // this pixmap. So we need to replace the pixmap's existing data with a new + // one which is created with the correct depth: + +#ifndef QT_NO_XRENDER + if (configDepth == 32) { + qWarning("Warning: EGLConfig's depth (32) != pixmap's depth (%d), converting to ARGB32", + x11PixmapData->depth()); + x11PixmapData->convertToARGB32(true); + } else +#endif + { + qWarning("Warning: EGLConfig's depth (%d) != pixmap's depth (%d)", + configDepth, x11PixmapData->depth()); + } + } QEglProperties surfaceAttribs; |