Debian Codegraph @

tests/benchmarks/gui/painting/qregion/main.cpp

raw
1 /****************************************************************************
2 **
3 ** Copyright (C) 2016 The Qt Company Ltd.
4 ** Contact: https://www.qt.io/licensing/
5 **
6 ** This file is part of the test suite of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:GPL-EXCEPT$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and The Qt Company. For licensing terms
14 ** and conditions see https://www.qt.io/terms-conditions. For further
15 ** information use the contact form at https://www.qt.io/contact-us.
16 **
17 ** GNU General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU
19 ** General Public License version 3 as published by the Free Software
20 ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
21 ** included in the packaging of this file. Please review the following
22 ** information to ensure the GNU General Public License requirements will
23 ** be met: https://www.gnu.org/licenses/gpl-3.0.html.
24 **
25 ** $QT_END_LICENSE$
26 **
27 ****************************************************************************/
28 // This file contains benchmarks for QRegion functions.
29
30 #include <QDebug>
31 #include <qtest.h>
32
33 class tst_qregion : public QObject
34 {
35 Q_OBJECT
36 private slots:
37 void map_data();
38 void map();
39
40 void intersects_data();
41 void intersects();
42 };
43
44
45 void tst_qregion::map_data()
46 {
47 QTest::addColumn<QRegion>("region");
48
49 {
50 QRegion region(0, 0, 100, 100);
51 QTest::newRow("single rect") << region;
52 }
53 {
54 QRegion region;
55 region = region.united(QRect(0, 0, 100, 100));
56 region = region.united(QRect(120, 20, 100, 100));
57
58 QTest::newRow("two rects") << region;
59 }
60 {
61 QRegion region(0, 0, 100, 100, QRegion::Ellipse);
62 QTest::newRow("ellipse") << region;
63 }
64 }
65
66 void tst_qregion::map()
67 {
68 QFETCH(QRegion, region);
69
70 QTransform transform;
71 transform.rotate(30);
72 QBENCHMARK {
73 transform.map(region);
74 }
75 }
76
77 void tst_qregion::intersects_data()
78 {
79 QTest::addColumn<QRegion>("region");
80 QTest::addColumn<QRect>("rect");
81
82 QRegion region(0, 0, 100, 100);
83 QRegion complexRegion;
84 complexRegion = complexRegion.united(QRect(0, 0, 100, 100));
85 complexRegion = complexRegion.united(QRect(120, 20, 100, 100));
86
87 {
88 QRect rect(0, 0, 100, 100);
89 QTest::newRow("same -- simple") << region << rect;
90 }
91 {
92 QRect rect(10, 10, 10, 10);
93 QTest::newRow("inside -- simple") << region << rect;
94 }
95 {
96 QRect rect(110, 110, 10, 10);
97 QTest::newRow("outside -- simple") << region << rect;
98 }
99
100 {
101 QRect rect(0, 0, 100, 100);
102 QTest::newRow("same -- complex") << complexRegion << rect;
103 }
104 {
105 QRect rect(10, 10, 10, 10);
106 QTest::newRow("inside -- complex") << complexRegion << rect;
107 }
108 {
109 QRect rect(110, 110, 10, 10);
110 QTest::newRow("outside -- complex") << complexRegion << rect;
111 }
112 }
113
114 void tst_qregion::intersects()
115 {
116 QFETCH(QRegion, region);
117 QFETCH(QRect, rect);
118
119 QBENCHMARK {
120 region.intersects(rect);
121 }
122 }
123
124 QTEST_MAIN(tst_qregion)
125
126 #include "main.moc"