Clean up wayland-cgl-readback.
authorMorten Sorvig <morten.sorvig@nokia.com>
Wed, 29 Jun 2011 10:33:05 +0000 (12:33 +0200)
committerMorten Sorvig <morten.sorvig@nokia.com>
Fri, 1 Jul 2011 07:39:52 +0000 (09:39 +0200)
Read directly into the window buffer - looks like we
don't need to do any byte swapping. Disable the frame
sync, since this causes a deadlock with the compositor.

src/plugins/platforms/wayland/gl_integration/readback_cgl/qwaylandreadbackcglcontext.cpp

index 7f21f2e..d0712a3 100644 (file)
@@ -49,6 +49,7 @@
 
 #include <OpenGL/OpenGL.h>
 #include <OpenGL/glext.h>
+#include <OpenGL/glu.h>
 
 #include <QtPlatformSupport/private/cglconvenience_p.h>
 
@@ -87,26 +88,15 @@ void QWaylandReadbackCGLContext::swapBuffers(QPlatformSurface *surface)
     CGLFlushDrawable(m_glContext);
 
     QWaylandReadbackCGLWindow *window = static_cast<QWaylandReadbackCGLWindow *>(surface);
-
     QSize size = window->geometry().size();
 
-    QImage img(size,QImage::Format_ARGB32);
-    img.fill(Qt::red);
-    const uchar *constBits = img.bits();
-    void *pixels = const_cast<uchar *>(constBits);
-
-//    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 = window->buffer();
-    uchar *dstBits = const_cast<uchar *>(constDstBits);
-    memcpy(dstBits,constBits,(img.width()*4) * img.height());
+    uchar *dstBits = const_cast<uchar *>(window->buffer());
+    glReadPixels(0,0, size.width(), size.height(), GL_BGRA,GL_UNSIGNED_BYTE, dstBits);
 
     window->damage(QRect(QPoint(0,0),size));
-    window->waitForFrameSync();
+
+    // ### Should sync here but this call deadlocks with the server.
+    //window->waitForFrameSync();
 }
 
 void (*QWaylandReadbackCGLContext::getProcAddress(const QByteArray &procName)) ()