diff options
author | Gunnar Sletta <gunnar.sletta@jollamobile.com> | 2014-08-04 10:10:10 +0200 |
---|---|---|
committer | Gunnar Sletta <gunnar.sletta@jollamobile.com> | 2014-08-04 14:30:04 +0200 |
commit | 6a3d776671bc618fcc184779a8cc8e2d08e08278 (patch) | |
tree | db23658437ed5302824dafcff4ab9b2bf040ebcb /tests | |
parent | a1dd62ce929a605febff8b7b5f0e29064555681b (diff) |
Speed up the test a bit..
Using hundreds of thousands of Items works, but it takes its
toll, so use a custom item to allocate QSGNodes directly which
are instantanous.
Change-Id: Iee5d8495b3d7d5abd24c14a53b2327e5efe9523b
Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/quick/scenegraph/data/render_DrawSets.qml | 33 | ||||
-rw-r--r-- | tests/auto/quick/scenegraph/tst_scenegraph.cpp | 52 |
2 files changed, 58 insertions, 27 deletions
diff --git a/tests/auto/quick/scenegraph/data/render_DrawSets.qml b/tests/auto/quick/scenegraph/data/render_DrawSets.qml index 7515bcf95a..35a8e2860c 100644 --- a/tests/auto/quick/scenegraph/data/render_DrawSets.qml +++ b/tests/auto/quick/scenegraph/data/render_DrawSets.qml @@ -40,6 +40,7 @@ ****************************************************************************/ import QtQuick 2.2 +import SceneGraphTest 1.0 /* The purpose of the test is to verify that a batch of more than 64K @@ -64,39 +65,20 @@ RenderTestBase { id: root - Grid { + Column { id: clipped width: 100 - height: 500 clip: true - columns: 100 - Repeater { - id: clippedRepeater - model: clipped.width * clipped.height - Rectangle { - width: 1 - height: 1 - color: index < clippedRepeater.model / 2 ? "red" : "blue"; - } - } + PerPixelRect { width: 100; height: 250; color: "red" } + PerPixelRect { width: 100; height: 250; color: "blue" } } - Grid { + Column { id: unclipped x: 100 width: 100 - height: 500 - clip: true - columns: 100 - Repeater { - id: unclippedRepeater - model: unclipped.width * unclipped.height - Rectangle { - width: 1 - height: 1 - color: index < unclippedRepeater.model / 2 ? "black" : "#00ff00"; - } - } + PerPixelRect { width: 100; height: 250; color: "black" } + PerPixelRect { width: 100; height: 250; color: "#00ff00" } } SequentialAnimation { @@ -108,6 +90,5 @@ RenderTestBase onEnterFinalStage: { animation.running = true; - } } diff --git a/tests/auto/quick/scenegraph/tst_scenegraph.cpp b/tests/auto/quick/scenegraph/tst_scenegraph.cpp index d510fdcda8..301174656c 100644 --- a/tests/auto/quick/scenegraph/tst_scenegraph.cpp +++ b/tests/auto/quick/scenegraph/tst_scenegraph.cpp @@ -45,14 +45,59 @@ #include <private/qopenglcontext_p.h> - #include <QtQml> +class PerPixelRect : public QQuickItem +{ + Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) + Q_OBJECT +public: + PerPixelRect() { + setFlag(ItemHasContents); + } + + void setColor(const QColor &c) { + if (c == m_color) + return; + m_color = c; + emit colorChanged(c); + } + + QColor color() const { return m_color; } + + QSGNode *updatePaintNode(QSGNode *old, UpdatePaintNodeData *) + { + if (old) + delete old; + + QSGNode *node = new QSGNode(); + + for (int y=0; y<height(); ++y) { + for (int x=0; x<width(); ++x) { + QSGSimpleRectNode *rn = new QSGSimpleRectNode(); + rn->setRect(x, y, 1, 1); + rn->setColor(m_color); + node->appendChildNode(rn); + } + } + + return node; + } + +Q_SIGNALS: + void colorChanged(const QColor &c ); + +private: + QColor m_color; +}; + class tst_SceneGraph : public QObject { Q_OBJECT private slots: + void initTestCase(); + void manyWindows_data(); void manyWindows(); @@ -67,6 +112,11 @@ public: ~ScopedList() { qDeleteAll(*this); } }; +void tst_SceneGraph::initTestCase() +{ + qmlRegisterType<PerPixelRect>("SceneGraphTest", 1, 0, "PerPixelRect"); +} + QQuickView *createView(const QString &file, QWindow *parent = 0, int x = -1, int y = -1, int w = -1, int h = -1) { QQuickView *view = new QQuickView(parent); |