diff options
Diffstat (limited to 'tests/benchmarks/gui/painting/qpainter/tst_qpainter.cpp')
-rw-r--r-- | tests/benchmarks/gui/painting/qpainter/tst_qpainter.cpp | 86 |
1 files changed, 58 insertions, 28 deletions
diff --git a/tests/benchmarks/gui/painting/qpainter/tst_qpainter.cpp b/tests/benchmarks/gui/painting/qpainter/tst_qpainter.cpp index d0719d716b..7954e964b3 100644 --- a/tests/benchmarks/gui/painting/qpainter/tst_qpainter.cpp +++ b/tests/benchmarks/gui/painting/qpainter/tst_qpainter.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 <qtest.h> #include <QPainter> @@ -220,6 +197,9 @@ private slots: void drawTransformedSemiTransparentImage(); void drawTransformedFilledImage(); + void drawPathExceedingDevice_data(); + void drawPathExceedingDevice(); + private: void setupBrushes(); void createPrimitives(); @@ -695,7 +675,7 @@ void tst_QPainter::drawPixmapImage_data_helper(bool pixmaps) for (; *targetFormats != QImage::Format_Invalid; ++targetFormats) { const QImage::Format *sourceFormats = pixmaps ? pixmapFormats : sourceImageFormats; for (; *sourceFormats != QImage::Format_Invalid; ++sourceFormats) { - for (const QSize &s : qAsConst(sizes)) { + for (const QSize &s : std::as_const(sizes)) { for (int type=0; type<=3; ++type) { QString name = QString::fromLatin1("%1 on %2, (%3x%4), %5") .arg(formatNames[*sourceFormats]) @@ -1684,6 +1664,56 @@ void tst_QPainter::drawTransformedFilledImage() } } +void tst_QPainter::drawPathExceedingDevice_data() +{ + QTest::addColumn<int>("dim"); + QTest::addColumn<QPainterPath>("path"); + + const int dim = 512; + QPainterPath p; + const int ext = 10 * dim; + for (int i = 0; i < ext; i += (ext / 50)) { + p.lineTo(ext, i); + p.lineTo(0, dim); + p.moveTo(0, 0); + } + + { + QPainterPath preClip; + preClip.addRect(0, 0, dim, dim); + QTest::newRow("devicesize") << dim << p.intersected(preClip); + } + + { + QPainterPath preClip; + preClip.addRect(0, 0, 2*dim, 2*dim); + QTest::newRow("devicesizex2") << dim << p.intersected(preClip); + } + + { + QPainterPath preClip; + preClip.addRect(0, 0, 5*dim, 5*dim); + QTest::newRow("devicesizex5") << dim << p.intersected(preClip); + } + + QTest::newRow("devicesizex10") << dim << p; +} + +void tst_QPainter::drawPathExceedingDevice() +{ + QFETCH(int, dim); + QFETCH(QPainterPath, path); + + QImage img(dim, dim, QImage::Format_RGB32); + QPainter p(&img); + p.setRenderHint(QPainter::Antialiasing); + p.setPen(QPen(Qt::black, 3)); + p.setBrush(Qt::NoBrush); + + QBENCHMARK { + p.drawPath(path); + } +} QTEST_MAIN(tst_QPainter) |