mirror of https://github.com/qt/qtbase.git
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
|
CONFIG += testcase
|
||||||
TARGET = tst_lancelot
|
TARGET = tst_lancelot
|
||||||
QT += testlib
|
QT += testlib gui-private
|
||||||
|
|
||||||
SOURCES += tst_lancelot.cpp \
|
SOURCES += tst_lancelot.cpp \
|
||||||
paintcommands.cpp
|
paintcommands.cpp
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
#include <qtextlayout.h>
|
#include <qtextlayout.h>
|
||||||
#include <qdebug.h>
|
#include <qdebug.h>
|
||||||
#include <QStaticText>
|
#include <QStaticText>
|
||||||
|
#include <private/qimage_p.h>
|
||||||
|
|
||||||
#ifndef QT_NO_OPENGL
|
#ifndef QT_NO_OPENGL
|
||||||
#include <QOpenGLFramebufferObjectFormat>
|
#include <QOpenGLFramebufferObjectFormat>
|
||||||
|
@ -2402,7 +2403,13 @@ void PaintCommands::command_surface_begin(QRegExp re)
|
||||||
m_painter = new QPainter(&m_surface_pixmap);
|
m_painter = new QPainter(&m_surface_pixmap);
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} 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_surface_image.fill(0);
|
||||||
m_painter = new QPainter(&m_surface_image);
|
m_painter = new QPainter(&m_surface_image);
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,9 +68,10 @@ class PaintCommands
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// construction / initialization
|
// 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_painter(0)
|
||||||
, m_surface_painter(0)
|
, m_surface_painter(0)
|
||||||
|
, m_format(format)
|
||||||
, m_commands(cmds)
|
, m_commands(cmds)
|
||||||
, m_gradientSpread(QGradient::PadSpread)
|
, m_gradientSpread(QGradient::PadSpread)
|
||||||
, m_gradientCoordinate(QGradient::LogicalMode)
|
, m_gradientCoordinate(QGradient::LogicalMode)
|
||||||
|
@ -246,8 +247,8 @@ private:
|
||||||
// attributes
|
// attributes
|
||||||
QPainter *m_painter;
|
QPainter *m_painter;
|
||||||
QPainter *m_surface_painter;
|
QPainter *m_surface_painter;
|
||||||
|
QImage::Format m_format;
|
||||||
QImage m_surface_image;
|
QImage m_surface_image;
|
||||||
QPixmap m_surface_pixmap;
|
|
||||||
QRectF m_surface_rect;
|
QRectF m_surface_rect;
|
||||||
QStringList m_commands;
|
QStringList m_commands;
|
||||||
QString m_currentCommand;
|
QString m_currentCommand;
|
||||||
|
|
|
@ -184,7 +184,7 @@ repeat_block postdraw
|
||||||
surface_end
|
surface_end
|
||||||
|
|
||||||
|
|
||||||
# Multiply
|
# ColorBurn
|
||||||
surface_begin 100 300 100 100
|
surface_begin 100 300 100 100
|
||||||
repeat_block predraw
|
repeat_block predraw
|
||||||
setCompositionMode ColorBurn
|
setCompositionMode ColorBurn
|
||||||
|
@ -192,7 +192,7 @@ repeat_block postdraw
|
||||||
surface_end
|
surface_end
|
||||||
|
|
||||||
|
|
||||||
# Screen
|
# HardLight
|
||||||
surface_begin 200 300 100 100
|
surface_begin 200 300 100 100
|
||||||
repeat_block predraw
|
repeat_block predraw
|
||||||
setCompositionMode HardLight
|
setCompositionMode HardLight
|
||||||
|
@ -200,7 +200,7 @@ repeat_block postdraw
|
||||||
surface_end
|
surface_end
|
||||||
|
|
||||||
|
|
||||||
# Overlay
|
# SoftLight
|
||||||
surface_begin 300 300 100 100
|
surface_begin 300 300 100 100
|
||||||
repeat_block predraw
|
repeat_block predraw
|
||||||
setCompositionMode SoftLight
|
setCompositionMode SoftLight
|
||||||
|
@ -208,7 +208,7 @@ repeat_block postdraw
|
||||||
surface_end
|
surface_end
|
||||||
|
|
||||||
|
|
||||||
# Darken
|
# Difference
|
||||||
surface_begin 400 300 100 100
|
surface_begin 400 300 100 100
|
||||||
repeat_block predraw
|
repeat_block predraw
|
||||||
setCompositionMode Difference
|
setCompositionMode Difference
|
||||||
|
@ -216,7 +216,7 @@ repeat_block postdraw
|
||||||
surface_end
|
surface_end
|
||||||
|
|
||||||
|
|
||||||
# Lighten
|
# Exclusion
|
||||||
surface_begin 500 300 100 100
|
surface_begin 500 300 100 100
|
||||||
repeat_block predraw
|
repeat_block predraw
|
||||||
setCompositionMode Exclusion
|
setCompositionMode Exclusion
|
||||||
|
@ -248,4 +248,4 @@ drawText 100 500 "ColorBurn"
|
||||||
drawText 200 500 "HardLight"
|
drawText 200 500 "HardLight"
|
||||||
drawText 300 500 "SoftLight"
|
drawText 300 500 "SoftLight"
|
||||||
drawText 400 500 "Difference"
|
drawText 400 500 "Difference"
|
||||||
drawText 500 500 "Exclusion"
|
drawText 500 500 "Exclusion"
|
||||||
|
|
|
@ -194,7 +194,7 @@ repeat_block postdraw
|
||||||
surface_end
|
surface_end
|
||||||
|
|
||||||
|
|
||||||
# Multiply
|
# ColorBurn
|
||||||
surface_begin 100 300 100 100
|
surface_begin 100 300 100 100
|
||||||
repeat_block predraw
|
repeat_block predraw
|
||||||
setCompositionMode ColorBurn
|
setCompositionMode ColorBurn
|
||||||
|
@ -202,7 +202,7 @@ repeat_block postdraw
|
||||||
surface_end
|
surface_end
|
||||||
|
|
||||||
|
|
||||||
# Screen
|
# HardLight
|
||||||
surface_begin 200 300 100 100
|
surface_begin 200 300 100 100
|
||||||
repeat_block predraw
|
repeat_block predraw
|
||||||
setCompositionMode HardLight
|
setCompositionMode HardLight
|
||||||
|
@ -210,7 +210,7 @@ repeat_block postdraw
|
||||||
surface_end
|
surface_end
|
||||||
|
|
||||||
|
|
||||||
# Overlay
|
# SoftLight
|
||||||
surface_begin 300 300 100 100
|
surface_begin 300 300 100 100
|
||||||
repeat_block predraw
|
repeat_block predraw
|
||||||
setCompositionMode SoftLight
|
setCompositionMode SoftLight
|
||||||
|
@ -218,7 +218,7 @@ repeat_block postdraw
|
||||||
surface_end
|
surface_end
|
||||||
|
|
||||||
|
|
||||||
# Darken
|
# Difference
|
||||||
surface_begin 400 300 100 100
|
surface_begin 400 300 100 100
|
||||||
repeat_block predraw
|
repeat_block predraw
|
||||||
setCompositionMode Difference
|
setCompositionMode Difference
|
||||||
|
@ -226,7 +226,7 @@ repeat_block postdraw
|
||||||
surface_end
|
surface_end
|
||||||
|
|
||||||
|
|
||||||
# Lighten
|
# Exclusion
|
||||||
surface_begin 500 300 100 100
|
surface_begin 500 300 100 100
|
||||||
repeat_block predraw
|
repeat_block predraw
|
||||||
setCompositionMode Exclusion
|
setCompositionMode Exclusion
|
||||||
|
@ -258,4 +258,4 @@ drawText 100 500 "ColorBurn"
|
||||||
drawText 200 500 "HardLight"
|
drawText 200 500 "HardLight"
|
||||||
drawText 300 500 "SoftLight"
|
drawText 300 500 "SoftLight"
|
||||||
drawText 400 500 "Difference"
|
drawText 400 500 "Difference"
|
||||||
drawText 500 500 "Exclusion"
|
drawText 500 500 "Exclusion"
|
||||||
|
|
|
@ -54,7 +54,7 @@ private:
|
||||||
|
|
||||||
void setupTestSuite(const QStringList& blacklist = QStringList());
|
void setupTestSuite(const QStringList& blacklist = QStringList());
|
||||||
void runTestSuite(GraphicsEngine engine, QImage::Format format, const QSurfaceFormat &contextFormat = QSurfaceFormat());
|
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;
|
QStringList qpsFiles;
|
||||||
QHash<QString, QStringList> scripts;
|
QHash<QString, QStringList> scripts;
|
||||||
|
@ -318,7 +318,7 @@ void tst_Lancelot::runTestSuite(GraphicsEngine engine, QImage::Format format, co
|
||||||
|
|
||||||
if (engine == Raster) {
|
if (engine == Raster) {
|
||||||
QImage img(800, 800, format);
|
QImage img(800, 800, format);
|
||||||
paint(&img, engine, script, QFileInfo(filePath).absoluteFilePath());
|
paint(&img, engine, format, script, QFileInfo(filePath).absoluteFilePath());
|
||||||
rendered = img;
|
rendered = img;
|
||||||
#ifndef QT_NO_OPENGL
|
#ifndef QT_NO_OPENGL
|
||||||
} else if (engine == OpenGL) {
|
} else if (engine == OpenGL) {
|
||||||
|
@ -336,7 +336,7 @@ void tst_Lancelot::runTestSuite(GraphicsEngine engine, QImage::Format format, co
|
||||||
QOpenGLFramebufferObject fbo(800, 800, fmt);
|
QOpenGLFramebufferObject fbo(800, 800, fmt);
|
||||||
fbo.bind();
|
fbo.bind();
|
||||||
QOpenGLPaintDevice pdv(800, 800);
|
QOpenGLPaintDevice pdv(800, 800);
|
||||||
paint(&pdv, engine, script, QFileInfo(filePath).absoluteFilePath());
|
paint(&pdv, engine, format, script, QFileInfo(filePath).absoluteFilePath());
|
||||||
rendered = fbo.toImage().convertToFormat(format);
|
rendered = fbo.toImage().convertToFormat(format);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -344,10 +344,10 @@ void tst_Lancelot::runTestSuite(GraphicsEngine engine, QImage::Format format, co
|
||||||
QBASELINE_TEST(rendered);
|
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);
|
QPainter p(device);
|
||||||
PaintCommands pcmd(script, 800, 800);
|
PaintCommands pcmd(script, 800, 800, format);
|
||||||
//pcmd.setShouldDrawText(false);
|
//pcmd.setShouldDrawText(false);
|
||||||
switch (engine) {
|
switch (engine) {
|
||||||
case OpenGL:
|
case OpenGL:
|
||||||
|
|
Loading…
Reference in New Issue