QNX: Fix OpenGL autotest
On QNX grabbing the frame buffer returns the content of the back buffer. In order to execute the OpenGL tests properly a swapBuffers is executed before in order to be able to retrieve the content of the front buffer. The patch also documents this platform behavior. Change-Id: I7a501818ec6eea061f2f54f95854f68cb72e0534 Reviewed-by: James McDonnell <jmcdonnell@qnx.com> Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
This commit is contained in:
parent
30b334ffeb
commit
2c36469a16
@ -4083,6 +4083,11 @@ QPixmap QGLWidget::renderPixmap(int w, int h, bool useContext)
|
|||||||
Depending on your hardware, you can explicitly select which color
|
Depending on your hardware, you can explicitly select which color
|
||||||
buffer to grab with a glReadBuffer() call before calling this
|
buffer to grab with a glReadBuffer() call before calling this
|
||||||
function.
|
function.
|
||||||
|
|
||||||
|
On QNX the back buffer is not preserved when swapBuffers() is called. The back buffer
|
||||||
|
where this function reads from, might thus not contain the same content as the front buffer.
|
||||||
|
In order to retrieve what is currently visible on the screen, swapBuffers()
|
||||||
|
has to be executed prior to this function call.
|
||||||
*/
|
*/
|
||||||
QImage QGLWidget::grabFrameBuffer(bool withAlpha)
|
QImage QGLWidget::grabFrameBuffer(bool withAlpha)
|
||||||
{
|
{
|
||||||
|
@ -1114,6 +1114,9 @@ QGLFramebufferObjectFormat QGLFramebufferObject::format() const
|
|||||||
\fn QImage QGLFramebufferObject::toImage() const
|
\fn QImage QGLFramebufferObject::toImage() const
|
||||||
|
|
||||||
Returns the contents of this framebuffer object as a QImage.
|
Returns the contents of this framebuffer object as a QImage.
|
||||||
|
|
||||||
|
On QNX the back buffer is not preserved when a buffer swap occures. So this function
|
||||||
|
might return old content.
|
||||||
*/
|
*/
|
||||||
QImage QGLFramebufferObject::toImage() const
|
QImage QGLFramebufferObject::toImage() const
|
||||||
{
|
{
|
||||||
|
@ -1064,6 +1064,12 @@ void tst_QGL::glWidgetRendering()
|
|||||||
QVERIFY(w.beginOk);
|
QVERIFY(w.beginOk);
|
||||||
QVERIFY(w.engineType == QPaintEngine::OpenGL || w.engineType == QPaintEngine::OpenGL2);
|
QVERIFY(w.engineType == QPaintEngine::OpenGL || w.engineType == QPaintEngine::OpenGL2);
|
||||||
|
|
||||||
|
#if defined(Q_OS_QNX)
|
||||||
|
// glReadPixels reads from the back buffer. On QNX the buffer is not preserved
|
||||||
|
// after a buffer swap. This is why we have to swap the buffer explicitly before calling
|
||||||
|
// grabFrameBuffer to retrieve the content of the front buffer.
|
||||||
|
w.swapBuffers();
|
||||||
|
#endif
|
||||||
QImage fb = w.grabFrameBuffer(false);
|
QImage fb = w.grabFrameBuffer(false);
|
||||||
qt_opengl_check_test_pattern(fb);
|
qt_opengl_check_test_pattern(fb);
|
||||||
}
|
}
|
||||||
@ -1104,6 +1110,9 @@ void tst_QGL::glFBOSimpleRendering()
|
|||||||
// buffer is actually missing. But that's probably ok anyway.
|
// buffer is actually missing. But that's probably ok anyway.
|
||||||
void tst_QGL::glFBORendering()
|
void tst_QGL::glFBORendering()
|
||||||
{
|
{
|
||||||
|
#if defined(Q_OS_QNX)
|
||||||
|
QSKIP("Reading the QGLFramebufferObject is unsupported on this platform");
|
||||||
|
#endif
|
||||||
if (!QGLFramebufferObject::hasOpenGLFramebufferObjects())
|
if (!QGLFramebufferObject::hasOpenGLFramebufferObjects())
|
||||||
QSKIP("QGLFramebufferObject not supported on this platform");
|
QSKIP("QGLFramebufferObject not supported on this platform");
|
||||||
|
|
||||||
@ -1280,7 +1289,7 @@ protected:
|
|||||||
fboPainter.end();
|
fboPainter.end();
|
||||||
fboImage = fbo->toImage();
|
fboImage = fbo->toImage();
|
||||||
|
|
||||||
widgetPainter.fillRect(-1, -1, width()+2, width()+2, Qt::blue);
|
widgetPainter.fillRect(-1, -1, width()+2, height()+2, Qt::blue);
|
||||||
|
|
||||||
delete fbo;
|
delete fbo;
|
||||||
}
|
}
|
||||||
@ -1301,6 +1310,13 @@ void tst_QGL::glFBOUseInGLWidget()
|
|||||||
QVERIFY(w.widgetPainterBeginOk);
|
QVERIFY(w.widgetPainterBeginOk);
|
||||||
QVERIFY(w.fboPainterBeginOk);
|
QVERIFY(w.fboPainterBeginOk);
|
||||||
|
|
||||||
|
#if defined(Q_OS_QNX)
|
||||||
|
// glReadPixels reads from the back buffer. On QNX the buffer is not preserved
|
||||||
|
// after a buffer swap. This is why we have to swap the buffer explicitly before calling
|
||||||
|
// grabFrameBuffer to retrieve the content of the front buffer
|
||||||
|
w.swapBuffers();
|
||||||
|
#endif
|
||||||
|
|
||||||
QImage widgetFB = w.grabFrameBuffer(false);
|
QImage widgetFB = w.grabFrameBuffer(false);
|
||||||
QImage widgetReference(widgetFB.size(), widgetFB.format());
|
QImage widgetReference(widgetFB.size(), widgetFB.format());
|
||||||
widgetReference.fill(0xff0000ff);
|
widgetReference.fill(0xff0000ff);
|
||||||
@ -1691,6 +1707,12 @@ void tst_QGL::replaceClipping()
|
|||||||
glw.paint(&referencePainter);
|
glw.paint(&referencePainter);
|
||||||
referencePainter.end();
|
referencePainter.end();
|
||||||
|
|
||||||
|
#if defined(Q_OS_QNX)
|
||||||
|
// glReadPixels reads from the back buffer. On QNX the buffer is not preserved
|
||||||
|
// after a buffer swap. This is why we have to swap the buffer explicitly before calling
|
||||||
|
// grabFrameBuffer to retrieve the content of the front buffer
|
||||||
|
glw.swapBuffers();
|
||||||
|
#endif
|
||||||
const QImage widgetFB = glw.grabFrameBuffer(false).convertToFormat(QImage::Format_RGB32);
|
const QImage widgetFB = glw.grabFrameBuffer(false).convertToFormat(QImage::Format_RGB32);
|
||||||
|
|
||||||
// Sample pixels in a grid pattern which avoids false failures due to
|
// Sample pixels in a grid pattern which avoids false failures due to
|
||||||
@ -1802,6 +1824,12 @@ void tst_QGL::clipTest()
|
|||||||
glw.paint(&referencePainter);
|
glw.paint(&referencePainter);
|
||||||
referencePainter.end();
|
referencePainter.end();
|
||||||
|
|
||||||
|
#if defined(Q_OS_QNX)
|
||||||
|
// glReadPixels reads from the back buffer. On QNX the buffer is not preserved
|
||||||
|
// after a buffer swap. This is why we have to swap the buffer explicitly before calling
|
||||||
|
// grabFrameBuffer to retrieve the content of the front buffer
|
||||||
|
glw.swapBuffers();
|
||||||
|
#endif
|
||||||
const QImage widgetFB = glw.grabFrameBuffer(false).convertToFormat(QImage::Format_RGB32);
|
const QImage widgetFB = glw.grabFrameBuffer(false).convertToFormat(QImage::Format_RGB32);
|
||||||
|
|
||||||
// Sample pixels in a grid pattern which avoids false failures due to
|
// Sample pixels in a grid pattern which avoids false failures due to
|
||||||
|
Loading…
x
Reference in New Issue
Block a user