From 3fa9dcbb4e1e2a0d41eb76896dd73a375b5e5185 Mon Sep 17 00:00:00 2001 From: Holden Date: Sat, 9 Nov 2024 15:28:44 -0500 Subject: [PATCH] Remove qt5compat Module --- .github/actions/qt-android/action.yml | 10 +- .github/workflows/ios.yml | 4 +- .github/workflows/linux.yml | 2 +- .github/workflows/macos.yml | 2 +- .github/workflows/windows.yml | 4 +- CMakeLists.txt | 1 - .../Custom/Widgets/CustomAttitudeWidget.qml | 30 +-- deploy/docker/Dockerfile-build-ubuntu | 2 +- deploy/vagrant/Vagrantfile | 2 +- .../APM/APMSafetyComponentCopter.qml | 12 +- src/CMakeLists.txt | 2 - src/FlightMap/Widgets/CompassRing.qml | 29 +-- src/QmlControls/CMakeLists.txt | 3 + .../GraphicalEffects/CMakeLists.txt | 27 +++ .../GraphicalEffects/ColorOverlay.qml | 110 +++++++++++ .../GraphicalEffects/coloroverlay.frag.qsb | Bin 0 -> 1908 bytes src/QmlControls/GraphicalEffects/plugin.cpp | 30 +++ .../GraphicalEffects/qgfxsourceproxy.cpp | 171 ++++++++++++++++++ .../GraphicalEffects/qgfxsourceproxy_p.h | 85 +++++++++ src/QmlControls/QGCColoredImage.qml | 4 +- tools/setup/install-dependencies-debian.sh | 2 + tools/setup/install-qt-debian.sh | 2 +- 22 files changed, 483 insertions(+), 51 deletions(-) create mode 100644 src/QmlControls/GraphicalEffects/CMakeLists.txt create mode 100644 src/QmlControls/GraphicalEffects/ColorOverlay.qml create mode 100644 src/QmlControls/GraphicalEffects/coloroverlay.frag.qsb create mode 100644 src/QmlControls/GraphicalEffects/plugin.cpp create mode 100644 src/QmlControls/GraphicalEffects/qgfxsourceproxy.cpp create mode 100644 src/QmlControls/GraphicalEffects/qgfxsourceproxy_p.h diff --git a/.github/actions/qt-android/action.yml b/.github/actions/qt-android/action.yml index 9bc90bf3325..8e6adc12f6d 100644 --- a/.github/actions/qt-android/action.yml +++ b/.github/actions/qt-android/action.yml @@ -68,7 +68,7 @@ runs: target: desktop arch: ${{ inputs.arch }} dir: ${{ runner.temp }} - modules: qtcharts qtlocation qtpositioning qtspeech qt5compat qtmultimedia qtserialport qtimageformats qtshadertools qtconnectivity qtquick3d qtsensors + modules: qtcharts qtlocation qtpositioning qtspeech qtmultimedia qtserialport qtimageformats qtshadertools qtconnectivity qtquick3d qtsensors cache: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} - name: Install Qt for Android (armv7) @@ -82,7 +82,7 @@ runs: arch: android_armv7 dir: ${{ runner.temp }} extra: --autodesktop - modules: qtcharts qtlocation qtpositioning qtspeech qt5compat qtmultimedia qtserialport qtimageformats qtshadertools qtconnectivity qtquick3d qtsensors + modules: qtcharts qtlocation qtpositioning qtspeech qtmultimedia qtserialport qtimageformats qtshadertools qtconnectivity qtquick3d qtsensors cache: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} - name: Install Qt for Android (arm64_v8a) @@ -96,7 +96,7 @@ runs: arch: android_arm64_v8a dir: ${{ runner.temp }} extra: --autodesktop - modules: qtcharts qtlocation qtpositioning qtspeech qt5compat qtmultimedia qtserialport qtimageformats qtshadertools qtconnectivity qtquick3d qtsensors + modules: qtcharts qtlocation qtpositioning qtspeech qtmultimedia qtserialport qtimageformats qtshadertools qtconnectivity qtquick3d qtsensors cache: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} - name: Install Qt for Android (x86) @@ -110,7 +110,7 @@ runs: arch: android_x86 dir: ${{ runner.temp }} extra: --autodesktop - modules: qtcharts qtlocation qtpositioning qtspeech qt5compat qtmultimedia qtserialport qtimageformats qtshadertools qtconnectivity qtquick3d qtsensors + modules: qtcharts qtlocation qtpositioning qtspeech qtmultimedia qtserialport qtimageformats qtshadertools qtconnectivity qtquick3d qtsensors cache: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} - name: Install Qt for Android (x86_64) @@ -124,5 +124,5 @@ runs: arch: android_x86_64 dir: ${{ runner.temp }} extra: --autodesktop - modules: qtcharts qtlocation qtpositioning qtspeech qt5compat qtmultimedia qtserialport qtimageformats qtshadertools qtconnectivity qtquick3d qtsensors + modules: qtcharts qtlocation qtpositioning qtspeech qtmultimedia qtserialport qtimageformats qtshadertools qtconnectivity qtquick3d qtsensors cache: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} diff --git a/.github/workflows/ios.yml b/.github/workflows/ios.yml index b0f4f0d7f32..25e72f6a9a6 100644 --- a/.github/workflows/ios.yml +++ b/.github/workflows/ios.yml @@ -72,7 +72,7 @@ jobs: target: desktop arch: clang_64 dir: ${{ runner.temp }} - modules: qtcharts qtlocation qtpositioning qtspeech qt5compat qtmultimedia qtserialport qtimageformats qtshadertools qtconnectivity qtquick3d qtsensors + modules: qtcharts qtlocation qtpositioning qtspeech qtmultimedia qtserialport qtimageformats qtshadertools qtconnectivity qtquick3d qtsensors cache: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} - name: Install Qt for iOS @@ -85,7 +85,7 @@ jobs: arch: ios dir: ${{ runner.temp }} extra: --autodesktop - modules: qtcharts qtlocation qtpositioning qtspeech qt5compat qtmultimedia qtimageformats qtshadertools qtconnectivity qtquick3d qtsensors + modules: qtcharts qtlocation qtpositioning qtspeech qtmultimedia qtimageformats qtshadertools qtconnectivity qtquick3d qtsensors cache: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} - run: mkdir ${{ runner.temp }}/shadow_build_dir diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 222dfaa6442..0cd117202f0 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -98,7 +98,7 @@ jobs: target: desktop arch: gcc_64 dir: ${{ runner.temp }} - modules: qtcharts qtlocation qtpositioning qtspeech qt5compat qtmultimedia qtserialport qtimageformats qtshadertools qtconnectivity qtquick3d qtsensors + modules: qtcharts qtlocation qtpositioning qtspeech qtmultimedia qtserialport qtimageformats qtshadertools qtconnectivity qtquick3d qtsensors cache: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} # - name: Build GStreamer diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 12155f1ad8e..c4cb773caf1 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -86,7 +86,7 @@ jobs: target: desktop arch: clang_64 dir: ${{ runner.temp }} - modules: qtcharts qtlocation qtpositioning qtspeech qt5compat qtmultimedia qtserialport qtimageformats qtshadertools qtconnectivity qtquick3d qtsensors + modules: qtcharts qtlocation qtpositioning qtspeech qtmultimedia qtserialport qtimageformats qtshadertools qtconnectivity qtquick3d qtsensors cache: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} - run: mkdir ${{ runner.temp }}/shadow_build_dir diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index c8eaa9331ef..3d98a22d5b5 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -94,7 +94,7 @@ jobs: target: desktop arch: win64_msvc2019_64 dir: ${{ runner.temp }} - modules: qtcharts qtlocation qtpositioning qtspeech qt5compat qtmultimedia qtserialport qtimageformats qtshadertools qtconnectivity qtquick3d qtsensors + modules: qtcharts qtlocation qtpositioning qtspeech qtmultimedia qtserialport qtimageformats qtshadertools qtconnectivity qtquick3d qtsensors cache: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} - name: Install Qt for Windows (Arm64) @@ -108,7 +108,7 @@ jobs: arch: win64_msvc2019_arm64 dir: ${{ runner.temp }} extra: --autodesktop - modules: qtcharts qtlocation qtpositioning qtspeech qt5compat qtmultimedia qtserialport qtimageformats qtshadertools qtconnectivity qtquick3d qtsensors + modules: qtcharts qtlocation qtpositioning qtspeech qtmultimedia qtserialport qtimageformats qtshadertools qtconnectivity qtquick3d qtsensors cache: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} - name: Set up Visual Studio shell diff --git a/CMakeLists.txt b/CMakeLists.txt index 3aaabc5be92..1c146dbc1da 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -159,7 +159,6 @@ find_package(Qt6 COMPONENTS Concurrent Core - Core5Compat Location Multimedia Network diff --git a/custom-example/res/Custom/Widgets/CustomAttitudeWidget.qml b/custom-example/res/Custom/Widgets/CustomAttitudeWidget.qml index 5df1920c6b4..82748c26066 100644 --- a/custom-example/res/Custom/Widgets/CustomAttitudeWidget.qml +++ b/custom-example/res/Custom/Widgets/CustomAttitudeWidget.qml @@ -10,13 +10,14 @@ */ import QtQuick +import QtQuick.Effects import QGroundControl import QGroundControl.Controls import QGroundControl.ScreenTools import QGroundControl.Palette import QGroundControl.FlightMap -import Qt5Compat.GraphicalEffects + Item { id: root @@ -99,18 +100,25 @@ Item { } } - Rectangle { - id: mask - anchors.fill: instrument - radius: width / 2 - color: "black" - visible: false + MultiEffect { + source: instrument + anchors.fill: instrument + maskEnabled: true + maskSource: mask } - OpacityMask { - anchors.fill: instrument - source: instrument - maskSource: mask + Item { + id: mask + width: instrument.width + height: instrument.height + layer.enabled: true + visible: false + Rectangle { + width: parent.width + height: parent.height + radius: width / 2 + color: "black" + } } Rectangle { diff --git a/deploy/docker/Dockerfile-build-ubuntu b/deploy/docker/Dockerfile-build-ubuntu index 2e44e7154d4..d84d9ae2879 100644 --- a/deploy/docker/Dockerfile-build-ubuntu +++ b/deploy/docker/Dockerfile-build-ubuntu @@ -1,7 +1,7 @@ FROM ubuntu:22.04 ARG QT_VERSION=6.6.3 -ARG QT_MODULES="qtcharts qtlocation qtpositioning qtspeech qt5compat qtmultimedia qtserialport qtimageformats qtshadertools qtconnectivity qtquick3d qtsensors" +ARG QT_MODULES="qtcharts qtlocation qtpositioning qtspeech qtmultimedia qtserialport qtimageformats qtshadertools qtconnectivity qtquick3d qtsensors" ENV DEBIAN_FRONTEND noninteractive diff --git a/deploy/vagrant/Vagrantfile b/deploy/vagrant/Vagrantfile index 7568b366105..9d520927a84 100644 --- a/deploy/vagrant/Vagrantfile +++ b/deploy/vagrant/Vagrantfile @@ -94,7 +94,7 @@ Vagrant.configure(2) do |config| version="6.6" host="linux" target="desktop" - modules="qtcharts qtlocation qtpositioning qtspeech qt5compat qtmultimedia qtserialport qtimageformats qtshadertools qtconnectivity qtquick3d qtsensors" + modules="qtcharts qtlocation qtpositioning qtspeech qtmultimedia qtserialport qtimageformats qtshadertools qtconnectivity qtquick3d qtsensors" su - vagrant -c "rm -rf ${dir}" su - vagrant -c "mkdir -p ${dir}" su - vagrant -c "python3 -m aqt install-qt -O ${dir} ${host} ${target} ${version} -m ${modules}" diff --git a/src/AutoPilotPlugins/APM/APMSafetyComponentCopter.qml b/src/AutoPilotPlugins/APM/APMSafetyComponentCopter.qml index 448d433df55..eb799fc11bb 100644 --- a/src/AutoPilotPlugins/APM/APMSafetyComponentCopter.qml +++ b/src/AutoPilotPlugins/APM/APMSafetyComponentCopter.qml @@ -408,27 +408,21 @@ SetupPage { height: rltAltFinalField.y + rltAltFinalField.height + _margins color: ggcPal.windowShade - Image { + QGCColoredImage { id: icon + visible: _showIcon anchors.margins: _margins anchors.left: parent.left anchors.top: parent.top height: ScreenTools.defaultFontPixelWidth * 20 width: ScreenTools.defaultFontPixelWidth * 20 + color: ggcPal.text sourceSize.width: width mipmap: true fillMode: Image.PreserveAspectFit - visible: false source: "/qmlimages/ReturnToHomeAltitude.svg" } - ColorOverlay { - anchors.fill: icon - source: icon - color: ggcPal.text - visible: _showIcon - } - QGCRadioButton { id: returnAtCurrentRadio anchors.margins: _margins diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 93b769f7eea..109ebf90a4d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -2,7 +2,6 @@ find_package(Qt6 REQUIRED COMPONENTS Core - Core5Compat QuickControls2 QuickWidgets Widgets @@ -64,7 +63,6 @@ target_link_libraries(QGC Qt6::Quick Qt6::QuickControls2 Qt6::QuickWidgets - Qt6::Core5Compat Qt6::Bluetooth API ADSB diff --git a/src/FlightMap/Widgets/CompassRing.qml b/src/FlightMap/Widgets/CompassRing.qml index 9bbe4ae3571..e3420eb8c85 100644 --- a/src/FlightMap/Widgets/CompassRing.qml +++ b/src/FlightMap/Widgets/CompassRing.qml @@ -8,6 +8,7 @@ ****************************************************************************/ import QtQuick +import QtQuick.Effects import QGroundControl.Controls import QGroundControl.ScreenTools @@ -67,18 +68,24 @@ Item { } } - Rectangle { - id: mask - anchors.fill: instrument - radius: width / 2 - color: "black" - visible: false + MultiEffect { + source: instrument + anchors.fill: instrument + maskEnabled: true + maskSource: mask } - OpacityMask { - anchors.fill: instrument - source: instrument - maskSource: mask + Item { + id: mask + width: instrument.width + height: instrument.height + layer.enabled: true + visible: false + Rectangle { + width: parent.width + height: parent.height + radius: width / 2 + color: "black" + } } - } diff --git a/src/QmlControls/CMakeLists.txt b/src/QmlControls/CMakeLists.txt index 8bbdbbfdd2e..194863427fd 100644 --- a/src/QmlControls/CMakeLists.txt +++ b/src/QmlControls/CMakeLists.txt @@ -1,3 +1,5 @@ +add_subdirectory(GraphicalEffects) + find_package(Qt6 REQUIRED COMPONENTS Concurrent Core Gui Location Positioning Qml QmlIntegration Quick Widgets) if(QGC_UTM_ADAPTER) @@ -72,6 +74,7 @@ target_link_libraries(QmlControls Geo GPS MockLink + qgcgraphicaleffectsplugin PUBLIC Qt6::Core Qt6::Gui diff --git a/src/QmlControls/GraphicalEffects/CMakeLists.txt b/src/QmlControls/GraphicalEffects/CMakeLists.txt new file mode 100644 index 00000000000..e7488e888fe --- /dev/null +++ b/src/QmlControls/GraphicalEffects/CMakeLists.txt @@ -0,0 +1,27 @@ +find_package(Qt6 REQUIRED COMPONENTS Core Qml Quick) + +qt_add_qml_module(qgcgraphicaleffectsplugin + URI "QGroundControl.GraphicalEffects" + VERSION 1.0 + STATIC + CLASS_NAME QGCGraphicalEffectsPlugin + PLUGIN_TARGET qgcgraphicaleffectsplugin + NO_GENERATE_PLUGIN_SOURCE + NO_PLUGIN_OPTIONAL + RESOURCE_PREFIX "/qt/qml" + QML_FILES "ColorOverlay.qml" + RESOURCES "coloroverlay.frag.qsb" + SOURCES + plugin.cpp + qgfxsourceproxy.cpp + qgfxsourceproxy_p.h +) + +target_include_directories(qgcgraphicaleffectsplugin PUBLIC ${Qt6Quick_PRIVATE_INCLUDE_DIRS}) + +target_link_libraries(qgcgraphicaleffectsplugin + PUBLIC + Qt::Core + Qt::Qml + Qt::Quick +) diff --git a/src/QmlControls/GraphicalEffects/ColorOverlay.qml b/src/QmlControls/GraphicalEffects/ColorOverlay.qml new file mode 100644 index 00000000000..b1fc3a78c1e --- /dev/null +++ b/src/QmlControls/GraphicalEffects/ColorOverlay.qml @@ -0,0 +1,110 @@ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +import QtQuick +import QGroundControl.GraphicalEffects + +/*! + \qmltype ColorOverlay + \inqmlmodule Qt5Compat.GraphicalEffects + \since QtGraphicalEffects 1.0 + \inherits QtQuick2::Item + \ingroup qtgraphicaleffects-color + \brief Alters the colors of the source item by applying an overlay color. + + The effect is similar to what happens when a colorized glass is put on top + of a grayscale image. The color for the overlay is given in the RGBA format. + + \table + \header + \li Source + \li Effect applied + \row + \li \image Original_butterfly.png + \li \image ColorOverlay_butterfly.png + \endtable + + \section1 Example + + The following example shows how to apply the effect. + \snippet ColorOverlay-example.qml example + +*/ +Item { + id: rootItem + + /*! + This property defines the source item that provides the source pixels + for the effect. + + \note It is not supported to let the effect include itself, for + instance by setting source to the effect's parent. + */ + property variant source + + /*! + This property defines the color value which is used to colorize the + source. + + By default, the property is set to \c "transparent". + + \table + \header + \li Output examples with different color values + \li + \li + \row + \li \image ColorOverlay_color1.png + \li \image ColorOverlay_color2.png + \li \image ColorOverlay_color3.png + \row + \li \b { color: #80ff0000 } + \li \b { color: #8000ff00 } + \li \b { color: #800000ff } + \endtable + + */ + property color color: "transparent" + + /*! + This property allows the effect output pixels to be cached in order to + improve the rendering performance. + + Every time the source or effect properties are changed, the pixels in + the cache must be updated. Memory consumption is increased, because an + extra buffer of memory is required for storing the effect output. + + It is recommended to disable the cache when the source or the effect + properties are animated. + + By default, the property is set to \c false. + + */ + property bool cached: false + + SourceProxy { + id: sourceProxy + input: rootItem.source + interpolation: input && input.smooth ? SourceProxy.LinearInterpolation : SourceProxy.NearestInterpolation + } + + ShaderEffectSource { + id: cacheItem + anchors.fill: parent + visible: rootItem.cached + smooth: true + sourceItem: shaderItem + live: true + hideSource: visible + } + + ShaderEffect { + id: shaderItem + property variant source: sourceProxy.output + property color color: rootItem.color + + anchors.fill: parent + + fragmentShader: "qrc:/qt/qml/QGroundControl/GraphicalEffects/coloroverlay.frag.qsb" + } +} diff --git a/src/QmlControls/GraphicalEffects/coloroverlay.frag.qsb b/src/QmlControls/GraphicalEffects/coloroverlay.frag.qsb new file mode 100644 index 0000000000000000000000000000000000000000..e1eb95539db58d09b1b9a5436cfb58b01442bc37 GIT binary patch literal 1908 zcmV-)2aEUs02bAFob6cMZxmG&zq6lZEfkOfg33TC?83V2_JcyVEiKzFH33^`!D?-m zVRyD2vtP{4;#Pubh>0d9Xrl3n|DePdV#14w5}$nX!3Se}_k|}O2rov@x%b?iyY04t zU^Fq_&2;Ac&gVVn+_`tk81pm6d~j)S?Pb@P!!m4^nXJxItPDS!pdFYwZYuU~}Zts?Amd?X|NisMJ6y3u$94OjFf1Q=}1~drpCV z^Lo01sNM#@6rnpH{~DilfZxxZpE)0^I=NV1KNg2=~)ika}?L1 zHS|HUg*3+bs>1J7=t-buJbq658+2Dg#>Ik6bcMt;k{eYp4`I{XpSOXb@9s6Rc2lf4 zUIZx*r@g$Q_`DmQuu*il_JDkliN^79%m-Z}V#4bss9K2lYa39~`@tTro)GD`6OLGt z=&gjIzYenJA^Gi0_L-1JdIw?1-^Ikb4H6&ePQuXMZnEd)xDR3$bHj0*=zYXTd;7^& zfcSV9wOdK<1^N*2eH<70KSc6DvT<0cNs{Pp!Z3y-6oW=SkUpx+IZV&eUXICtw%xgXCK$ zU#J_QTpv~9Jw~{U_c&q4*2Np(xqeNtp~f5|o{af~5_4=#%yHt&OU9fa|8d1%&j$W_ zi6?FL5hky8nomE)5u=t2`Z_LRk<>ZXwdyMeg)Td|3#uyWQ+DX_S;Q5qz1Nmr=L88tY zL;I%dx@lLfa!F70#6zK~W7o2d4jV@3Mo5QIG@L%Yv0o%PmM@eIM|U?1fnGPWeLCMM zlA)W)P^eb2@@2b-w)9NzfPz$wVx?f(J>$CA)PQx}u$QgUA{yz@)vXPAWh+x7yDtp_{6wFdTWP9*IjCQdGwWMQ{>@G_+ATLRX-yt zo1yNJ2O>P%tllHvKe6V6>?G~JqeNdJTKbmvk2Lp$iZR~VK<+!uJ)WZ6&l|`=$ujOC zi?5fydLLW$@PlB>b1)y5wT7-dh;e1My1I%p)HXTaenGn8uqJ$>p2qby_W2{|U9hrt zxmwOUdiY{QpM+zsKC@)xOj}QtixmsfttaBK1bcnv+#6A<2X3gkVn^2A3lFmsbE&DR zi{t2j>M3+^^PRbznKkT16DK<}IWhMU<=TMjy*8%34dqGS7TWj{dnc4eD7tc#jHuMQ=plv68WN4%KcO^NvB5Y%S!lvJ56F+^+#RG&* zF!t#KP)c3uWRC#DxuwZp`a}A7q1eDz@D}L}lC1OzeuC%+dnxS^yvH4lj~_P%PvgFV zFL{)QMIVy<$Dg?|DzaSe6#0<0HAMz^Z8A6MZGsn|JYdJbrlQTvj?I3_#KBe8%R{x4 zW3#WWr}-j#j-hUBIoF-`ySuT)te`XUD4*%Z@|HiEl zOaGP9c;C7$(El%JB;)*I6MY9SXOr2}BTIq7De!8|0(rROnL5w?| zff6^FRq8T7&y~XQ$ihMkO{=6THn$Gw)~co*E|jw+R~=0k&646;JcXq}c(;LO)iD-L zpcWRQ5OxX35}*DNtN`%gF>i{nqK!96Zit65LM;tqvIm76^*pg>fWQe7%4H&r6(@tk zYgoT=vni2HeJ-rUgqg5nI|@^Ywdi^<8B;r77;WAAoYx!98&zj;@LAWuI^|8)0?9t# uYQWjqCS<&Xla#B&&$G!`<6l +#include +#include + +#include "qgfxsourceproxy_p.h" + +QT_BEGIN_NAMESPACE + +class QGCGraphicalEffectsPlugin : public QQmlExtensionPlugin +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) + +public: + QGCGraphicalEffectsPlugin(QObject *parent = 0) : QQmlExtensionPlugin(parent) { } + void registerTypes(const char *uri) override + { + Q_ASSERT(QLatin1String(uri) == QLatin1String("QGroundControl.GraphicalEffects")); + + qmlRegisterType(uri, 1, 0, "SourceProxy"); + qmlRegisterModule(uri, 1, 0); + } +}; + +QT_END_NAMESPACE + +#include "plugin.moc" diff --git a/src/QmlControls/GraphicalEffects/qgfxsourceproxy.cpp b/src/QmlControls/GraphicalEffects/qgfxsourceproxy.cpp new file mode 100644 index 00000000000..5651c55142f --- /dev/null +++ b/src/QmlControls/GraphicalEffects/qgfxsourceproxy.cpp @@ -0,0 +1,171 @@ +// Copyright (C) 2016 Jolla Ltd, author: +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#include "qgfxsourceproxy_p.h" + +#include +#include +#include + +QT_BEGIN_NAMESPACE + +QGfxSourceProxy::QGfxSourceProxy(QQuickItem *parentItem) + : QQuickItem(parentItem) + , m_input(0) + , m_output(0) + , m_proxy(0) + , m_interpolation(AnyInterpolation) +{ +} + +QGfxSourceProxy::~QGfxSourceProxy() +{ + delete m_proxy; +} + +void QGfxSourceProxy::setInput(QQuickItem *input) +{ + if (m_input == input) + return; + + if (m_input != nullptr) + disconnect(m_input, nullptr, this, nullptr); + m_input = input; + polish(); + if (m_input != nullptr) { + if (QQuickImage *image = qobject_cast(m_input)) { + connect(image, &QQuickImage::sourceSizeChanged, this, &QGfxSourceProxy::repolish); + connect(image, &QQuickImage::fillModeChanged, this, &QGfxSourceProxy::repolish); + } + connect(m_input, &QQuickItem::childrenChanged, this, &QGfxSourceProxy::repolish); + } + emit inputChanged(); +} + +void QGfxSourceProxy::setOutput(QQuickItem *output) +{ + if (m_output == output) + return; + m_output = output; + emit activeChanged(); + emit outputChanged(); +} + +void QGfxSourceProxy::setSourceRect(const QRectF &sourceRect) +{ + if (m_sourceRect == sourceRect) + return; + m_sourceRect = sourceRect; + polish(); + emit sourceRectChanged(); +} + +void QGfxSourceProxy::setInterpolation(Interpolation i) +{ + if (m_interpolation == i) + return; + m_interpolation = i; + polish(); + emit interpolationChanged(); +} + + +void QGfxSourceProxy::useProxy() +{ + if (!m_proxy) + m_proxy = new QQuickShaderEffectSource(this); + m_proxy->setSourceRect(m_sourceRect); + m_proxy->setSourceItem(m_input); + m_proxy->setSmooth(m_interpolation != NearestInterpolation); + setOutput(m_proxy); +} + +void QGfxSourceProxy::repolish() +{ + polish(); +} + +QObject *QGfxSourceProxy::findLayer(QQuickItem *item) +{ + if (!item) + return 0; + QQuickItemPrivate *d = QQuickItemPrivate::get(item); + if (d->extra.isAllocated() && d->extra->layer) { + QObject *layer = qvariant_cast(item->property("layer")); + if (layer && layer->property("enabled").toBool()) + return layer; + } + return 0; +} + +void QGfxSourceProxy::updatePolish() +{ + if (m_input == 0) { + setOutput(0); + return; + } + + QQuickImage *image = qobject_cast(m_input); + QQuickShaderEffectSource *shaderSource = qobject_cast(m_input); + bool childless = m_input->childItems().size() == 0; + bool interpOk = m_interpolation == AnyInterpolation + || (m_interpolation == LinearInterpolation && m_input->smooth() == true) + || (m_interpolation == NearestInterpolation && m_input->smooth() == false); + + // Layers can be used in two different ways. Option 1 is when the item is + // used as input to a separate ShaderEffect component. In this case, + // m_input will be the item itself. + QObject *layer = findLayer(m_input); + if (!layer && shaderSource) { + // Alternatively, the effect is applied via layer.effect, and the + // input to the effect will be the layer's internal ShaderEffectSource + // item. In this case, we need to backtrack and find the item that has + // the layer and configure it accordingly. + layer = findLayer(shaderSource->sourceItem()); + } + + // A bit crude test, but we're only using source rect for + // blurring+transparent edge, so this is good enough. + bool padded = m_sourceRect.x() < 0 || m_sourceRect.y() < 0; + + bool direct = false; + + if (layer) { + // Auto-configure the layer so interpolation and padding works as + // expected without allocating additional FBOs. In edgecases, where + // this feature is undesiered, the user can simply use + // ShaderEffectSource rather than layer. + layer->setProperty("sourceRect", m_sourceRect); + layer->setProperty("smooth", m_interpolation != NearestInterpolation); + direct = true; + + } else if (childless && interpOk) { + + if (shaderSource) { + if (shaderSource->sourceRect() == m_sourceRect || m_sourceRect.isEmpty()) + direct = true; + + } else if (!padded && ((image && image->fillMode() == QQuickImage::Stretch && !image->sourceSize().isNull()) + || (!image && m_input->isTextureProvider()) + ) + ) { + direct = true; + } + } + + if (direct) { + setOutput(m_input); + } else { + useProxy(); + } + + // Remove the proxy if it is not in use.. + if (m_proxy && m_output == m_input) { + delete m_proxy; + m_proxy = 0; + } +} + +QT_END_NAMESPACE + +#include "moc_qgfxsourceproxy_p.cpp" diff --git a/src/QmlControls/GraphicalEffects/qgfxsourceproxy_p.h b/src/QmlControls/GraphicalEffects/qgfxsourceproxy_p.h new file mode 100644 index 00000000000..0b62fab7095 --- /dev/null +++ b/src/QmlControls/GraphicalEffects/qgfxsourceproxy_p.h @@ -0,0 +1,85 @@ +// Copyright (C) 2022 The Qt Company Ltd. +// Copyright (C) 2016 Jolla Ltd, author: +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QGFXSOURCEPROXY_P_H +#define QGFXSOURCEPROXY_P_H + +#include +#include + +#include + +QT_BEGIN_NAMESPACE + +class QQuickShaderEffectSource; + +class QGfxSourceProxy : public QQuickItem +{ + Q_OBJECT + + Q_PROPERTY(QQuickItem *input READ input WRITE setInput NOTIFY inputChanged RESET resetInput) + Q_PROPERTY(QQuickItem *output READ output NOTIFY outputChanged) + Q_PROPERTY(QRectF sourceRect READ sourceRect WRITE setSourceRect NOTIFY sourceRectChanged) + + Q_PROPERTY(bool active READ isActive NOTIFY activeChanged) + Q_PROPERTY(Interpolation interpolation READ interpolation WRITE setInterpolation NOTIFY interpolationChanged) + + Q_ENUMS(Interpolation) + + QML_NAMED_ELEMENT(SourceProxy) + QML_ADDED_IN_VERSION(5, 0) + +public: + enum Interpolation { + AnyInterpolation, + NearestInterpolation, + LinearInterpolation + }; + + QGfxSourceProxy(QQuickItem *item = 0); + ~QGfxSourceProxy(); + + QQuickItem *input() const { return m_input; } + void setInput(QQuickItem *input); + void resetInput() { setInput(0); } + + QQuickItem *output() const { return m_output; } + + QRectF sourceRect() const { return m_sourceRect; } + void setSourceRect(const QRectF &sourceRect); + + bool isActive() const { return m_output && m_output != m_input; } + + void setInterpolation(Interpolation i); + Interpolation interpolation() const { return m_interpolation; } + +protected: + void updatePolish() override; + +signals: + void inputChanged(); + void outputChanged(); + void sourceRectChanged(); + void activeChanged(); + void interpolationChanged(); + +private slots: + void repolish(); + +private: + void setOutput(QQuickItem *output); + void useProxy(); + static QObject *findLayer(QQuickItem *); + + QRectF m_sourceRect; + QQuickItem *m_input; + QQuickItem *m_output; + QQuickShaderEffectSource *m_proxy; + + Interpolation m_interpolation; +}; + +QT_END_NAMESPACE + +#endif // QGFXSOURCEPROXY_P_H diff --git a/src/QmlControls/QGCColoredImage.qml b/src/QmlControls/QGCColoredImage.qml index 5769463f5d1..36e21be7ed6 100644 --- a/src/QmlControls/QGCColoredImage.qml +++ b/src/QmlControls/QGCColoredImage.qml @@ -1,8 +1,6 @@ import QtQuick -import QtQuick.Controls -import Qt5Compat.GraphicalEffects -import QGroundControl.Palette +import QGroundControl.GraphicalEffects Item { property color color: "white" // Image color diff --git a/tools/setup/install-dependencies-debian.sh b/tools/setup/install-dependencies-debian.sh index 187851b561d..17685757c5b 100755 --- a/tools/setup/install-dependencies-debian.sh +++ b/tools/setup/install-dependencies-debian.sh @@ -193,3 +193,5 @@ if apt-cache show libgeographic-dev >/dev/null 2>&1 && apt-cache show libgeograp elif apt-cache show libgeographiclib-dev >/dev/null 2>&1 && apt-cache show libgeographiclib-dev 2>/dev/null | grep -q "^Package: libgeographiclib-dev"; then DEBIAN_FRONTEND=noninteractive apt-get install -y --quiet libgeographiclib-dev fi + +DEBIAN_FRONTEND=noninteractive pip install --upgrade cmake ninja diff --git a/tools/setup/install-qt-debian.sh b/tools/setup/install-qt-debian.sh index 6ba4521b86c..67af91a1ca7 100755 --- a/tools/setup/install-qt-debian.sh +++ b/tools/setup/install-qt-debian.sh @@ -5,7 +5,7 @@ QT_PATH="${QT_PATH:-/opt/Qt}" QT_HOST="${QT_HOST:-linux}" QT_TARGET="${QT_TARGET:-desktop}" QT_ARCH="${QT_ARCH:-gcc_64}" -QT_MODULES="${QT_MODULES:-qtcharts qtlocation qtpositioning qtspeech qt5compat qtmultimedia qtserialport qtimageformats qtshadertools qtconnectivity qtquick3d qtsensors}" +QT_MODULES="${QT_MODULES:-qtcharts qtlocation qtpositioning qtspeech qtmultimedia qtserialport qtimageformats qtshadertools qtconnectivity qtquick3d qtsensors}" set -e