summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Cooksey <thomas.cooksey@nokia.com>2010-03-01 15:53:17 (GMT)
committerTom Cooksey <thomas.cooksey@nokia.com>2010-03-02 08:24:26 (GMT)
commit9c1ff07b427765beb71755e964b017d8258b834e (patch)
tree6d29345397572b5f72d849d833d9f91e21af92a3
parentb2cbb880273ae6516d68be5b5f3f9b614c31ca79 (diff)
downloadQt-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
-rw-r--r--src/gui/egl/qegl.cpp8
-rw-r--r--src/gui/egl/qegl_p.h6
-rw-r--r--src/gui/egl/qegl_x11.cpp23
-rw-r--r--src/gui/image/qpixmap_x11.cpp4
-rw-r--r--src/gui/image/qpixmap_x11_p.h9
-rw-r--r--src/opengl/qgl_x11egl.cpp9
6 files changed, 39 insertions, 20 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;
diff --git a/src/gui/image/qpixmap_x11.cpp b/src/gui/image/qpixmap_x11.cpp
index b976376..5a882af 100644
--- a/src/gui/image/qpixmap_x11.cpp
+++ b/src/gui/image/qpixmap_x11.cpp
@@ -314,8 +314,8 @@ static int qt_pixmap_serial = 0;
int Q_GUI_EXPORT qt_x11_preferred_pixmap_depth = 0;
QX11PixmapData::QX11PixmapData(PixelType type)
- : QPixmapData(type, X11Class), hd(0),
- flags(Uninitialized), x11_mask(0), picture(0), mask_picture(0), hd2(0), gl_surface(0),
+ : QPixmapData(type, X11Class), gl_surface(0), hd(0),
+ flags(Uninitialized), x11_mask(0), picture(0), mask_picture(0), hd2(0),
share_mode(QPixmap::ImplicitlyShared), pengine(0)
{
}
diff --git a/src/gui/image/qpixmap_x11_p.h b/src/gui/image/qpixmap_x11_p.h
index 7bc586d..521a612 100644
--- a/src/gui/image/qpixmap_x11_p.h
+++ b/src/gui/image/qpixmap_x11_p.h
@@ -94,6 +94,11 @@ public:
static Qt::HANDLE createBitmapFromImage(const QImage &image);
+ Qt::HANDLE gl_surface;
+#ifndef QT_NO_XRENDER
+ void convertToARGB32(bool preserveContents = true);
+#endif
+
protected:
int metric(QPaintDevice::PaintDeviceMetric metric) const;
@@ -131,10 +136,6 @@ private:
Qt::HANDLE picture;
Qt::HANDLE mask_picture;
Qt::HANDLE hd2; // sorted in the default display depth
- Qt::HANDLE gl_surface;
-#ifndef QT_NO_XRENDER
- void convertToARGB32(bool preserveContents = true);
-#endif
QPixmap::ShareMode share_mode;
QX11PaintEngine *pengine;
diff --git a/src/opengl/qgl_x11egl.cpp b/src/opengl/qgl_x11egl.cpp
index 18a2ee5..bcde8c4 100644
--- a/src/opengl/qgl_x11egl.cpp
+++ b/src/opengl/qgl_x11egl.cpp
@@ -508,8 +508,13 @@ QGLTexture *QGLContextPrivate::bindTextureFromNativePixmap(QPixmapData* pd, cons
}
if (pixmapData->gl_surface == 0) {
- bool success = qt_createEGLSurfaceForPixmap(pixmapData, true);
- if (!success) {
+ EGLConfig config = QEgl::defaultConfig(QInternal::Pixmap,
+ QEgl::OpenGL,
+ hasAlpha ? QEgl::Translucent : QEgl::NoOptions);
+
+ QPixmap tmpPixmap(pixmapData); //###
+ pixmapData->gl_surface = (Qt::HANDLE)QEgl::createSurface(&tmpPixmap, config);
+ if (pixmapData->gl_surface == (Qt::HANDLE)EGL_NO_SURFACE) {
haveTFP = false;
return 0;
}