aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/rendernode
diff options
context:
space:
mode:
authorGunnar Sletta <gunnar.sletta@jollamobile.com>2014-05-06 14:54:52 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-05-07 13:53:57 +0200
commitea164757cd709613c2aa2271a71fa32c9a987b1d (patch)
treebd9353ea693eb0e54c83115f06fdfd47856d623c /tests/auto/quick/rendernode
parent2e24488fb16b67a387f58668a8cfe66b04081d40 (diff)
Use correct matrix for render nodes.
Change-Id: I8c137383fa32a64ba64ffb4ed48aa123d0ebf000 Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
Diffstat (limited to 'tests/auto/quick/rendernode')
-rw-r--r--tests/auto/quick/rendernode/data/matrix.qml87
-rw-r--r--tests/auto/quick/rendernode/rendernode.pro2
-rw-r--r--tests/auto/quick/rendernode/tst_rendernode.cpp79
3 files changed, 168 insertions, 0 deletions
diff --git a/tests/auto/quick/rendernode/data/matrix.qml b/tests/auto/quick/rendernode/data/matrix.qml
new file mode 100644
index 0000000000..8b721e5075
--- /dev/null
+++ b/tests/auto/quick/rendernode/data/matrix.qml
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Jolla Ltd, author: <gunnar.sletta@jollamobile.com>
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** 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, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import RenderNode 1.0
+
+Item {
+ width: 320
+ height: 480
+
+ Item { x: 10; y: 10; width: 10; height: 10;
+ StateRecorder { x: 10; y: 10; objectName: "no-clip; no-rotation"; }
+ }
+
+ Item { x: 10; y: 10; width: 10; height: 10; clip: true
+ StateRecorder { x: 10; y: 10; objectName: "parent-clip; no-rotation"; }
+ }
+
+ Item { x: 10; y: 10; width: 10; height: 10;
+ StateRecorder { x: 10; y: 10; objectName: "self-clip; no-rotation"; clip: true }
+ }
+
+
+ Item { x: 10; y: 10; width: 10; height: 10; rotation: 90
+ StateRecorder { x: 10; y: 10; objectName: "no-clip; parent-rotation"; }
+ }
+
+ Item { x: 10; y: 10; width: 10; height: 10; clip: true; rotation: 90
+ StateRecorder { x: 10; y: 10; objectName: "parent-clip; parent-rotation"; }
+ }
+
+ Item { x: 10; y: 10; width: 10; height: 10; rotation: 90
+ StateRecorder { x: 10; y: 10; objectName: "self-clip; parent-rotation"; clip: true }
+ }
+
+
+ Item { x: 10; y: 10; width: 10; height: 10;
+ StateRecorder { x: 10; y: 10; objectName: "no-clip; self-rotation"; rotation: 90 }
+ }
+
+ Item { x: 10; y: 10; width: 10; height: 10; clip: true;
+ StateRecorder { x: 10; y: 10; objectName: "parent-clip; self-rotation"; rotation: 90}
+ }
+
+ Item { x: 10; y: 10; width: 10; height: 10;
+ StateRecorder { x: 10; y: 10; objectName: "self-clip; self-rotation"; clip: true; rotation: 90 }
+ }
+
+}
diff --git a/tests/auto/quick/rendernode/rendernode.pro b/tests/auto/quick/rendernode/rendernode.pro
index b55b7b0bec..bedcefde86 100644
--- a/tests/auto/quick/rendernode/rendernode.pro
+++ b/tests/auto/quick/rendernode/rendernode.pro
@@ -14,4 +14,6 @@ QT += core-private gui-private qml-private quick-private testlib
OTHER_FILES += \
data/RenderOrder.qml \
data/MessUpState.qml \
+ data/matrix.qml
+
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
diff --git a/tests/auto/quick/rendernode/tst_rendernode.cpp b/tests/auto/quick/rendernode/tst_rendernode.cpp
index 06338e09e2..98e31329a0 100644
--- a/tests/auto/quick/rendernode/tst_rendernode.cpp
+++ b/tests/auto/quick/rendernode/tst_rendernode.cpp
@@ -72,6 +72,7 @@ public:
private slots:
void renderOrder();
void messUpState();
+ void matrix();
};
class ClearNode : public QSGRenderNode
@@ -261,6 +262,84 @@ void tst_rendernode::messUpState()
QCOMPARE(fb.pixel(x2, y5), qRgb(0x00, 0x00, 0x00));
}
+class StateRecordingRenderNode : public QSGRenderNode
+{
+public:
+ StateFlags changedStates() { return StateFlags(-1); }
+ void render(const RenderState &) {
+ matrices[name] = *matrix();
+
+ }
+
+ QString name;
+ static QHash<QString, QMatrix4x4> matrices;
+};
+
+QHash<QString, QMatrix4x4> StateRecordingRenderNode::matrices;
+
+class StateRecordingRenderNodeItem : public QQuickItem
+{
+ Q_OBJECT
+public:
+ StateRecordingRenderNodeItem() { setFlag(ItemHasContents, true); }
+ QSGNode *updatePaintNode(QSGNode *r, UpdatePaintNodeData *) {
+ if (r)
+ return r;
+ StateRecordingRenderNode *rn = new StateRecordingRenderNode();
+ rn->name = objectName();
+ return rn;
+ }
+};
+
+void tst_rendernode::matrix()
+{
+ qmlRegisterType<StateRecordingRenderNodeItem>("RenderNode", 1, 0, "StateRecorder");
+ StateRecordingRenderNode::matrices.clear();
+ runTest("matrix.qml");
+
+ QMatrix4x4 noRotateOffset;
+ noRotateOffset.translate(20, 20);
+ { QMatrix4x4 result = StateRecordingRenderNode::matrices.value(QStringLiteral("no-clip; no-rotation"));
+ QCOMPARE(result, noRotateOffset);
+ }
+ { QMatrix4x4 result = StateRecordingRenderNode::matrices.value(QStringLiteral("parent-clip; no-rotation"));
+ QCOMPARE(result, noRotateOffset);
+ }
+ { QMatrix4x4 result = StateRecordingRenderNode::matrices.value(QStringLiteral("self-clip; no-rotation"));
+ QCOMPARE(result, noRotateOffset);
+ }
+
+ QMatrix4x4 parentRotation;
+ parentRotation.translate(10, 10); // parent at x/y: 10
+ parentRotation.translate(5, 5); // rotate 90 around center (width/height: 10)
+ parentRotation.rotate(90, 0, 0, 1);
+ parentRotation.translate(-5, -5);
+ parentRotation.translate(10, 10); // StateRecorder at: x/y: 10
+ { QMatrix4x4 result = StateRecordingRenderNode::matrices.value(QStringLiteral("no-clip; parent-rotation"));
+ QCOMPARE(result, parentRotation);
+ }
+ { QMatrix4x4 result = StateRecordingRenderNode::matrices.value(QStringLiteral("parent-clip; parent-rotation"));
+ QCOMPARE(result, parentRotation);
+ }
+ { QMatrix4x4 result = StateRecordingRenderNode::matrices.value(QStringLiteral("self-clip; parent-rotation"));
+ QCOMPARE(result, parentRotation);
+ }
+
+ QMatrix4x4 selfRotation;
+ selfRotation.translate(10, 10); // parent at x/y: 10
+ selfRotation.translate(10, 10); // StateRecorder at: x/y: 10
+ selfRotation.rotate(90, 0, 0, 1); // rotate 90, width/height: 0
+ { QMatrix4x4 result = StateRecordingRenderNode::matrices.value(QStringLiteral("no-clip; self-rotation"));
+ QCOMPARE(result, selfRotation);
+ }
+ { QMatrix4x4 result = StateRecordingRenderNode::matrices.value(QStringLiteral("parent-clip; self-rotation"));
+ QCOMPARE(result, selfRotation);
+ }
+ { QMatrix4x4 result = StateRecordingRenderNode::matrices.value(QStringLiteral("self-clip; self-rotation"));
+ QCOMPARE(result, selfRotation);
+ }
+}
+
QTEST_MAIN(tst_rendernode)