diff options
author | Jørgen Lind <jorgen.lind@nokia.com> | 2011-03-24 10:19:44 (GMT) |
---|---|---|
committer | Jørgen Lind <jorgen.lind@nokia.com> | 2011-03-24 10:20:33 (GMT) |
commit | cfd32d1f590fff2545932347d0ff6081a4a4477a (patch) | |
tree | be49512cb5024fda75052d0400b33be83f3a287b /src | |
parent | d7594cbb83f223ec4a56ba3d999412a1c0185937 (diff) | |
download | Qt-cfd32d1f590fff2545932347d0ff6081a4a4477a.zip Qt-cfd32d1f590fff2545932347d0ff6081a4a4477a.tar.gz Qt-cfd32d1f590fff2545932347d0ff6081a4a4477a.tar.bz2 |
Lighthouse: Wayland: Make QGLWidget work with the glx integration
Still missing same code for egl integration
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/platforms/wayland/gl_integration/xpixmap_glx/qwaylandxpixmapglxcontext.cpp | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/src/plugins/platforms/wayland/gl_integration/xpixmap_glx/qwaylandxpixmapglxcontext.cpp b/src/plugins/platforms/wayland/gl_integration/xpixmap_glx/qwaylandxpixmapglxcontext.cpp index c8b5fba..50bf4ee 100644 --- a/src/plugins/platforms/wayland/gl_integration/xpixmap_glx/qwaylandxpixmapglxcontext.cpp +++ b/src/plugins/platforms/wayland/gl_integration/xpixmap_glx/qwaylandxpixmapglxcontext.cpp @@ -5,6 +5,28 @@ #include <QtCore/QDebug> +static inline void qgl_byteSwapImage(QImage &img, GLenum pixel_type) +{ + const int width = img.width(); + const int height = img.height(); + + if (pixel_type == GL_UNSIGNED_INT_8_8_8_8_REV + || (pixel_type == GL_UNSIGNED_BYTE && QSysInfo::ByteOrder == QSysInfo::LittleEndian)) + { + for (int i = 0; i < height; ++i) { + uint *p = (uint *) img.scanLine(i); + for (int x = 0; x < width; ++x) + p[x] = ((p[x] << 16) & 0xff0000) | ((p[x] >> 16) & 0xff) | (p[x] & 0xff00ff00); + } + } else { + for (int i = 0; i < height; ++i) { + uint *p = (uint *) img.scanLine(i); + for (int x = 0; x < width; ++x) + p[x] = (p[x] << 8) | ((p[x] >> 24) & 0xff); + } + } +} + QWaylandXPixmapGLXContext::QWaylandXPixmapGLXContext(QWaylandXPixmapGLXIntegration *glxIntegration, QWaylandXPixmapGLXWindow *window) : QPlatformGLContext() , mGlxIntegration(glxIntegration) @@ -51,6 +73,7 @@ void QWaylandXPixmapGLXContext::swapBuffers() glReadPixels(0,0, size.width(), size.height(), GL_RGBA,GL_UNSIGNED_BYTE, pixels); img = img.mirrored(); + qgl_byteSwapImage(img,GL_UNSIGNED_INT_8_8_8_8_REV); constBits = img.bits(); const uchar *constDstBits = mBuffer->image()->bits(); @@ -74,15 +97,20 @@ QPlatformWindowFormat QWaylandXPixmapGLXContext::platformWindowFormat() const void QWaylandXPixmapGLXContext::geometryChanged() { + QSize size(mWindow->geometry().size()); + if (size.isEmpty()) { + //QGLWidget wants a context for a window without geometry + size = QSize(1,1); + } + while (mWindow->waitingForFrameSync()) mGlxIntegration->waylandDisplay()->iterate(); - QSize size(mWindow->geometry().size()); delete mBuffer; - if (mPixmap) + //XFreePixmap deletes the glxPixmap as well + if (mPixmap) { XFreePixmap(mGlxIntegration->xDisplay(),mPixmap); - if (mGlxPixmap) - glXDestroyPixmap(mGlxIntegration->xDisplay(),mGlxPixmap); + } mBuffer = new QWaylandShmBuffer(mGlxIntegration->waylandDisplay(),size,QImage::Format_ARGB32); mWindow->attach(mBuffer); |