summaryrefslogtreecommitdiffstats
path: root/tests/auto/other/lancelot/paintcommands.cpp
diff options
context:
space:
mode:
authoraavit <eirik.aavitsland@digia.com>2012-10-29 10:34:20 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-11-09 16:07:44 +0100
commitf4a8e940eda1904ed2fba247c1d2752106ccc5c9 (patch)
tree9121c2b03d70591c1345379a3dad75298df31923 /tests/auto/other/lancelot/paintcommands.cpp
parent6dffbccbf3045d928ffcc3af0d2c659c1a3b8b1f (diff)
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 <eirik.aavitsland@digia.com>
Diffstat (limited to 'tests/auto/other/lancelot/paintcommands.cpp')
-rw-r--r--tests/auto/other/lancelot/paintcommands.cpp48
1 files changed, 29 insertions, 19 deletions
diff --git a/tests/auto/other/lancelot/paintcommands.cpp b/tests/auto/other/lancelot/paintcommands.cpp
index 7b3767505b..1e651ff8cf 100644
--- a/tests/auto/other/lancelot/paintcommands.cpp
+++ b/tests/auto/other/lancelot/paintcommands.cpp
@@ -51,7 +51,9 @@
#include <QStaticText>
#ifndef QT_NO_OPENGL
-#include <qglpixelbuffer.h>
+#include <QOpenGLFramebufferObjectFormat>
+#include <QOpenGLContext>
+#include <QOpenGLPaintDevice>
#endif
/*********************************************************************************
@@ -2375,10 +2377,20 @@ void PaintCommands::command_surface_begin(QRegExp re)
m_surface_painter = m_painter;
- if (m_type == OpenGLType || m_type == OpenGLPBufferType) {
+ if (m_type == OpenGLType || m_type == OpenGLBufferType) {
#ifndef QT_NO_OPENGL
- m_surface_pbuffer = new QGLPixelBuffer(qRound(w), qRound(h));
- m_painter = new QPainter(m_surface_pbuffer);
+ m_default_glcontext = QOpenGLContext::currentContext();
+ m_surface_glcontext = new QOpenGLContext();
+ m_surface_glcontext->setFormat(m_default_glcontext->format());
+ m_surface_glcontext->create();
+ m_surface_glcontext->makeCurrent(m_default_glcontext->surface());
+ QOpenGLFramebufferObjectFormat fmt; // ###TBD: get format from caller
+ fmt.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil);
+ fmt.setSamples(4);
+ m_surface_glbuffer = new QOpenGLFramebufferObject(qRound(w), qRound(h), fmt);
+ m_surface_glbuffer->bind();
+ m_surface_glpaintdevice = new QOpenGLPaintDevice(qRound(w), qRound(h));
+ m_painter = new QPainter(m_surface_glpaintdevice);
m_painter->fillRect(QRect(0, 0, qRound(w), qRound(h)), Qt::transparent);
#endif
#ifdef Q_WS_X11
@@ -2415,23 +2427,21 @@ void PaintCommands::command_surface_end(QRegExp)
m_painter = m_surface_painter;
m_surface_painter = 0;
- if (m_type == OpenGLType || m_type == OpenGLPBufferType) {
+ if (m_type == OpenGLType || m_type == OpenGLBufferType) {
#ifndef QT_NO_OPENGL
- QImage image = m_surface_pbuffer->toImage();
- QImage new_image(image.bits(), image.width(),
- image.height(), QImage::Format_ARGB32_Premultiplied);
- QPaintDevice *pdev = m_painter->device();
- if (pdev->devType() == QInternal::Widget) {
- QWidget *w = static_cast<QWidget *>(pdev);
- static_cast<QGLWidget *>(w)->makeCurrent();
- } else if (pdev->devType() == QInternal::Pbuffer) {
- static_cast<QGLPixelBuffer *>(pdev)->makeCurrent();
- }
-
+ QImage new_image = m_surface_glbuffer->toImage().convertToFormat(QImage::Format_ARGB32_Premultiplied);
+ m_default_glcontext->makeCurrent(m_default_glcontext->surface());
m_painter->drawImage(m_surface_rect, new_image);
-
- delete m_surface_pbuffer;
- m_surface_pbuffer = 0;
+ // Flush the pipeline:
+ m_painter->beginNativePainting();
+ m_painter->endNativePainting();
+
+ delete m_surface_glpaintdevice;
+ m_surface_glpaintdevice = 0;
+ delete m_surface_glbuffer;
+ m_surface_glbuffer = 0;
+ delete m_surface_glcontext;
+ m_surface_glcontext = 0;
#endif
#ifdef Q_WS_X11
} else if (m_type == WidgetType) {