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>
This commit is contained in:
parent
c76b0c87b0
commit
32a94e54b5
@ -1,6 +1,6 @@
|
||||
CONFIG += testcase
|
||||
TARGET = tst_lancelot
|
||||
QT += testlib
|
||||
QT += testlib gui-private
|
||||
|
||||
SOURCES += tst_lancelot.cpp \
|
||||
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);
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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"
|
||||
drawText 500 500 "Exclusion"
|
||||
|
@ -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"
|
||||
drawText 500 500 "Exclusion"
|
||||
|
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user