summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2017-05-23 13:57:20 +0200
committerLiang Qi <liang.qi@qt.io>2017-05-31 18:53:57 +0000
commit32a94e54b58f311f37689f4bc8e0c8a54f0f9216 (patch)
treeebc56016f1f5eeacd2e82303fa691665c68dab59
parentc76b0c87b0cd9ba55dcb50eee0792592226672b3 (diff)
Do not always use argb32pm for subsurfaces
A number of drawing paths were never tested by lancelot because we always used argb32pm for subsurfaces. This patch switches the subsurfaces to use the painter format or its alpha version. This means changes to composition tests as it changes precision, especially of alpha in the a2rgb30 formats. Change-Id: I24d53bf6e1db8cca36bda69e2ddf07f20256b3c8 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
-rw-r--r--tests/auto/other/lancelot/lancelot.pro2
-rw-r--r--tests/auto/other/lancelot/paintcommands.cpp9
-rw-r--r--tests/auto/other/lancelot/paintcommands.h5
-rw-r--r--tests/auto/other/lancelot/scripts/porter_duff.qps12
-rw-r--r--tests/auto/other/lancelot/scripts/porter_duff2.qps12
-rw-r--r--tests/auto/other/lancelot/tst_lancelot.cpp10
6 files changed, 29 insertions, 21 deletions
diff --git a/tests/auto/other/lancelot/lancelot.pro b/tests/auto/other/lancelot/lancelot.pro
index 73c12e67a2..6ece7315ed 100644
--- a/tests/auto/other/lancelot/lancelot.pro
+++ b/tests/auto/other/lancelot/lancelot.pro
@@ -1,6 +1,6 @@
CONFIG += testcase
TARGET = tst_lancelot
-QT += testlib
+QT += testlib gui-private
SOURCES += tst_lancelot.cpp \
paintcommands.cpp
diff --git a/tests/auto/other/lancelot/paintcommands.cpp b/tests/auto/other/lancelot/paintcommands.cpp
index c28812e120..8419f93e3b 100644
--- a/tests/auto/other/lancelot/paintcommands.cpp
+++ b/tests/auto/other/lancelot/paintcommands.cpp
@@ -36,6 +36,7 @@
#include <qtextlayout.h>
#include <qdebug.h>
#include <QStaticText>
+#include <private/qimage_p.h>
#ifndef QT_NO_OPENGL
#include <QOpenGLFramebufferObjectFormat>
@@ -2402,7 +2403,13 @@ void PaintCommands::command_surface_begin(QRegExp re)
m_painter = new QPainter(&m_surface_pixmap);
#endif
} else {
- m_surface_image = QImage(qRound(w), qRound(h), QImage::Format_ARGB32_Premultiplied);
+ QImage::Format surface_format;
+ if (QImage::toPixelFormat(m_format).alphaUsage() != QPixelFormat::UsesAlpha)
+ surface_format = qt_alphaVersion(m_format);
+ else
+ surface_format = m_format;
+
+ m_surface_image = QImage(qRound(w), qRound(h), surface_format);
m_surface_image.fill(0);
m_painter = new QPainter(&m_surface_image);
}
diff --git a/tests/auto/other/lancelot/paintcommands.h b/tests/auto/other/lancelot/paintcommands.h
index 4113fd6881..fc7496ce11 100644
--- a/tests/auto/other/lancelot/paintcommands.h
+++ b/tests/auto/other/lancelot/paintcommands.h
@@ -68,9 +68,10 @@ class PaintCommands
{
public:
// construction / initialization
- PaintCommands(const QStringList &cmds, int w, int h)
+ PaintCommands(const QStringList &cmds, int w, int h, QImage::Format format)
: m_painter(0)
, m_surface_painter(0)
+ , m_format(format)
, m_commands(cmds)
, m_gradientSpread(QGradient::PadSpread)
, m_gradientCoordinate(QGradient::LogicalMode)
@@ -246,8 +247,8 @@ private:
// attributes
QPainter *m_painter;
QPainter *m_surface_painter;
+ QImage::Format m_format;
QImage m_surface_image;
- QPixmap m_surface_pixmap;
QRectF m_surface_rect;
QStringList m_commands;
QString m_currentCommand;
diff --git a/tests/auto/other/lancelot/scripts/porter_duff.qps b/tests/auto/other/lancelot/scripts/porter_duff.qps
index 166e48a57f..94e9c68522 100644
--- a/tests/auto/other/lancelot/scripts/porter_duff.qps
+++ b/tests/auto/other/lancelot/scripts/porter_duff.qps
@@ -184,7 +184,7 @@ repeat_block postdraw
surface_end
-# Multiply
+# ColorBurn
surface_begin 100 300 100 100
repeat_block predraw
setCompositionMode ColorBurn
@@ -192,7 +192,7 @@ repeat_block postdraw
surface_end
-# Screen
+# HardLight
surface_begin 200 300 100 100
repeat_block predraw
setCompositionMode HardLight
@@ -200,7 +200,7 @@ repeat_block postdraw
surface_end
-# Overlay
+# SoftLight
surface_begin 300 300 100 100
repeat_block predraw
setCompositionMode SoftLight
@@ -208,7 +208,7 @@ repeat_block postdraw
surface_end
-# Darken
+# Difference
surface_begin 400 300 100 100
repeat_block predraw
setCompositionMode Difference
@@ -216,7 +216,7 @@ repeat_block postdraw
surface_end
-# Lighten
+# Exclusion
surface_begin 500 300 100 100
repeat_block predraw
setCompositionMode Exclusion
@@ -248,4 +248,4 @@ drawText 100 500 "ColorBurn"
drawText 200 500 "HardLight"
drawText 300 500 "SoftLight"
drawText 400 500 "Difference"
-drawText 500 500 "Exclusion" \ No newline at end of file
+drawText 500 500 "Exclusion"
diff --git a/tests/auto/other/lancelot/scripts/porter_duff2.qps b/tests/auto/other/lancelot/scripts/porter_duff2.qps
index a792d9b278..f538371ca1 100644
--- a/tests/auto/other/lancelot/scripts/porter_duff2.qps
+++ b/tests/auto/other/lancelot/scripts/porter_duff2.qps
@@ -194,7 +194,7 @@ repeat_block postdraw
surface_end
-# Multiply
+# ColorBurn
surface_begin 100 300 100 100
repeat_block predraw
setCompositionMode ColorBurn
@@ -202,7 +202,7 @@ repeat_block postdraw
surface_end
-# Screen
+# HardLight
surface_begin 200 300 100 100
repeat_block predraw
setCompositionMode HardLight
@@ -210,7 +210,7 @@ repeat_block postdraw
surface_end
-# Overlay
+# SoftLight
surface_begin 300 300 100 100
repeat_block predraw
setCompositionMode SoftLight
@@ -218,7 +218,7 @@ repeat_block postdraw
surface_end
-# Darken
+# Difference
surface_begin 400 300 100 100
repeat_block predraw
setCompositionMode Difference
@@ -226,7 +226,7 @@ repeat_block postdraw
surface_end
-# Lighten
+# Exclusion
surface_begin 500 300 100 100
repeat_block predraw
setCompositionMode Exclusion
@@ -258,4 +258,4 @@ drawText 100 500 "ColorBurn"
drawText 200 500 "HardLight"
drawText 300 500 "SoftLight"
drawText 400 500 "Difference"
-drawText 500 500 "Exclusion" \ No newline at end of file
+drawText 500 500 "Exclusion"
diff --git a/tests/auto/other/lancelot/tst_lancelot.cpp b/tests/auto/other/lancelot/tst_lancelot.cpp
index 63c62bab86..79d0f7c6cf 100644
--- a/tests/auto/other/lancelot/tst_lancelot.cpp
+++ b/tests/auto/other/lancelot/tst_lancelot.cpp
@@ -54,7 +54,7 @@ private:
void setupTestSuite(const QStringList& blacklist = QStringList());
void runTestSuite(GraphicsEngine engine, QImage::Format format, const QSurfaceFormat &contextFormat = QSurfaceFormat());
- void paint(QPaintDevice *device, GraphicsEngine engine, const QStringList &script, const QString &filePath);
+ void paint(QPaintDevice *device, GraphicsEngine engine, QImage::Format format, const QStringList &script, const QString &filePath);
QStringList qpsFiles;
QHash<QString, QStringList> scripts;
@@ -318,7 +318,7 @@ void tst_Lancelot::runTestSuite(GraphicsEngine engine, QImage::Format format, co
if (engine == Raster) {
QImage img(800, 800, format);
- paint(&img, engine, script, QFileInfo(filePath).absoluteFilePath());
+ paint(&img, engine, format, script, QFileInfo(filePath).absoluteFilePath());
rendered = img;
#ifndef QT_NO_OPENGL
} else if (engine == OpenGL) {
@@ -336,7 +336,7 @@ void tst_Lancelot::runTestSuite(GraphicsEngine engine, QImage::Format format, co
QOpenGLFramebufferObject fbo(800, 800, fmt);
fbo.bind();
QOpenGLPaintDevice pdv(800, 800);
- paint(&pdv, engine, script, QFileInfo(filePath).absoluteFilePath());
+ paint(&pdv, engine, format, script, QFileInfo(filePath).absoluteFilePath());
rendered = fbo.toImage().convertToFormat(format);
#endif
}
@@ -344,10 +344,10 @@ void tst_Lancelot::runTestSuite(GraphicsEngine engine, QImage::Format format, co
QBASELINE_TEST(rendered);
}
-void tst_Lancelot::paint(QPaintDevice *device, GraphicsEngine engine, const QStringList &script, const QString &filePath)
+void tst_Lancelot::paint(QPaintDevice *device, GraphicsEngine engine, QImage::Format format, const QStringList &script, const QString &filePath)
{
QPainter p(device);
- PaintCommands pcmd(script, 800, 800);
+ PaintCommands pcmd(script, 800, 800, format);
//pcmd.setShouldDrawText(false);
switch (engine) {
case OpenGL: