diff options
author | Paul Lemire <paul.lemire@kdab.com> | 2018-07-20 09:17:18 +0200 |
---|---|---|
committer | Paul Lemire <paul.lemire@kdab.com> | 2018-08-08 13:41:13 +0000 |
commit | 85f8e910fa484296afd19a4568ba939502d562f7 (patch) | |
tree | 253c300a1266c5cd1b5997c90796bbb1af0f9369 /tests/manual | |
parent | 0b10ab797fea863ff2c4897b1c4eb993b21b153d (diff) |
Properly update properties from Backend to Frontend textures
Taking into account we have texture sharing in the backend,
we can only update frontend texture properties once we have
created the shared backend texture.
Code was adjusted to retrieve these properties when creating
the GLTexture. Such changes are stored and sent on the next
run loop from a job where they are distributed to all referenced
frontend Texture.
The status property handling has also been updated to send status
changes to all shared textures instead of just the texture whose
data generator is used to gather the data.
A manual test checking texture property updates, sharing and
remote url sharing has also been added.
Change-Id: I8ed2449fe57c9d7337580b0f7561f974cbd5006d
Task-number: QTBUG-65775
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'tests/manual')
-rw-r--r-- | tests/manual/manual.pro | 3 | ||||
-rw-r--r-- | tests/manual/texture_property_updates/image.jpg | bin | 0 -> 6173 bytes | |||
-rw-r--r-- | tests/manual/texture_property_updates/image2.jpg | bin | 0 -> 3983 bytes | |||
-rw-r--r-- | tests/manual/texture_property_updates/main.cpp | 102 | ||||
-rw-r--r-- | tests/manual/texture_property_updates/main.qml | 187 | ||||
-rw-r--r-- | tests/manual/texture_property_updates/texture_property_updates.pro | 10 | ||||
-rw-r--r-- | tests/manual/texture_property_updates/texture_property_updates.qrc | 7 |
7 files changed, 308 insertions, 1 deletions
diff --git a/tests/manual/manual.pro b/tests/manual/manual.pro index f5f60f6cb..643d03e6e 100644 --- a/tests/manual/manual.pro +++ b/tests/manual/manual.pro @@ -58,7 +58,8 @@ SUBDIRS += \ rendercapture-qml-fbo \ blitframebuffer-qml \ raycasting-qml \ - shared_texture_image + shared_texture_image \ + texture_property_updates qtHaveModule(widgets): { SUBDIRS += \ diff --git a/tests/manual/texture_property_updates/image.jpg b/tests/manual/texture_property_updates/image.jpg Binary files differnew file mode 100644 index 000000000..495afa5ce --- /dev/null +++ b/tests/manual/texture_property_updates/image.jpg diff --git a/tests/manual/texture_property_updates/image2.jpg b/tests/manual/texture_property_updates/image2.jpg Binary files differnew file mode 100644 index 000000000..37f6de3e5 --- /dev/null +++ b/tests/manual/texture_property_updates/image2.jpg diff --git a/tests/manual/texture_property_updates/main.cpp b/tests/manual/texture_property_updates/main.cpp new file mode 100644 index 000000000..e145b0a26 --- /dev/null +++ b/tests/manual/texture_property_updates/main.cpp @@ -0,0 +1,102 @@ +/**************************************************************************** +** +** Copyright (C) 2018 Klaralvdalens Datakonsult AB (KDAB). +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QQuickView> +#include <QGuiApplication> +#include <QQmlContext> +#include <Qt3DRender/QAbstractTexture> + +template<typename Obj> +QHash<int, QString> enumToNameMap(const char *enumName) +{ + const QMetaObject metaObj = Obj::staticMetaObject; + const int indexOfEnum = metaObj.indexOfEnumerator(enumName); + const QMetaEnum metaEnum = metaObj.enumerator(indexOfEnum); + const int keysCount = metaEnum.keyCount(); + + QHash<int, QString> v; + v.reserve(keysCount); + for (int i = 0; i < keysCount; ++i) + v[metaEnum.value(i)] = metaEnum.key(i); + return v; +} + + +class EnumNameMapper : public QObject +{ + Q_OBJECT + +public: + Q_INVOKABLE QString statusName(int v) const { return m_statusMap.value(v); } + Q_INVOKABLE QString formatName(int v) const { return m_formatMap.value(v); } + Q_INVOKABLE QString targetName(int v) const { return m_targetMap.value(v); } + +private: + const QHash<int, QString> m_statusMap = enumToNameMap<Qt3DRender::QAbstractTexture>("Status"); + const QHash<int, QString> m_formatMap = enumToNameMap<Qt3DRender::QAbstractTexture>("TextureFormat"); + const QHash<int, QString> m_targetMap = enumToNameMap<Qt3DRender::QAbstractTexture>("Target"); +}; + +int main(int argc, char* argv[]) +{ + QGuiApplication app(argc, argv); + QQuickView view; + + QQmlContext *ctx =view.rootContext(); + EnumNameMapper mapper; + ctx->setContextProperty(QStringLiteral("nameMapper"), &mapper); + + view.setSource(QUrl("qrc:/main.qml")); + view.show(); + + return app.exec(); +} + +#include "main.moc" diff --git a/tests/manual/texture_property_updates/main.qml b/tests/manual/texture_property_updates/main.qml new file mode 100644 index 000000000..ebefdc725 --- /dev/null +++ b/tests/manual/texture_property_updates/main.qml @@ -0,0 +1,187 @@ +/**************************************************************************** +** +** Copyright (C) 2018 Klaralvdalens Datakonsult AB (KDAB). +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.2 as QQ2 +import QtQuick.Scene3D 2.0 +import Qt3D.Core 2.0 +import Qt3D.Render 2.0 +import Qt3D.Input 2.0 +import Qt3D.Extras 2.0 + +QQ2.Item { + id: root + width: 1280 + height: 720 + + property int i: 0 + readonly property var sources: ["https://codereview.qt-project.org/gitweb?p=qt/qt3d.git;a=blob_plain;hb=refs/heads/dev;f=examples/qt3d/planets-qml/images/solarsystemscope/earthmap2k.jpg", "qrc:/image.jpg", "qrc:/image2.jpg", "qrc:/wrongpath.jpg"] + readonly property url textureSource: sources[i] + + QQ2.Timer { + interval: 3000 + repeat: true + running: true + onTriggered: i = (i + 1) % sources.length + } + + Scene3D { + anchors.fill: parent + focus: true + + aspects: ["input", "logic"] + + Entity { + id: sceneRoot + + readonly property var textureModel: [texture1, texture2, texture3, texture4] + + readonly property Texture texture1: TextureLoader { + source: textureSource + } + + readonly property Texture texture2: TextureLoader { + source: textureSource + } + + readonly property Texture texture3: Texture2D { + textureImages: TextureImage { + source: textureSource + } + } + + readonly property Texture texture4: Texture2D { + textureImages: TextureImage { + source: textureSource + } + } + + Camera { + id: camera + projectionType: CameraLens.PerspectiveProjection + fieldOfView: 45 + aspectRatio: 16/9 + nearPlane : 0.1 + farPlane : 1000.0 + position: Qt.vector3d( 0.0, 20.0, -40.0 ) + upVector: Qt.vector3d( 0.0, 1.0, 0.0 ) + viewCenter: Qt.vector3d( 0.0, 0.0, 0.0 ) + } + + OrbitCameraController { + camera: camera + } + + components: [ + RenderSettings { + activeFrameGraph: ForwardRenderer { + clearColor: Qt.rgba(0, 0.5, 1, 1) + camera: camera + } + }, + // Event Source will be set by the Qt3DQuickWindow + InputSettings { } + ] + + CuboidMesh { id: mesh } + + NodeInstantiator { + id: instantiator + model: sceneRoot.textureModel + + Entity { + readonly property Transform transform: Transform { + readonly property real angle: model.index / instantiator.count * Math.PI * 2 + translation: Qt.vector3d(Math.cos(angle) * 10, 0, Math.sin(angle) * 10) + scale: 10 + } + + readonly property DiffuseMapMaterial material: DiffuseMapMaterial { + diffuse: model.modelData + } + components: [ mesh, material, transform ] + } + } + } + } + + QQ2.Text { + anchors { + horizontalCenter: parent.horizontalCenter + bottom: parent.bottom + } + font.pointSize: 20 + text: "Source (" + (i + 1) + " of " + sources.length + "): " + textureSource + } + + QQ2.ListView { + anchors { + left: parent.left + top: parent.top + bottom: parent.bottom + } + readonly property var targets: [] + readonly property var status: [] + + spacing: 30 + model: sceneRoot.textureModel + width: parent.width / 4 + delegate: QQ2.Grid { + spacing: 10 + columns: 2 + QQ2.Text { text: "Target: " + nameMapper.targetName(model.modelData.target) } + QQ2.Text { text: "Format: " + nameMapper.formatName(model.modelData.format.toString()) } + QQ2.Text { text: "Width: " + model.modelData.width } + QQ2.Text { text: "Height: " + model.modelData.height } + QQ2.Text { text: "Depth: " + model.modelData.depth} + QQ2.Text { text: "Layers: " + model.modelData.layers} + QQ2.Text { text: "Status: " + nameMapper.statusName(model.modelData.status.toString()) } + } + } +} diff --git a/tests/manual/texture_property_updates/texture_property_updates.pro b/tests/manual/texture_property_updates/texture_property_updates.pro new file mode 100644 index 000000000..33d72da68 --- /dev/null +++ b/tests/manual/texture_property_updates/texture_property_updates.pro @@ -0,0 +1,10 @@ +QT += 3dcore 3drender 3dinput 3dquick 3dlogic qml quick 3dquickextras + +SOURCES += \ + main.cpp + +OTHER_FILES += \ + main.qml + +RESOURCES += \ + texture_property_updates.qrc diff --git a/tests/manual/texture_property_updates/texture_property_updates.qrc b/tests/manual/texture_property_updates/texture_property_updates.qrc new file mode 100644 index 000000000..eb086cd72 --- /dev/null +++ b/tests/manual/texture_property_updates/texture_property_updates.qrc @@ -0,0 +1,7 @@ +<RCC> + <qresource prefix="/"> + <file>main.qml</file> + <file>image.jpg</file> + <file>image2.jpg</file> + </qresource> +</RCC> |