From f4a8e940eda1904ed2fba247c1d2752106ccc5c9 Mon Sep 17 00:00:00 2001 From: aavit Date: Mon, 29 Oct 2012 10:34:20 +0100 Subject: Qt5 updates to the QPainter lancelot autotest a) Use the new Qt5 OpenGL API for testing of GL painting b) Simplify: Use the higher-level QBaselineTest API instead of the low-level baselineprotocol API. Change-Id: Ib5f47f6fe68837dfdc8dc3a74638c5cb0b724614 Reviewed-by: aavit --- tests/manual/lance/main.cpp | 31 +++++++++++++++++++++++-------- tests/manual/lance/widgets.h | 4 +++- 2 files changed, 26 insertions(+), 9 deletions(-) (limited to 'tests/manual') diff --git a/tests/manual/lance/main.cpp b/tests/manual/lance/main.cpp index c44710620f..97197f0509 100644 --- a/tests/manual/lance/main.cpp +++ b/tests/manual/lance/main.cpp @@ -102,8 +102,8 @@ static void printHelp() " -imagemono Paints the files to a monochrome image\n" " -imagewidget same as image, but with interacion...\n" #ifndef QT_NO_OPENGL - " -opengl Paints the files to an OpenGL on screen\n" - " -pbuffer Paints the files to an OpenGL pbuffer\n" + " -opengl Paints the files to a QGLWidget (Qt4 style) on screen\n" + " -glbuffer Paints the files to a QOpenGLFrameBufferObject (Qt5 style) \n" #endif #ifdef USE_CUSTOM_DEVICE " -customdevice Paints the files to the custom paint device\n" @@ -289,8 +289,8 @@ int main(int argc, char **argv) #ifndef QT_NO_OPENGL else if (option == "opengl") type = OpenGLType; - else if (option == "pbuffer") - type = OpenGLPBufferType; + else if (option == "glbuffer") + type = OpenGLBufferType; #endif #ifdef USE_CUSTOM_DEVICE else if (option == "customdevice") @@ -424,16 +424,28 @@ int main(int argc, char **argv) } #ifndef QT_NO_OPENGL - case OpenGLPBufferType: + case OpenGLBufferType: { - QGLPixelBuffer pbuffer(QSize(width, height)); - QPainter pt(&pbuffer); + QWindow win; + win.setSurfaceType(QSurface::OpenGLSurface); + win.create(); + QOpenGLFramebufferObjectFormat fmt; + fmt.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil); + fmt.setSamples(4); + QOpenGLContext ctx; + ctx.create(); + ctx.makeCurrent(&win); + QOpenGLFramebufferObject fbo(width, height, fmt); + fbo.bind(); + QOpenGLPaintDevice pdev(width, height); + + QPainter pt(&pdev); pcmd.setPainter(&pt); pcmd.setFilePath(fileinfo.absolutePath()); pcmd.runCommands(); pt.end(); - QImage image = pbuffer.toImage(); + QImage image = fbo.toImage(); QLabel *label = createLabel(); label->setPixmap(QPixmap::fromImage(image)); @@ -456,8 +468,11 @@ int main(int argc, char **argv) } #else case OpenGLType: + case OpenGLBufferType: + { printf("OpenGL type not supported in this Qt build\n"); break; + } #endif #ifdef USE_CUSTOM_DEVICE case CustomDeviceType: diff --git a/tests/manual/lance/widgets.h b/tests/manual/lance/widgets.h index 3d2d92d56c..e5e21f4b35 100644 --- a/tests/manual/lance/widgets.h +++ b/tests/manual/lance/widgets.h @@ -231,11 +231,13 @@ public: } } } - +#if 0 + // ### TBD: Make this work with Qt5 if (m_render_view.isNull()) { m_render_view = QPixmap::grabWidget(this); m_render_view.save("renderView.png"); } +#endif } void paintBaselineView() { -- cgit v1.2.3