aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/scenegraph
diff options
context:
space:
mode:
authorGunnar Sletta <gunnar@sletta.org>2015-06-11 10:17:45 +0200
committerSimon Hausmann <simon.hausmann@theqtcompany.com>2015-06-15 09:31:08 +0000
commite9c5ac78deaae6775ad5cf08c022a0105f7702a7 (patch)
tree8eca91f4d1dc1c13f07f96369023e42b65bbcded /tests/auto/quick/scenegraph
parentd845227aca013f9d3c0d63a394a5c27733f6d019 (diff)
Add QQuickWindow::TextureIsOpaque as option to createTextureFromImage.
Opaque textures can be a lot faster, so give this option without forcing the user to reimplement her/his own QSGTexture class. The old behavior was that createTextureFromImage() disregarded TextureHasAlphaChannel and looked solely at the image's format. To keep this behavior intact, we introduce a second opt-in flag to switch textures from auto-detect to false, namely TextureIsOpaque. [ChangeLog][QtQuick][QQuickWindow] Add TextureIsOpaque option to createTextureFromImage() Change-Id: I248db4bc5f7920864b6aa8d831ce24d23ad370ef Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
Diffstat (limited to 'tests/auto/quick/scenegraph')
-rw-r--r--tests/auto/quick/scenegraph/tst_scenegraph.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/auto/quick/scenegraph/tst_scenegraph.cpp b/tests/auto/quick/scenegraph/tst_scenegraph.cpp
index 3e1285b7fe..80672e234e 100644
--- a/tests/auto/quick/scenegraph/tst_scenegraph.cpp
+++ b/tests/auto/quick/scenegraph/tst_scenegraph.cpp
@@ -104,6 +104,9 @@ private slots:
void hideWithOtherContext();
+ void createTextureFromImage_data();
+ void createTextureFromImage();
+
private:
bool m_brokenMipmapSupport;
};
@@ -534,6 +537,34 @@ void tst_SceneGraph::hideWithOtherContext()
QVERIFY(!renderingOnMainThread || QOpenGLContext::currentContext() != &context);
}
+void tst_SceneGraph::createTextureFromImage_data()
+{
+ QImage rgba(64, 64, QImage::Format_ARGB32_Premultiplied);
+ QImage rgb(64, 64, QImage::Format_RGB32);
+
+ QTest::addColumn<QImage>("image");
+ QTest::addColumn<uint>("flags");
+ QTest::addColumn<bool>("expectedAlpha");
+
+ QTest::newRow("rgb") << rgb << uint(0) << false;
+ QTest::newRow("argb") << rgba << uint(0) << true;
+ QTest::newRow("rgb,alpha") << rgb << uint(QQuickWindow::TextureHasAlphaChannel) << false;
+ QTest::newRow("argb,alpha") << rgba << uint(QQuickWindow::TextureHasAlphaChannel) << true;
+ QTest::newRow("rgb,!alpha") << rgb << uint(QQuickWindow::TextureIsOpaque) << false;
+ QTest::newRow("argb,!alpha") << rgba << uint(QQuickWindow::TextureIsOpaque) << false;
+}
+
+void tst_SceneGraph::createTextureFromImage()
+{
+ QFETCH(QImage, image);
+ QFETCH(uint, flags);
+ QFETCH(bool, expectedAlpha);
+
+ QQuickView view;
+ QScopedPointer<QSGTexture> texture(view.createTextureFromImage(image, (QQuickWindow::CreateTextureOptions) flags));
+ QCOMPARE(texture->hasAlphaChannel(), expectedAlpha);
+}
+
#include "tst_scenegraph.moc"