diff options
author | Jørgen Lind <jorgen.lind@nokia.com> | 2011-03-25 07:32:57 (GMT) |
---|---|---|
committer | Jørgen Lind <jorgen.lind@nokia.com> | 2011-03-25 07:34:10 (GMT) |
commit | 372539b350b8c48863d04e46438267210569768e (patch) | |
tree | bdfc65cd17e6aa7fc1041bb5c4f73b9dedc2e701 /src | |
parent | f55e9ff471a29eb4c8f0e1558bc5b0592686ddf2 (diff) | |
download | Qt-372539b350b8c48863d04e46438267210569768e.zip Qt-372539b350b8c48863d04e46438267210569768e.tar.gz Qt-372539b350b8c48863d04e46438267210569768e.tar.bz2 |
Lighthouse: Wayland: Fix the readback for the glContext in the egl
backend
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapeglcontext.cpp | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapeglcontext.cpp b/src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapeglcontext.cpp index e29ad97..32ba6de 100644 --- a/src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapeglcontext.cpp +++ b/src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapeglcontext.cpp @@ -3,11 +3,34 @@ #include "../../../eglconvenience/qeglconvenience.h" #include <QtOpenGL/QGLContext> +#include <QtOpenGL/private/qglextensions_p.h> #include "qwaylandshmsurface.h" #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); + } + } +} + QXPixmapReadbackGLContext::QXPixmapReadbackGLContext(QWaylandXPixmapEglIntegration *eglIntegration, QWaylandXPixmapWindow *window) : mEglIntegration(eglIntegration) , mWindow(window) @@ -65,6 +88,7 @@ void QXPixmapReadbackGLContext::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(); @@ -87,15 +111,18 @@ QPlatformWindowFormat QXPixmapReadbackGLContext::platformWindowFormat() const void QXPixmapReadbackGLContext::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()) mEglIntegration->waylandDisplay()->iterate(); - QSize size(mWindow->geometry().size()); delete mBuffer; if (mPixmap) XFreePixmap(mEglIntegration->xDisplay(),mPixmap); - if (mPixmapSurface != EGL_NO_SURFACE) - eglDestroySurface(mEglIntegration->eglDisplay(),mPixmapSurface); mBuffer = new QWaylandShmBuffer(mEglIntegration->waylandDisplay(),size,QImage::Format_ARGB32); mWindow->attach(mBuffer); |