From 2a3181769f44ae1a825e8616474273c6981bf9de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kai=20K=C3=B6hne?= Date: Thu, 8 Jul 2021 17:42:32 +0200 Subject: Get rid of shared snippets directory Avoiding code duplication is a noble goal, but the examples need to be self-contained. E.g. Qt Creator sometimes does copy the example (and just the example) to a tmp directory, where navigating out of the source directory will fail. Change-Id: I009c3f253fea9bf260f9cd58a58f2541a249d3af Reviewed-by: Lars Knoll (cherry picked from commit 8d9ffe8ae68d34b05e6219fd9f1fc5009638e4d6) Reviewed-by: Qt Cherry-pick Bot --- examples/multimedia/video/qmlvideo/CMakeLists.txt | 38 +-- .../multimedia/video/qmlvideo/frequencymonitor.cpp | 254 +++++++++++++++++++++ .../multimedia/video/qmlvideo/frequencymonitor.h | 111 +++++++++ .../video/qmlvideo/frequencymonitordeclarative.cpp | 57 +++++ .../video/qmlvideo/performancemonitor.cpp | 78 +++++++ .../multimedia/video/qmlvideo/performancemonitor.h | 77 +++++++ .../qmlvideo/performancemonitordeclarative.cpp | 60 +++++ .../video/qmlvideo/performancemonitordeclarative.h | 60 +++++ .../qml/frequencymonitor/FrequencyItem.qml | 114 +++++++++ .../qml/performancemonitor/PerformanceItem.qml | 150 ++++++++++++ examples/multimedia/video/qmlvideo/qmlvideo.pro | 76 +++++- examples/multimedia/video/qmlvideo/qmlvideo.qrc | 51 ----- .../multimedia/video/qmlvideofx/CMakeLists.txt | 41 +--- .../video/qmlvideofx/frequencymonitor.cpp | 254 +++++++++++++++++++++ .../multimedia/video/qmlvideofx/frequencymonitor.h | 111 +++++++++ .../qmlvideofx/frequencymonitordeclarative.cpp | 57 +++++ .../video/qmlvideofx/performancemonitor.cpp | 78 +++++++ .../video/qmlvideofx/performancemonitor.h | 77 +++++++ .../qmlvideofx/performancemonitordeclarative.cpp | 60 +++++ .../qmlvideofx/performancemonitordeclarative.h | 60 +++++ .../qml/frequencymonitor/FrequencyItem.qml | 114 +++++++++ .../qml/performancemonitor/PerformanceItem.qml | 150 ++++++++++++ .../multimedia/video/qmlvideofx/qmlvideofx.pro | 95 +++++++- .../multimedia/video/qmlvideofx/qmlvideofx.qrc | 71 ------ .../snippets/frequencymonitor/frequencymonitor.cpp | 254 --------------------- .../snippets/frequencymonitor/frequencymonitor.h | 111 --------- .../snippets/frequencymonitor/frequencymonitor.pri | 5 - .../frequencymonitordeclarative.cpp | 57 ----- .../frequencymonitordeclarative.pri | 5 - .../frequencymonitordeclarative.qrc | 5 - .../qml/frequencymonitor/FrequencyItem.qml | 114 --------- .../performancemonitor/performancemonitor.cpp | 78 ------- .../performancemonitor/performancemonitor.h | 77 ------- .../performancemonitor/performancemonitor.pri | 5 - .../performancemonitordeclarative.cpp | 60 ----- .../performancemonitordeclarative.h | 60 ----- .../performancemonitordeclarative.pri | 6 - .../performancemonitordeclarative.qrc | 5 - .../qml/performancemonitor/PerformanceItem.qml | 150 ------------ 39 files changed, 2095 insertions(+), 1191 deletions(-) create mode 100644 examples/multimedia/video/qmlvideo/frequencymonitor.cpp create mode 100644 examples/multimedia/video/qmlvideo/frequencymonitor.h create mode 100644 examples/multimedia/video/qmlvideo/frequencymonitordeclarative.cpp create mode 100644 examples/multimedia/video/qmlvideo/performancemonitor.cpp create mode 100644 examples/multimedia/video/qmlvideo/performancemonitor.h create mode 100644 examples/multimedia/video/qmlvideo/performancemonitordeclarative.cpp create mode 100644 examples/multimedia/video/qmlvideo/performancemonitordeclarative.h create mode 100644 examples/multimedia/video/qmlvideo/qml/frequencymonitor/FrequencyItem.qml create mode 100644 examples/multimedia/video/qmlvideo/qml/performancemonitor/PerformanceItem.qml delete mode 100644 examples/multimedia/video/qmlvideo/qmlvideo.qrc create mode 100644 examples/multimedia/video/qmlvideofx/frequencymonitor.cpp create mode 100644 examples/multimedia/video/qmlvideofx/frequencymonitor.h create mode 100644 examples/multimedia/video/qmlvideofx/frequencymonitordeclarative.cpp create mode 100644 examples/multimedia/video/qmlvideofx/performancemonitor.cpp create mode 100644 examples/multimedia/video/qmlvideofx/performancemonitor.h create mode 100644 examples/multimedia/video/qmlvideofx/performancemonitordeclarative.cpp create mode 100644 examples/multimedia/video/qmlvideofx/performancemonitordeclarative.h create mode 100644 examples/multimedia/video/qmlvideofx/qml/frequencymonitor/FrequencyItem.qml create mode 100644 examples/multimedia/video/qmlvideofx/qml/performancemonitor/PerformanceItem.qml delete mode 100644 examples/multimedia/video/qmlvideofx/qmlvideofx.qrc delete mode 100644 examples/multimedia/video/snippets/frequencymonitor/frequencymonitor.cpp delete mode 100644 examples/multimedia/video/snippets/frequencymonitor/frequencymonitor.h delete mode 100644 examples/multimedia/video/snippets/frequencymonitor/frequencymonitor.pri delete mode 100644 examples/multimedia/video/snippets/frequencymonitor/frequencymonitordeclarative.cpp delete mode 100644 examples/multimedia/video/snippets/frequencymonitor/frequencymonitordeclarative.pri delete mode 100644 examples/multimedia/video/snippets/frequencymonitor/frequencymonitordeclarative.qrc delete mode 100644 examples/multimedia/video/snippets/frequencymonitor/qml/frequencymonitor/FrequencyItem.qml delete mode 100644 examples/multimedia/video/snippets/performancemonitor/performancemonitor.cpp delete mode 100644 examples/multimedia/video/snippets/performancemonitor/performancemonitor.h delete mode 100644 examples/multimedia/video/snippets/performancemonitor/performancemonitor.pri delete mode 100644 examples/multimedia/video/snippets/performancemonitor/performancemonitordeclarative.cpp delete mode 100644 examples/multimedia/video/snippets/performancemonitor/performancemonitordeclarative.h delete mode 100644 examples/multimedia/video/snippets/performancemonitor/performancemonitordeclarative.pri delete mode 100644 examples/multimedia/video/snippets/performancemonitor/performancemonitordeclarative.qrc delete mode 100644 examples/multimedia/video/snippets/performancemonitor/qml/performancemonitor/PerformanceItem.qml diff --git a/examples/multimedia/video/qmlvideo/CMakeLists.txt b/examples/multimedia/video/qmlvideo/CMakeLists.txt index d2e9e1f4d..dce82772a 100644 --- a/examples/multimedia/video/qmlvideo/CMakeLists.txt +++ b/examples/multimedia/video/qmlvideo/CMakeLists.txt @@ -22,10 +22,10 @@ find_package(Qt6 COMPONENTS Multimedia) find_package(Qt6 COMPONENTS Qml) qt_add_executable(qmlvideo - ../snippets/frequencymonitor/frequencymonitor.cpp ../snippets/frequencymonitor/frequencymonitor.h - ../snippets/frequencymonitor/frequencymonitordeclarative.cpp - ../snippets/performancemonitor/performancemonitor.cpp ../snippets/performancemonitor/performancemonitor.h - ../snippets/performancemonitor/performancemonitordeclarative.cpp ../snippets/performancemonitor/performancemonitordeclarative.h + frequencymonitor.cpp frequencymonitor.h + frequencymonitordeclarative.cpp + performancemonitor.cpp performancemonitor.h + performancemonitordeclarative.cpp performancemonitordeclarative.h main.cpp trace.h ) @@ -34,10 +34,6 @@ set_target_properties(qmlvideo PROPERTIES MACOSX_BUNDLE TRUE MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist.in ) -target_include_directories(qmlvideo PUBLIC - ../snippets/frequencymonitor - ../snippets/performancemonitor -) target_compile_definitions(qmlvideo PUBLIC FREQUENCYMONITOR_SUPPORT @@ -67,6 +63,8 @@ set(qmlvideo_resource_files "images/folder.png" "images/leaves.jpg" "images/up.png" + "qml/frequencymonitor/FrequencyItem.qml" + "qml/performancemonitor/PerformanceItem.qml" "qml/qmlvideo/Button.qml" "qml/qmlvideo/CameraBasic.qml" "qml/qmlvideo/CameraDrag.qml" @@ -119,30 +117,6 @@ qt6_add_resources(qmlvideo "qmlvideo" FILES ${qmlvideo_resource_files} ) -set(frequencymonitordeclarative_resource_files - "../snippets/frequencymonitor/qml/frequencymonitor/FrequencyItem.qml" -) - -qt6_add_resources(qmlvideo "frequencymonitordeclarative" - PREFIX - "/" - BASE - "../snippets/frequencymonitor" - FILES - ${frequencymonitordeclarative_resource_files} -) -set(performancemonitordeclarative_resource_files - "../snippets/performancemonitor/qml/performancemonitor/PerformanceItem.qml" -) - -qt6_add_resources(qmlvideo "performancemonitordeclarative" - PREFIX - "/" - BASE - "../snippets/performancemonitor" - FILES - ${performancemonitordeclarative_resource_files} -) install(TARGETS qmlvideo RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" diff --git a/examples/multimedia/video/qmlvideo/frequencymonitor.cpp b/examples/multimedia/video/qmlvideo/frequencymonitor.cpp new file mode 100644 index 000000000..5f48cd35e --- /dev/null +++ b/examples/multimedia/video/qmlvideo/frequencymonitor.cpp @@ -0,0 +1,254 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Mobility Components. +** +** $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 "frequencymonitor.h" +#include +#include +#include +#include +#include + +//#define VERBOSE_TRACE + +inline QDebug qtTrace() { return qDebug() << "[frequencymonitor]"; } +#ifdef VERBOSE_TRACE +inline QDebug qtVerboseTrace() { return qtTrace(); } +#else +inline QNoDebug qtVerboseTrace() { return QNoDebug(); } +#endif + +static const int DefaultSamplingInterval = 100; +static const int DefaultTraceInterval = 0; + +class FrequencyMonitorPrivate : public QObject +{ + Q_OBJECT + +public: + FrequencyMonitorPrivate(FrequencyMonitor *parent); + void calculateInstantaneousFrequency(); + +private slots: + void calculateAverageFrequency(); + void stalled(); + +public: + FrequencyMonitor *const q_ptr; + QString m_label; + bool m_active; + qreal m_instantaneousFrequency; + QElapsedTimer m_instantaneousElapsed; + QTimer *m_averageTimer; + QElapsedTimer m_averageElapsed; + int m_count; + qreal m_averageFrequency; + QTimer *m_traceTimer; + QTimer *m_stalledTimer; +}; + +FrequencyMonitorPrivate::FrequencyMonitorPrivate(FrequencyMonitor *parent) +: QObject(parent) +, q_ptr(parent) +, m_active(false) +, m_instantaneousFrequency(0) +, m_averageTimer(new QTimer(this)) +, m_count(0) +, m_averageFrequency(0) +, m_traceTimer(new QTimer(this)) +, m_stalledTimer(new QTimer(this)) +{ + m_instantaneousElapsed.start(); + connect(m_averageTimer, &QTimer::timeout, + this, &FrequencyMonitorPrivate::calculateAverageFrequency); + if (DefaultSamplingInterval) + m_averageTimer->start(DefaultSamplingInterval); + m_averageElapsed.start(); + connect(m_traceTimer, &QTimer::timeout, + q_ptr, &FrequencyMonitor::trace); + if (DefaultTraceInterval) + m_traceTimer->start(DefaultTraceInterval); + m_stalledTimer->setSingleShot(true); + connect(m_stalledTimer, &QTimer::timeout, + this, &FrequencyMonitorPrivate::stalled); +} + +void FrequencyMonitorPrivate::calculateInstantaneousFrequency() +{ + const qint64 ms = m_instantaneousElapsed.restart(); + m_instantaneousFrequency = ms ? qreal(1000) / ms : 0; + m_stalledTimer->start(3 * ms); + if (m_instantaneousFrequency) + q_ptr->setActive(true); + emit q_ptr->instantaneousFrequencyChanged(m_instantaneousFrequency); + emit q_ptr->frequencyChanged(); +} + +void FrequencyMonitorPrivate::calculateAverageFrequency() +{ + const qint64 ms = m_averageElapsed.restart(); + m_averageFrequency = qreal(m_count * 1000) / ms; + emit q_ptr->averageFrequencyChanged(m_averageFrequency); + emit q_ptr->frequencyChanged(); + m_count = 0; +} + +void FrequencyMonitorPrivate::stalled() +{ + if (m_instantaneousFrequency) { + m_instantaneousFrequency = 0; + emit q_ptr->instantaneousFrequencyChanged(m_instantaneousFrequency); + emit q_ptr->frequencyChanged(); + } +} + +FrequencyMonitor::FrequencyMonitor(QObject *parent) +: QObject(parent) +{ + d_ptr = new FrequencyMonitorPrivate(this); +} + +FrequencyMonitor::~FrequencyMonitor() = default; + +QString FrequencyMonitor::label() const +{ + return d_func()->m_label; +} + +bool FrequencyMonitor::active() const +{ + return d_func()->m_active; +} + +int FrequencyMonitor::samplingInterval() const +{ + return d_ptr->m_averageTimer->isActive() ? d_ptr->m_averageTimer->interval() : 0; +} + +int FrequencyMonitor::traceInterval() const +{ + return d_ptr->m_traceTimer->isActive() ? d_ptr->m_traceTimer->interval() : 0; +} + +qreal FrequencyMonitor::instantaneousFrequency() const +{ + return d_func()->m_instantaneousFrequency; +} + +qreal FrequencyMonitor::averageFrequency() const +{ + return d_func()->m_averageFrequency; +} + +void FrequencyMonitor::notify() +{ + Q_D(FrequencyMonitor); + ++(d->m_count); + d->calculateInstantaneousFrequency(); +} + +void FrequencyMonitor::trace() +{ + Q_D(FrequencyMonitor); + const QString value = QString::fromLatin1("instant %1 average %2") + .arg(d->m_instantaneousFrequency, 0, 'f', 2) + .arg(d->m_averageFrequency, 0, 'f', 2); + if (d->m_label.isEmpty()) + qtTrace() << "FrequencyMonitor::trace" << value; + else + qtTrace() << "FrequencyMonitor::trace" << "label" << d->m_label << value; +} + +void FrequencyMonitor::setLabel(const QString &value) +{ + Q_D(FrequencyMonitor); + if (d->m_label != value) { + d->m_label = value; + emit labelChanged(d->m_label); + } +} + +void FrequencyMonitor::setActive(bool value) +{ + Q_D(FrequencyMonitor); + if (d->m_active != value) { + d->m_active = value; + emit activeChanged(d->m_active); + } +} + +void FrequencyMonitor::setSamplingInterval(int value) +{ + Q_D(FrequencyMonitor); + if (samplingInterval() != value) { + if (value) { + d->m_averageTimer->setInterval(value); + d->m_averageTimer->start(); + } else { + d->m_averageTimer->stop(); + } + emit samplingIntervalChanged(value); + } +} + +void FrequencyMonitor::setTraceInterval(int value) +{ + Q_D(FrequencyMonitor); + if (traceInterval() != value) { + if (value) { + d->m_traceTimer->setInterval(value); + d->m_traceTimer->start(); + } else { + d->m_traceTimer->stop(); + } + emit traceIntervalChanged(value); + } +} + +#include "frequencymonitor.moc" diff --git a/examples/multimedia/video/qmlvideo/frequencymonitor.h b/examples/multimedia/video/qmlvideo/frequencymonitor.h new file mode 100644 index 000000000..efeb78589 --- /dev/null +++ b/examples/multimedia/video/qmlvideo/frequencymonitor.h @@ -0,0 +1,111 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Mobility Components. +** +** $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 FREQUENCYMONITOR_H +#define FREQUENCYMONITOR_H + +#include +#include + +class FrequencyMonitorPrivate; + +/** + * Class for measuring frequency of events + * + * Occurrence of the event is notified by the client via the notify() slot. + * On a regular interval, both an instantaneous and a rolling average + * event frequency are calculated. + */ +class FrequencyMonitor : public QObject +{ + Q_OBJECT + Q_DECLARE_PRIVATE(FrequencyMonitor) + Q_PROPERTY(QString label READ label WRITE setLabel NOTIFY labelChanged) + Q_PROPERTY(bool active READ active WRITE setActive NOTIFY activeChanged) + Q_PROPERTY(int samplingInterval READ samplingInterval WRITE setSamplingInterval NOTIFY samplingIntervalChanged) + Q_PROPERTY(int traceInterval READ traceInterval WRITE setTraceInterval NOTIFY traceIntervalChanged) + Q_PROPERTY(qreal instantaneousFrequency READ instantaneousFrequency NOTIFY instantaneousFrequencyChanged) + Q_PROPERTY(qreal averageFrequency READ averageFrequency NOTIFY averageFrequencyChanged) + +public: + FrequencyMonitor(QObject *parent = 0); + ~FrequencyMonitor(); + + static void qmlRegisterType(); + + QString label() const; + bool active() const; + int samplingInterval() const; + int traceInterval() const; + qreal instantaneousFrequency() const; + qreal averageFrequency() const; + +signals: + void labelChanged(const QString &value); + void activeChanged(bool); + void samplingIntervalChanged(int value); + void traceIntervalChanged(int value); + void frequencyChanged(); + void instantaneousFrequencyChanged(qreal value); + void averageFrequencyChanged(qreal value); + +public slots: + Q_INVOKABLE void notify(); + Q_INVOKABLE void trace(); + void setActive(bool value); + void setLabel(const QString &value); + void setSamplingInterval(int value); + void setTraceInterval(int value); + +private: + FrequencyMonitorPrivate *d_ptr; +}; + +#endif // FREQUENCYMONITOR_H diff --git a/examples/multimedia/video/qmlvideo/frequencymonitordeclarative.cpp b/examples/multimedia/video/qmlvideo/frequencymonitordeclarative.cpp new file mode 100644 index 000000000..0994ae213 --- /dev/null +++ b/examples/multimedia/video/qmlvideo/frequencymonitordeclarative.cpp @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Mobility Components. +** +** $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 "frequencymonitor.h" +#include + +void FrequencyMonitor::qmlRegisterType() +{ + ::qmlRegisterType("FrequencyMonitor", 1, 0, "FrequencyMonitor"); +} diff --git a/examples/multimedia/video/qmlvideo/performancemonitor.cpp b/examples/multimedia/video/qmlvideo/performancemonitor.cpp new file mode 100644 index 000000000..204eabc5a --- /dev/null +++ b/examples/multimedia/video/qmlvideo/performancemonitor.cpp @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Mobility Components. +** +** $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 "performancemonitor.h" + +namespace PerformanceMonitor { + +bool State::parseArgument(const QByteArray &arg) +{ + bool result = false; + if (arg == "-log-perf") { + logging = true; + valid = true; + result = true; + } else if (arg == "-no-log-perf") { + logging = false; + valid = true; + result = true; + } else if (arg == "-show-perf") { + visible = true; + valid = true; + result = true; + } else if (arg == "-hide-perf") { + visible = false; + valid = true; + result = true; + } + return result; +} + +} // namespace PerformanceMonitor diff --git a/examples/multimedia/video/qmlvideo/performancemonitor.h b/examples/multimedia/video/qmlvideo/performancemonitor.h new file mode 100644 index 000000000..97b76caf3 --- /dev/null +++ b/examples/multimedia/video/qmlvideo/performancemonitor.h @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Mobility Components. +** +** $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 PERFORMANCEMONITOR_H +#define PERFORMANCEMONITOR_H + +#include + +namespace PerformanceMonitor { + +struct State +{ + State() : valid(true), logging(false), visible(true) { } + State(bool l, bool v) : valid(true), logging(l), visible(v) { } + bool operator==(const State &other) const + { return logging == other.logging && visible == other.visible; } + bool operator!=(const State &other) const + { return logging != other.logging || visible != other.visible; } + + bool parseArgument(const QByteArray &arg); + + bool valid; + bool logging; + bool visible; +}; + +} // namespace PerformanceMonitor + +#endif // PERFORMANCEMONITOR_H + diff --git a/examples/multimedia/video/qmlvideo/performancemonitordeclarative.cpp b/examples/multimedia/video/qmlvideo/performancemonitordeclarative.cpp new file mode 100644 index 000000000..0783fdbd9 --- /dev/null +++ b/examples/multimedia/video/qmlvideo/performancemonitordeclarative.cpp @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Mobility Components. +** +** $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 "frequencymonitor.h" +#include "performancemonitor.h" + +namespace PerformanceMonitor { + + void qmlRegisterTypes() + { + FrequencyMonitor::qmlRegisterType(); + } +} diff --git a/examples/multimedia/video/qmlvideo/performancemonitordeclarative.h b/examples/multimedia/video/qmlvideo/performancemonitordeclarative.h new file mode 100644 index 000000000..ca70657ce --- /dev/null +++ b/examples/multimedia/video/qmlvideo/performancemonitordeclarative.h @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Mobility Components. +** +** $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 PERFORMANCEMONITORDECLARATIVE_H +#define PERFORMANCEMONITORDECLARATIVE_H + +#include "performancemonitor.h" + +namespace PerformanceMonitor { + void qmlRegisterTypes(); +} + +#endif // PERFORMANCEMONITORDECLARATIVE_H diff --git a/examples/multimedia/video/qmlvideo/qml/frequencymonitor/FrequencyItem.qml b/examples/multimedia/video/qmlvideo/qml/frequencymonitor/FrequencyItem.qml new file mode 100644 index 000000000..ec1bab299 --- /dev/null +++ b/examples/multimedia/video/qmlvideo/qml/frequencymonitor/FrequencyItem.qml @@ -0,0 +1,114 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Mobility Components. +** +** $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 +import FrequencyMonitor 1.0 + +Rectangle { + id: root + property bool logging: true + property bool displayed: true + property bool enabled: logging || displayed + property alias active: monitor.active + property int samplingInterval: 500 + property color textColor: "yellow" + property int textSize: 20 + property alias label: monitor.label + + border.width: 1 + border.color: "yellow" + width: 5.5 * root.textSize + height: 3.0 * root.textSize + color: "black" + opacity: 0.5 + radius: 10 + visible: displayed && active + + // This should ensure that the monitor is on top of all other content + z: 999 + + function notify() { + monitor.notify() + } + + FrequencyMonitor { + id: monitor + samplingInterval: root.enabled ? root.samplingInterval : 0 + onAverageFrequencyChanged: { + if (root.logging) trace() + averageFrequencyText.text = monitor.averageFrequency.toFixed(2) + } + } + + Text { + id: labelText + anchors { + left: parent.left + top: parent.top + margins: 10 + } + color: root.textColor + font.pixelSize: 0.6 * root.textSize + text: root.label + width: root.width - 2*anchors.margins + elide: Text.ElideRight + } + + Text { + id: averageFrequencyText + anchors { + right: parent.right + bottom: parent.bottom + margins: 10 + } + color: root.textColor + font.pixelSize: root.textSize + } +} diff --git a/examples/multimedia/video/qmlvideo/qml/performancemonitor/PerformanceItem.qml b/examples/multimedia/video/qmlvideo/qml/performancemonitor/PerformanceItem.qml new file mode 100644 index 000000000..5621450cb --- /dev/null +++ b/examples/multimedia/video/qmlvideo/qml/performancemonitor/PerformanceItem.qml @@ -0,0 +1,150 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Mobility Components. +** +** $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 + +Rectangle { + id: root + property bool logging: true + property bool displayed: true + property bool videoActive + property int margins: 5 + property bool enabled: true + + color: "transparent" + + // This should ensure that the monitor is on top of all other content + z: 999 + + Column { + id: column + anchors { + fill: root + margins: 10 + } + spacing: 10 + } + + QtObject { + id: d + property Item qmlFrameRateItem: null + property Item videoFrameRateItem: null + } + + Connections { + id: videoFrameRateActiveConnections + ignoreUnknownSignals: true + function onActiveChanged() { root.videoActive = videoFrameRateActiveConnections.target.active } + } + + states: [ + State { + name: "hidden" + PropertyChanges { + target: root + opacity: 0 + } + } + ] + + transitions: [ + Transition { + from: "*" + to: "*" + NumberAnimation { + properties: "opacity" + easing.type: Easing.OutQuart + duration: 500 + } + } + ] + + state: enabled ? "baseState" : "hidden" + + function createQmlFrameRateItem() { + var component = Qt.createComponent("../frequencymonitor/FrequencyItem.qml") + if (component.status == Component.Ready) + d.qmlFrameRateItem = component.createObject(column, { label: "QML frame rate", + displayed: root.displayed, + logging: root.logging + }) + } + + function createVideoFrameRateItem() { + var component = Qt.createComponent("../frequencymonitor/FrequencyItem.qml") + if (component.status == Component.Ready) + d.videoFrameRateItem = component.createObject(column, { label: "Video frame rate", + displayed: root.displayed, + logging: root.logging + }) + videoFrameRateActiveConnections.target = d.videoFrameRateItem + } + + + function init() { + createQmlFrameRateItem() + createVideoFrameRateItem() + } + + function videoFramePainted() { + if (d.videoFrameRateItem) + d.videoFrameRateItem.notify() + } + + function qmlFramePainted() { + if (d.qmlFrameRateItem) + d.qmlFrameRateItem.notify() + } + + onVideoActiveChanged: { + if (d.videoFrameRateItem) + d.videoFrameRateItem.active = root.videoActive + } +} diff --git a/examples/multimedia/video/qmlvideo/qmlvideo.pro b/examples/multimedia/video/qmlvideo/qmlvideo.pro index dbd3a42a1..4fa9d2b3b 100644 --- a/examples/multimedia/video/qmlvideo/qmlvideo.pro +++ b/examples/multimedia/video/qmlvideo/qmlvideo.pro @@ -7,15 +7,77 @@ android: qtHaveModule(androidextras) { DEFINES += REQUEST_PERMISSIONS_ON_ANDROID } -LOCAL_SOURCES = main.cpp -LOCAL_HEADERS = trace.h +DEFINES += \ + FREQUENCYMONITOR_SUPPORT \ + PERFORMANCEMONITOR_SUPPORT -SOURCES += $$LOCAL_SOURCES -HEADERS += $$LOCAL_HEADERS -RESOURCES += qmlvideo.qrc +SOURCES += \ + main.cpp \ + frequencymonitor.cpp \ + frequencymonitordeclarative.cpp \ + performancemonitor.cpp \ + performancemonitordeclarative.cpp -SNIPPETS_PATH = ../snippets -include($$SNIPPETS_PATH/performancemonitor/performancemonitordeclarative.pri) +HEADERS += \ + trace.h \ + frequencymonitor.h \ + performancemonitor.h \ + performancemonitordeclarative.h + +resources.files = \ + images/folder.png \ + images/leaves.jpg \ + images/up.png \ + qml/frequencymonitor/FrequencyItem.qml \ + qml/performancemonitor/PerformanceItem.qml \ + qml/qmlvideo/Button.qml \ + qml/qmlvideo/CameraBasic.qml \ + qml/qmlvideo/CameraDrag.qml \ + qml/qmlvideo/CameraDummy.qml \ + qml/qmlvideo/CameraFullScreen.qml \ + qml/qmlvideo/CameraFullScreenInverted.qml \ + qml/qmlvideo/CameraItem.qml \ + qml/qmlvideo/CameraMove.qml \ + qml/qmlvideo/CameraOverlay.qml \ + qml/qmlvideo/CameraResize.qml \ + qml/qmlvideo/CameraRotate.qml \ + qml/qmlvideo/CameraSpin.qml \ + qml/qmlvideo/Content.qml \ + qml/qmlvideo/ErrorDialog.qml \ + qml/qmlvideo/FileBrowser.qml \ + qml/qmlvideo/Scene.qml \ + qml/qmlvideo/SceneBasic.qml \ + qml/qmlvideo/SceneDrag.qml \ + qml/qmlvideo/SceneFullScreen.qml \ + qml/qmlvideo/SceneFullScreenInverted.qml \ + qml/qmlvideo/SceneMove.qml \ + qml/qmlvideo/SceneMulti.qml \ + qml/qmlvideo/SceneOverlay.qml \ + qml/qmlvideo/SceneResize.qml \ + qml/qmlvideo/SceneRotate.qml \ + qml/qmlvideo/SceneSelectionPanel.qml \ + qml/qmlvideo/SceneSpin.qml \ + qml/qmlvideo/SeekControl.qml \ + qml/qmlvideo/VideoBasic.qml \ + qml/qmlvideo/VideoDrag.qml \ + qml/qmlvideo/VideoDummy.qml \ + qml/qmlvideo/VideoFillMode.qml \ + qml/qmlvideo/VideoFullScreen.qml \ + qml/qmlvideo/VideoFullScreenInverted.qml \ + qml/qmlvideo/VideoItem.qml \ + qml/qmlvideo/VideoMetadata.qml \ + qml/qmlvideo/VideoMove.qml \ + qml/qmlvideo/VideoOverlay.qml \ + qml/qmlvideo/VideoPlaybackRate.qml \ + qml/qmlvideo/VideoResize.qml \ + qml/qmlvideo/VideoRotate.qml \ + qml/qmlvideo/VideoSeek.qml \ + qml/qmlvideo/VideoSpin.qml \ + qml/qmlvideo/main.qml + +resources.prefix = / + +RESOURCES += resources target.path = $$[QT_INSTALL_EXAMPLES]/multimedia/video/qmlvideo INSTALLS += target diff --git a/examples/multimedia/video/qmlvideo/qmlvideo.qrc b/examples/multimedia/video/qmlvideo/qmlvideo.qrc deleted file mode 100644 index 6418215d0..000000000 --- a/examples/multimedia/video/qmlvideo/qmlvideo.qrc +++ /dev/null @@ -1,51 +0,0 @@ - - - images/leaves.jpg - images/folder.png - images/up.png - qml/qmlvideo/Button.qml - qml/qmlvideo/CameraBasic.qml - qml/qmlvideo/CameraDrag.qml - qml/qmlvideo/CameraDummy.qml - qml/qmlvideo/CameraFullScreen.qml - qml/qmlvideo/CameraFullScreenInverted.qml - qml/qmlvideo/CameraItem.qml - qml/qmlvideo/CameraMove.qml - qml/qmlvideo/CameraOverlay.qml - qml/qmlvideo/CameraResize.qml - qml/qmlvideo/CameraRotate.qml - qml/qmlvideo/CameraSpin.qml - qml/qmlvideo/Content.qml - qml/qmlvideo/ErrorDialog.qml - qml/qmlvideo/FileBrowser.qml - qml/qmlvideo/main.qml - qml/qmlvideo/Scene.qml - qml/qmlvideo/SceneBasic.qml - qml/qmlvideo/SceneDrag.qml - qml/qmlvideo/SceneFullScreen.qml - qml/qmlvideo/SceneFullScreenInverted.qml - qml/qmlvideo/SceneMove.qml - qml/qmlvideo/SceneMulti.qml - qml/qmlvideo/SceneOverlay.qml - qml/qmlvideo/SceneResize.qml - qml/qmlvideo/SceneRotate.qml - qml/qmlvideo/SceneSelectionPanel.qml - qml/qmlvideo/SceneSpin.qml - qml/qmlvideo/SeekControl.qml - qml/qmlvideo/VideoBasic.qml - qml/qmlvideo/VideoDrag.qml - qml/qmlvideo/VideoDummy.qml - qml/qmlvideo/VideoFillMode.qml - qml/qmlvideo/VideoFullScreen.qml - qml/qmlvideo/VideoFullScreenInverted.qml - qml/qmlvideo/VideoItem.qml - qml/qmlvideo/VideoMetadata.qml - qml/qmlvideo/VideoMove.qml - qml/qmlvideo/VideoOverlay.qml - qml/qmlvideo/VideoPlaybackRate.qml - qml/qmlvideo/VideoResize.qml - qml/qmlvideo/VideoRotate.qml - qml/qmlvideo/VideoSeek.qml - qml/qmlvideo/VideoSpin.qml - - diff --git a/examples/multimedia/video/qmlvideofx/CMakeLists.txt b/examples/multimedia/video/qmlvideofx/CMakeLists.txt index c833d82f5..853aa2ca7 100644 --- a/examples/multimedia/video/qmlvideofx/CMakeLists.txt +++ b/examples/multimedia/video/qmlvideofx/CMakeLists.txt @@ -22,22 +22,17 @@ find_package(Qt6 COMPONENTS Multimedia) find_package(Qt6 COMPONENTS Qml) qt_add_executable(qmlvideofx - ../snippets/frequencymonitor/frequencymonitor.cpp ../snippets/frequencymonitor/frequencymonitor.h - ../snippets/frequencymonitor/frequencymonitordeclarative.cpp - ../snippets/performancemonitor/performancemonitor.cpp ../snippets/performancemonitor/performancemonitor.h - ../snippets/performancemonitor/performancemonitordeclarative.cpp ../snippets/performancemonitor/performancemonitordeclarative.h - filereader.cpp filereader.h + frequencymonitor.cpp + frequencymonitordeclarative.cpp + performancemonitor.cpp + performancemonitordeclarative.cpp + filereader.cpp main.cpp - trace.h ) set_target_properties(qmlvideofx PROPERTIES WIN32_EXECUTABLE TRUE MACOSX_BUNDLE TRUE ) -target_include_directories(qmlvideofx PUBLIC - ../snippets/frequencymonitor - ../snippets/performancemonitor -) target_compile_definitions(qmlvideofx PUBLIC FREQUENCYMONITOR_SUPPORT @@ -64,6 +59,8 @@ set(qmlvideofx_resource_files "images/icon_Folder.png" "images/icon_Menu.png" "images/qt-logo.png" + "qml/frequencymonitor/FrequencyItem.qml" + "qml/performancemonitor/PerformanceItem.qml" "qml/qmlvideofx/Button.qml" "qml/qmlvideofx/Content.qml" "qml/qmlvideofx/ContentCamera.qml" @@ -130,30 +127,6 @@ qt6_add_resources(qmlvideofx "qmlvideofx" FILES ${qmlvideofx_resource_files} ) -set(frequencymonitordeclarative_resource_files - "../snippets/frequencymonitor/qml/frequencymonitor/FrequencyItem.qml" -) - -qt6_add_resources(qmlvideofx "frequencymonitordeclarative" - PREFIX - "/" - BASE - "../snippets/frequencymonitor" - FILES - ${frequencymonitordeclarative_resource_files} -) -set(performancemonitordeclarative_resource_files - "../snippets/performancemonitor/qml/performancemonitor/PerformanceItem.qml" -) - -qt6_add_resources(qmlvideofx "performancemonitordeclarative" - PREFIX - "/" - BASE - "../snippets/performancemonitor" - FILES - ${performancemonitordeclarative_resource_files} -) install(TARGETS qmlvideofx RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" diff --git a/examples/multimedia/video/qmlvideofx/frequencymonitor.cpp b/examples/multimedia/video/qmlvideofx/frequencymonitor.cpp new file mode 100644 index 000000000..5f48cd35e --- /dev/null +++ b/examples/multimedia/video/qmlvideofx/frequencymonitor.cpp @@ -0,0 +1,254 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Mobility Components. +** +** $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 "frequencymonitor.h" +#include +#include +#include +#include +#include + +//#define VERBOSE_TRACE + +inline QDebug qtTrace() { return qDebug() << "[frequencymonitor]"; } +#ifdef VERBOSE_TRACE +inline QDebug qtVerboseTrace() { return qtTrace(); } +#else +inline QNoDebug qtVerboseTrace() { return QNoDebug(); } +#endif + +static const int DefaultSamplingInterval = 100; +static const int DefaultTraceInterval = 0; + +class FrequencyMonitorPrivate : public QObject +{ + Q_OBJECT + +public: + FrequencyMonitorPrivate(FrequencyMonitor *parent); + void calculateInstantaneousFrequency(); + +private slots: + void calculateAverageFrequency(); + void stalled(); + +public: + FrequencyMonitor *const q_ptr; + QString m_label; + bool m_active; + qreal m_instantaneousFrequency; + QElapsedTimer m_instantaneousElapsed; + QTimer *m_averageTimer; + QElapsedTimer m_averageElapsed; + int m_count; + qreal m_averageFrequency; + QTimer *m_traceTimer; + QTimer *m_stalledTimer; +}; + +FrequencyMonitorPrivate::FrequencyMonitorPrivate(FrequencyMonitor *parent) +: QObject(parent) +, q_ptr(parent) +, m_active(false) +, m_instantaneousFrequency(0) +, m_averageTimer(new QTimer(this)) +, m_count(0) +, m_averageFrequency(0) +, m_traceTimer(new QTimer(this)) +, m_stalledTimer(new QTimer(this)) +{ + m_instantaneousElapsed.start(); + connect(m_averageTimer, &QTimer::timeout, + this, &FrequencyMonitorPrivate::calculateAverageFrequency); + if (DefaultSamplingInterval) + m_averageTimer->start(DefaultSamplingInterval); + m_averageElapsed.start(); + connect(m_traceTimer, &QTimer::timeout, + q_ptr, &FrequencyMonitor::trace); + if (DefaultTraceInterval) + m_traceTimer->start(DefaultTraceInterval); + m_stalledTimer->setSingleShot(true); + connect(m_stalledTimer, &QTimer::timeout, + this, &FrequencyMonitorPrivate::stalled); +} + +void FrequencyMonitorPrivate::calculateInstantaneousFrequency() +{ + const qint64 ms = m_instantaneousElapsed.restart(); + m_instantaneousFrequency = ms ? qreal(1000) / ms : 0; + m_stalledTimer->start(3 * ms); + if (m_instantaneousFrequency) + q_ptr->setActive(true); + emit q_ptr->instantaneousFrequencyChanged(m_instantaneousFrequency); + emit q_ptr->frequencyChanged(); +} + +void FrequencyMonitorPrivate::calculateAverageFrequency() +{ + const qint64 ms = m_averageElapsed.restart(); + m_averageFrequency = qreal(m_count * 1000) / ms; + emit q_ptr->averageFrequencyChanged(m_averageFrequency); + emit q_ptr->frequencyChanged(); + m_count = 0; +} + +void FrequencyMonitorPrivate::stalled() +{ + if (m_instantaneousFrequency) { + m_instantaneousFrequency = 0; + emit q_ptr->instantaneousFrequencyChanged(m_instantaneousFrequency); + emit q_ptr->frequencyChanged(); + } +} + +FrequencyMonitor::FrequencyMonitor(QObject *parent) +: QObject(parent) +{ + d_ptr = new FrequencyMonitorPrivate(this); +} + +FrequencyMonitor::~FrequencyMonitor() = default; + +QString FrequencyMonitor::label() const +{ + return d_func()->m_label; +} + +bool FrequencyMonitor::active() const +{ + return d_func()->m_active; +} + +int FrequencyMonitor::samplingInterval() const +{ + return d_ptr->m_averageTimer->isActive() ? d_ptr->m_averageTimer->interval() : 0; +} + +int FrequencyMonitor::traceInterval() const +{ + return d_ptr->m_traceTimer->isActive() ? d_ptr->m_traceTimer->interval() : 0; +} + +qreal FrequencyMonitor::instantaneousFrequency() const +{ + return d_func()->m_instantaneousFrequency; +} + +qreal FrequencyMonitor::averageFrequency() const +{ + return d_func()->m_averageFrequency; +} + +void FrequencyMonitor::notify() +{ + Q_D(FrequencyMonitor); + ++(d->m_count); + d->calculateInstantaneousFrequency(); +} + +void FrequencyMonitor::trace() +{ + Q_D(FrequencyMonitor); + const QString value = QString::fromLatin1("instant %1 average %2") + .arg(d->m_instantaneousFrequency, 0, 'f', 2) + .arg(d->m_averageFrequency, 0, 'f', 2); + if (d->m_label.isEmpty()) + qtTrace() << "FrequencyMonitor::trace" << value; + else + qtTrace() << "FrequencyMonitor::trace" << "label" << d->m_label << value; +} + +void FrequencyMonitor::setLabel(const QString &value) +{ + Q_D(FrequencyMonitor); + if (d->m_label != value) { + d->m_label = value; + emit labelChanged(d->m_label); + } +} + +void FrequencyMonitor::setActive(bool value) +{ + Q_D(FrequencyMonitor); + if (d->m_active != value) { + d->m_active = value; + emit activeChanged(d->m_active); + } +} + +void FrequencyMonitor::setSamplingInterval(int value) +{ + Q_D(FrequencyMonitor); + if (samplingInterval() != value) { + if (value) { + d->m_averageTimer->setInterval(value); + d->m_averageTimer->start(); + } else { + d->m_averageTimer->stop(); + } + emit samplingIntervalChanged(value); + } +} + +void FrequencyMonitor::setTraceInterval(int value) +{ + Q_D(FrequencyMonitor); + if (traceInterval() != value) { + if (value) { + d->m_traceTimer->setInterval(value); + d->m_traceTimer->start(); + } else { + d->m_traceTimer->stop(); + } + emit traceIntervalChanged(value); + } +} + +#include "frequencymonitor.moc" diff --git a/examples/multimedia/video/qmlvideofx/frequencymonitor.h b/examples/multimedia/video/qmlvideofx/frequencymonitor.h new file mode 100644 index 000000000..efeb78589 --- /dev/null +++ b/examples/multimedia/video/qmlvideofx/frequencymonitor.h @@ -0,0 +1,111 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Mobility Components. +** +** $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 FREQUENCYMONITOR_H +#define FREQUENCYMONITOR_H + +#include +#include + +class FrequencyMonitorPrivate; + +/** + * Class for measuring frequency of events + * + * Occurrence of the event is notified by the client via the notify() slot. + * On a regular interval, both an instantaneous and a rolling average + * event frequency are calculated. + */ +class FrequencyMonitor : public QObject +{ + Q_OBJECT + Q_DECLARE_PRIVATE(FrequencyMonitor) + Q_PROPERTY(QString label READ label WRITE setLabel NOTIFY labelChanged) + Q_PROPERTY(bool active READ active WRITE setActive NOTIFY activeChanged) + Q_PROPERTY(int samplingInterval READ samplingInterval WRITE setSamplingInterval NOTIFY samplingIntervalChanged) + Q_PROPERTY(int traceInterval READ traceInterval WRITE setTraceInterval NOTIFY traceIntervalChanged) + Q_PROPERTY(qreal instantaneousFrequency READ instantaneousFrequency NOTIFY instantaneousFrequencyChanged) + Q_PROPERTY(qreal averageFrequency READ averageFrequency NOTIFY averageFrequencyChanged) + +public: + FrequencyMonitor(QObject *parent = 0); + ~FrequencyMonitor(); + + static void qmlRegisterType(); + + QString label() const; + bool active() const; + int samplingInterval() const; + int traceInterval() const; + qreal instantaneousFrequency() const; + qreal averageFrequency() const; + +signals: + void labelChanged(const QString &value); + void activeChanged(bool); + void samplingIntervalChanged(int value); + void traceIntervalChanged(int value); + void frequencyChanged(); + void instantaneousFrequencyChanged(qreal value); + void averageFrequencyChanged(qreal value); + +public slots: + Q_INVOKABLE void notify(); + Q_INVOKABLE void trace(); + void setActive(bool value); + void setLabel(const QString &value); + void setSamplingInterval(int value); + void setTraceInterval(int value); + +private: + FrequencyMonitorPrivate *d_ptr; +}; + +#endif // FREQUENCYMONITOR_H diff --git a/examples/multimedia/video/qmlvideofx/frequencymonitordeclarative.cpp b/examples/multimedia/video/qmlvideofx/frequencymonitordeclarative.cpp new file mode 100644 index 000000000..0994ae213 --- /dev/null +++ b/examples/multimedia/video/qmlvideofx/frequencymonitordeclarative.cpp @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Mobility Components. +** +** $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 "frequencymonitor.h" +#include + +void FrequencyMonitor::qmlRegisterType() +{ + ::qmlRegisterType("FrequencyMonitor", 1, 0, "FrequencyMonitor"); +} diff --git a/examples/multimedia/video/qmlvideofx/performancemonitor.cpp b/examples/multimedia/video/qmlvideofx/performancemonitor.cpp new file mode 100644 index 000000000..204eabc5a --- /dev/null +++ b/examples/multimedia/video/qmlvideofx/performancemonitor.cpp @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Mobility Components. +** +** $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 "performancemonitor.h" + +namespace PerformanceMonitor { + +bool State::parseArgument(const QByteArray &arg) +{ + bool result = false; + if (arg == "-log-perf") { + logging = true; + valid = true; + result = true; + } else if (arg == "-no-log-perf") { + logging = false; + valid = true; + result = true; + } else if (arg == "-show-perf") { + visible = true; + valid = true; + result = true; + } else if (arg == "-hide-perf") { + visible = false; + valid = true; + result = true; + } + return result; +} + +} // namespace PerformanceMonitor diff --git a/examples/multimedia/video/qmlvideofx/performancemonitor.h b/examples/multimedia/video/qmlvideofx/performancemonitor.h new file mode 100644 index 000000000..97b76caf3 --- /dev/null +++ b/examples/multimedia/video/qmlvideofx/performancemonitor.h @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Mobility Components. +** +** $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 PERFORMANCEMONITOR_H +#define PERFORMANCEMONITOR_H + +#include + +namespace PerformanceMonitor { + +struct State +{ + State() : valid(true), logging(false), visible(true) { } + State(bool l, bool v) : valid(true), logging(l), visible(v) { } + bool operator==(const State &other) const + { return logging == other.logging && visible == other.visible; } + bool operator!=(const State &other) const + { return logging != other.logging || visible != other.visible; } + + bool parseArgument(const QByteArray &arg); + + bool valid; + bool logging; + bool visible; +}; + +} // namespace PerformanceMonitor + +#endif // PERFORMANCEMONITOR_H + diff --git a/examples/multimedia/video/qmlvideofx/performancemonitordeclarative.cpp b/examples/multimedia/video/qmlvideofx/performancemonitordeclarative.cpp new file mode 100644 index 000000000..0783fdbd9 --- /dev/null +++ b/examples/multimedia/video/qmlvideofx/performancemonitordeclarative.cpp @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Mobility Components. +** +** $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 "frequencymonitor.h" +#include "performancemonitor.h" + +namespace PerformanceMonitor { + + void qmlRegisterTypes() + { + FrequencyMonitor::qmlRegisterType(); + } +} diff --git a/examples/multimedia/video/qmlvideofx/performancemonitordeclarative.h b/examples/multimedia/video/qmlvideofx/performancemonitordeclarative.h new file mode 100644 index 000000000..ca70657ce --- /dev/null +++ b/examples/multimedia/video/qmlvideofx/performancemonitordeclarative.h @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Mobility Components. +** +** $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 PERFORMANCEMONITORDECLARATIVE_H +#define PERFORMANCEMONITORDECLARATIVE_H + +#include "performancemonitor.h" + +namespace PerformanceMonitor { + void qmlRegisterTypes(); +} + +#endif // PERFORMANCEMONITORDECLARATIVE_H diff --git a/examples/multimedia/video/qmlvideofx/qml/frequencymonitor/FrequencyItem.qml b/examples/multimedia/video/qmlvideofx/qml/frequencymonitor/FrequencyItem.qml new file mode 100644 index 000000000..ec1bab299 --- /dev/null +++ b/examples/multimedia/video/qmlvideofx/qml/frequencymonitor/FrequencyItem.qml @@ -0,0 +1,114 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Mobility Components. +** +** $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 +import FrequencyMonitor 1.0 + +Rectangle { + id: root + property bool logging: true + property bool displayed: true + property bool enabled: logging || displayed + property alias active: monitor.active + property int samplingInterval: 500 + property color textColor: "yellow" + property int textSize: 20 + property alias label: monitor.label + + border.width: 1 + border.color: "yellow" + width: 5.5 * root.textSize + height: 3.0 * root.textSize + color: "black" + opacity: 0.5 + radius: 10 + visible: displayed && active + + // This should ensure that the monitor is on top of all other content + z: 999 + + function notify() { + monitor.notify() + } + + FrequencyMonitor { + id: monitor + samplingInterval: root.enabled ? root.samplingInterval : 0 + onAverageFrequencyChanged: { + if (root.logging) trace() + averageFrequencyText.text = monitor.averageFrequency.toFixed(2) + } + } + + Text { + id: labelText + anchors { + left: parent.left + top: parent.top + margins: 10 + } + color: root.textColor + font.pixelSize: 0.6 * root.textSize + text: root.label + width: root.width - 2*anchors.margins + elide: Text.ElideRight + } + + Text { + id: averageFrequencyText + anchors { + right: parent.right + bottom: parent.bottom + margins: 10 + } + color: root.textColor + font.pixelSize: root.textSize + } +} diff --git a/examples/multimedia/video/qmlvideofx/qml/performancemonitor/PerformanceItem.qml b/examples/multimedia/video/qmlvideofx/qml/performancemonitor/PerformanceItem.qml new file mode 100644 index 000000000..5621450cb --- /dev/null +++ b/examples/multimedia/video/qmlvideofx/qml/performancemonitor/PerformanceItem.qml @@ -0,0 +1,150 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Mobility Components. +** +** $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 + +Rectangle { + id: root + property bool logging: true + property bool displayed: true + property bool videoActive + property int margins: 5 + property bool enabled: true + + color: "transparent" + + // This should ensure that the monitor is on top of all other content + z: 999 + + Column { + id: column + anchors { + fill: root + margins: 10 + } + spacing: 10 + } + + QtObject { + id: d + property Item qmlFrameRateItem: null + property Item videoFrameRateItem: null + } + + Connections { + id: videoFrameRateActiveConnections + ignoreUnknownSignals: true + function onActiveChanged() { root.videoActive = videoFrameRateActiveConnections.target.active } + } + + states: [ + State { + name: "hidden" + PropertyChanges { + target: root + opacity: 0 + } + } + ] + + transitions: [ + Transition { + from: "*" + to: "*" + NumberAnimation { + properties: "opacity" + easing.type: Easing.OutQuart + duration: 500 + } + } + ] + + state: enabled ? "baseState" : "hidden" + + function createQmlFrameRateItem() { + var component = Qt.createComponent("../frequencymonitor/FrequencyItem.qml") + if (component.status == Component.Ready) + d.qmlFrameRateItem = component.createObject(column, { label: "QML frame rate", + displayed: root.displayed, + logging: root.logging + }) + } + + function createVideoFrameRateItem() { + var component = Qt.createComponent("../frequencymonitor/FrequencyItem.qml") + if (component.status == Component.Ready) + d.videoFrameRateItem = component.createObject(column, { label: "Video frame rate", + displayed: root.displayed, + logging: root.logging + }) + videoFrameRateActiveConnections.target = d.videoFrameRateItem + } + + + function init() { + createQmlFrameRateItem() + createVideoFrameRateItem() + } + + function videoFramePainted() { + if (d.videoFrameRateItem) + d.videoFrameRateItem.notify() + } + + function qmlFramePainted() { + if (d.qmlFrameRateItem) + d.qmlFrameRateItem.notify() + } + + onVideoActiveChanged: { + if (d.videoFrameRateItem) + d.videoFrameRateItem.active = root.videoActive + } +} diff --git a/examples/multimedia/video/qmlvideofx/qmlvideofx.pro b/examples/multimedia/video/qmlvideofx/qmlvideofx.pro index 07047aec8..fd43fb5b5 100644 --- a/examples/multimedia/video/qmlvideofx/qmlvideofx.pro +++ b/examples/multimedia/video/qmlvideofx/qmlvideofx.pro @@ -7,12 +7,99 @@ android: qtHaveModule(androidextras) { DEFINES += REQUEST_PERMISSIONS_ON_ANDROID } -SOURCES += filereader.cpp main.cpp -HEADERS += filereader.h trace.h +DEFINES += \ + FREQUENCYMONITOR_SUPPORT \ + PERFORMANCEMONITOR_SUPPORT -RESOURCES += qmlvideofx.qrc +SOURCES += \ + main.cpp \ + filereader.cpp \ + frequencymonitor.cpp \ + frequencymonitordeclarative.cpp \ + performancemonitor.cpp \ + performancemonitordeclarative.cpp -include($$PWD/../snippets/performancemonitor/performancemonitordeclarative.pri) +HEADERS += \ + filereader.h \ + frequencymonitor.h \ + performancemonitor.h \ + performancemonitordeclarative.h \ + trace.h + +resources.files = \ + images/Dropdown_arrows.png \ + images/Slider_bar.png \ + images/Slider_handle.png \ + images/Triangle_Top.png \ + images/Triangle_bottom.png \ + images/icon_BackArrow.png \ + images/icon_Folder.png \ + images/icon_Menu.png \ + images/qt-logo.png \ + qml/frequencymonitor/FrequencyItem.qml \ + qml/performancemonitor/PerformanceItem.qml \ + qml/qmlvideofx/Button.qml \ + qml/qmlvideofx/Content.qml \ + qml/qmlvideofx/ContentCamera.qml \ + qml/qmlvideofx/ContentImage.qml \ + qml/qmlvideofx/ContentVideo.qml \ + qml/qmlvideofx/Curtain.qml \ + qml/qmlvideofx/Divider.qml \ + qml/qmlvideofx/Effect.qml \ + qml/qmlvideofx/EffectBillboard.qml \ + qml/qmlvideofx/EffectBlackAndWhite.qml \ + qml/qmlvideofx/EffectEmboss.qml \ + qml/qmlvideofx/EffectGaussianBlur.qml \ + qml/qmlvideofx/EffectGlow.qml \ + qml/qmlvideofx/EffectIsolate.qml \ + qml/qmlvideofx/EffectMagnify.qml \ + qml/qmlvideofx/EffectPageCurl.qml \ + qml/qmlvideofx/EffectPassThrough.qml \ + qml/qmlvideofx/EffectPixelate.qml \ + qml/qmlvideofx/EffectPosterize.qml \ + qml/qmlvideofx/EffectRipple.qml \ + qml/qmlvideofx/EffectSelectionList.qml \ + qml/qmlvideofx/EffectSepia.qml \ + qml/qmlvideofx/EffectSharpen.qml \ + qml/qmlvideofx/EffectShockwave.qml \ + qml/qmlvideofx/EffectSobelEdgeDetection1.qml \ + qml/qmlvideofx/EffectTiltShift.qml \ + qml/qmlvideofx/EffectToon.qml \ + qml/qmlvideofx/EffectVignette.qml \ + qml/qmlvideofx/EffectWarhol.qml \ + qml/qmlvideofx/EffectWobble.qml \ + qml/qmlvideofx/FileBrowser.qml \ + qml/qmlvideofx/FileOpen.qml \ + qml/qmlvideofx/HintedMouseArea.qml \ + qml/qmlvideofx/Main.qml \ + qml/qmlvideofx/ParameterPanel.qml \ + qml/qmlvideofx/Slider.qml \ + shaders/billboard.fsh \ + shaders/blackandwhite.fsh \ + shaders/emboss.fsh \ + shaders/gaussianblur_h.fsh \ + shaders/gaussianblur_v.fsh \ + shaders/glow.fsh \ + shaders/isolate.fsh \ + shaders/magnify.fsh \ + shaders/pagecurl.fsh \ + shaders/pixelate.fsh \ + shaders/posterize.fsh \ + shaders/ripple.fsh \ + shaders/selectionpanel.fsh \ + shaders/sepia.fsh \ + shaders/sharpen.fsh \ + shaders/shockwave.fsh \ + shaders/sobeledgedetection1.fsh \ + shaders/tiltshift.fsh \ + shaders/toon.fsh \ + shaders/vignette.fsh \ + shaders/warhol.fsh \ + shaders/wobble.fsh + +resources.prefix = / + +RESOURCES += resources target.path = $$[QT_INSTALL_EXAMPLES]/multimedia/video/qmlvideofx INSTALLS += target diff --git a/examples/multimedia/video/qmlvideofx/qmlvideofx.qrc b/examples/multimedia/video/qmlvideofx/qmlvideofx.qrc deleted file mode 100644 index f3ad27704..000000000 --- a/examples/multimedia/video/qmlvideofx/qmlvideofx.qrc +++ /dev/null @@ -1,71 +0,0 @@ - - - images/qt-logo.png - qml/qmlvideofx/Button.qml - qml/qmlvideofx/Content.qml - qml/qmlvideofx/ContentCamera.qml - qml/qmlvideofx/ContentImage.qml - qml/qmlvideofx/ContentVideo.qml - qml/qmlvideofx/Divider.qml - qml/qmlvideofx/Effect.qml - qml/qmlvideofx/EffectBillboard.qml - qml/qmlvideofx/EffectBlackAndWhite.qml - qml/qmlvideofx/EffectEmboss.qml - qml/qmlvideofx/EffectGaussianBlur.qml - qml/qmlvideofx/EffectGlow.qml - qml/qmlvideofx/EffectIsolate.qml - qml/qmlvideofx/EffectMagnify.qml - qml/qmlvideofx/EffectPageCurl.qml - qml/qmlvideofx/EffectPassThrough.qml - qml/qmlvideofx/EffectPixelate.qml - qml/qmlvideofx/EffectPosterize.qml - qml/qmlvideofx/EffectRipple.qml - qml/qmlvideofx/EffectSepia.qml - qml/qmlvideofx/EffectSharpen.qml - qml/qmlvideofx/EffectShockwave.qml - qml/qmlvideofx/EffectSobelEdgeDetection1.qml - qml/qmlvideofx/EffectTiltShift.qml - qml/qmlvideofx/EffectToon.qml - qml/qmlvideofx/EffectVignette.qml - qml/qmlvideofx/EffectWarhol.qml - qml/qmlvideofx/EffectWobble.qml - qml/qmlvideofx/FileBrowser.qml - qml/qmlvideofx/FileOpen.qml - qml/qmlvideofx/HintedMouseArea.qml - qml/qmlvideofx/ParameterPanel.qml - qml/qmlvideofx/Slider.qml - shaders/billboard.fsh - shaders/blackandwhite.fsh - shaders/emboss.fsh - shaders/gaussianblur_h.fsh - shaders/gaussianblur_v.fsh - shaders/glow.fsh - shaders/isolate.fsh - shaders/magnify.fsh - shaders/pagecurl.fsh - shaders/pixelate.fsh - shaders/posterize.fsh - shaders/ripple.fsh - shaders/selectionpanel.fsh - shaders/sepia.fsh - shaders/sharpen.fsh - shaders/shockwave.fsh - shaders/sobeledgedetection1.fsh - shaders/tiltshift.fsh - shaders/toon.fsh - shaders/vignette.fsh - shaders/warhol.fsh - shaders/wobble.fsh - images/Slider_handle.png - images/Slider_bar.png - qml/qmlvideofx/Curtain.qml - images/Triangle_bottom.png - images/Triangle_Top.png - images/Dropdown_arrows.png - images/icon_Folder.png - images/icon_BackArrow.png - qml/qmlvideofx/Main.qml - images/icon_Menu.png - qml/qmlvideofx/EffectSelectionList.qml - - diff --git a/examples/multimedia/video/snippets/frequencymonitor/frequencymonitor.cpp b/examples/multimedia/video/snippets/frequencymonitor/frequencymonitor.cpp deleted file mode 100644 index 5f48cd35e..000000000 --- a/examples/multimedia/video/snippets/frequencymonitor/frequencymonitor.cpp +++ /dev/null @@ -1,254 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Mobility Components. -** -** $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 "frequencymonitor.h" -#include -#include -#include -#include -#include - -//#define VERBOSE_TRACE - -inline QDebug qtTrace() { return qDebug() << "[frequencymonitor]"; } -#ifdef VERBOSE_TRACE -inline QDebug qtVerboseTrace() { return qtTrace(); } -#else -inline QNoDebug qtVerboseTrace() { return QNoDebug(); } -#endif - -static const int DefaultSamplingInterval = 100; -static const int DefaultTraceInterval = 0; - -class FrequencyMonitorPrivate : public QObject -{ - Q_OBJECT - -public: - FrequencyMonitorPrivate(FrequencyMonitor *parent); - void calculateInstantaneousFrequency(); - -private slots: - void calculateAverageFrequency(); - void stalled(); - -public: - FrequencyMonitor *const q_ptr; - QString m_label; - bool m_active; - qreal m_instantaneousFrequency; - QElapsedTimer m_instantaneousElapsed; - QTimer *m_averageTimer; - QElapsedTimer m_averageElapsed; - int m_count; - qreal m_averageFrequency; - QTimer *m_traceTimer; - QTimer *m_stalledTimer; -}; - -FrequencyMonitorPrivate::FrequencyMonitorPrivate(FrequencyMonitor *parent) -: QObject(parent) -, q_ptr(parent) -, m_active(false) -, m_instantaneousFrequency(0) -, m_averageTimer(new QTimer(this)) -, m_count(0) -, m_averageFrequency(0) -, m_traceTimer(new QTimer(this)) -, m_stalledTimer(new QTimer(this)) -{ - m_instantaneousElapsed.start(); - connect(m_averageTimer, &QTimer::timeout, - this, &FrequencyMonitorPrivate::calculateAverageFrequency); - if (DefaultSamplingInterval) - m_averageTimer->start(DefaultSamplingInterval); - m_averageElapsed.start(); - connect(m_traceTimer, &QTimer::timeout, - q_ptr, &FrequencyMonitor::trace); - if (DefaultTraceInterval) - m_traceTimer->start(DefaultTraceInterval); - m_stalledTimer->setSingleShot(true); - connect(m_stalledTimer, &QTimer::timeout, - this, &FrequencyMonitorPrivate::stalled); -} - -void FrequencyMonitorPrivate::calculateInstantaneousFrequency() -{ - const qint64 ms = m_instantaneousElapsed.restart(); - m_instantaneousFrequency = ms ? qreal(1000) / ms : 0; - m_stalledTimer->start(3 * ms); - if (m_instantaneousFrequency) - q_ptr->setActive(true); - emit q_ptr->instantaneousFrequencyChanged(m_instantaneousFrequency); - emit q_ptr->frequencyChanged(); -} - -void FrequencyMonitorPrivate::calculateAverageFrequency() -{ - const qint64 ms = m_averageElapsed.restart(); - m_averageFrequency = qreal(m_count * 1000) / ms; - emit q_ptr->averageFrequencyChanged(m_averageFrequency); - emit q_ptr->frequencyChanged(); - m_count = 0; -} - -void FrequencyMonitorPrivate::stalled() -{ - if (m_instantaneousFrequency) { - m_instantaneousFrequency = 0; - emit q_ptr->instantaneousFrequencyChanged(m_instantaneousFrequency); - emit q_ptr->frequencyChanged(); - } -} - -FrequencyMonitor::FrequencyMonitor(QObject *parent) -: QObject(parent) -{ - d_ptr = new FrequencyMonitorPrivate(this); -} - -FrequencyMonitor::~FrequencyMonitor() = default; - -QString FrequencyMonitor::label() const -{ - return d_func()->m_label; -} - -bool FrequencyMonitor::active() const -{ - return d_func()->m_active; -} - -int FrequencyMonitor::samplingInterval() const -{ - return d_ptr->m_averageTimer->isActive() ? d_ptr->m_averageTimer->interval() : 0; -} - -int FrequencyMonitor::traceInterval() const -{ - return d_ptr->m_traceTimer->isActive() ? d_ptr->m_traceTimer->interval() : 0; -} - -qreal FrequencyMonitor::instantaneousFrequency() const -{ - return d_func()->m_instantaneousFrequency; -} - -qreal FrequencyMonitor::averageFrequency() const -{ - return d_func()->m_averageFrequency; -} - -void FrequencyMonitor::notify() -{ - Q_D(FrequencyMonitor); - ++(d->m_count); - d->calculateInstantaneousFrequency(); -} - -void FrequencyMonitor::trace() -{ - Q_D(FrequencyMonitor); - const QString value = QString::fromLatin1("instant %1 average %2") - .arg(d->m_instantaneousFrequency, 0, 'f', 2) - .arg(d->m_averageFrequency, 0, 'f', 2); - if (d->m_label.isEmpty()) - qtTrace() << "FrequencyMonitor::trace" << value; - else - qtTrace() << "FrequencyMonitor::trace" << "label" << d->m_label << value; -} - -void FrequencyMonitor::setLabel(const QString &value) -{ - Q_D(FrequencyMonitor); - if (d->m_label != value) { - d->m_label = value; - emit labelChanged(d->m_label); - } -} - -void FrequencyMonitor::setActive(bool value) -{ - Q_D(FrequencyMonitor); - if (d->m_active != value) { - d->m_active = value; - emit activeChanged(d->m_active); - } -} - -void FrequencyMonitor::setSamplingInterval(int value) -{ - Q_D(FrequencyMonitor); - if (samplingInterval() != value) { - if (value) { - d->m_averageTimer->setInterval(value); - d->m_averageTimer->start(); - } else { - d->m_averageTimer->stop(); - } - emit samplingIntervalChanged(value); - } -} - -void FrequencyMonitor::setTraceInterval(int value) -{ - Q_D(FrequencyMonitor); - if (traceInterval() != value) { - if (value) { - d->m_traceTimer->setInterval(value); - d->m_traceTimer->start(); - } else { - d->m_traceTimer->stop(); - } - emit traceIntervalChanged(value); - } -} - -#include "frequencymonitor.moc" diff --git a/examples/multimedia/video/snippets/frequencymonitor/frequencymonitor.h b/examples/multimedia/video/snippets/frequencymonitor/frequencymonitor.h deleted file mode 100644 index efeb78589..000000000 --- a/examples/multimedia/video/snippets/frequencymonitor/frequencymonitor.h +++ /dev/null @@ -1,111 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Mobility Components. -** -** $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 FREQUENCYMONITOR_H -#define FREQUENCYMONITOR_H - -#include -#include - -class FrequencyMonitorPrivate; - -/** - * Class for measuring frequency of events - * - * Occurrence of the event is notified by the client via the notify() slot. - * On a regular interval, both an instantaneous and a rolling average - * event frequency are calculated. - */ -class FrequencyMonitor : public QObject -{ - Q_OBJECT - Q_DECLARE_PRIVATE(FrequencyMonitor) - Q_PROPERTY(QString label READ label WRITE setLabel NOTIFY labelChanged) - Q_PROPERTY(bool active READ active WRITE setActive NOTIFY activeChanged) - Q_PROPERTY(int samplingInterval READ samplingInterval WRITE setSamplingInterval NOTIFY samplingIntervalChanged) - Q_PROPERTY(int traceInterval READ traceInterval WRITE setTraceInterval NOTIFY traceIntervalChanged) - Q_PROPERTY(qreal instantaneousFrequency READ instantaneousFrequency NOTIFY instantaneousFrequencyChanged) - Q_PROPERTY(qreal averageFrequency READ averageFrequency NOTIFY averageFrequencyChanged) - -public: - FrequencyMonitor(QObject *parent = 0); - ~FrequencyMonitor(); - - static void qmlRegisterType(); - - QString label() const; - bool active() const; - int samplingInterval() const; - int traceInterval() const; - qreal instantaneousFrequency() const; - qreal averageFrequency() const; - -signals: - void labelChanged(const QString &value); - void activeChanged(bool); - void samplingIntervalChanged(int value); - void traceIntervalChanged(int value); - void frequencyChanged(); - void instantaneousFrequencyChanged(qreal value); - void averageFrequencyChanged(qreal value); - -public slots: - Q_INVOKABLE void notify(); - Q_INVOKABLE void trace(); - void setActive(bool value); - void setLabel(const QString &value); - void setSamplingInterval(int value); - void setTraceInterval(int value); - -private: - FrequencyMonitorPrivate *d_ptr; -}; - -#endif // FREQUENCYMONITOR_H diff --git a/examples/multimedia/video/snippets/frequencymonitor/frequencymonitor.pri b/examples/multimedia/video/snippets/frequencymonitor/frequencymonitor.pri deleted file mode 100644 index 3ac8a08c4..000000000 --- a/examples/multimedia/video/snippets/frequencymonitor/frequencymonitor.pri +++ /dev/null @@ -1,5 +0,0 @@ -HEADERS += $$PWD/frequencymonitor.h -SOURCES += $$PWD/frequencymonitor.cpp -INCLUDEPATH += $$PWD -DEFINES += FREQUENCYMONITOR_SUPPORT - diff --git a/examples/multimedia/video/snippets/frequencymonitor/frequencymonitordeclarative.cpp b/examples/multimedia/video/snippets/frequencymonitor/frequencymonitordeclarative.cpp deleted file mode 100644 index 0994ae213..000000000 --- a/examples/multimedia/video/snippets/frequencymonitor/frequencymonitordeclarative.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Mobility Components. -** -** $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 "frequencymonitor.h" -#include - -void FrequencyMonitor::qmlRegisterType() -{ - ::qmlRegisterType("FrequencyMonitor", 1, 0, "FrequencyMonitor"); -} diff --git a/examples/multimedia/video/snippets/frequencymonitor/frequencymonitordeclarative.pri b/examples/multimedia/video/snippets/frequencymonitor/frequencymonitordeclarative.pri deleted file mode 100644 index 071b7286a..000000000 --- a/examples/multimedia/video/snippets/frequencymonitor/frequencymonitordeclarative.pri +++ /dev/null @@ -1,5 +0,0 @@ -include($$PWD/frequencymonitor.pri) -QT += qml - -SOURCES += $$PWD/frequencymonitordeclarative.cpp -RESOURCES += $$PWD/frequencymonitordeclarative.qrc diff --git a/examples/multimedia/video/snippets/frequencymonitor/frequencymonitordeclarative.qrc b/examples/multimedia/video/snippets/frequencymonitor/frequencymonitordeclarative.qrc deleted file mode 100644 index 48e60cf1e..000000000 --- a/examples/multimedia/video/snippets/frequencymonitor/frequencymonitordeclarative.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - qml/frequencymonitor/FrequencyItem.qml - - diff --git a/examples/multimedia/video/snippets/frequencymonitor/qml/frequencymonitor/FrequencyItem.qml b/examples/multimedia/video/snippets/frequencymonitor/qml/frequencymonitor/FrequencyItem.qml deleted file mode 100644 index ec1bab299..000000000 --- a/examples/multimedia/video/snippets/frequencymonitor/qml/frequencymonitor/FrequencyItem.qml +++ /dev/null @@ -1,114 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Mobility Components. -** -** $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 -import FrequencyMonitor 1.0 - -Rectangle { - id: root - property bool logging: true - property bool displayed: true - property bool enabled: logging || displayed - property alias active: monitor.active - property int samplingInterval: 500 - property color textColor: "yellow" - property int textSize: 20 - property alias label: monitor.label - - border.width: 1 - border.color: "yellow" - width: 5.5 * root.textSize - height: 3.0 * root.textSize - color: "black" - opacity: 0.5 - radius: 10 - visible: displayed && active - - // This should ensure that the monitor is on top of all other content - z: 999 - - function notify() { - monitor.notify() - } - - FrequencyMonitor { - id: monitor - samplingInterval: root.enabled ? root.samplingInterval : 0 - onAverageFrequencyChanged: { - if (root.logging) trace() - averageFrequencyText.text = monitor.averageFrequency.toFixed(2) - } - } - - Text { - id: labelText - anchors { - left: parent.left - top: parent.top - margins: 10 - } - color: root.textColor - font.pixelSize: 0.6 * root.textSize - text: root.label - width: root.width - 2*anchors.margins - elide: Text.ElideRight - } - - Text { - id: averageFrequencyText - anchors { - right: parent.right - bottom: parent.bottom - margins: 10 - } - color: root.textColor - font.pixelSize: root.textSize - } -} diff --git a/examples/multimedia/video/snippets/performancemonitor/performancemonitor.cpp b/examples/multimedia/video/snippets/performancemonitor/performancemonitor.cpp deleted file mode 100644 index 204eabc5a..000000000 --- a/examples/multimedia/video/snippets/performancemonitor/performancemonitor.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Mobility Components. -** -** $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 "performancemonitor.h" - -namespace PerformanceMonitor { - -bool State::parseArgument(const QByteArray &arg) -{ - bool result = false; - if (arg == "-log-perf") { - logging = true; - valid = true; - result = true; - } else if (arg == "-no-log-perf") { - logging = false; - valid = true; - result = true; - } else if (arg == "-show-perf") { - visible = true; - valid = true; - result = true; - } else if (arg == "-hide-perf") { - visible = false; - valid = true; - result = true; - } - return result; -} - -} // namespace PerformanceMonitor diff --git a/examples/multimedia/video/snippets/performancemonitor/performancemonitor.h b/examples/multimedia/video/snippets/performancemonitor/performancemonitor.h deleted file mode 100644 index 97b76caf3..000000000 --- a/examples/multimedia/video/snippets/performancemonitor/performancemonitor.h +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Mobility Components. -** -** $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 PERFORMANCEMONITOR_H -#define PERFORMANCEMONITOR_H - -#include - -namespace PerformanceMonitor { - -struct State -{ - State() : valid(true), logging(false), visible(true) { } - State(bool l, bool v) : valid(true), logging(l), visible(v) { } - bool operator==(const State &other) const - { return logging == other.logging && visible == other.visible; } - bool operator!=(const State &other) const - { return logging != other.logging || visible != other.visible; } - - bool parseArgument(const QByteArray &arg); - - bool valid; - bool logging; - bool visible; -}; - -} // namespace PerformanceMonitor - -#endif // PERFORMANCEMONITOR_H - diff --git a/examples/multimedia/video/snippets/performancemonitor/performancemonitor.pri b/examples/multimedia/video/snippets/performancemonitor/performancemonitor.pri deleted file mode 100644 index 2df3cfb13..000000000 --- a/examples/multimedia/video/snippets/performancemonitor/performancemonitor.pri +++ /dev/null @@ -1,5 +0,0 @@ -INCLUDEPATH += $$PWD -HEADERS += $$PWD/performancemonitor.h -SOURCES += $$PWD/performancemonitor.cpp -DEFINES += PERFORMANCEMONITOR_SUPPORT - diff --git a/examples/multimedia/video/snippets/performancemonitor/performancemonitordeclarative.cpp b/examples/multimedia/video/snippets/performancemonitor/performancemonitordeclarative.cpp deleted file mode 100644 index 0783fdbd9..000000000 --- a/examples/multimedia/video/snippets/performancemonitor/performancemonitordeclarative.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Mobility Components. -** -** $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 "frequencymonitor.h" -#include "performancemonitor.h" - -namespace PerformanceMonitor { - - void qmlRegisterTypes() - { - FrequencyMonitor::qmlRegisterType(); - } -} diff --git a/examples/multimedia/video/snippets/performancemonitor/performancemonitordeclarative.h b/examples/multimedia/video/snippets/performancemonitor/performancemonitordeclarative.h deleted file mode 100644 index ca70657ce..000000000 --- a/examples/multimedia/video/snippets/performancemonitor/performancemonitordeclarative.h +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Mobility Components. -** -** $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 PERFORMANCEMONITORDECLARATIVE_H -#define PERFORMANCEMONITORDECLARATIVE_H - -#include "performancemonitor.h" - -namespace PerformanceMonitor { - void qmlRegisterTypes(); -} - -#endif // PERFORMANCEMONITORDECLARATIVE_H diff --git a/examples/multimedia/video/snippets/performancemonitor/performancemonitordeclarative.pri b/examples/multimedia/video/snippets/performancemonitor/performancemonitordeclarative.pri deleted file mode 100644 index 9a18e35e5..000000000 --- a/examples/multimedia/video/snippets/performancemonitor/performancemonitordeclarative.pri +++ /dev/null @@ -1,6 +0,0 @@ -include($$PWD/../frequencymonitor/frequencymonitordeclarative.pri) -include($$PWD/performancemonitor.pri) - -HEADERS += $$PWD/performancemonitordeclarative.h -SOURCES += $$PWD/performancemonitordeclarative.cpp -RESOURCES += $$PWD/performancemonitordeclarative.qrc diff --git a/examples/multimedia/video/snippets/performancemonitor/performancemonitordeclarative.qrc b/examples/multimedia/video/snippets/performancemonitor/performancemonitordeclarative.qrc deleted file mode 100644 index 9ec54a3e4..000000000 --- a/examples/multimedia/video/snippets/performancemonitor/performancemonitordeclarative.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - qml/performancemonitor/PerformanceItem.qml - - diff --git a/examples/multimedia/video/snippets/performancemonitor/qml/performancemonitor/PerformanceItem.qml b/examples/multimedia/video/snippets/performancemonitor/qml/performancemonitor/PerformanceItem.qml deleted file mode 100644 index 5621450cb..000000000 --- a/examples/multimedia/video/snippets/performancemonitor/qml/performancemonitor/PerformanceItem.qml +++ /dev/null @@ -1,150 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Mobility Components. -** -** $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 - -Rectangle { - id: root - property bool logging: true - property bool displayed: true - property bool videoActive - property int margins: 5 - property bool enabled: true - - color: "transparent" - - // This should ensure that the monitor is on top of all other content - z: 999 - - Column { - id: column - anchors { - fill: root - margins: 10 - } - spacing: 10 - } - - QtObject { - id: d - property Item qmlFrameRateItem: null - property Item videoFrameRateItem: null - } - - Connections { - id: videoFrameRateActiveConnections - ignoreUnknownSignals: true - function onActiveChanged() { root.videoActive = videoFrameRateActiveConnections.target.active } - } - - states: [ - State { - name: "hidden" - PropertyChanges { - target: root - opacity: 0 - } - } - ] - - transitions: [ - Transition { - from: "*" - to: "*" - NumberAnimation { - properties: "opacity" - easing.type: Easing.OutQuart - duration: 500 - } - } - ] - - state: enabled ? "baseState" : "hidden" - - function createQmlFrameRateItem() { - var component = Qt.createComponent("../frequencymonitor/FrequencyItem.qml") - if (component.status == Component.Ready) - d.qmlFrameRateItem = component.createObject(column, { label: "QML frame rate", - displayed: root.displayed, - logging: root.logging - }) - } - - function createVideoFrameRateItem() { - var component = Qt.createComponent("../frequencymonitor/FrequencyItem.qml") - if (component.status == Component.Ready) - d.videoFrameRateItem = component.createObject(column, { label: "Video frame rate", - displayed: root.displayed, - logging: root.logging - }) - videoFrameRateActiveConnections.target = d.videoFrameRateItem - } - - - function init() { - createQmlFrameRateItem() - createVideoFrameRateItem() - } - - function videoFramePainted() { - if (d.videoFrameRateItem) - d.videoFrameRateItem.notify() - } - - function qmlFramePainted() { - if (d.qmlFrameRateItem) - d.qmlFrameRateItem.notify() - } - - onVideoActiveChanged: { - if (d.videoFrameRateItem) - d.videoFrameRateItem.active = root.videoActive - } -} -- cgit v1.2.3