summaryrefslogtreecommitdiffstats
path: root/tests/benchmarks/gui/painting/qtbench/benchmarktests.h
diff options
context:
space:
mode:
Diffstat (limited to 'tests/benchmarks/gui/painting/qtbench/benchmarktests.h')
-rw-r--r--tests/benchmarks/gui/painting/qtbench/benchmarktests.h150
1 files changed, 69 insertions, 81 deletions
diff --git a/tests/benchmarks/gui/painting/qtbench/benchmarktests.h b/tests/benchmarks/gui/painting/qtbench/benchmarktests.h
index ed03182597..9d890f1577 100644
--- a/tests/benchmarks/gui/painting/qtbench/benchmarktests.h
+++ b/tests/benchmarks/gui/painting/qtbench/benchmarktests.h
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the FOO module 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
#ifndef BENCHMARKTESTS_H
#define BENCHMARKTESTS_H
@@ -128,13 +103,15 @@ public:
{
}
- virtual void draw(QPainter *p, const QRect &rect, int iterationCount) {
+ void draw(QPainter *p, const QRect &rect, int iterationCount) override
+ {
p->fillRect(rect, randomColor(iterationCount));
}
- virtual QString name() const {
+ QString name() const override
+ {
return QString::fromLatin1("fillRect(%1)").arg(m_size.width());
- }
+ }
};
class ImageFillRectBenchmark : public Benchmark
@@ -154,13 +131,12 @@ public:
m_brush = QBrush(m_content);
}
- virtual void draw(QPainter *p, const QRect &rect, int) {
- p->fillRect(rect, m_brush);
- }
+ void draw(QPainter *p, const QRect &rect, int) override { p->fillRect(rect, m_brush); }
- virtual QString name() const {
+ QString name() const override
+ {
return QString::fromLatin1("fillRect with image(%1)").arg(m_size.width());
- }
+ }
private:
QImage m_content;
@@ -176,19 +152,18 @@ public:
{
}
- virtual void begin(QPainter *p, int) {
+ void begin(QPainter *p, int) override
+ {
p->setPen(Qt::NoPen);
p->setBrush(randomColor(m_size.width()));
}
+ void draw(QPainter *p, const QRect &rect, int) override { p->drawRect(rect); }
- virtual void draw(QPainter *p, const QRect &rect, int) {
- p->drawRect(rect);
- }
-
- virtual QString name() const {
+ QString name() const override
+ {
return QString::fromLatin1("drawRect(%1)").arg(m_size.width());
- }
+ }
};
@@ -200,19 +175,18 @@ public:
{
}
- virtual void begin(QPainter *p, int) {
- p->setPen(Qt::NoPen);
- }
-
+ void begin(QPainter *p, int) override { p->setPen(Qt::NoPen); }
- virtual void draw(QPainter *p, const QRect &rect, int i) {
+ void draw(QPainter *p, const QRect &rect, int i) override
+ {
p->setBrush(randomColor(i));
p->drawRect(rect);
}
- virtual QString name() const {
+ QString name() const override
+ {
return QString::fromLatin1("drawRect with brushchange(%1)").arg(m_size.width());
- }
+ }
};
class RoundRectBenchmark : public Benchmark
@@ -224,16 +198,19 @@ public:
m_roundness = size / 4.;
}
- virtual void begin(QPainter *p, int) {
+ void begin(QPainter *p, int) override
+ {
p->setPen(Qt::NoPen);
p->setBrush(Qt::red);
}
- virtual void draw(QPainter *p, const QRect &rect, int) {
+ void draw(QPainter *p, const QRect &rect, int) override
+ {
p->drawRoundedRect(rect, m_roundness, m_roundness);
}
- virtual QString name() const {
+ QString name() const override
+ {
return QString::fromLatin1("drawRoundedRect(%1)").arg(m_size.width());
}
@@ -262,7 +239,8 @@ public:
{
}
- virtual void begin(QPainter *p, int) {
+ void begin(QPainter *p, int) override
+ {
if (m_type & Stroked)
p->setPen(Qt::black);
else
@@ -274,7 +252,8 @@ public:
p->setBrush(Qt::NoBrush);
}
- virtual void draw(QPainter *p, const QRect &rect, int) {
+ void draw(QPainter *p, const QRect &rect, int) override
+ {
switch (m_type & Shapes) {
case ArcShape:
p->drawArc(rect, 45*16, 120*16);
@@ -291,7 +270,8 @@ public:
}
}
- virtual QString name() const {
+ QString name() const override
+ {
QString fillStroke;
if ((m_type & (Stroked|Filled)) == (Stroked|Filled)) {
@@ -336,24 +316,24 @@ public:
{
}
- virtual void begin(QPainter *p, int) {
- p->scale(m_scale, m_scale);
- }
+ void begin(QPainter *p, int) override { p->scale(m_scale, m_scale); }
- virtual void draw(QPainter *p, const QRect &rect, int) {
+ void draw(QPainter *p, const QRect &rect, int) override
+ {
if (m_as_pixmap)
p->drawPixmap(rect.topLeft(), m_pixmap);
else
p->drawImage(rect.topLeft(), m_image);
}
- virtual QString name() const {
+ QString name() const override
+ {
return QString::fromLatin1("draw%4(%1) at scale=%2, depth=%3")
.arg(m_size.width())
.arg(m_scale)
.arg(m_as_pixmap ? m_pixmap.depth() : m_image.depth())
.arg(m_type);
- }
+ }
private:
QImage m_image;
@@ -382,7 +362,8 @@ public:
{
}
- virtual void draw(QPainter *p, const QRect &rect, int) {
+ void draw(QPainter *p, const QRect &rect, int) override
+ {
QTransform oldTransform = p->transform();
p->translate(0.5 * rect.width() + rect.left(), 0.5 * rect.height() + rect.top());
p->shear(0.25, 0.0);
@@ -394,12 +375,13 @@ public:
p->setTransform(oldTransform);
}
- virtual QString name() const {
+ QString name() const override
+ {
return QString::fromLatin1("draw%3(%1) w/transform, depth=%2")
.arg(m_size.width())
.arg(m_as_pixmap ? m_pixmap.depth() : m_image.depth())
.arg(m_type);
- }
+ }
private:
QImage m_image;
@@ -428,19 +410,21 @@ public:
{
}
- virtual void draw(QPainter *p, const QRect &rect, int) {
+ void draw(QPainter *p, const QRect &rect, int) override
+ {
if (m_as_pixmap)
p->drawPixmap(rect.topLeft(), m_pixmap);
else
p->drawImage(rect.topLeft(), m_image);
}
- virtual QString name() const {
+ QString name() const override
+ {
return QString::fromLatin1("draw%2(%1), depth=%3")
.arg(m_size.width())
.arg(m_type)
.arg(m_as_pixmap ? m_pixmap.depth() : m_image.depth());
- }
+ }
private:
QImage m_image;
@@ -469,7 +453,8 @@ public:
{
}
- virtual void begin(QPainter *p, int iterations) {
+ void begin(QPainter *p, int iterations) override
+ {
m_staticTexts.clear();
m_currentStaticText = 0;
m_pixmaps.clear();
@@ -544,20 +529,20 @@ public:
m_staticTexts.append(staticText);
QFontMetrics fm(p->font());
- m_size = QSize(fm.horizontalAdvance(m_text, m_text.length()), fm.height());
+ m_size = QSize(fm.horizontalAdvance(m_text, m_text.size()), fm.height());
break;
}
case PainterQPointMode: {
QFontMetrics fm(p->font());
- m_size = QSize(fm.horizontalAdvance(m_text, m_text.length()), fm.height());
+ m_size = QSize(fm.horizontalAdvance(m_text, m_text.size()), fm.height());
break;
}
}
}
- virtual void draw(QPainter *p, const QRect &rect, int)
+ void draw(QPainter *p, const QRect &rect, int) override
{
switch (m_mode) {
case PainterMode:
@@ -589,8 +574,9 @@ public:
}
}
- virtual QString name() const {
- int letters = m_text.length();
+ QString name() const override
+ {
+ int letters = m_text.size();
int lines = m_text.count('\n');
if (lines == 0)
lines = 1;
@@ -644,7 +630,8 @@ public:
{
}
- virtual void begin(QPainter *p, int) {
+ void begin(QPainter *p, int) override
+ {
QRect m_bounds = QRect(0,0,p->device()->width(), p->device()->height());
p->setPen(Qt::NoPen);
p->setBrush(Qt::red);
@@ -706,11 +693,10 @@ public:
}
}
- virtual void draw(QPainter *p, const QRect &rect, int) {
- p->drawRect(rect);
- }
+ void draw(QPainter *p, const QRect &rect, int) override { p->drawRect(rect); }
- virtual QString name() const {
+ QString name() const override
+ {
QString namedType;
switch (m_type) {
case RectClip:
@@ -739,7 +725,7 @@ public:
break;
}
return QString::fromLatin1("%1-clipped-drawRect(%2)").arg(namedType).arg(m_size.width());
- }
+ }
ClipType m_type;
};
@@ -764,7 +750,8 @@ public:
}
- virtual void draw(QPainter *p, const QRect &rect, int) {
+ void draw(QPainter *p, const QRect &rect, int) override
+ {
switch (m_type) {
case Horizontal_Integer:
p->drawLine(QLine(rect.x(), rect.y(), rect.x() + m_length, rect.y()));
@@ -787,7 +774,8 @@ public:
}
}
- virtual QString name() const {
+ QString name() const override
+ {
const char *names[] = {
"Hor_I",
"Diag_I",