summaryrefslogtreecommitdiffstats
path: root/tests/benchmarks
diff options
context:
space:
mode:
authorOlivier Goffart <olivier.goffart@nokia.com>2010-05-19 09:46:19 (GMT)
committerOlivier Goffart <olivier.goffart@nokia.com>2010-05-19 09:46:19 (GMT)
commit20befffe67104368f527bab871fec17c33d58977 (patch)
tree88c6e9541ecc4433abcb79197c8ecb720cbdefbd /tests/benchmarks
parentd9e6c98c5cb39c7f6397a8015e1395e040135949 (diff)
parent85611635a3589d56c2670445ea5272e864e57a98 (diff)
downloadQt-20befffe67104368f527bab871fec17c33d58977.zip
Qt-20befffe67104368f527bab871fec17c33d58977.tar.gz
Qt-20befffe67104368f527bab871fec17c33d58977.tar.bz2
Merge remote branch 'origin/4.7' into qt-master-from-4.7
Conflicts: tools/assistant/tools/assistant/centralwidget.cpp tools/assistant/tools/assistant/helpviewer_qwv.cpp tools/assistant/tools/assistant/helpviewer_qwv.h tools/qdoc3/test/assistant.qdocconf tools/qdoc3/test/designer.qdocconf tools/qdoc3/test/linguist.qdocconf tools/qdoc3/test/qmake.qdocconf
Diffstat (limited to 'tests/benchmarks')
-rw-r--r--tests/benchmarks/declarative/binding/binding.pro14
-rw-r--r--tests/benchmarks/declarative/compilation/compilation.pro11
-rw-r--r--tests/benchmarks/declarative/compilation/data/BoomBlock.qml65
-rw-r--r--tests/benchmarks/declarative/compilation/tst_compilation.cpp90
-rw-r--r--tests/benchmarks/declarative/creation/creation.pro11
-rw-r--r--tests/benchmarks/declarative/creation/tst_creation.cpp10
-rw-r--r--tests/benchmarks/declarative/declarative.pro5
-rw-r--r--tests/benchmarks/declarative/painting/painting.pro1
-rw-r--r--tests/benchmarks/declarative/qdeclarativecomponent/qdeclarativecomponent.pro18
-rw-r--r--tests/benchmarks/declarative/qdeclarativeimage/qdeclarativeimage.pro10
-rw-r--r--tests/benchmarks/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp12
-rw-r--r--tests/benchmarks/declarative/qdeclarativemetaproperty/qdeclarativemetaproperty.pro9
-rw-r--r--tests/benchmarks/declarative/script/data/slot_complex_js.js8
-rw-r--r--tests/benchmarks/declarative/script/data/slot_complex_js.qml14
-rw-r--r--tests/benchmarks/declarative/script/data/slot_simple_js.js3
-rw-r--r--tests/benchmarks/declarative/script/data/slot_simple_js.qml10
-rw-r--r--tests/benchmarks/declarative/script/script.pro9
-rw-r--r--tests/benchmarks/declarative/script/tst_script.cpp6
-rw-r--r--tests/benchmarks/gui/image/qpixmap/tst_qpixmap.cpp38
-rw-r--r--tests/benchmarks/gui/kernel/qwidget/tst_qwidget.cpp5
-rw-r--r--tests/benchmarks/gui/painting/qpainter/tst_qpainter.cpp79
21 files changed, 323 insertions, 105 deletions
diff --git a/tests/benchmarks/declarative/binding/binding.pro b/tests/benchmarks/declarative/binding/binding.pro
index 5ceaf34..268541f 100644
--- a/tests/benchmarks/declarative/binding/binding.pro
+++ b/tests/benchmarks/declarative/binding/binding.pro
@@ -8,11 +8,11 @@ SOURCES += tst_binding.cpp testtypes.cpp
HEADERS += testtypes.h
# Define SRCDIR equal to test's source directory
-DEFINES += SRCDIR=\\\"$$PWD\\\"
-
-symbian* {
- data.sources = data/*
- data.path = data
- DEPLOYMENT = data
+symbian: {
+ DEFINES += SRCDIR=\".\"
+ importFiles.sources = data
+ importFiles.path =
+ DEPLOYMENT = importFiles
+} else {
+ DEFINES += SRCDIR=\\\"$$PWD\\\"
}
-
diff --git a/tests/benchmarks/declarative/compilation/compilation.pro b/tests/benchmarks/declarative/compilation/compilation.pro
new file mode 100644
index 0000000..32f4aba
--- /dev/null
+++ b/tests/benchmarks/declarative/compilation/compilation.pro
@@ -0,0 +1,11 @@
+load(qttest_p4)
+TEMPLATE = app
+TARGET = tst_compilation
+QT += declarative
+macx:CONFIG -= app_bundle
+
+CONFIG += release
+
+SOURCES += tst_compilation.cpp
+
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/benchmarks/declarative/compilation/data/BoomBlock.qml b/tests/benchmarks/declarative/compilation/data/BoomBlock.qml
new file mode 100644
index 0000000..47f43c2
--- /dev/null
+++ b/tests/benchmarks/declarative/compilation/data/BoomBlock.qml
@@ -0,0 +1,65 @@
+import Qt 4.7
+import Qt.labs.particles 1.0
+
+Item {
+ id: block
+ property bool dying: false
+ property bool spawned: false
+ property int type: 0
+ property int targetX: 0
+ property int targetY: 0
+
+ SpringFollow on x { enabled: spawned; to: targetX; spring: 2; damping: 0.2 }
+ SpringFollow on y { to: targetY; spring: 2; damping: 0.2 }
+
+ Image {
+ id: img
+ source: {
+ if(type == 0){
+ "pics/redStone.png";
+ } else if(type == 1) {
+ "pics/blueStone.png";
+ } else {
+ "pics/greenStone.png";
+ }
+ }
+ opacity: 0
+ Behavior on opacity { NumberAnimation { duration: 200 } }
+ anchors.fill: parent
+ }
+
+ Particles {
+ id: particles
+
+ width: 1; height: 1
+ anchors.centerIn: parent
+
+ emissionRate: 0
+ lifeSpan: 700; lifeSpanDeviation: 600
+ angle: 0; angleDeviation: 360;
+ velocity: 100; velocityDeviation: 30
+ source: {
+ if(type == 0){
+ "pics/redStar.png";
+ } else if (type == 1) {
+ "pics/blueStar.png";
+ } else {
+ "pics/greenStar.png";
+ }
+ }
+ }
+
+ states: [
+ State {
+ name: "AliveState"; when: spawned == true && dying == false
+ PropertyChanges { target: img; opacity: 1 }
+ },
+
+ State {
+ name: "DeathState"; when: dying == true
+ StateChangeScript { script: particles.burst(50); }
+ PropertyChanges { target: img; opacity: 0 }
+ StateChangeScript { script: block.destroy(1000); }
+ }
+ ]
+}
diff --git a/tests/benchmarks/declarative/compilation/tst_compilation.cpp b/tests/benchmarks/declarative/compilation/tst_compilation.cpp
new file mode 100644
index 0000000..5694d5b
--- /dev/null
+++ b/tests/benchmarks/declarative/compilation/tst_compilation.cpp
@@ -0,0 +1,90 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qtest.h>
+#include <QDeclarativeEngine>
+#include <QDeclarativeComponent>
+#include <QFile>
+
+#ifdef Q_OS_SYMBIAN
+// In Symbian OS test data is located in applications private dir
+// Application private dir is default serach path for files, so SRCDIR can be set to empty
+#define SRCDIR ""
+#endif
+
+class tst_compilation : public QObject
+{
+ Q_OBJECT
+public:
+ tst_compilation();
+
+private slots:
+ void boomblock();
+
+private:
+ QDeclarativeEngine engine;
+};
+
+tst_compilation::tst_compilation()
+{
+}
+
+inline QUrl TEST_FILE(const QString &filename)
+{
+ return QUrl::fromLocalFile(QLatin1String(SRCDIR) + QLatin1String("/data/") + filename);
+}
+
+void tst_compilation::boomblock()
+{
+ QFile f(SRCDIR + QLatin1String("/data/BoomBlock.qml"));
+ QVERIFY(f.open(QIODevice::ReadOnly));
+ QByteArray data = f.readAll();
+
+ QBENCHMARK {
+ QDeclarativeComponent c(&engine);
+ c.setData(data, QUrl());
+// QVERIFY(c.isReady());
+ }
+}
+
+QTEST_MAIN(tst_compilation)
+
+#include "tst_compilation.moc"
diff --git a/tests/benchmarks/declarative/creation/creation.pro b/tests/benchmarks/declarative/creation/creation.pro
index 3e0caf6..08ad772 100644
--- a/tests/benchmarks/declarative/creation/creation.pro
+++ b/tests/benchmarks/declarative/creation/creation.pro
@@ -6,10 +6,11 @@ macx:CONFIG -= app_bundle
SOURCES += tst_creation.cpp
-symbian* {
- data.sources = data/*
- data.path = data
- DEPLOYMENT += addFiles
+symbian: {
+ DEFINES += SRCDIR=\".\"
+ importFiles.sources = data
+ importFiles.path =
+ DEPLOYMENT = importFiles
} else {
DEFINES += SRCDIR=\\\"$$PWD\\\"
-} \ No newline at end of file
+}
diff --git a/tests/benchmarks/declarative/creation/tst_creation.cpp b/tests/benchmarks/declarative/creation/tst_creation.cpp
index 6f00473..6e9197b 100644
--- a/tests/benchmarks/declarative/creation/tst_creation.cpp
+++ b/tests/benchmarks/declarative/creation/tst_creation.cpp
@@ -50,12 +50,6 @@
#include <QDeclarativeContext>
#include <private/qobject_p.h>
-#ifdef Q_OS_SYMBIAN
-// In Symbian OS test data is located in applications private dir
-// Application private dir is default serach path for files, so SRCDIR can be set to empty
-#define SRCDIR ""
-#endif
-
class tst_creation : public QObject
{
Q_OBJECT
@@ -203,7 +197,7 @@ void tst_creation::qobject_10tree_cpp()
void tst_creation::qobject_qmltype()
{
- QDeclarativeType *t = QDeclarativeMetaType::qmlType("Qt/QtObject", 4, 6);
+ QDeclarativeType *t = QDeclarativeMetaType::qmlType("Qt/QtObject", 4, 7);
QBENCHMARK {
QObject *obj = t->create();
@@ -347,7 +341,7 @@ void tst_creation::elements_data()
void tst_creation::elements()
{
QFETCH(QByteArray, type);
- QDeclarativeType *t = QDeclarativeMetaType::qmlType(type, 4, 6);
+ QDeclarativeType *t = QDeclarativeMetaType::qmlType(type, 4, 7);
if (!t || !t->isCreatable())
QSKIP("Non-creatable type", SkipSingle);
diff --git a/tests/benchmarks/declarative/declarative.pro b/tests/benchmarks/declarative/declarative.pro
index a7d426c..262247a 100644
--- a/tests/benchmarks/declarative/declarative.pro
+++ b/tests/benchmarks/declarative/declarative.pro
@@ -1,8 +1,11 @@
TEMPLATE = subdirs
+!symbian: {
+ SUBDIRS += painting
+}
+
SUBDIRS += \
binding \
creation \
- painting \
pointers \
qdeclarativecomponent \
qdeclarativeimage \
diff --git a/tests/benchmarks/declarative/painting/painting.pro b/tests/benchmarks/declarative/painting/painting.pro
index 2f98e8b..a228ea7 100644
--- a/tests/benchmarks/declarative/painting/painting.pro
+++ b/tests/benchmarks/declarative/painting/painting.pro
@@ -11,3 +11,4 @@ INCLUDEPATH += .
SOURCES += paintbenchmark.cpp
QT += opengl
CONFIG += console
+macx:CONFIG -= app_bundle
diff --git a/tests/benchmarks/declarative/qdeclarativecomponent/qdeclarativecomponent.pro b/tests/benchmarks/declarative/qdeclarativecomponent/qdeclarativecomponent.pro
index 30ef235..670e425 100644
--- a/tests/benchmarks/declarative/qdeclarativecomponent/qdeclarativecomponent.pro
+++ b/tests/benchmarks/declarative/qdeclarativecomponent/qdeclarativecomponent.pro
@@ -8,15 +8,11 @@ SOURCES += tst_qdeclarativecomponent.cpp testtypes.cpp
HEADERS += testtypes.h
# Define SRCDIR equal to test's source directory
-DEFINES += SRCDIR=\\\"$$PWD\\\"
-
-symbian* {
- data.sources = data/*
- data.path = data
- samegame.sources = data/samegame/*
- samegame.path = data/samegame
- samegame_pics.sources = data/samegame/pics/*
- samegame_pics.path = data/samegame/pics
- DEPLOYMENT += data samegame samegame_pics
+symbian: {
+ DEFINES += SRCDIR=\".\"
+ importFiles.sources = data
+ importFiles.path =
+ DEPLOYMENT = importFiles
+} else {
+ DEFINES += SRCDIR=\\\"$$PWD\\\"
}
-
diff --git a/tests/benchmarks/declarative/qdeclarativeimage/qdeclarativeimage.pro b/tests/benchmarks/declarative/qdeclarativeimage/qdeclarativeimage.pro
index bbe4e8d..fb5779a 100644
--- a/tests/benchmarks/declarative/qdeclarativeimage/qdeclarativeimage.pro
+++ b/tests/benchmarks/declarative/qdeclarativeimage/qdeclarativeimage.pro
@@ -7,10 +7,12 @@ CONFIG += release
SOURCES += tst_qdeclarativeimage.cpp
-symbian* {
- data.sources = image.png
- data.path = .
- DEPLOYMENT += data
+symbian: {
+ DEFINES += SRCDIR=\".\"
+ importFiles.sources = image.png
+ importFiles.path =
+ DEPLOYMENT = importFiles
} else {
DEFINES += SRCDIR=\\\"$$PWD\\\"
}
+
diff --git a/tests/benchmarks/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp b/tests/benchmarks/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp
index 4bba022..e979f20 100644
--- a/tests/benchmarks/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp
+++ b/tests/benchmarks/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp
@@ -44,12 +44,6 @@
#include <QDeclarativeComponent>
#include <private/qdeclarativeimage_p.h>
-#ifdef Q_OS_SYMBIAN
-// In Symbian OS test data is located in applications private dir
-// Application private dir is default serach path for files, so SRCDIR can be set to empty
-#define SRCDIR ""
-#endif
-
class tst_qmlgraphicsimage : public QObject
{
Q_OBJECT
@@ -68,7 +62,7 @@ private:
void tst_qmlgraphicsimage::qmlgraphicsimage()
{
int x = 0;
- QUrl url("image.png");
+ QUrl url(SRCDIR "/image.png");
QBENCHMARK {
QUrl url2("http://localhost/image" + QString::number(x++) + ".png");
QDeclarativeImage *image = new QDeclarativeImage;
@@ -80,7 +74,7 @@ void tst_qmlgraphicsimage::qmlgraphicsimage()
void tst_qmlgraphicsimage::qmlgraphicsimage_file()
{
int x = 0;
- QUrl url("image.png");
+ QUrl url(SRCDIR "/image.png");
QBENCHMARK {
QUrl url2("http://localhost/image" + QString::number(x++) + ".png");
QDeclarativeImage *image = new QDeclarativeImage;
@@ -93,7 +87,7 @@ void tst_qmlgraphicsimage::qmlgraphicsimage_file()
void tst_qmlgraphicsimage::qmlgraphicsimage_url()
{
int x = 0;
- QUrl url("image.png");
+ QUrl url(SRCDIR "/image.png");
QBENCHMARK {
QUrl url2("http://localhost/image" + QString::number(x++) + ".png");
QDeclarativeImage *image = new QDeclarativeImage;
diff --git a/tests/benchmarks/declarative/qdeclarativemetaproperty/qdeclarativemetaproperty.pro b/tests/benchmarks/declarative/qdeclarativemetaproperty/qdeclarativemetaproperty.pro
index 79fdd26..55dfafe 100644
--- a/tests/benchmarks/declarative/qdeclarativemetaproperty/qdeclarativemetaproperty.pro
+++ b/tests/benchmarks/declarative/qdeclarativemetaproperty/qdeclarativemetaproperty.pro
@@ -7,4 +7,11 @@ macx:CONFIG -= app_bundle
SOURCES += tst_qdeclarativemetaproperty.cpp
# Define SRCDIR equal to test's source directory
-DEFINES += SRCDIR=\\\"$$PWD\\\"
+symbian: {
+ DEFINES += SRCDIR=\".\"
+ importFiles.sources = data
+ importFiles.path =
+ DEPLOYMENT = importFiles
+} else {
+ DEFINES += SRCDIR=\\\"$$PWD\\\"
+}
diff --git a/tests/benchmarks/declarative/script/data/slot_complex_js.js b/tests/benchmarks/declarative/script/data/slot_complex_js.js
new file mode 100644
index 0000000..64a1f65
--- /dev/null
+++ b/tests/benchmarks/declarative/script/data/slot_complex_js.js
@@ -0,0 +1,8 @@
+function myCustomFunction(n) {
+ var a = 1;
+ while (n > 0) {
+ a = a * n;
+ n--;
+ }
+ return a;
+}
diff --git a/tests/benchmarks/declarative/script/data/slot_complex_js.qml b/tests/benchmarks/declarative/script/data/slot_complex_js.qml
index ed4f78b..7bda48b 100644
--- a/tests/benchmarks/declarative/script/data/slot_complex_js.qml
+++ b/tests/benchmarks/declarative/script/data/slot_complex_js.qml
@@ -1,18 +1,8 @@
import Qt.test 1.0
+import "slot_complex_js.js" as Logic
TestObject {
- Script {
- function myCustomFunction(n) {
- var a = 1;
- while (n > 0) {
- a = a * n;
- n--;
- }
- return a;
- }
- }
-
- onMySignal: { for (var ii = 0; ii < 10000; ++ii) { myCustomFunction(10); } }
+ onMySignal: { for (var ii = 0; ii < 10000; ++ii) { Logic.myCustomFunction(10); } }
}
diff --git a/tests/benchmarks/declarative/script/data/slot_simple_js.js b/tests/benchmarks/declarative/script/data/slot_simple_js.js
new file mode 100644
index 0000000..d6e6060
--- /dev/null
+++ b/tests/benchmarks/declarative/script/data/slot_simple_js.js
@@ -0,0 +1,3 @@
+function myCustomFunction() {
+ return 0;
+}
diff --git a/tests/benchmarks/declarative/script/data/slot_simple_js.qml b/tests/benchmarks/declarative/script/data/slot_simple_js.qml
index a88265c..7ea3177 100644
--- a/tests/benchmarks/declarative/script/data/slot_simple_js.qml
+++ b/tests/benchmarks/declarative/script/data/slot_simple_js.qml
@@ -1,13 +1,7 @@
import Qt.test 1.0
+import "slot_simple_js.js" as Logic
TestObject {
-
- Script {
- function myCustomFunction() {
- return 0;
- }
- }
-
- onMySignal: { for (var ii = 0; ii < 10000; ++ii) { myCustomFunction(); } }
+ onMySignal: { for (var ii = 0; ii < 10000; ++ii) { Logic.myCustomFunction(); } }
}
diff --git a/tests/benchmarks/declarative/script/script.pro b/tests/benchmarks/declarative/script/script.pro
index 6255acc..91db871 100644
--- a/tests/benchmarks/declarative/script/script.pro
+++ b/tests/benchmarks/declarative/script/script.pro
@@ -7,10 +7,11 @@ CONFIG += release
SOURCES += tst_script.cpp
-symbian* {
- data.sources = data/*
- data.path = data
- DEPLOYMENT += data
+symbian: {
+ DEFINES += SRCDIR=\".\"
+ importFiles.sources = data
+ importFiles.path =
+ DEPLOYMENT = importFiles
} else {
DEFINES += SRCDIR=\\\"$$PWD\\\"
}
diff --git a/tests/benchmarks/declarative/script/tst_script.cpp b/tests/benchmarks/declarative/script/tst_script.cpp
index 8ea6dcd..6dc7ed6 100644
--- a/tests/benchmarks/declarative/script/tst_script.cpp
+++ b/tests/benchmarks/declarative/script/tst_script.cpp
@@ -48,12 +48,6 @@
#include <QScriptEngine>
#include <QScriptValue>
-#ifdef Q_OS_SYMBIAN
-// In Symbian OS test data is located in applications private dir
-// Application private dir is default serach path for files, so SRCDIR can be set to empty
-#define SRCDIR "."
-#endif
-
class tst_script : public QObject
{
Q_OBJECT
diff --git a/tests/benchmarks/gui/image/qpixmap/tst_qpixmap.cpp b/tests/benchmarks/gui/image/qpixmap/tst_qpixmap.cpp
index 9ffbefb..8e9de4a 100644
--- a/tests/benchmarks/gui/image/qpixmap/tst_qpixmap.cpp
+++ b/tests/benchmarks/gui/image/qpixmap/tst_qpixmap.cpp
@@ -43,6 +43,7 @@
#include <QPixmap>
#include <QBitmap>
#include <QPainter>
+#include <private/qpixmap_raster_p.h>
class tst_QPixmap : public QObject
{
@@ -67,6 +68,31 @@ Q_DECLARE_METATYPE(QImage::Format)
Q_DECLARE_METATYPE(Qt::AspectRatioMode)
Q_DECLARE_METATYPE(Qt::TransformationMode)
+QPixmap rasterPixmap(int width, int height)
+{
+ QPixmapData *data =
+ new QRasterPixmapData(QPixmapData::PixmapType);
+
+ data->resize(width, height);
+
+ return QPixmap(data);
+}
+
+QPixmap rasterPixmap(const QSize &size)
+{
+ return rasterPixmap(size.width(), size.height());
+}
+
+QPixmap rasterPixmap(const QImage &image)
+{
+ QPixmapData *data =
+ new QRasterPixmapData(QPixmapData::PixmapType);
+
+ data->fromImage(image, Qt::AutoColor);
+
+ return QPixmap(data);
+}
+
tst_QPixmap::tst_QPixmap()
{
}
@@ -90,7 +116,7 @@ void tst_QPixmap::fill()
QFETCH(int, height);
const QColor color = opaque ? QColor(255, 0, 0) : QColor(255, 0, 0, 200);
- QPixmap pixmap(width, height);
+ QPixmap pixmap = rasterPixmap(width, height);
QBENCHMARK {
pixmap.fill(color);
@@ -126,8 +152,8 @@ void tst_QPixmap::scaled()
QFETCH(Qt::AspectRatioMode, ratioMode);
QFETCH(Qt::TransformationMode, transformMode);
- QPixmap opaque(size);
- QPixmap transparent(size);
+ QPixmap opaque = rasterPixmap(size);
+ QPixmap transparent = rasterPixmap(size);
opaque.fill(QColor(255, 0, 0));
transparent.fill(QColor(255, 0, 0, 200));
@@ -180,8 +206,8 @@ void tst_QPixmap::transformed()
QFETCH(QTransform, transform);
QFETCH(Qt::TransformationMode, transformMode);
- QPixmap opaque(size);
- QPixmap transparent(size);
+ QPixmap opaque = rasterPixmap(size);
+ QPixmap transparent = rasterPixmap(size);
opaque.fill(QColor(255, 0, 0));
transparent.fill(QColor(255, 0, 0, 200));
@@ -209,7 +235,7 @@ void tst_QPixmap::mask()
{
QFETCH(QSize, size);
- QPixmap src(size);
+ QPixmap src = rasterPixmap(size);
src.fill(Qt::transparent);
{
QPainter p(&src);
diff --git a/tests/benchmarks/gui/kernel/qwidget/tst_qwidget.cpp b/tests/benchmarks/gui/kernel/qwidget/tst_qwidget.cpp
index 8c30be4..7015bd1 100644
--- a/tests/benchmarks/gui/kernel/qwidget/tst_qwidget.cpp
+++ b/tests/benchmarks/gui/kernel/qwidget/tst_qwidget.cpp
@@ -159,12 +159,17 @@ void tst_QWidget::update_data()
QTest::newRow("10x10x1 opaque") << 10 << 10 << 1 << true;
QTest::newRow("10x10x10 opaque") << 10 << 10 << 10 << true;
QTest::newRow("10x10x100 opaque") << 10 << 10 << 100 << true;
+#ifndef Q_OS_SYMBIAN
+ //These test cases cause stack overflow in QWidgetPrivate::paintSiblingsRecursive
+ //see http://bugreports.qt.nokia.com/browse/QTBUG-8512
+ //Symbian threads have a hard limit of 80kB user stack
QTest::newRow("25x25x1 transparent ") << 25 << 25 << 1 << false;
QTest::newRow("25x25x10 transparent") << 25 << 25 << 10 << false;
QTest::newRow("25x25x100 transparent") << 25 << 25 << 100 << false;
QTest::newRow("25x25x1 opaque") << 25 << 25 << 1 << true;
QTest::newRow("25x25x10 opaque") << 25 << 25 << 10 << true;
QTest::newRow("25x25x100 opaque") << 25 << 25 << 100 << true;
+#endif
}
void tst_QWidget::update()
diff --git a/tests/benchmarks/gui/painting/qpainter/tst_qpainter.cpp b/tests/benchmarks/gui/painting/qpainter/tst_qpainter.cpp
index d570bb3..318b671 100644
--- a/tests/benchmarks/gui/painting/qpainter/tst_qpainter.cpp
+++ b/tests/benchmarks/gui/painting/qpainter/tst_qpainter.cpp
@@ -50,6 +50,8 @@
#define M_PI 3.14159265358979323846
#endif
+#include <private/qpixmap_raster_p.h>
+
Q_DECLARE_METATYPE(QLine)
Q_DECLARE_METATYPE(QRect)
Q_DECLARE_METATYPE(QSize)
@@ -125,6 +127,32 @@ struct PrimitiveSet {
};
+QPixmap rasterPixmap(int width, int height)
+{
+ QPixmapData *data =
+ new QRasterPixmapData(QPixmapData::PixmapType);
+
+ data->resize(width, height);
+
+ return QPixmap(data);
+}
+
+QPixmap rasterPixmap(const QSize &size)
+{
+ return rasterPixmap(size.width(), size.height());
+}
+
+QPixmap rasterPixmap(const QImage &image)
+{
+ QPixmapData *data =
+ new QRasterPixmapData(QPixmapData::PixmapType);
+
+ data->fromImage(image, Qt::AutoColor);
+
+ return QPixmap(data);
+}
+
+
class tst_QPainter : public QObject
{
Q_OBJECT
@@ -222,7 +250,8 @@ private:
QPaintDevice *surface()
{
- return new QPixmap(1024, 1024);
+ m_pixmap = rasterPixmap(1024, 1024);
+ return &m_pixmap;
}
@@ -233,6 +262,7 @@ private:
PrimitiveSet m_primitives_100;
PrimitiveSet m_primitives_1000;
+ QPixmap m_pixmap;
QPaintDevice *m_surface;
QPainter m_painter;
@@ -490,7 +520,7 @@ void tst_QPainter::setupBrushes()
void tst_QPainter::beginAndEnd()
{
- QPixmap pixmap(100, 100);
+ QPixmap pixmap = rasterPixmap(100, 100);
QBENCHMARK {
QPainter p;
@@ -505,10 +535,11 @@ void tst_QPainter::drawLine()
QFETCH(QPen, pen);
const int offset = 5;
- QPixmap pixmapUnclipped(qMin(line.x1(), line.x2())
- + 2*offset + qAbs(line.dx()),
- qMin(line.y1(), line.y2())
- + 2*offset + qAbs(line.dy()));
+ QPixmap pixmapUnclipped =
+ rasterPixmap(qMin(line.x1(), line.x2())
+ + 2*offset + qAbs(line.dx()),
+ qMin(line.y1(), line.y2())
+ + 2*offset + qAbs(line.dy()));
pixmapUnclipped.fill(Qt::white);
QPainter p(&pixmapUnclipped);
@@ -535,10 +566,11 @@ void tst_QPainter::drawLine_clipped()
QFETCH(QPen, pen);
const int offset = 5;
- QPixmap pixmapClipped(qMin(line.x1(), line.x2())
- + 2*offset + qAbs(line.dx()),
- qMin(line.y1(), line.y2())
- + 2*offset + qAbs(line.dy()));
+ QPixmap pixmapClipped
+ = rasterPixmap(qMin(line.x1(), line.x2())
+ + 2*offset + qAbs(line.dx()),
+ qMin(line.y1(), line.y2())
+ + 2*offset + qAbs(line.dy()));
const QRect clip = QRect(line.p1(), line.p2()).normalized();
@@ -569,10 +601,11 @@ void tst_QPainter::drawLine_antialiased_clipped()
QFETCH(QPen, pen);
const int offset = 5;
- QPixmap pixmapClipped(qMin(line.x1(), line.x2())
- + 2*offset + qAbs(line.dx()),
- qMin(line.y1(), line.y2())
- + 2*offset + qAbs(line.dy()));
+ QPixmap pixmapClipped
+ = rasterPixmap(qMin(line.x1(), line.x2())
+ + 2*offset + qAbs(line.dx()),
+ qMin(line.y1(), line.y2())
+ + 2*offset + qAbs(line.dy()));
const QRect clip = QRect(line.p1(), line.p2()).normalized();
@@ -696,8 +729,8 @@ void tst_QPainter::drawPixmap()
QImage sourceImage = createImage(type, size).convertToFormat(sourceFormat);
QImage targetImage(size, targetFormat);
- QPixmap sourcePixmap = QPixmap::fromImage(sourceImage);
- QPixmap targetPixmap = QPixmap::fromImage(targetImage);
+ QPixmap sourcePixmap = rasterPixmap(sourceImage);
+ QPixmap targetPixmap = rasterPixmap(targetImage);
QPainter p(&targetPixmap);
@@ -759,10 +792,10 @@ void tst_QPainter::compositionModes()
QFETCH(QSize, size);
QFETCH(QColor, color);
- QPixmap src(size);
+ QPixmap src = rasterPixmap(size);
src.fill(color);
- QPixmap dest(size);
+ QPixmap dest = rasterPixmap(size);
if (mode < QPainter::RasterOp_SourceOrDestination)
color.setAlpha(127); // porter-duff needs an alpha channel
dest.fill(color);
@@ -844,11 +877,11 @@ void tst_QPainter::drawTiledPixmap()
QFETCH(QColor, color);
QFETCH(QPainter::RenderHint, renderHint);
- QPixmap src(srcSize);
+ QPixmap src = rasterPixmap(srcSize);
src.fill(color);
const QRect dstRect = transform.mapRect(QRect(QPoint(), dstSize));
- QPixmap dst(dstRect.right() + 5, dstRect.bottom() + 5);
+ QPixmap dst = rasterPixmap(dstRect.right() + 5, dstRect.bottom() + 5);
QPainter p(&dst);
p.setTransform(transform);
p.setRenderHint(renderHint);
@@ -1411,7 +1444,7 @@ void tst_QPainter::drawBorderPixmapRoundedRect()
rp.drawRoundedRect(QRectF(qreal(pw)/2+1, qreal(pw)/2+1, rectImage.width()-(pw+1), rectImage.height()-(pw+1)), radius, radius);
else
rp.drawRoundedRect(QRectF(qreal(pw)/2, qreal(pw)/2, rectImage.width()-pw, rectImage.height()-pw), radius, radius);
- QPixmap rectPixmap = QPixmap::fromImage(rectImage);
+ QPixmap rectPixmap = rasterPixmap(rectImage);
//setup surface
QImage surface(100, 100, QImage::Format_RGB16);
@@ -1466,7 +1499,7 @@ void tst_QPainter::drawScaledBorderPixmapRoundedRect()
else
rp.drawRoundedRect(QRectF(qreal(pw)/2, qreal(pw)/2, rectImage.width()-pw, rectImage.height()-pw), radius, radius);
- QPixmap rectPixmap = QPixmap::fromImage(rectImage);
+ QPixmap rectPixmap = rasterPixmap(rectImage);
//setup surface
QImage surface(400, 400, QImage::Format_RGB16);
@@ -1522,7 +1555,7 @@ void tst_QPainter::drawTransformedBorderPixmapRoundedRect()
else
rp.drawRoundedRect(QRectF(qreal(pw)/2, qreal(pw)/2, rectImage.width()-pw, rectImage.height()-pw), radius, radius);
- QPixmap rectPixmap = QPixmap::fromImage(rectImage);
+ QPixmap rectPixmap = rasterPixmap(rectImage);
//setup surface
QImage surface(400, 400, QImage::Format_RGB16);