summaryrefslogtreecommitdiffstats
path: root/examples/quick
diff options
context:
space:
mode:
authorJonas Karlsson <jonas.karlsson@qt.io>2020-06-10 09:32:18 +0200
committerJonas Karlsson <jonas.karlsson@qt.io>2020-06-10 12:51:53 +0200
commit1ca74842e8427eb21d37697b3c130eed56b7091f (patch)
treea19f64bc038f5298d56a0009f68d61f2b1bdda7c /examples/quick
parentd5c13c42f101552bb62ae5064115dcb7f7624063 (diff)
Remove rendernode and opengltextureinthread examples
Task-Id: QTBUG-84623 Change-Id: I786a7a8ee256d8c395dd0e828213c5d137ba20dc Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Diffstat (limited to 'examples/quick')
-rw-r--r--examples/quick/scenegraph/CMakeLists.txt2
-rw-r--r--examples/quick/scenegraph/opengltextureinthread/CMakeLists.txt64
-rw-r--r--examples/quick/scenegraph/opengltextureinthread/doc/images/opengltextureinthread-example.jpgbin33269 -> 0 bytes
-rw-r--r--examples/quick/scenegraph/opengltextureinthread/doc/src/opengltextureinthread.qdoc36
-rw-r--r--examples/quick/scenegraph/opengltextureinthread/error.qml59
-rw-r--r--examples/quick/scenegraph/opengltextureinthread/main.cpp103
-rw-r--r--examples/quick/scenegraph/opengltextureinthread/main.qml120
-rw-r--r--examples/quick/scenegraph/opengltextureinthread/opengltextureinthread.pro24
-rw-r--r--examples/quick/scenegraph/opengltextureinthread/textureinthread.qrc6
-rw-r--r--examples/quick/scenegraph/opengltextureinthread/threadrenderer.cpp302
-rw-r--r--examples/quick/scenegraph/opengltextureinthread/threadrenderer.h78
-rw-r--r--examples/quick/scenegraph/rendernode/CMakeLists.txt73
-rw-r--r--examples/quick/scenegraph/rendernode/customrenderitem.cpp123
-rw-r--r--examples/quick/scenegraph/rendernode/customrenderitem.h68
-rw-r--r--examples/quick/scenegraph/rendernode/doc/images/rendernode-example.jpgbin77210 -> 0 bytes
-rw-r--r--examples/quick/scenegraph/rendernode/doc/src/rendernode.qdoc165
-rw-r--r--examples/quick/scenegraph/rendernode/main.cpp87
-rw-r--r--examples/quick/scenegraph/rendernode/main.qml167
-rw-r--r--examples/quick/scenegraph/rendernode/metalrenderer.h104
-rw-r--r--examples/quick/scenegraph/rendernode/metalrenderer.mm334
-rw-r--r--examples/quick/scenegraph/rendernode/metalshader.frag28
-rw-r--r--examples/quick/scenegraph/rendernode/metalshader.vert31
-rw-r--r--examples/quick/scenegraph/rendernode/openglrenderer.cpp200
-rw-r--r--examples/quick/scenegraph/rendernode/openglrenderer.h94
-rw-r--r--examples/quick/scenegraph/rendernode/rendernode.pro28
-rw-r--r--examples/quick/scenegraph/rendernode/rendernode.qrc7
-rw-r--r--examples/quick/scenegraph/rendernode/shader.hlsl28
-rw-r--r--examples/quick/scenegraph/rendernode/softwarerenderer.cpp117
-rw-r--r--examples/quick/scenegraph/rendernode/softwarerenderer.h76
-rw-r--r--examples/quick/scenegraph/scenegraph.pro2
30 files changed, 0 insertions, 2526 deletions
diff --git a/examples/quick/scenegraph/CMakeLists.txt b/examples/quick/scenegraph/CMakeLists.txt
index 58eef63060..867a0acb16 100644
--- a/examples/quick/scenegraph/CMakeLists.txt
+++ b/examples/quick/scenegraph/CMakeLists.txt
@@ -1,13 +1,11 @@
# Generated from scenegraph.pro.
add_subdirectory(customgeometry)
-# add_subdirectory(rendernode) # special case needs fixing
add_subdirectory(threadedanimation)
if(QT_FEATURE_opengl OR QT_FEATURE_opengles2 OR QT_FEATURE_opengles3)
add_subdirectory(graph)
add_subdirectory(fboitem)
add_subdirectory(openglunderqml)
- add_subdirectory(opengltextureinthread)
add_subdirectory(twotextureproviders)
endif()
if(IOS OR MACOS)
diff --git a/examples/quick/scenegraph/opengltextureinthread/CMakeLists.txt b/examples/quick/scenegraph/opengltextureinthread/CMakeLists.txt
deleted file mode 100644
index 1ff98ee7c6..0000000000
--- a/examples/quick/scenegraph/opengltextureinthread/CMakeLists.txt
+++ /dev/null
@@ -1,64 +0,0 @@
-# Generated from opengltextureinthread.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(opengltextureinthread LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/quick/scenegraph/opengltextureinthread")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Quick)
-
-add_qt_gui_executable(opengltextureinthread
- ../shared/logorenderer.cpp ../shared/logorenderer.h
- main.cpp
- threadrenderer.cpp threadrenderer.h
-)
-target_include_directories(opengltextureinthread PUBLIC
- ../shared
-)
-
-target_link_libraries(opengltextureinthread PUBLIC
- Qt::Core
- Qt::CorePrivate
- Qt::Gui
- Qt::GuiPrivate
- Qt::Quick
-)
-
-
-# Resources:
-set(textureinthread_resource_files
- "error.qml"
- "main.qml"
-)
-
-qt6_add_resources(opengltextureinthread "textureinthread"
- PREFIX
- "/scenegraph/textureinthread"
- FILES
- ${textureinthread_resource_files}
-)
-
-install(TARGETS opengltextureinthread
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
-
-set_target_properties(opengltextureinthread PROPERTIES
- QT_QML_MODULE_VERSION 1.0
- QT_QML_MODULE_URI SceneGraphRendering
-)
-
-qt6_qml_type_registration(opengltextureinthread)
diff --git a/examples/quick/scenegraph/opengltextureinthread/doc/images/opengltextureinthread-example.jpg b/examples/quick/scenegraph/opengltextureinthread/doc/images/opengltextureinthread-example.jpg
deleted file mode 100644
index 59134e07c4..0000000000
--- a/examples/quick/scenegraph/opengltextureinthread/doc/images/opengltextureinthread-example.jpg
+++ /dev/null
Binary files differ
diff --git a/examples/quick/scenegraph/opengltextureinthread/doc/src/opengltextureinthread.qdoc b/examples/quick/scenegraph/opengltextureinthread/doc/src/opengltextureinthread.qdoc
deleted file mode 100644
index 3c26138332..0000000000
--- a/examples/quick/scenegraph/opengltextureinthread/doc/src/opengltextureinthread.qdoc
+++ /dev/null
@@ -1,36 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** 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.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \example scenegraph/opengltextureinthread
- \title Scene Graph - Rendering FBOs in a thread
- \ingroup qtquickexamples
-
- \brief Shows how to use FramebufferObjects in a thread together with Qt Quick.
-
- \image opengltextureinthread-example.jpg
- */
diff --git a/examples/quick/scenegraph/opengltextureinthread/error.qml b/examples/quick/scenegraph/opengltextureinthread/error.qml
deleted file mode 100644
index 6c300af808..0000000000
--- a/examples/quick/scenegraph/opengltextureinthread/error.qml
+++ /dev/null
@@ -1,59 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples 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.0
-
-Text {
- width: 400
- height: 100
- text: 'Platform does not support threaded OpenGL needed by this example.'
- verticalAlignment: Text.AlignVCenter
- horizontalAlignment: Text.AlignHCenter
-}
diff --git a/examples/quick/scenegraph/opengltextureinthread/main.cpp b/examples/quick/scenegraph/opengltextureinthread/main.cpp
deleted file mode 100644
index 08bf8ff66a..0000000000
--- a/examples/quick/scenegraph/opengltextureinthread/main.cpp
+++ /dev/null
@@ -1,103 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples 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 <QtCore/QThread>
-
-#include <QGuiApplication>
-
-#include <QtGui/private/qguiapplication_p.h>
-#include <QtGui/qpa/qplatformintegration.h>
-
-#include <QtQuick/QQuickView>
-
-#include "threadrenderer.h"
-
-int main(int argc, char **argv)
-{
- QGuiApplication app(argc, argv);
-
- // this example is only compatible with OpenGL
- QQuickWindow::setSceneGraphBackend(QSGRendererInterface::OpenGLRhi);
-
- if (!QGuiApplicationPrivate::platform_integration->hasCapability(QPlatformIntegration::ThreadedOpenGL)) {
- QQuickView view;
- view.setSource(QUrl("qrc:///scenegraph/textureinthread/error.qml"));
- view.show();
- return app.exec();
- }
-
- int execReturn = 0;
-
- {
- QQuickView view;
-
- // Rendering in a thread introduces a slightly more complicated cleanup
- // so we ensure that no cleanup of graphics resources happen until the
- // application is shutting down.
- view.setPersistentOpenGLContext(true);
- view.setPersistentSceneGraph(true);
-
- view.setResizeMode(QQuickView::SizeRootObjectToView);
- view.setSource(QUrl("qrc:///scenegraph/textureinthread/main.qml"));
- view.show();
-
- execReturn = app.exec();
- }
-
- // As the render threads make use of our QGuiApplication object
- // to clean up gracefully, wait for them to finish before
- // QGuiApp is taken off the heap.
- for (QThread *t : qAsConst(ThreadRenderer::threads)) {
- t->wait();
- delete t;
- }
-
- return execReturn;
-}
diff --git a/examples/quick/scenegraph/opengltextureinthread/main.qml b/examples/quick/scenegraph/opengltextureinthread/main.qml
deleted file mode 100644
index 51a3744f76..0000000000
--- a/examples/quick/scenegraph/opengltextureinthread/main.qml
+++ /dev/null
@@ -1,120 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples 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.0
-
-import SceneGraphRendering 1.0
-
-Rectangle {
- width: 400
- height: 400
- color: "lightGray"
-
- Renderer {
- id: renderer
- anchors.fill: parent
- anchors.margins: 10
-
- // The transform is just to show something interesting..
- transform: [
- Rotation { id: rotation; axis.x: 0; axis.z: 0; axis.y: 1; angle: 0; origin.x: renderer.width / 2; origin.y: renderer.height / 2; },
- Translate { id: txOut; x: -renderer.width / 2; y: -renderer.height / 2 },
- Scale { id: scale; },
- Translate { id: txIn; x: renderer.width / 2; y: renderer.height / 2 }
- ]
-
- Behavior on opacity { NumberAnimation { duration: 500 } }
- opacity: 0
- Component.onCompleted: renderer.opacity = 1;
- }
-
- // Just to show something interesting
- SequentialAnimation {
- PauseAnimation { duration: 5000 }
- ParallelAnimation {
- NumberAnimation { target: scale; property: "xScale"; to: 0.6; duration: 1000; easing.type: Easing.InOutBack }
- NumberAnimation { target: scale; property: "yScale"; to: 0.6; duration: 1000; easing.type: Easing.InOutBack }
- }
- NumberAnimation { target: rotation; property: "angle"; to: 80; duration: 1000; easing.type: Easing.InOutCubic }
- NumberAnimation { target: rotation; property: "angle"; to: -80; duration: 1000; easing.type: Easing.InOutCubic }
- NumberAnimation { target: rotation; property: "angle"; to: 0; duration: 1000; easing.type: Easing.InOutCubic }
- NumberAnimation { target: renderer; property: "opacity"; to: 0.5; duration: 1000; easing.type: Easing.InOutCubic }
- PauseAnimation { duration: 1000 }
- NumberAnimation { target: renderer; property: "opacity"; to: 0.8; duration: 1000; easing.type: Easing.InOutCubic }
- ParallelAnimation {
- NumberAnimation { target: scale; property: "xScale"; to: 1; duration: 1000; easing.type: Easing.InOutBack }
- NumberAnimation { target: scale; property: "yScale"; to: 1; duration: 1000; easing.type: Easing.InOutBack }
- }
- running: true
- loops: Animation.Infinite
- }
-
- Rectangle {
- id: labelFrame
- anchors.margins: -10
- radius: 5
- color: "white"
- border.color: "black"
- opacity: 0.8
- anchors.fill: label
- }
-
- Text {
- id: label
- anchors.bottom: renderer.bottom
- anchors.left: renderer.left
- anchors.right: renderer.right
- anchors.margins: 20
- wrapMode: Text.WordWrap
- text: "The blue rectangle with the vintage 'Q' is an FBO, rendered by the application in a dedicated background thread. The background thread juggles two FBOs, one that is being rendered to and one for displaying. The texture to display is posted to the scene graph and displayed using a QSGSimpleTextureNode."
- }
-
-
-}
diff --git a/examples/quick/scenegraph/opengltextureinthread/opengltextureinthread.pro b/examples/quick/scenegraph/opengltextureinthread/opengltextureinthread.pro
deleted file mode 100644
index d07149a2f9..0000000000
--- a/examples/quick/scenegraph/opengltextureinthread/opengltextureinthread.pro
+++ /dev/null
@@ -1,24 +0,0 @@
-QT += quick
-
-# To make threaded gl check...
-QT += core-private gui-private
-
-CONFIG += qmltypes
-QML_IMPORT_NAME = SceneGraphRendering
-QML_IMPORT_MAJOR_VERSION = 1
-
-HEADERS += threadrenderer.h
-SOURCES += threadrenderer.cpp main.cpp
-
-INCLUDEPATH += ../shared
-HEADERS += ../shared/logorenderer.h
-SOURCES += ../shared/logorenderer.cpp
-
-RESOURCES += textureinthread.qrc
-
-target.path = $$[QT_INSTALL_EXAMPLES]/quick/scenegraph/opengltextureinthread
-INSTALLS += target
-
-OTHER_FILES += \
- main.qml \
- error.qml
diff --git a/examples/quick/scenegraph/opengltextureinthread/textureinthread.qrc b/examples/quick/scenegraph/opengltextureinthread/textureinthread.qrc
deleted file mode 100644
index 66eb53b736..0000000000
--- a/examples/quick/scenegraph/opengltextureinthread/textureinthread.qrc
+++ /dev/null
@@ -1,6 +0,0 @@
-<RCC>
- <qresource prefix="/scenegraph/textureinthread">
- <file>main.qml</file>
- <file>error.qml</file>
- </qresource>
-</RCC>
diff --git a/examples/quick/scenegraph/opengltextureinthread/threadrenderer.cpp b/examples/quick/scenegraph/opengltextureinthread/threadrenderer.cpp
deleted file mode 100644
index 6f6ec467dc..0000000000
--- a/examples/quick/scenegraph/opengltextureinthread/threadrenderer.cpp
+++ /dev/null
@@ -1,302 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples 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 "threadrenderer.h"
-#include "logorenderer.h"
-
-#include <QtCore/QMutex>
-#include <QtCore/QThread>
-
-#include <QOpenGLContext>
-#include <QOpenGLFramebufferObject>
-#include <QtGui/QGuiApplication>
-#include <QtGui/QOffscreenSurface>
-
-#include <QtQuick/QQuickWindow>
-#include <qsgsimpletexturenode.h>
-
-QList<QThread *> ThreadRenderer::threads;
-
-/*
- * The render thread shares a context with the scene graph and will
- * render into two separate FBOs, one to use for display and one
- * to use for rendering
- */
-class RenderThread : public QThread
-{
- Q_OBJECT
-public:
- RenderThread(const QSize &size)
- : surface(nullptr)
- , context(nullptr)
- , m_renderFbo(nullptr)
- , m_displayFbo(nullptr)
- , m_logoRenderer(nullptr)
- , m_size(size)
- {
- ThreadRenderer::threads << this;
- }
-
- QOffscreenSurface *surface;
- QOpenGLContext *context;
-
-public slots:
- void renderNext()
- {
- context->makeCurrent(surface);
-
- if (!m_renderFbo) {
- // Initialize the buffers and renderer
- QOpenGLFramebufferObjectFormat format;
- format.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil);
- m_renderFbo = new QOpenGLFramebufferObject(m_size, format);
- m_displayFbo = new QOpenGLFramebufferObject(m_size, format);
- m_logoRenderer = new LogoRenderer();
- m_logoRenderer->initialize();
- }
-
- m_renderFbo->bind();
- context->functions()->glViewport(0, 0, m_size.width(), m_size.height());
-
- m_logoRenderer->render();
-
- // We need to flush the contents to the FBO before posting
- // the texture to the other thread, otherwise, we might
- // get unexpected results.
- context->functions()->glFlush();
-
- m_renderFbo->bindDefault();
- qSwap(m_renderFbo, m_displayFbo);
-
- emit textureReady(m_displayFbo->texture(), m_size);
- }
-
- void shutDown()
- {
- context->makeCurrent(surface);
- delete m_renderFbo;
- delete m_displayFbo;
- delete m_logoRenderer;
- context->doneCurrent();
- delete context;
-
- // schedule this to be deleted only after we're done cleaning up
- surface->deleteLater();
-
- // Stop event processing, move the thread to GUI and make sure it is deleted.
- exit();
- moveToThread(QGuiApplication::instance()->thread());
- }
-
-signals:
- void textureReady(int id, const QSize &size);
-
-private:
- QOpenGLFramebufferObject *m_renderFbo;
- QOpenGLFramebufferObject *m_displayFbo;
-
- LogoRenderer *m_logoRenderer;
- QSize m_size;
-};
-
-
-
-class TextureNode : public QObject, public QSGSimpleTextureNode
-{
- Q_OBJECT
-
-public:
- TextureNode(QQuickWindow *window)
- : m_id(0)
- , m_size(0, 0)
- , m_texture(nullptr)
- , m_window(window)
- {
- // Our texture node must have a texture, so use the default 0 texture.
- GLuint id = 0;
- m_texture = m_window->createTextureFromNativeObject(QQuickWindow::NativeObjectTexture, id, 0, QSize(1, 1));
- setTexture(m_texture);
- setFiltering(QSGTexture::Linear);
- }
-
- ~TextureNode() override
- {
- delete m_texture;
- }
-
-signals:
- void textureInUse();
- void pendingNewTexture();
-
-public slots:
-
- // This function gets called on the FBO rendering thread and will store the
- // texture id and size and schedule an update on the window.
- void newTexture(int id, const QSize &size) {
- m_mutex.lock();
- m_id = id;
- m_size = size;
- m_mutex.unlock();
-
- // We cannot call QQuickWindow::update directly here, as this is only allowed
- // from the rendering thread or GUI thread.
- emit pendingNewTexture();
- }
-
-
- // Before the scene graph starts to render, we update to the pending texture
- void prepareNode() {
- m_mutex.lock();
- int newId = m_id;
- QSize size = m_size;
- m_id = 0;
- m_mutex.unlock();
- if (newId) {
- delete m_texture;
- // note: include QQuickWindow::TextureHasAlphaChannel if the rendered content
- // has alpha.
- m_texture = m_window->createTextureFromNativeObject(QQuickWindow::NativeObjectTexture, newId, 0, QSize(1, 1));
- setTexture(m_texture);
-
- markDirty(DirtyMaterial);
-
- // This will notify the rendering thread that the texture is now being rendered
- // and it can start rendering to the other one.
- emit textureInUse();
- }
- }
-
-private:
-
- int m_id;
- QSize m_size;
-
- QMutex m_mutex;
-
- QSGTexture *m_texture;
- QQuickWindow *m_window;
-};
-
-ThreadRenderer::ThreadRenderer()
- : m_renderThread(nullptr)
-{
- setFlag(ItemHasContents, true);
- m_renderThread = new RenderThread(QSize(512, 512));
-}
-
-void ThreadRenderer::ready()
-{
- m_renderThread->surface = new QOffscreenSurface();
- m_renderThread->surface->setFormat(m_renderThread->context->format());
- m_renderThread->surface->create();
-
- m_renderThread->moveToThread(m_renderThread);
-
- connect(window(), &QQuickWindow::sceneGraphInvalidated, m_renderThread, &RenderThread::shutDown, Qt::QueuedConnection);
-
- m_renderThread->start();
- update();
-}
-
-QSGNode *ThreadRenderer::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *)
-{
- TextureNode *node = static_cast<TextureNode *>(oldNode);
-
- if (!m_renderThread->context) {
- QOpenGLContext *current = window()->openglContext();
- // Some GL implementations requres that the currently bound context is
- // made non-current before we set up sharing, so we doneCurrent here
- // and makeCurrent down below while setting up our own context.
- current->doneCurrent();
-
- m_renderThread->context = new QOpenGLContext();
- m_renderThread->context->setFormat(current->format());
- m_renderThread->context->setShareContext(current);
- m_renderThread->context->create();
- m_renderThread->context->moveToThread(m_renderThread);
-
- current->makeCurrent(window());
-
- QMetaObject::invokeMethod(this, "ready");
- return nullptr;
- }
-
- if (!node) {
- node = new TextureNode(window());
-
- /* Set up connections to get the production of FBO textures in sync with vsync on the
- * rendering thread.
- *
- * When a new texture is ready on the rendering thread, we use a direct connection to
- * the texture node to let it know a new texture can be used. The node will then
- * emit pendingNewTexture which we bind to QQuickWindow::update to schedule a redraw.
- *
- * When the scene graph starts rendering the next frame, the prepareNode() function
- * is used to update the node with the new texture. Once it completes, it emits
- * textureInUse() which we connect to the FBO rendering thread's renderNext() to have
- * it start producing content into its current "back buffer".
- *
- * This FBO rendering pipeline is throttled by vsync on the scene graph rendering thread.
- */
- connect(m_renderThread, &RenderThread::textureReady, node, &TextureNode::newTexture, Qt::DirectConnection);
- connect(node, &TextureNode::pendingNewTexture, window(), &QQuickWindow::update, Qt::QueuedConnection);
- connect(window(), &QQuickWindow::beforeRendering, node, &TextureNode::prepareNode, Qt::DirectConnection);
- connect(node, &TextureNode::textureInUse, m_renderThread, &RenderThread::renderNext, Qt::QueuedConnection);
-
- // Get the production of FBO textures started..
- QMetaObject::invokeMethod(m_renderThread, "renderNext", Qt::QueuedConnection);
- }
-
- node->setRect(boundingRect());
-
- return node;
-}
-
-#include "threadrenderer.moc"
diff --git a/examples/quick/scenegraph/opengltextureinthread/threadrenderer.h b/examples/quick/scenegraph/opengltextureinthread/threadrenderer.h
deleted file mode 100644
index 96c00e7b2e..0000000000
--- a/examples/quick/scenegraph/opengltextureinthread/threadrenderer.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples 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$
-**
-****************************************************************************/
-
-#ifndef THREADRENDERER_H
-#define THREADRENDERER_H
-
-#include <QQuickItem>
-
-class RenderThread;
-
-class ThreadRenderer : public QQuickItem
-{
- Q_OBJECT
- QML_NAMED_ELEMENT(Renderer)
-
-public:
- ThreadRenderer();
-
- static QList<QThread *> threads;
-
-public Q_SLOTS:
- void ready();
-
-protected:
- QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *);
-
-private:
- RenderThread *m_renderThread;
-};
-
-#endif
diff --git a/examples/quick/scenegraph/rendernode/CMakeLists.txt b/examples/quick/scenegraph/rendernode/CMakeLists.txt
deleted file mode 100644
index 38b6101aaf..0000000000
--- a/examples/quick/scenegraph/rendernode/CMakeLists.txt
+++ /dev/null
@@ -1,73 +0,0 @@
-# Generated from rendernode.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(rendernode LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/quick/scenegraph/rendernode")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Qml)
-find_package(Qt6 COMPONENTS Quick)
-
-add_qt_gui_executable(rendernode
- customrenderitem.cpp customrenderitem.h
- main.cpp
- openglrenderer.cpp openglrenderer.h
- softwarerenderer.cpp softwarerenderer.h
-)
-target_link_libraries(rendernode PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Qml
- Qt::Quick
-)
-
-
-# Resources:
-set(rendernode_resource_files
- "main.qml"
- "metalshader.frag"
- "metalshader.vert"
-)
-
-qt6_add_resources(rendernode "rendernode"
- PREFIX
- "/scenegraph/rendernode"
- FILES
- ${rendernode_resource_files}
-)
-
-if(MACOS)
- target_sources(rendernode PUBLIC
- metalrenderer.h metalrenderer.mm
- )
-
- target_link_libraries(rendernode PUBLIC
- "-framework AppKit"
- "-framework Metal"
- )
-endif()
-
-install(TARGETS rendernode
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
-
-set_target_properties(rendernode PROPERTIES
- QT_QML_MODULE_VERSION 2.0
- QT_QML_MODULE_URI SceneGraphRendering
-)
-
-qt6_qml_type_registration(rendernode)
diff --git a/examples/quick/scenegraph/rendernode/customrenderitem.cpp b/examples/quick/scenegraph/rendernode/customrenderitem.cpp
deleted file mode 100644
index aae91120a7..0000000000
--- a/examples/quick/scenegraph/rendernode/customrenderitem.cpp
+++ /dev/null
@@ -1,123 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples 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 "customrenderitem.h"
-#include <QQuickWindow>
-#include <QSGRendererInterface>
-
-#include "openglrenderer.h"
-#ifdef Q_OS_MACOS
-#include "metalrenderer.h"
-#endif
-#include "softwarerenderer.h"
-
-//! [1]
-CustomRenderItem::CustomRenderItem(QQuickItem *parent)
- : QQuickItem(parent)
-{
- // Our item shows something so set the flag.
- setFlag(ItemHasContents);
-}
-//! [1]
-
-//! [2]
-QSGNode *CustomRenderItem::updatePaintNode(QSGNode *node, UpdatePaintNodeData *)
-{
- QSGRenderNode *n = static_cast<QSGRenderNode *>(node);
-
- QSGRendererInterface *ri = window()->rendererInterface();
- if (!ri)
- return nullptr;
-
- switch (ri->graphicsApi()) {
- case QSGRendererInterface::OpenGL:
- Q_FALLTHROUGH();
- case QSGRendererInterface::OpenGLRhi:
-#if QT_CONFIG(opengl)
- if (!n)
- n = new OpenGLRenderNode;
- static_cast<OpenGLRenderNode *>(n)->sync(this);
-#endif
- break;
-
- case QSGRendererInterface::MetalRhi:
-// Restore when QTBUG-78580 is done and the .pro is updated accordingly
-//#ifdef Q_OS_DARWIN
-#ifdef Q_OS_MACOS
- if (!n) {
- MetalRenderNode *metalNode = new MetalRenderNode;
- n = metalNode;
- metalNode->resourceBuilder()->setWindow(window());
- QObject::connect(window(), &QQuickWindow::beforeRendering,
- metalNode->resourceBuilder(), &MetalRenderNodeResourceBuilder::build);
- }
- static_cast<MetalRenderNode *>(n)->sync(this);
-#endif
- break;
-
- case QSGRendererInterface::Software:
- if (!n)
- n = new SoftwareRenderNode;
- static_cast<SoftwareRenderNode *>(n)->sync(this);
- break;
-
- default:
- break;
- }
-
- if (!n)
- qWarning("QSGRendererInterface reports unknown graphics API %d", ri->graphicsApi());
-
- return n;
-}
-//! [2]
-
-// This item does not support being moved between windows. If that is desired,
-// itemChange() should be reimplemented as well.
diff --git a/examples/quick/scenegraph/rendernode/customrenderitem.h b/examples/quick/scenegraph/rendernode/customrenderitem.h
deleted file mode 100644
index 28be54925b..0000000000
--- a/examples/quick/scenegraph/rendernode/customrenderitem.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples 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$
-**
-****************************************************************************/
-
-#ifndef CUSTOMRENDERITEM_H
-#define CUSTOMRENDERITEM_H
-
-#include <QQuickItem>
-
-//! [0]
-class CustomRenderItem : public QQuickItem
-{
- Q_OBJECT
- QML_ELEMENT
-
-public:
- CustomRenderItem(QQuickItem *parent = nullptr);
- QSGNode *updatePaintNode(QSGNode *node, UpdatePaintNodeData *) override;
-};
-//! [0]
-
-#endif
diff --git a/examples/quick/scenegraph/rendernode/doc/images/rendernode-example.jpg b/examples/quick/scenegraph/rendernode/doc/images/rendernode-example.jpg
deleted file mode 100644
index cbb59b950d..0000000000
--- a/examples/quick/scenegraph/rendernode/doc/images/rendernode-example.jpg
+++ /dev/null
Binary files differ
diff --git a/examples/quick/scenegraph/rendernode/doc/src/rendernode.qdoc b/examples/quick/scenegraph/rendernode/doc/src/rendernode.qdoc
deleted file mode 100644
index 87e3c8b506..0000000000
--- a/examples/quick/scenegraph/rendernode/doc/src/rendernode.qdoc
+++ /dev/null
@@ -1,165 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** 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.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \example scenegraph/rendernode
- \title Scene Graph - Custom Rendering with QSGRenderNode
- \ingroup qtquickexamples
- \brief Shows how to integrate drawing via the native graphics API with the Qt Quick scene graph.
-
- \image rendernode-example.jpg
-
- \l QSGRenderNode allows integrating draw and other calls made directly via
- the Qt Quick scene graph's underlying native graphics API (such as, Vulkan,
- Metal, Direct 3D, or OpenGL). This example demonstrates implementing a
- custom QQuickItem backed by a QSGRenderNode implementation, where the node
- renders a triangle directly via the graphics API. The rest of the scene
- (background, text, rectangles) are standard Qt Quick items. The example has
- full support for OpenGL and Metal, as well as the software backend of Qt
- Quick.
-
- The custom item behaves like any other Qt Quick item, meaning it
- participates and stacking and clipping as usual, which is a big difference
- to the alternative approaches like having the custom rendering as an
- overlay (connecting to \l QQuickWindow::afterRendering()) and underlay
- (connecting to \l QQuickWindow::beforeRendering()) because those do not
- offer the possibility of proper mixing of the custom content with the Qt
- Quick scene.
-
- Another important feature is that QSGRenderNode can be helpful to preserve
- performance, when compared to some of the alternatives. Going through \l
- QQuickFramebufferObject allows creating a custom item similarly to what
- this example does, but it does it by rendering the custom content in a
- texture, and then drawing a textured quad with that texture. This can be
- expensive on some systems due to the cost of texturing and blending.
- QSGRenderNode avoids this since the native graphics calls are issued in
- line with the draw calls for the scene graph's batches.
-
- All this comes at the cost of being more complex, and not necessarily being
- suitable for all types of 3D content, in particular where vertices and
- different depth would clash with the 2D content in the Qt Quick scene
- graph's batches (those are better served by "flattening" into a 2D texture
- via approaches like QQuickFramebufferObject). Therefore QSGRenderNode is
- not always the right choice. It can however a good and powerful choice in
- many cases. This is what the example demonstrates.
-
- Let's go through the most important parts of the code:
-
- \snippet scenegraph/rendernode/customrenderitem.h 0
-
- Our custom QML type is implemented in the class CustomRenderItem.
-
- \snippet scenegraph/rendernode/main.qml 2
-
- The corresponding import in the QML document.
-
- \snippet scenegraph/rendernode/main.qml 3
-
- The CustomRenderItem object. It is positioned to fill a big part of the
- scene, covering its parent (the yellow rectangle; this will be used to
- demonstrate clipping). The item will have its scale and rotation animated.
-
- \snippet scenegraph/rendernode/main.qml 4
-
- Text items are used to show some helpful information, such as, the
- active graphics API Qt Quick uses.
-
- \snippet scenegraph/rendernode/main.qml 5
-
- Clicking the left mouse button is used to toggle clipping on the custom
- item's parent item. By default this is done using scissoring (GL_SCISSOR_TEST
- with OpenGL). A well-written QSGRenderNode implementation is expected to be
- able to take this into account and enable scissor testing when the scene graph
- indicates that it is necessary.
-
- The right mouse button is used to toggle an animation on the rotation of
- the parent item. With clipping enabled, this demonstrates clipping via the
- stencil buffer since a rectangular scissor is not appropriate when we need
- to clip to a rotated rectangle shape. The scene graph fills up the stencil
- buffer as necessary, the QSGRenderNode implementation just has to enable
- stencil testing using the provided reference value.
-
- \snippet scenegraph/rendernode/customrenderitem.cpp 1
-
- Moving on to the CustomRenderItem implementation. This is a visual item.
-
- \snippet scenegraph/rendernode/customrenderitem.cpp 2
-
- The implementation of \l QQuickItem::updatePaintNode() creates (if not yet
- done) and returns an instance of a suitable QSGRenderNode subclass. The
- example supports multiple graphics APIs, and also the \c software backend.
-
- Let's look at the the render node for OpenGL (supporting both the
- traditional, direct OpenGL-based scene graph, and also the modern,
- abstracted variant using the RHI). For other graphics APIs, the concepts
- and the outline of a QSGRenderNode implementation are the same. It is worth
- noting that in some cases it will also be necessary to connect to a signal
- like \l QQuickWindow::beforeRendering() to perform copy type of operations
- (such as, vertex buffer uploads). This is not necessary for OpenGL, but it
- is essential for Vulkan or Metal since there such operations cannot be
- issued in render() as there is a renderpass being recorded when render() is
- called.
-
- \snippet scenegraph/rendernode/openglrenderer.h 1
-
- The main job is to provide implementations of the virtual QSGRenderNode functions.
-
- \snippet scenegraph/rendernode/openglrenderer.cpp 1
-
- The pattern for safe graphics resource management is to do any cleanup in
- \l{QSGRenderNode::releaseResources()}{releaseResources()}, while also
- calling this from the destructor.
-
- \snippet scenegraph/rendernode/openglrenderer.cpp 2
-
- The render() function initializes graphics resources (in this case, an
- OpenGL shader program and a vertex buffer), if not yet done. It then
- makes sure the necessary resources are bound and updates uniforms.
- The transformation matrix and the opacity are provided by the scene graph
- either via the \c state argument or base class functions.
-
- \snippet scenegraph/rendernode/openglrenderer.cpp 5
-
- This render node is well-behaving since it basically renders in 2D,
- respecting the item's geometry. This is not mandatory, but then flags() has
- to return (or not return) the appropriate flags.
-
- \snippet scenegraph/rendernode/openglrenderer.cpp 3
-
- After setting up vertex inputs, but before recording a draw call for our
- triangle, it is important to set some state in order to integrate with the
- rest of the scene correctly. Setting scissor and stencil as instructed by
- \c state allows our item to render correctly even when there are one or
- more clips in the parent chain.
-
- \snippet scenegraph/rendernode/openglrenderer.cpp 4
-
- As shown above, we only really render in 2D (no depth), within the item's
- geometry. changedStates() returns the flags corresponding to the OpenGL
- states render() touches.
-
-*/
diff --git a/examples/quick/scenegraph/rendernode/main.cpp b/examples/quick/scenegraph/rendernode/main.cpp
deleted file mode 100644
index 645360eaba..0000000000
--- a/examples/quick/scenegraph/rendernode/main.cpp
+++ /dev/null
@@ -1,87 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples 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 <QCommandLineParser>
-#include <QCommandLineOption>
-#include <QGuiApplication>
-#include <QQuickView>
-#include "customrenderitem.h"
-
-int main(int argc, char **argv)
-{
- QGuiApplication app(argc, argv);
-
- QQuickView view;
-
- QCoreApplication::setApplicationName("Qt Scene Graph Render Node Example");
- QCoreApplication::setOrganizationName("QtProject");
- QCoreApplication::setApplicationVersion(QT_VERSION_STR);
- QCommandLineParser parser;
- parser.setApplicationDescription(QCoreApplication::applicationName());
- parser.addHelpOption();
- parser.addVersionOption();
- QCommandLineOption multipleSampleOption("multisample", "Multisampling");
- parser.addOption(multipleSampleOption);
-
- parser.process(app);
-
- if (parser.isSet(multipleSampleOption)) {
- QSurfaceFormat fmt;
- fmt.setSamples(4);
- view.setFormat(fmt);
- }
-
- view.setResizeMode(QQuickView::SizeRootObjectToView);
- view.setSource(QUrl("qrc:///scenegraph/rendernode/main.qml"));
- view.resize(1024, 768);
- view.show();
-
- return app.exec();
-}
diff --git a/examples/quick/scenegraph/rendernode/main.qml b/examples/quick/scenegraph/rendernode/main.qml
deleted file mode 100644
index a02fa128d5..0000000000
--- a/examples/quick/scenegraph/rendernode/main.qml
+++ /dev/null
@@ -1,167 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples 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.8
-//! [2]
-import SceneGraphRendering 2.0
-//! [2]
-
-Item {
- Rectangle {
- id: bg
- anchors.fill: parent
- gradient: Gradient {
- GradientStop { position: 0; color: "steelblue" }
- GradientStop { position: 1; color: "black" }
- }
-
- //! [5]
- MouseArea {
- anchors.fill: parent
- acceptedButtons: Qt.LeftButton | Qt.RightButton
- onClicked: (mouse) => {
- if (mouse.button === Qt.LeftButton) {
- clipper.clip = !clipper.clip
- } else if (mouse.button === Qt.RightButton) {
- nonRectClipAnim.running = !nonRectClipAnim.running
- if (!nonRectClipAnim.running)
- clipper.rotation = 0;
- }
- }
- }
- // ![5]
-
- Rectangle {
- id: clipper
- width: parent.width / 2
- height: parent.height / 2
- anchors.centerIn: parent
- border.color: "yellow"
- border.width: 2
- color: "transparent"
- NumberAnimation on rotation {
- id: nonRectClipAnim
- from: 0; to: 360; duration: 5000; loops: Animation.Infinite
- running: false
- }
-
- //! [3]
- CustomRenderItem {
- id: renderer
- width: bg.width - 20
- height: bg.height - 20
- x: -clipper.x + 10
- y: -clipper.y + 10
-
- transform: [
- Rotation { id: rotation; axis.x: 0; axis.z: 0; axis.y: 1; angle: 0; origin.x: renderer.width / 2; origin.y: renderer.height / 2; },
- Translate { id: txOut; x: -renderer.width / 2; y: -renderer.height / 2 },
- Scale { id: scale; },
- Translate { id: txIn; x: renderer.width / 2; y: renderer.height / 2 }
- ]
- }
- //! [3]
- }
-
- SequentialAnimation {
- PauseAnimation { duration: 3000 }
- ParallelAnimation {
- NumberAnimation { target: scale; property: "xScale"; to: 0.6; duration: 1000; easing.type: Easing.InOutBack }
- NumberAnimation { target: scale; property: "yScale"; to: 0.6; duration: 1000; easing.type: Easing.InOutBack }
- }
- NumberAnimation { target: rotation; property: "angle"; to: 80; duration: 1000; easing.type: Easing.InOutCubic }
- NumberAnimation { target: rotation; property: "angle"; to: -80; duration: 1000; easing.type: Easing.InOutCubic }
- NumberAnimation { target: rotation; property: "angle"; to: 0; duration: 1000; easing.type: Easing.InOutCubic }
- NumberAnimation { target: renderer; property: "opacity"; to: 0.1; duration: 1000; easing.type: Easing.InOutCubic }
- PauseAnimation { duration: 1000 }
- NumberAnimation { target: renderer; property: "opacity"; to: 1.0; duration: 1000; easing.type: Easing.InOutCubic }
- ParallelAnimation {
- NumberAnimation { target: scale; property: "xScale"; to: 1; duration: 1000; easing.type: Easing.InOutBack }
- NumberAnimation { target: scale; property: "yScale"; to: 1; duration: 1000; easing.type: Easing.InOutBack }
- }
- running: true
- loops: Animation.Infinite
- }
-
- //! [4]
- Text {
- id: label
- anchors.bottom: parent.bottom
- anchors.left: parent.left
- anchors.margins: 20
- color: "yellow"
- wrapMode: Text.WordWrap
- property int api: GraphicsInfo.api
- text: {
- var apiStr;
- switch (api) {
- case GraphicsInfo.OpenGL: apiStr = "OpenGL (direct)"; break;
- case GraphicsInfo.Software: apiStr = "Software (QPainter)"; break;
- case GraphicsInfo.OpenGLRhi: apiStr = "OpenGL (RHI)"; break;
- case GraphicsInfo.MetalRhi: apiStr = "Metal (RHI)"; break;
- // the example has no other QSGRenderNode subclasses
- default: apiStr = "<UNSUPPORTED>"; break;
- }
- "Custom rendering via the graphics API " + apiStr
- + "\nLeft click to toggle clipping to yellow rect"
- + "\nRight click to rotate (can be used to exercise stencil clip instead of scissor)"
- }
- // ![4]
- }
-
- Text {
- id: label2
- anchors.top: parent.top
- anchors.right: parent.right
- color: "yellow"
- text: "Clip: " + (clipper.clip ? "ON" : "OFF") + " Rotation: " + (nonRectClipAnim.running ? "ON" : "OFF")
- }
- }
-}
diff --git a/examples/quick/scenegraph/rendernode/metalrenderer.h b/examples/quick/scenegraph/rendernode/metalrenderer.h
deleted file mode 100644
index cf7fccb930..0000000000
--- a/examples/quick/scenegraph/rendernode/metalrenderer.h
+++ /dev/null
@@ -1,104 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples 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$
-**
-****************************************************************************/
-
-#ifndef METALRENDERER_H
-#define METALRENDERER_H
-
-#include <qsgrendernode.h>
-#include <QQuickItem>
-
-//#ifdef Q_OS_DARWIN
-#ifdef Q_OS_MACOS
-
-QT_BEGIN_NAMESPACE
-
-QT_END_NAMESPACE
-
-class MetalRenderNodeResourceBuilder : public QObject
-{
- Q_OBJECT
-
-public:
- void setWindow(QQuickWindow *w) { m_window = w; }
-
-public slots:
- void build();
-
-private:
- QQuickWindow *m_window = nullptr;
-};
-
-class MetalRenderNode : public QSGRenderNode
-{
-public:
- MetalRenderNode();
- ~MetalRenderNode();
-
- void render(const RenderState *state) override;
- void releaseResources() override;
- StateFlags changedStates() const override;
- RenderingFlags flags() const override;
- QRectF rect() const override;
-
- MetalRenderNodeResourceBuilder *resourceBuilder() { return &m_resourceBuilder; }
-
- void sync(QQuickItem *item);
-
-private:
- MetalRenderNodeResourceBuilder m_resourceBuilder;
- QQuickWindow *m_window = nullptr;
- int m_width = 0;
- int m_height = 0;
- int m_outputHeight = 0;
-};
-
-#endif // Q_OS_DARWIN
-
-#endif
diff --git a/examples/quick/scenegraph/rendernode/metalrenderer.mm b/examples/quick/scenegraph/rendernode/metalrenderer.mm
deleted file mode 100644
index d78a54b88a..0000000000
--- a/examples/quick/scenegraph/rendernode/metalrenderer.mm
+++ /dev/null
@@ -1,334 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples 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 "metalrenderer.h"
-#include <QQuickItem>
-#include <QQuickWindow>
-#include <QFile>
-
-#include <Metal/Metal.h>
-
-using FuncAndLib = QPair<id<MTLFunction>, id<MTLLibrary> >;
-
-const int MAX_FRAMES_IN_FLIGHT = 3;
-
-struct {
- id<MTLDevice> dev = nil;
- QByteArray vsSource;
- FuncAndLib vs;
- QByteArray fsSource;
- FuncAndLib fs;
- id<MTLBuffer> vbuf[MAX_FRAMES_IN_FLIGHT];
- id<MTLBuffer> ubuf[MAX_FRAMES_IN_FLIGHT];
- id<MTLDepthStencilState> stencilEnabledDsState = nil;
- id<MTLRenderPipelineState> pipeline = nil;
-} g;
-
-static FuncAndLib compileShaderFromSource(const QByteArray &src, const QByteArray &entryPoint)
-{
- FuncAndLib fl;
-
- NSString *srcstr = [NSString stringWithUTF8String: src.constData()];
- MTLCompileOptions *opts = [[MTLCompileOptions alloc] init];
- opts.languageVersion = MTLLanguageVersion1_2;
- NSError *err = nil;
- fl.second = [g.dev newLibraryWithSource: srcstr options: opts error: &err];
- [opts release];
- // srcstr is autoreleased
-
- if (err) {
- const QString msg = QString::fromNSString(err.localizedDescription);
- qFatal("%s", qPrintable(msg));
- return fl;
- }
-
- NSString *name = [NSString stringWithUTF8String: entryPoint.constData()];
- fl.first = [fl.second newFunctionWithName: name];
- [name release];
-
- return fl;
-}
-
-const int VERTEX_SIZE = 6 * sizeof(float);
-
-static float colors[] = {
- 1.0f, 0.0f, 0.0f,
- 0.0f, 1.0f, 0.0f,
- 0.0f, 0.0f, 1.0f
-};
-
-void MetalRenderNodeResourceBuilder::build()
-{
- if (!g.dev) {
- QSGRendererInterface *rif = m_window->rendererInterface();
- Q_ASSERT(rif->graphicsApi() == QSGRendererInterface::MetalRhi);
-
- g.dev = (id<MTLDevice>) rif->getResource(m_window, QSGRendererInterface::DeviceResource);
- Q_ASSERT(g.dev);
- }
-
- if (g.vsSource.isEmpty()) {
- const QString filename = QLatin1String(":/scenegraph/rendernode/metalshader.vert");
- QFile f(filename);
- if (!f.open(QIODevice::ReadOnly | QIODevice::Text))
- qFatal("Failed to read shader %s", qPrintable(filename));
- g.vsSource = f.readAll();
- g.vs = compileShaderFromSource(g.vsSource, QByteArrayLiteral("main0"));
- }
-
- if (g.fsSource.isEmpty()) {
- const QString filename = QLatin1String(":/scenegraph/rendernode/metalshader.frag");
- QFile f(filename);
- if (!f.open(QIODevice::ReadOnly | QIODevice::Text))
- qFatal("Failed to read shader %s", qPrintable(filename));
- g.fsSource = f.readAll();
- g.fs = compileShaderFromSource(g.fsSource, QByteArrayLiteral("main0"));
- }
-
- const int framesInFlight = m_window->graphicsStateInfo().framesInFlight;
-
- // For simplicity's sake we use shared mode (something like host visible +
- // host coherent) for everything.
-
- for (int i = 0; i < framesInFlight; ++i) {
- // Have multiple versions for vertex too since we'll just memcpy new
- // vertices based on item width and height on every render(). This could
- // be optimized further however.
- if (!g.vbuf[i]) {
- g.vbuf[i] = [g.dev newBufferWithLength: VERTEX_SIZE + sizeof(colors) options: MTLResourceStorageModeShared];
- char *p = (char *) [g.vbuf[i] contents];
- memcpy(p + VERTEX_SIZE, colors, sizeof(colors));
- }
-
- if (!g.ubuf[i])
- g.ubuf[i] = [g.dev newBufferWithLength: 256 options: MTLResourceStorageModeShared];
- }
-
- if (!g.stencilEnabledDsState) {
- MTLDepthStencilDescriptor *dsDesc = [[MTLDepthStencilDescriptor alloc] init];
- dsDesc.frontFaceStencil = [[MTLStencilDescriptor alloc] init];
- dsDesc.frontFaceStencil.stencilFailureOperation = MTLStencilOperationKeep;
- dsDesc.frontFaceStencil.depthFailureOperation = MTLStencilOperationKeep;
- dsDesc.frontFaceStencil.depthStencilPassOperation = MTLStencilOperationKeep;
- dsDesc.frontFaceStencil.stencilCompareFunction = MTLCompareFunctionEqual;
- dsDesc.frontFaceStencil.readMask = 0xFF;
- dsDesc.frontFaceStencil.writeMask = 0xFF;
-
- dsDesc.backFaceStencil = [[MTLStencilDescriptor alloc] init];
- dsDesc.backFaceStencil.stencilFailureOperation = MTLStencilOperationKeep;
- dsDesc.backFaceStencil.depthFailureOperation = MTLStencilOperationKeep;
- dsDesc.backFaceStencil.depthStencilPassOperation = MTLStencilOperationKeep;
- dsDesc.backFaceStencil.stencilCompareFunction = MTLCompareFunctionEqual;
- dsDesc.backFaceStencil.readMask = 0xFF;
- dsDesc.backFaceStencil.writeMask = 0xFF;
-
- g.stencilEnabledDsState = [g.dev newDepthStencilStateWithDescriptor: dsDesc];
- [dsDesc release];
- }
-
- if (!g.pipeline) {
- MTLVertexDescriptor *inputLayout = [MTLVertexDescriptor vertexDescriptor];
- inputLayout.attributes[0].format = MTLVertexFormatFloat2;
- inputLayout.attributes[0].offset = 0;
- inputLayout.attributes[0].bufferIndex = 1; // ubuf is 0, vbuf is 1 and 2
- inputLayout.attributes[1].format = MTLVertexFormatFloat3;
- inputLayout.attributes[1].offset = 0;
- inputLayout.attributes[1].bufferIndex = 2;
- inputLayout.layouts[1].stride = 2 * sizeof(float);
- inputLayout.layouts[2].stride = 3 * sizeof(float);
-
- MTLRenderPipelineDescriptor *rpDesc = [[MTLRenderPipelineDescriptor alloc] init];
- rpDesc.vertexDescriptor = inputLayout;
-
- rpDesc.vertexFunction = g.vs.first;
- rpDesc.fragmentFunction = g.fs.first;
-
- rpDesc.colorAttachments[0].pixelFormat = MTLPixelFormatBGRA8Unorm;
- rpDesc.colorAttachments[0].blendingEnabled = true;
- rpDesc.colorAttachments[0].sourceRGBBlendFactor = MTLBlendFactorOne;
- rpDesc.colorAttachments[0].sourceAlphaBlendFactor = MTLBlendFactorOne;
- rpDesc.colorAttachments[0].destinationRGBBlendFactor = MTLBlendFactorOneMinusSourceAlpha;
- rpDesc.colorAttachments[0].destinationAlphaBlendFactor = MTLBlendFactorOneMinusSourceAlpha;
-
- if (g.dev.depth24Stencil8PixelFormatSupported) {
- rpDesc.depthAttachmentPixelFormat = MTLPixelFormatDepth24Unorm_Stencil8;
- rpDesc.stencilAttachmentPixelFormat = MTLPixelFormatDepth24Unorm_Stencil8;
- } else {
- rpDesc.depthAttachmentPixelFormat = MTLPixelFormatDepth32Float_Stencil8;
- rpDesc.stencilAttachmentPixelFormat = MTLPixelFormatDepth32Float_Stencil8;
- }
-
- NSError *err = nil;
- g.pipeline = [g.dev newRenderPipelineStateWithDescriptor: rpDesc error: &err];
- if (!g.pipeline) {
- const QString msg = QString::fromNSString(err.localizedDescription);
- qFatal("Failed to create render pipeline state: %s", qPrintable(msg));
- }
- [rpDesc release];
- }
-}
-
-MetalRenderNode::MetalRenderNode()
-{
- g.vs.first = g.fs.first = nil;
- g.vs.second = g.fs.second = nil;
-
- for (int i = 0; i < MAX_FRAMES_IN_FLIGHT; ++i) {
- g.vbuf[i] = nil;
- g.ubuf[i] = nil;
- }
-}
-
-MetalRenderNode::~MetalRenderNode()
-{
- releaseResources();
-}
-
-void MetalRenderNode::releaseResources()
-{
- [g.stencilEnabledDsState release];
- g.stencilEnabledDsState = nil;
-
- [g.pipeline release];
- g.pipeline = nil;
-
- [g.vs.first release];
- [g.vs.second release];
-
- [g.fs.first release];
- [g.fs.second release];
-
- g.vs.first = g.fs.first = nil;
- g.vs.second = g.fs.second = nil;
-
- for (int i = 0; i < MAX_FRAMES_IN_FLIGHT; ++i) {
- [g.vbuf[i] release];
- g.vbuf[i] = nil;
- [g.ubuf[i] release];
- g.ubuf[i] = nil;
- }
-}
-
-void MetalRenderNode::render(const RenderState *state)
-{
- Q_ASSERT(m_window);
- const QQuickWindow::GraphicsStateInfo &stateInfo(m_window->graphicsStateInfo());
- id<MTLBuffer> vbuf = g.vbuf[stateInfo.currentFrameSlot];
- id<MTLBuffer> ubuf = g.ubuf[stateInfo.currentFrameSlot];
-
- QPointF p0(m_width - 1, m_height - 1);
- QPointF p1(0, 0);
- QPointF p2(0, m_height - 1);
-
- float vertices[6] = { float(p0.x()), float(p0.y()),
- float(p1.x()), float(p1.y()),
- float(p2.x()), float(p2.y()) };
- char *p = (char *) [vbuf contents];
- memcpy(p, vertices, VERTEX_SIZE);
-
- const QMatrix4x4 mvp = *state->projectionMatrix() * *matrix();
- const float opacity = inheritedOpacity();
-
- p = (char *) [ubuf contents];
- memcpy(p, mvp.constData(), 64);
- memcpy(p + 64, &opacity, 4);
-
- QSGRendererInterface *rif = m_window->rendererInterface();
- id<MTLRenderCommandEncoder> encoder = (id<MTLRenderCommandEncoder>) rif->getResource(
- m_window, QSGRendererInterface::CommandEncoderResource);
- Q_ASSERT(encoder);
-
- [encoder setVertexBuffer: vbuf offset: 0 atIndex: 1];
- [encoder setVertexBuffer: vbuf offset: VERTEX_SIZE atIndex: 2];
-
- [encoder setVertexBuffer: ubuf offset: 0 atIndex: 0];
- [encoder setFragmentBuffer: ubuf offset: 0 atIndex: 0];
-
- // Clip support.
- if (state->scissorEnabled()) {
- const QRect r = state->scissorRect(); // bottom-up
- MTLScissorRect s;
- s.x = r.x();
- s.y = m_outputHeight - (r.y() + r.height());
- s.width = r.width();
- s.height = r.height();
- [encoder setScissorRect: s];
- }
- if (state->stencilEnabled()) {
- [encoder setDepthStencilState: g.stencilEnabledDsState];
- [encoder setStencilReferenceValue: state->stencilValue()];
- }
-
- [encoder setRenderPipelineState: g.pipeline];
- [encoder drawPrimitives: MTLPrimitiveTypeTriangle vertexStart: 0 vertexCount: 3 instanceCount: 1 baseInstance: 0];
-}
-
-QSGRenderNode::StateFlags MetalRenderNode::changedStates() const
-{
- return BlendState | ScissorState | StencilState;
-}
-
-QSGRenderNode::RenderingFlags MetalRenderNode::flags() const
-{
- return BoundedRectRendering | DepthAwareRendering;
-}
-
-QRectF MetalRenderNode::rect() const
-{
- return QRect(0, 0, m_width, m_height);
-}
-
-void MetalRenderNode::sync(QQuickItem *item)
-{
- m_window = item->window();
- m_width = item->width();
- m_height = item->height();
- m_outputHeight = m_window->height() * m_window->effectiveDevicePixelRatio();
-}
diff --git a/examples/quick/scenegraph/rendernode/metalshader.frag b/examples/quick/scenegraph/rendernode/metalshader.frag
deleted file mode 100644
index 907faa537f..0000000000
--- a/examples/quick/scenegraph/rendernode/metalshader.frag
+++ /dev/null
@@ -1,28 +0,0 @@
-#include <metal_stdlib>
-#include <simd/simd.h>
-
-using namespace metal;
-
-struct buf
-{
- float4x4 matrix;
- float opacity;
-};
-
-struct main0_out
-{
- float4 fragColor [[color(0)]];
-};
-
-struct main0_in
-{
- float4 v_color [[user(locn0)]];
-};
-
-fragment main0_out main0(main0_in in [[stage_in]], constant buf& ubuf [[buffer(0)]])
-{
- main0_out out = {};
- out.fragColor = in.v_color * ubuf.opacity;
- return out;
-}
-
diff --git a/examples/quick/scenegraph/rendernode/metalshader.vert b/examples/quick/scenegraph/rendernode/metalshader.vert
deleted file mode 100644
index 12b721f524..0000000000
--- a/examples/quick/scenegraph/rendernode/metalshader.vert
+++ /dev/null
@@ -1,31 +0,0 @@
-#include <metal_stdlib>
-#include <simd/simd.h>
-
-using namespace metal;
-
-struct buf
-{
- float4x4 matrix;
- float opacity;
-};
-
-struct main0_out
-{
- float4 v_color [[user(locn0)]];
- float4 gl_Position [[position]];
-};
-
-struct main0_in
-{
- float4 pos [[attribute(0)]];
- float4 color [[attribute(1)]];
-};
-
-vertex main0_out main0(main0_in in [[stage_in]], constant buf& ubuf [[buffer(0)]])
-{
- main0_out out = {};
- out.v_color = in.color;
- out.gl_Position = ubuf.matrix * in.pos;
- return out;
-}
-
diff --git a/examples/quick/scenegraph/rendernode/openglrenderer.cpp b/examples/quick/scenegraph/rendernode/openglrenderer.cpp
deleted file mode 100644
index a4e619bea9..0000000000
--- a/examples/quick/scenegraph/rendernode/openglrenderer.cpp
+++ /dev/null
@@ -1,200 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples 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 "openglrenderer.h"
-#include <QQuickItem>
-
-#if QT_CONFIG(opengl)
-
-#include <QOpenGLShaderProgram>
-#include <QOpenGLBuffer>
-#include <QOpenGLFunctions>
-
-//! [1]
-OpenGLRenderNode::~OpenGLRenderNode()
-{
- releaseResources();
-}
-
-void OpenGLRenderNode::releaseResources()
-{
- delete m_program;
- m_program = nullptr;
- delete m_vbo;
- m_vbo = nullptr;
-}
-//! [1]
-
-void OpenGLRenderNode::init()
-{
- m_program = new QOpenGLShaderProgram;
-
- static const char *vertexShaderSource =
- "attribute highp vec4 posAttr;\n"
- "attribute lowp vec4 colAttr;\n"
- "varying lowp vec4 col;\n"
- "uniform highp mat4 matrix;\n"
- "void main() {\n"
- " col = colAttr;\n"
- " gl_Position = matrix * posAttr;\n"
- "}\n";
-
- static const char *fragmentShaderSource =
- "varying lowp vec4 col;\n"
- "uniform lowp float opacity;\n"
- "void main() {\n"
- " gl_FragColor = col * opacity;\n"
- "}\n";
-
- m_program->addCacheableShaderFromSourceCode(QOpenGLShader::Vertex, vertexShaderSource);
- m_program->addCacheableShaderFromSourceCode(QOpenGLShader::Fragment, fragmentShaderSource);
- m_program->bindAttributeLocation("posAttr", 0);
- m_program->bindAttributeLocation("colAttr", 1);
- m_program->link();
-
- m_matrixUniform = m_program->uniformLocation("matrix");
- m_opacityUniform = m_program->uniformLocation("opacity");
-
- const int VERTEX_SIZE = 6 * sizeof(GLfloat);
-
- static GLfloat colors[] = {
- 1.0f, 0.0f, 0.0f,
- 0.0f, 1.0f, 0.0f,
- 0.0f, 0.0f, 1.0f
- };
-
- m_vbo = new QOpenGLBuffer;
- m_vbo->create();
- m_vbo->bind();
- m_vbo->allocate(VERTEX_SIZE + sizeof(colors));
- m_vbo->write(VERTEX_SIZE, colors, sizeof(colors));
- m_vbo->release();
-}
-
-//! [2]
-void OpenGLRenderNode::render(const RenderState *state)
-{
- if (!m_program)
- init();
-
- QOpenGLFunctions *f = QOpenGLContext::currentContext()->functions();
- m_program->bind();
- m_program->setUniformValue(m_matrixUniform, *state->projectionMatrix() * *matrix());
- m_program->setUniformValue(m_opacityUniform, float(inheritedOpacity()));
-//! [2]
-
- m_vbo->bind();
-
-//! [5]
- QPointF p0(m_width - 1, m_height - 1);
- QPointF p1(0, 0);
- QPointF p2(0, m_height - 1);
-
- GLfloat vertices[6] = { GLfloat(p0.x()), GLfloat(p0.y()),
- GLfloat(p1.x()), GLfloat(p1.y()),
- GLfloat(p2.x()), GLfloat(p2.y()) };
- m_vbo->write(0, vertices, sizeof(vertices));
-//! [5]
-
- m_program->setAttributeBuffer(0, GL_FLOAT, 0, 2);
- m_program->setAttributeBuffer(1, GL_FLOAT, sizeof(vertices), 3);
- m_program->enableAttributeArray(0);
- m_program->enableAttributeArray(1);
-
- // We are prepared both for the legacy (direct OpenGL) and the modern
- // (abstracted by RHI) OpenGL scenegraph. So set all the states that are
- // important to us.
-
- //! [3]
- f->glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
-
- f->glEnable(GL_BLEND);
- f->glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
-
- // Clip support.
- if (state->scissorEnabled()) {
- f->glEnable(GL_SCISSOR_TEST);
- const QRect r = state->scissorRect(); // already bottom-up
- f->glScissor(r.x(), r.y(), r.width(), r.height());
- }
- if (state->stencilEnabled()) {
- f->glEnable(GL_STENCIL_TEST);
- f->glStencilFunc(GL_EQUAL, state->stencilValue(), 0xFF);
- f->glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
- }
-
- f->glDrawArrays(GL_TRIANGLES, 0, 3);
- //! [3]
-}
-
-//! [4]
-QSGRenderNode::StateFlags OpenGLRenderNode::changedStates() const
-{
- return BlendState | ScissorState | StencilState;
-}
-
-QSGRenderNode::RenderingFlags OpenGLRenderNode::flags() const
-{
- return BoundedRectRendering | DepthAwareRendering;
-}
-
-QRectF OpenGLRenderNode::rect() const
-{
- return QRect(0, 0, m_width, m_height);
-}
-//! [4]
-
-void OpenGLRenderNode::sync(QQuickItem *item)
-{
- m_width = item->width();
- m_height = item->height();
-}
-
-#endif // opengl
diff --git a/examples/quick/scenegraph/rendernode/openglrenderer.h b/examples/quick/scenegraph/rendernode/openglrenderer.h
deleted file mode 100644
index 1e7977481a..0000000000
--- a/examples/quick/scenegraph/rendernode/openglrenderer.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples 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$
-**
-****************************************************************************/
-
-#ifndef OPENGLRENDERER_H
-#define OPENGLRENDERER_H
-
-#include <qsgrendernode.h>
-#include <QQuickItem>
-
-#if QT_CONFIG(opengl)
-
-QT_BEGIN_NAMESPACE
-
-class QOpenGLShaderProgram;
-class QOpenGLBuffer;
-
-QT_END_NAMESPACE
-
-//! [1]
-class OpenGLRenderNode : public QSGRenderNode
-{
-public:
- ~OpenGLRenderNode();
-
- void render(const RenderState *state) override;
- void releaseResources() override;
- StateFlags changedStates() const override;
- RenderingFlags flags() const override;
- QRectF rect() const override;
-//! [1]
-
- void sync(QQuickItem *item);
-
-private:
- void init();
-
- int m_width = 0;
- int m_height = 0;
- QOpenGLShaderProgram *m_program = nullptr;
- int m_matrixUniform;
- int m_opacityUniform;
- QOpenGLBuffer *m_vbo = nullptr;
-};
-
-#endif // opengl
-
-#endif
diff --git a/examples/quick/scenegraph/rendernode/rendernode.pro b/examples/quick/scenegraph/rendernode/rendernode.pro
deleted file mode 100644
index 4ae46de2a4..0000000000
--- a/examples/quick/scenegraph/rendernode/rendernode.pro
+++ /dev/null
@@ -1,28 +0,0 @@
-QT += qml quick
-
-CONFIG += qmltypes
-QML_IMPORT_NAME = SceneGraphRendering
-QML_IMPORT_MAJOR_VERSION = 2
-
-HEADERS += customrenderitem.h \
- openglrenderer.h \
- softwarerenderer.h
-
-SOURCES += customrenderitem.cpp \
- openglrenderer.cpp \
- softwarerenderer.cpp \
- main.cpp
-
-RESOURCES += rendernode.qrc
-
-target.path = $$[QT_INSTALL_EXAMPLES]/quick/scenegraph/rendernode
-INSTALLS += target
-
-OTHER_FILES += \
- main.qml
-
-macos {
- HEADERS += metalrenderer.h
- SOURCES += metalrenderer.mm
- LIBS += -framework Metal -framework AppKit
-}
diff --git a/examples/quick/scenegraph/rendernode/rendernode.qrc b/examples/quick/scenegraph/rendernode/rendernode.qrc
deleted file mode 100644
index a93fd0270f..0000000000
--- a/examples/quick/scenegraph/rendernode/rendernode.qrc
+++ /dev/null
@@ -1,7 +0,0 @@
-<RCC>
- <qresource prefix="/scenegraph/rendernode">
- <file>main.qml</file>
- <file>metalshader.vert</file>
- <file>metalshader.frag</file>
- </qresource>
-</RCC>
diff --git a/examples/quick/scenegraph/rendernode/shader.hlsl b/examples/quick/scenegraph/rendernode/shader.hlsl
deleted file mode 100644
index f300fe7aa5..0000000000
--- a/examples/quick/scenegraph/rendernode/shader.hlsl
+++ /dev/null
@@ -1,28 +0,0 @@
-cbuffer ConstantBuffer : register(b0)
-{
- float4x4 modelview;
- float4x4 projection;
- float opacity;
-};
-
-struct PSInput
-{
- float4 position : SV_POSITION;
- float3 color : COLOR;
-};
-
-PSInput VS_Simple(float4 position : POSITION, float3 color : COLOR)
-{
- PSInput result;
-
- float4x4 mvp = mul(projection, modelview);
- result.position = mul(mvp, position);
- result.color = color;
-
- return result;
-}
-
-float4 PS_Simple(PSInput input) : SV_TARGET
-{
- return float4(input.color, 1.0) * opacity;
-}
diff --git a/examples/quick/scenegraph/rendernode/softwarerenderer.cpp b/examples/quick/scenegraph/rendernode/softwarerenderer.cpp
deleted file mode 100644
index d6d97a8151..0000000000
--- a/examples/quick/scenegraph/rendernode/softwarerenderer.cpp
+++ /dev/null
@@ -1,117 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples 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 "softwarerenderer.h"
-#include <QQuickItem>
-#include <QQuickWindow>
-#include <QSGRendererInterface>
-#include <QPainter>
-#include <QPainterPath>
-
-SoftwareRenderNode::~SoftwareRenderNode()
-{
- releaseResources();
-}
-
-void SoftwareRenderNode::releaseResources()
-{
-}
-
-void SoftwareRenderNode::render(const RenderState *renderState)
-{
- Q_ASSERT(m_window);
-
- QSGRendererInterface *rif = m_window->rendererInterface();
- QPainter *p = static_cast<QPainter *>(rif->getResource(m_window, QSGRendererInterface::PainterResource));
- Q_ASSERT(p);
-
- const QRegion *clipRegion = renderState->clipRegion();
- if (clipRegion && !clipRegion->isEmpty())
- p->setClipRegion(*clipRegion, Qt::ReplaceClip); // must be done before setTransform
-
- p->setTransform(matrix()->toTransform());
- p->setOpacity(inheritedOpacity());
-
- const QPointF p0(m_width - 1, m_height - 1);
- const QPointF p1(0, 0);
- const QPointF p2(0, m_height - 1);
- QPainterPath path(p0);
- path.lineTo(p1);
- path.lineTo(p2);
- path.closeSubpath();
-
- QLinearGradient gradient(QPointF(0, 0), QPointF(m_width, m_height));
- gradient.setColorAt(0, Qt::green);
- gradient.setColorAt(1, Qt::red);
-
- p->fillPath(path, gradient);
-}
-
-QSGRenderNode::StateFlags SoftwareRenderNode::changedStates() const
-{
- return {};
-}
-
-QSGRenderNode::RenderingFlags SoftwareRenderNode::flags() const
-{
- return BoundedRectRendering;
-}
-
-QRectF SoftwareRenderNode::rect() const
-{
- return QRect(0, 0, m_width, m_height);
-}
-
-void SoftwareRenderNode::sync(QQuickItem *item)
-{
- m_window = item->window();
- m_width = item->width();
- m_height = item->height();
-}
diff --git a/examples/quick/scenegraph/rendernode/softwarerenderer.h b/examples/quick/scenegraph/rendernode/softwarerenderer.h
deleted file mode 100644
index 6091a13ca3..0000000000
--- a/examples/quick/scenegraph/rendernode/softwarerenderer.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples 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$
-**
-****************************************************************************/
-
-#ifndef SOFTWARERENDERER_H
-#define SOFTWARERENDERER_H
-
-#include <qsgrendernode.h>
-#include <QQuickItem>
-
-class SoftwareRenderNode : public QSGRenderNode
-{
-public:
- ~SoftwareRenderNode();
-
- void render(const RenderState *state) override;
- void releaseResources() override;
- StateFlags changedStates() const override;
- RenderingFlags flags() const override;
- QRectF rect() const override;
-
- void sync(QQuickItem *item);
-
-private:
- QQuickWindow *m_window = nullptr;
- int m_width = 0;
- int m_height = 0;
-};
-
-#endif
diff --git a/examples/quick/scenegraph/scenegraph.pro b/examples/quick/scenegraph/scenegraph.pro
index 147fa9a156..58e3d9f6d2 100644
--- a/examples/quick/scenegraph/scenegraph.pro
+++ b/examples/quick/scenegraph/scenegraph.pro
@@ -5,13 +5,11 @@ qtConfig(opengl(es1|es2)?) {
graph \
fboitem \
openglunderqml \
- opengltextureinthread \
twotextureproviders
}
SUBDIRS += \
customgeometry \
- rendernode \
threadedanimation
macos|ios {