diff options
author | Samuel Rødal <samuel.rodal@nokia.com> | 2011-09-12 13:01:30 +0200 |
---|---|---|
committer | Gunnar Sletta <gunnar.sletta@nokia.com> | 2011-09-12 14:11:18 +0200 |
commit | 2d5fbd05bb93dcc4c5a85f8cf36e6b8ea522e86d (patch) | |
tree | 859e38e92c0182a894ece8f1e9ca9354f3c0bd8b | |
parent | a15d07918771b13cb468db6a207fa2e9f3f8d5e4 (diff) |
Added new QOpenGLPaintDevice test case in tst_QOpenGL.
Change-Id: Ic56e4c236f52fbd5c570bb647d5d1f4e5f9e7924
Reviewed-on: http://codereview.qt-project.org/4662
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Gunnar Sletta <gunnar.sletta@nokia.com>
-rw-r--r-- | tests/auto/qopengl/tst_qopengl.cpp | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/auto/qopengl/tst_qopengl.cpp b/tests/auto/qopengl/tst_qopengl.cpp index 2f4bb0cad9..18e7e07d94 100644 --- a/tests/auto/qopengl/tst_qopengl.cpp +++ b/tests/auto/qopengl/tst_qopengl.cpp @@ -54,6 +54,7 @@ private slots: void fboSimpleRendering(); void fboRendering(); void fboHandleNulledAfterContextDestroyed(); + void openGLPaintDevice(); }; struct SharedResourceTracker @@ -385,5 +386,46 @@ void tst_QOpenGL::fboHandleNulledAfterContextDestroyed() QCOMPARE(fbo->handle(), 0U); } +void tst_QOpenGL::openGLPaintDevice() +{ + QWindow window; + window.setGeometry(0, 0, 128, 128); + window.create(); + + QOpenGLContext ctx; + ctx.create(); + + ctx.makeCurrent(&window); + + QImage image(128, 128, QImage::Format_RGB32); + QPainter p(&image); + p.fillRect(0, 0, image.width() / 2, image.height() / 2, Qt::red); + p.fillRect(image.width() / 2, 0, image.width() / 2, image.height() / 2, Qt::green); + p.fillRect(image.width() / 2, image.height() / 2, image.width() / 2, image.height() / 2, Qt::blue); + p.fillRect(0, image.height() / 2, image.width() / 2, image.height() / 2, Qt::white); + p.end(); + + QOpenGLFramebufferObject fbo(128, 128); + fbo.bind(); + + QOpenGLPaintDevice device(128, 128); + p.begin(&device); + p.fillRect(0, 0, image.width() / 2, image.height() / 2, Qt::red); + p.fillRect(image.width() / 2, 0, image.width() / 2, image.height() / 2, Qt::green); + p.fillRect(image.width() / 2, image.height() / 2, image.width() / 2, image.height() / 2, Qt::blue); + p.fillRect(0, image.height() / 2, image.width() / 2, image.height() / 2, Qt::white); + p.end(); + + QCOMPARE(image, fbo.toImage().convertToFormat(QImage::Format_RGB32)); + + QSKIP("Image / pixmap painting needs to be implemented", SkipSingle); + p.begin(&device); + p.drawImage(0, 0, image); + p.end(); + + QCOMPARE(image, fbo.toImage().convertToFormat(QImage::Format_RGB32)); +} + + QTEST_MAIN(tst_QOpenGL) #include "tst_qopengl.moc" |