summaryrefslogtreecommitdiffstats
path: root/tests/auto/gui/qopengl/tst_qopengl.cpp
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@digia.com>2014-07-03 13:36:01 +0200
committerAllan Sandfeld Jensen <allan.jensen@digia.com>2014-07-04 16:09:27 +0200
commit8a031696a154fe115983372022c142db0e877962 (patch)
treecbbe6ea6536b061a5645a64d2427941afe5ae64a /tests/auto/gui/qopengl/tst_qopengl.cpp
parent0eefa785a0d8bfe96403f9c13e80544cf8bb8eb3 (diff)
Make QOpenGLTextureCache::bindTexture upload efficiently
Currently QOpenGLTextureCache::bindTexture always convert any uploaded image to RGBA8888 before uploading. This is quite inefficient when OpenGL natively supports uploading formats in the original format. This patch adds support for uploading a few native QImage formats. This also get the performance of QOpenGLTextureCache::bindTexture on par with QGLContext::bindTexture. The texture brush used by QOpenGLPaintEngine is also converted to QImage, since bindTexture will convert it to QImage anyway, and going over QPixmap may cause an unnecessary conversion. [ChangeLog][QtGui][QOpenGLTextureCache] Support uploading common QImage formats directly to OpenGL when supported. Change-Id: I828a763126441a98e4547c32ef52dddf7c129a32 Reviewed-by: Gunnar Sletta <gunnar.sletta@jollamobile.com>
Diffstat (limited to 'tests/auto/gui/qopengl/tst_qopengl.cpp')
-rw-r--r--tests/auto/gui/qopengl/tst_qopengl.cpp20
1 files changed, 15 insertions, 5 deletions
diff --git a/tests/auto/gui/qopengl/tst_qopengl.cpp b/tests/auto/gui/qopengl/tst_qopengl.cpp
index 7de1989ada..1e8727ca04 100644
--- a/tests/auto/gui/qopengl/tst_qopengl.cpp
+++ b/tests/auto/gui/qopengl/tst_qopengl.cpp
@@ -65,6 +65,8 @@
#include <QtPlatformHeaders/QGLXNativeContext>
#endif
+Q_DECLARE_METATYPE(QImage::Format)
+
class tst_QOpenGL : public QObject
{
Q_OBJECT
@@ -605,7 +607,14 @@ void tst_QOpenGL::fboHandleNulledAfterContextDestroyed()
void tst_QOpenGL::openGLPaintDevice_data()
{
- common_data();
+ QTest::addColumn<int>("surfaceClass");
+ QTest::addColumn<QImage::Format>("imageFormat");
+
+ QTest::newRow("Using QWindow - RGB32") << int(QSurface::Window) << QImage::Format_RGB32;
+ QTest::newRow("Using QOffscreenSurface - RGB32") << int(QSurface::Offscreen) << QImage::Format_RGB32;
+ QTest::newRow("Using QOffscreenSurface - RGBx8888") << int(QSurface::Offscreen) << QImage::Format_RGBX8888;
+ QTest::newRow("Using QOffscreenSurface - RGB888") << int(QSurface::Offscreen) << QImage::Format_RGB888;
+ QTest::newRow("Using QOffscreenSurface - RGB16") << int(QSurface::Offscreen) << QImage::Format_RGB16;
}
void tst_QOpenGL::openGLPaintDevice()
@@ -615,6 +624,7 @@ void tst_QOpenGL::openGLPaintDevice()
#endif
QFETCH(int, surfaceClass);
+ QFETCH(QImage::Format, imageFormat);
QScopedPointer<QSurface> surface(createSurface(surfaceClass));
QOpenGLContext ctx;
@@ -627,7 +637,7 @@ void tst_QOpenGL::openGLPaintDevice()
const QSize size(128, 128);
- QImage image(size, QImage::Format_RGB32);
+ QImage image(size, imageFormat);
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);
@@ -646,7 +656,7 @@ void tst_QOpenGL::openGLPaintDevice()
p.fillRect(0, image.height() / 2, image.width() / 2, image.height() / 2, Qt::white);
p.end();
- QImage actual = fbo.toImage().convertToFormat(QImage::Format_RGB32);
+ QImage actual = fbo.toImage().convertToFormat(imageFormat);
QCOMPARE(image.size(), actual.size());
QCOMPARE(image, actual);
@@ -655,7 +665,7 @@ void tst_QOpenGL::openGLPaintDevice()
p.drawImage(0, 0, image);
p.end();
- actual = fbo.toImage().convertToFormat(QImage::Format_RGB32);
+ actual = fbo.toImage().convertToFormat(imageFormat);
QCOMPARE(image.size(), actual.size());
QCOMPARE(image, actual);
@@ -664,7 +674,7 @@ void tst_QOpenGL::openGLPaintDevice()
p.fillRect(0, 0, image.width(), image.height(), QBrush(image));
p.end();
- actual = fbo.toImage().convertToFormat(QImage::Format_RGB32);
+ actual = fbo.toImage().convertToFormat(imageFormat);
QCOMPARE(image.size(), actual.size());
QCOMPARE(image, actual);
}