diff options
Diffstat (limited to 'tests/baseline/painting')
-rw-r--r-- | tests/baseline/painting/CMakeLists.txt | 9 | ||||
-rw-r--r-- | tests/baseline/painting/scripts/aliasing.qps | 13 | ||||
-rw-r--r-- | tests/baseline/painting/scripts/cliprects.qps | 295 | ||||
-rw-r--r-- | tests/baseline/painting/scripts/pattern_xform.qps | 79 | ||||
-rw-r--r-- | tests/baseline/painting/scripts/pattern_xform2.qps | 81 | ||||
-rw-r--r-- | tests/baseline/painting/scripts/pixmapfragments.qps | 65 | ||||
-rw-r--r-- | tests/baseline/painting/scripts/text.qps | 2 | ||||
-rw-r--r-- | tests/baseline/painting/tst_baseline_painting.cpp | 83 |
8 files changed, 575 insertions, 52 deletions
diff --git a/tests/baseline/painting/CMakeLists.txt b/tests/baseline/painting/CMakeLists.txt index b32d8f1324..72e737d227 100644 --- a/tests/baseline/painting/CMakeLists.txt +++ b/tests/baseline/painting/CMakeLists.txt @@ -1,3 +1,6 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + ##################################################################### ## tst_baseline_painting Test: ##################################################################### @@ -14,9 +17,11 @@ qt_internal_add_test(tst_baseline_painting ../shared/qbaselinetest.cpp ../shared/qbaselinetest.h ../shared/paintcommands.cpp ../shared/paintcommands.h tst_baseline_painting.cpp + NO_PCH_SOURCES + tst_baseline_painting.cpp # undef QT_NO_FOREACH INCLUDE_DIRECTORIES ../shared - PUBLIC_LIBRARIES + LIBRARIES Qt::Gui Qt::GuiPrivate Qt::Network @@ -68,6 +73,6 @@ qt_internal_add_resource(tst_baseline_painting "images" ##################################################################### qt_internal_extend_target(tst_baseline_painting CONDITION QT_FEATURE_opengl - PUBLIC_LIBRARIES + LIBRARIES Qt::OpenGL ) diff --git a/tests/baseline/painting/scripts/aliasing.qps b/tests/baseline/painting/scripts/aliasing.qps index 59878f9c4d..1fb0113396 100644 --- a/tests/baseline/painting/scripts/aliasing.qps +++ b/tests/baseline/painting/scripts/aliasing.qps @@ -19,6 +19,17 @@ begin_block drawing setPen black drawText 0 68 "QwErTy@" + setPen green 1 SolidLine + drawLine 0 75 10 75 + setPen 800000ff 1 + drawPoint 0 75 + drawPoint 10 75 + + setPen green 2 SolidLine + drawLine 20 75 30 75 + setPen 800000ff 2 + drawPoint 20 75 + drawPoint 30 75 setPen black 1 setBrush 7f7fff @@ -153,4 +164,4 @@ drawText 15 185 "1.0" resetMatrix drawText 430 95 "Aliased" -drawText 430 275 "Anti-Aliased"
\ No newline at end of file +drawText 430 275 "Anti-Aliased" diff --git a/tests/baseline/painting/scripts/cliprects.qps b/tests/baseline/painting/scripts/cliprects.qps index aa0367eccf..cbc2a90055 100644 --- a/tests/baseline/painting/scripts/cliprects.qps +++ b/tests/baseline/painting/scripts/cliprects.qps @@ -1,7 +1,7 @@ # Version: 1 # CheckVsReference: 5% - +save translate 10 10 setPen NoPen @@ -56,4 +56,297 @@ setRenderHint Antialiasing setRenderHint SmoothPixmapTransform repeat_block clipping +restore + +# Excercise combining different clips + +translate 0 250 +scale 0.9 0.9 +setFont "times" 10 bold +region_addRect dummyRegion 1000 1000 10 10 +region_addRect realRegion 20 10 60 30 +path_addRect dummyPath 1000 1000 10 10 +path_addRect realPath 20 10 60 30 +begin_block paintstuff +fillRect 0 0 100 50 orange +drawText 0 5 "Should be clipped" +drawText 0 15 "Should be clipped" +drawText 0 25 "Should be clipped" +drawText 0 35 "Should be clipped" +drawText 0 45 "Should be clipped" +drawText 0 55 "Should be clipped" +end_block + +translate 0 100 + +# rect replaced by x +save +setClipRect 1000 1000 10 10 ReplaceClip +setClipRect 20 10 60 30 ReplaceClip +repeat_block paintstuff +restore +translate 100 0 + +save +setClipRect 1000 1000 10 10 ReplaceClip +setClipRectF 20 10 60 30 ReplaceClip +repeat_block paintstuff +restore +translate 100 0 + +save +setClipRect 1000 1000 10 10 ReplaceClip +setClipRegion realRegion ReplaceClip +repeat_block paintstuff +restore +translate 100 0 + +save +setClipRect 1000 1000 10 10 ReplaceClip +setClipPath realPath ReplaceClip +repeat_block paintstuff +restore +translate 100 0 + +# rectF replaced by x +save +setClipRectF 1000 1000 10 10 ReplaceClip +setClipRect 20 10 60 30 ReplaceClip +repeat_block paintstuff +restore +translate 100 0 + +save +setClipRectF 1000 1000 10 10 ReplaceClip +setClipRectF 20 10 60 30 ReplaceClip +repeat_block paintstuff +restore +translate 100 0 + +save +setClipRectF 1000 1000 10 10 ReplaceClip +setClipRegion realRegion ReplaceClip +repeat_block paintstuff +restore +translate 100 0 + +save +setClipRectF 1000 1000 10 10 ReplaceClip +setClipPath realPath ReplaceClip +repeat_block paintstuff +restore +translate 100 0 + +translate -800 100 + +# region replaced by x +save +setClipRegion dummyRegion ReplaceClip +setClipRect 20 10 60 30 ReplaceClip +repeat_block paintstuff +restore +translate 100 0 + +save +setClipRegion dummyRegion ReplaceClip +setClipRectF 20 10 60 30 ReplaceClip +repeat_block paintstuff +restore +translate 100 0 + +save +setClipRegion dummyRegion ReplaceClip +setClipRegion realRegion ReplaceClip +repeat_block paintstuff +restore +translate 100 0 + +save +setClipRegion dummyRegion ReplaceClip +setClipPath realPath ReplaceClip +repeat_block paintstuff +restore +translate 100 0 + +# path replaced by x +save +setClipPath dummyPath ReplaceClip +setClipRect 20 10 60 30 ReplaceClip +repeat_block paintstuff +restore +translate 100 0 + +save +setClipPath dummyPath ReplaceClip +setClipRectF 20 10 60 30 ReplaceClip +repeat_block paintstuff +restore +translate 100 0 + +save +setClipPath dummyPath ReplaceClip +setClipRegion realRegion ReplaceClip +repeat_block paintstuff +restore +translate 100 0 +save +setClipPath dummyPath ReplaceClip +setClipPath realPath ReplaceClip +repeat_block paintstuff +restore +translate 100 0 + +region_addRect intregion 0 10 60 30 +path_addRect intpath 0 10 60 30 + +translate -800 100 +# rect & x +save +setClipRect 0 10 60 30 ReplaceClip +translate 40 0 +setClipRect 0 10 60 30 IntersectClip +translate -40 0 +repeat_block paintstuff +restore +translate 100 0 + +save +setClipRect 0 10 60 30 ReplaceClip +translate 40 0 +setClipRectF 0 10 60 30 IntersectClip +translate -40 0 +repeat_block paintstuff +restore +translate 100 0 + +save +setClipRect 0 10 60 30 ReplaceClip +translate 40 0 +setClipRegion intregion IntersectClip +translate -40 0 +repeat_block paintstuff +restore +translate 100 0 + +save +setClipRect 0 10 60 30 ReplaceClip +translate 40 0 +setClipPath intpath IntersectClip +translate -40 0 +repeat_block paintstuff +restore +translate 100 0 + +# rectF & x +save +setClipRectF 0 10 60 30 ReplaceClip +translate 40 0 +setClipRect 0 10 60 30 IntersectClip +translate -40 0 +repeat_block paintstuff +restore +translate 100 0 + +save +setClipRectF 0 10 60 30 ReplaceClip +translate 40 0 +setClipRectF 0 10 60 30 IntersectClip +translate -40 0 +repeat_block paintstuff +restore +translate 100 0 + +save +setClipRectF 0 10 60 30 ReplaceClip +translate 40 0 +setClipRegion intregion IntersectClip +translate -40 0 +repeat_block paintstuff +restore +translate 100 0 + +save +setClipRectF 0 10 60 30 ReplaceClip +translate 40 0 +setClipPath intpath IntersectClip +translate -40 0 +repeat_block paintstuff +restore +translate 100 0 + +translate -800 100 + +# region & x +save +setClipRegion intregion ReplaceClip +translate 40 0 +setClipRect 0 10 60 30 IntersectClip +translate -40 0 +repeat_block paintstuff +restore +translate 100 0 + +save +setClipRegion intregion ReplaceClip +translate 40 0 +setClipRectF 0 10 60 30 IntersectClip +translate -40 0 +repeat_block paintstuff +restore +translate 100 0 + +save +setClipRegion intregion ReplaceClip +translate 40 0 +setClipRegion intregion IntersectClip +translate -40 0 +repeat_block paintstuff +restore +translate 100 0 + +save +setClipRegion intregion ReplaceClip +translate 40 0 +setClipPath intpath IntersectClip +translate -40 0 +repeat_block paintstuff +restore +translate 100 0 + +# path & x +save +setClipPath intpath ReplaceClip +translate 40 0 +setClipRect 0 10 60 30 IntersectClip +translate -40 0 +repeat_block paintstuff +restore +translate 100 0 + +save +setClipPath intpath ReplaceClip +translate 40 0 +setClipRectF 0 10 60 30 IntersectClip +translate -40 0 +repeat_block paintstuff +restore +translate 100 0 + +save +setClipPath intpath ReplaceClip +translate 40 0 +setClipRegion intregion IntersectClip +translate -40 0 +repeat_block paintstuff +restore +translate 100 0 + +save +setClipPath intpath ReplaceClip +translate 40 0 +setClipPath intpath IntersectClip +translate -40 0 +repeat_block paintstuff +restore +translate 100 0 diff --git a/tests/baseline/painting/scripts/pattern_xform.qps b/tests/baseline/painting/scripts/pattern_xform.qps new file mode 100644 index 0000000000..224969f1c7 --- /dev/null +++ b/tests/baseline/painting/scripts/pattern_xform.qps @@ -0,0 +1,79 @@ +# Version: 1 +# CheckVsReference: 5% + +#define basic block off screen +save +translate -1000 -1000 +begin_block drawrects +setBrush green Dense4Pattern +drawRect 0 0 40 40 +setBrush green DiagCrossPattern +drawRect 40 0 40 40 +setBrush green HorPattern +brushRotate 30 +drawRect 80 0 40 40 +fillRect 120 0 40 40 +save +setPen brush 40 SolidLine FlatCap +setBrush NoBrush +drawLine 160 20 200 20 +restore +end_block +restore + +begin_block hintsuite +save +setRenderHint NonCosmeticBrushPatterns false +setRenderHint SmoothPixmapTransform false +translate 10 10 +repeat_block drawrects + +setRenderHint NonCosmeticBrushPatterns false +setRenderHint SmoothPixmapTransform true +translate 0 50 +repeat_block drawrects + +setRenderHint NonCosmeticBrushPatterns true +setRenderHint SmoothPixmapTransform false +translate 0 50 +repeat_block drawrects + +setRenderHint NonCosmeticBrushPatterns true +setRenderHint SmoothPixmapTransform true +translate 0 50 +repeat_block drawrects +restore +end_block + +save +translate 0 200 +scale 2 2 +repeat_block hintsuite +restore + +save +translate 500 0 +scale 1.5 2.5 +rotate_y 60 +repeat_block hintsuite +restore + + +translate 0 650 +setBrush blue CrossPattern +setPen red +setRenderHint NonCosmeticBrushPatterns false + +begin_block dots +save +drawRect 0 0 50 50 +setBrushOrigin 12 0 +drawRect 50 0 50 50 +scale 2 1 +drawRect 50 0 50 50 +restore +end_block dots + +setRenderHint NonCosmeticBrushPatterns true +translate 0 60 +repeat_block dots diff --git a/tests/baseline/painting/scripts/pattern_xform2.qps b/tests/baseline/painting/scripts/pattern_xform2.qps new file mode 100644 index 0000000000..4f9314272d --- /dev/null +++ b/tests/baseline/painting/scripts/pattern_xform2.qps @@ -0,0 +1,81 @@ +# Version: 1 +# CheckVsReference: 5% + +# 1: Check brush origin vs (non)cosmetic brush patterns + +setBrush blue CrossPattern +begin_block blockName +save +setBrushOrigin 0 0 +fillRect 0 0 32 32 +translate 0 32 +setBrushOrigin 1 0 +fillRect 0 0 32 32 +translate 0 32 +setBrushOrigin 2 0 +fillRect 0 0 32 32 +translate 0 32 +setBrushOrigin 3 0 +fillRect 0 0 32 32 +translate 0 32 +setBrushOrigin 4 0 +fillRect 0 0 32 32 +translate 0 32 +setBrushOrigin 5 0 +fillRect 0 0 32 32 +translate 0 32 +setBrushOrigin 6 0 +fillRect 0 0 32 32 +translate 0 32 +setBrushOrigin 7 0 +fillRect 0 0 32 32 +translate 0 32 +setBrushOrigin 8 0 +fillRect 0 0 32 32 +restore +end_block blockName + +save +setBrush red CrossPattern +scale 2 1 +repeat_block blockName +restore + +save +translate 0 300 +setRenderHint NonCosmeticBrushPatterns true +setBrush blue CrossPattern +repeat_block blockName +setBrush red CrossPattern +scale 2 1 +repeat_block blockName +restore + +# 2: Check brush update after only xform or hint change +translate 100 0 + +save +setPen NoPen +setBrush blue DiagCrossPattern +setRenderHint NonCosmeticBrushPatterns true +drawRect 10 10 200 100 +scale 10 10 +drawRect 22 1 20 10 +drawRect 22 12 20 10 +setRenderHint NonCosmeticBrushPatterns false +drawRect 1 12 20 10 +restore + +setBrush green DiagCrossPattern +setPen brush 100 SolidLine FlatCap +pen_setCosmetic true +setBrush NoBrush +translate 0 250 +setRenderHint NonCosmeticBrushPatterns true +drawLine 10 60 210 60 +scale 10 10 +drawLine 22 6 42 6 +drawLine 22 17 42 17 +setRenderHint NonCosmeticBrushPatterns false +drawLine 1 17 21 17 + diff --git a/tests/baseline/painting/scripts/pixmapfragments.qps b/tests/baseline/painting/scripts/pixmapfragments.qps new file mode 100644 index 0000000000..4c837b760f --- /dev/null +++ b/tests/baseline/painting/scripts/pixmapfragments.qps @@ -0,0 +1,65 @@ +# Version: 1 +# CheckVsReference: 1% (0 0 690 580) + + +setRenderHint Antialiasing + +setPen #00ff00 + +pixmap_load dome_argb32.png the_pixmap +begin_block draw_stuff +save + drawPixmapFragments the_pixmap 1 50 50 25 25 60 60 1 1 0 1 + drawPixmapFragments the_pixmap 1 150 50 25 25 60 60 1 1 0 0.5 + drawPixmapFragments the_pixmap 1 250 50 25 25 60 60 1 1 30 1 + drawPixmapFragments the_pixmap 1 350 50 25 25 60 60 1.5 1 0 1 + drawPixmapFragments the_pixmap 1 450 50 25 25 60 60 1 1.5 0 1 + drawPixmapFragments the_pixmap 2 550 50 25 25 40 40 0.5 0.5 -45 1 600 50 25 25 40 40 0.7 0.7 45 1 +restore +end_block + + +translate 0 120 +pixmap_load dome_rgb32.png the_pixmap +repeat_block draw_stuff + +translate 0 120 +pixmap_load dome_indexed.png the_pixmap +repeat_block draw_stuff + +translate 0 120 +pixmap_load dome_indexed_mask.png the_pixmap +repeat_block draw_stuff + +translate 0 120 +pixmap_load dome_mono.png the_pixmap +repeat_block draw_stuff + + +resetMatrix +translate 700 60 +setPen black +drawText 0 0 "32 bit w/alpha" +translate 0 120 +drawText 0 0 "32 bit w/o alpha" +translate 0 120 +drawText 0 0 "8 bit indexed" +translate 0 120 +drawText 0 0 "8 bit indexed w/mask" +translate 0 120 +drawText 0 0 "1 bit" + +resetMatrix +translate 25 600 +drawText 0 0 "simple" +translate 100 0 +drawText 0 0 "opacity" +translate 100 0 +drawText 0 0 "rotation" +translate 100 0 +drawText 0 0 "scale x" +translate 100 0 +drawText 0 0 "scale y" +translate 100 0 +drawText 0 0 "two fragments" +translate 100 0 diff --git a/tests/baseline/painting/scripts/text.qps b/tests/baseline/painting/scripts/text.qps index 4d81b3084c..6bacdfd5e6 100644 --- a/tests/baseline/painting/scripts/text.qps +++ b/tests/baseline/painting/scripts/text.qps @@ -165,7 +165,7 @@ translate 0 75 save setPen black setFont "sansserif" 16 normal - drawText 0 40 "e😃m😇o😍j😜i😸!" + drawText 0 40 "e😃m😇o😍j😜i😸!✈️" restore translate 0 75 diff --git a/tests/baseline/painting/tst_baseline_painting.cpp b/tests/baseline/painting/tst_baseline_painting.cpp index a5d787f6ce..c8de08e7d2 100644 --- a/tests/baseline/painting/tst_baseline_painting.cpp +++ b/tests/baseline/painting/tst_baseline_painting.cpp @@ -1,30 +1,7 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#undef QT_NO_FOREACH // this file contains unported legacy Q_FOREACH uses #include "paintcommands.h" #include <qbaselinetest.h> @@ -66,7 +43,8 @@ private: }; 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::defaultFormat()); void paint(QPaintDevice *device, GraphicsEngine engine, QImage::Format format, const QStringList &script, const QString &filePath); QStringList qpsFiles; @@ -76,7 +54,7 @@ private: private slots: void initTestCase(); - void cleanupTestCase() {} + void init(); void testRasterARGB32PM_data(); void testRasterARGB32PM(); @@ -112,6 +90,7 @@ private slots: void testCoreOpenGL_data(); void testCoreOpenGL(); private: + void initOpenGL(); bool checkSystemGLSupport(); bool checkSystemCoreGLSupport(); #endif @@ -143,13 +122,22 @@ void tst_Lancelot::initTestCase() std::sort(qpsFiles.begin(), qpsFiles.end()); foreach (const QString& fileName, qpsFiles) { QFile file(scriptsDir + fileName); - file.open(QFile::ReadOnly); + QVERIFY(file.open(QFile::ReadOnly)); QByteArray cont = file.readAll(); scripts.insert(fileName, QString::fromUtf8(cont).split(QLatin1Char('\n'), Qt::SkipEmptyParts)); scriptChecksums.insert(fileName, qChecksum(cont)); } + +#ifndef QT_NO_OPENGL + initOpenGL(); +#endif } +void tst_Lancelot::init() +{ + // This gets called for every row. QSKIP if current item is blacklisted on the baseline server: + QBASELINE_SKIP_IF_BLACKLISTED; +} void tst_Lancelot::testRasterARGB32PM_data() { @@ -292,6 +280,14 @@ void tst_Lancelot::testPdf() #ifndef QT_NO_OPENGL +void tst_Lancelot::initOpenGL() +{ + // Stencil buffer is needed for clipping + QSurfaceFormat glFormat; + glFormat.setStencilBufferSize(8); + QSurfaceFormat::setDefaultFormat(glFormat); +} + bool tst_Lancelot::checkSystemGLSupport() { QWindow win; @@ -315,7 +311,7 @@ bool tst_Lancelot::checkSystemCoreGLSupport() if (QOpenGLContext::openGLModuleType() != QOpenGLContext::LibGL) return false; - QSurfaceFormat coreFormat; + QSurfaceFormat coreFormat(QSurfaceFormat::defaultFormat()); coreFormat.setVersion(3, 2); coreFormat.setProfile(QSurfaceFormat::CoreProfile); QWindow win; @@ -370,7 +366,7 @@ void tst_Lancelot::testCoreOpenGL_data() void tst_Lancelot::testCoreOpenGL() { - QSurfaceFormat coreFormat; + QSurfaceFormat coreFormat(QSurfaceFormat::defaultFormat()); coreFormat.setVersion(3, 2); coreFormat.setProfile(QSurfaceFormat::CoreProfile); runTestSuite(OpenGL, QImage::Format_RGB32, coreFormat); @@ -427,19 +423,22 @@ void tst_Lancelot::runTestSuite(GraphicsEngine engine, QImage::Format format, co QString tempStem(QDir::tempPath() + QLatin1String("/lancelot_XXXXXX_") + qpsFile.chopped(4)); QTemporaryFile pdfFile(tempStem + QLatin1String(".pdf")); - pdfFile.open(); + QVERIFY(pdfFile.open()); QPdfWriter writer(&pdfFile); writer.setPdfVersion(QPdfWriter::PdfVersion_1_6); - writer.setResolution(150); + QPageSize pageSize(QSize(800, 800), QStringLiteral("LancePage"), QPageSize::ExactMatch); + writer.setPageSize(pageSize); + writer.setPageMargins(QMarginsF()); + writer.setResolution(72); paint(&writer, engine, format, script, QFileInfo(filePath).absoluteFilePath()); pdfFile.close(); // Convert pdf to something we can read into a QImage, using macOS' sips utility QTemporaryFile pngFile(tempStem + QLatin1String(".png")); - pngFile.open(); // Just create the file name + QVERIFY(pngFile.open()); // Just create the file name pngFile.close(); QProcess proc; - const char *rawArgs = "-s format png --cropOffset 20 20 -c 800 800 -o"; + const char *rawArgs = "-s format png -o"; QStringList argList = QString::fromLatin1(rawArgs).split(QLatin1Char(' ')); proc.start(QLatin1String("sips"), argList << pngFile.fileName() << pdfFile.fileName()); proc.waitForFinished(2 * 60 * 1000); // May need some time @@ -474,16 +473,6 @@ void tst_Lancelot::paint(QPaintDevice *device, GraphicsEngine engine, QImage::Fo p.end(); } -#define main _realmain -QTEST_MAIN(tst_Lancelot) -#undef main - -int main(int argc, char *argv[]) -{ - qSetGlobalQHashSeed(0); // Avoid rendering variations caused by QHash randomization - - QBaselineTest::handleCmdLineArgs(&argc, &argv); - return _realmain(argc, argv); -} +QBASELINETEST_MAIN(tst_Lancelot); #include "tst_baseline_painting.moc" |