diff options
author | hjk <qthjk@ovi.com> | 2012-12-18 15:11:44 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2012-12-20 19:28:19 +0100 |
commit | 416168db8a9bb54614117469a43f751a401de854 (patch) | |
tree | be708f7ba13950041eaea0f481c2c1f050f4a9c3 | |
parent | 5739d43eef89e415974ca64fb348371f9f8659c7 (diff) | |
download | qtmultimedia-416168db8a9bb54614117469a43f751a401de854.tar.gz |
Polish and fix qmlvideofx example
Change-Id: I30f6d7d2af784ba018a659a16aceb4876a4b1be6
Reviewed-by: hjk <qthjk@ovi.com>
33 files changed, 122 insertions, 123 deletions
diff --git a/examples/multimedia/video/qmlvideo/main.cpp b/examples/multimedia/video/qmlvideo/main.cpp index 8230e9441..ac26c983a 100644 --- a/examples/multimedia/video/qmlvideo/main.cpp +++ b/examples/multimedia/video/qmlvideo/main.cpp @@ -69,8 +69,8 @@ int main(int argc, char *argv[]) QStringList args = app.arguments(); PerformanceMonitor::State performanceMonitorState; bool sourceIsUrl = false; - for (int i=1; i<args.count(); ++i) { - const QString &arg = args.at(i); + for (int i = 1; i < args.size(); ++i) { + const QByteArray arg = args.at(i).toUtf8(); if (arg.startsWith('-')) { if ("-volume" == arg) { if (i+1 < args.count()) @@ -79,7 +79,7 @@ int main(int argc, char *argv[]) qtTrace() << "Option \"-volume\" takes a value"; } #ifdef PERFORMANCEMONITOR_SUPPORT - else if (PerformanceMonitor::parseArgument(arg, performanceMonitorState)) { + else if (performanceMonitorState.parseArgument(arg)) { // Do nothing } #endif diff --git a/examples/multimedia/video/qmlvideofx/filereader.cpp b/examples/multimedia/video/qmlvideofx/filereader.cpp index 065766323..6c9773337 100644 --- a/examples/multimedia/video/qmlvideofx/filereader.cpp +++ b/examples/multimedia/video/qmlvideofx/filereader.cpp @@ -41,36 +41,18 @@ #include "filereader.h" #include "trace.h" -#include <QtCore/QCoreApplication> -#include <QtCore/QDir> -#include <QtCore/QFile> -#include <QtCore/QFileInfo> -#include <QtCore/QTextStream> -QString adjustPath(const QString &path) -{ -#ifdef Q_OS_UNIX -#ifdef Q_OS_MAC - if (!QDir::isAbsolutePath(path)) - return QCoreApplication::applicationDirPath() - + QLatin1String("/../Resources/") + path; -#else - QString pathInInstallDir; - const QString applicationDirPath = QCoreApplication::applicationDirPath(); - pathInInstallDir = QString::fromLatin1("%1/../%2").arg(applicationDirPath, path); - - if (QFileInfo(pathInInstallDir).exists()) - return pathInInstallDir; -#endif -#endif - return path; -} +#include <QCoreApplication> +#include <QDir> +#include <QFile> +#include <QFileInfo> +#include <QTextStream> QString FileReader::readFile(const QString &fileName) { qtTrace() << "FileReader::readFile" << "fileName" << fileName; QString content; - QFile file(adjustPath(fileName)); + QFile file(fileName); if (file.open(QIODevice::ReadOnly)) { QTextStream stream(&file); content = stream.readAll(); diff --git a/examples/multimedia/video/qmlvideofx/filereader.h b/examples/multimedia/video/qmlvideofx/filereader.h index 44393b1c7..443a2a2fe 100644 --- a/examples/multimedia/video/qmlvideofx/filereader.h +++ b/examples/multimedia/video/qmlvideofx/filereader.h @@ -39,7 +39,7 @@ ** ****************************************************************************/ -#include <QtCore/QObject> +#include <QObject> class FileReader : public QObject { diff --git a/examples/multimedia/video/qmlvideofx/main.cpp b/examples/multimedia/video/qmlvideofx/main.cpp index 9f47a9c17..056c274e9 100644 --- a/examples/multimedia/video/qmlvideofx/main.cpp +++ b/examples/multimedia/video/qmlvideofx/main.cpp @@ -72,17 +72,17 @@ int main(int argc, char *argv[]) #ifdef PERFORMANCEMONITOR_SUPPORT PerformanceMonitor::State performanceMonitorState; #endif - for (int i=1; i<args.count(); ++i) { - const QString &arg = args.at(i); + for (int i = 1; i < args.size(); ++i) { + const QByteArray arg = args.at(i).toUtf8(); if (arg.startsWith('-')) { if ("-volume" == arg) { - if (i+1 < args.count()) + if (i + 1 < args.size()) volume = 0.01 * args.at(++i).toInt(); else qtTrace() << "Option \"-volume\" takes a value"; } #ifdef PERFORMANCEMONITOR_SUPPORT - else if (PerformanceMonitor::parseArgument(arg, performanceMonitorState)) { + else if (performanceMonitorState.parseArgument(arg)) { // Do nothing } #endif diff --git a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/Effect.qml b/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/Effect.qml index 535ab106b..0010673e3 100644 --- a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/Effect.qml +++ b/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/Effect.qml @@ -69,7 +69,7 @@ ShaderEffect { // rather than being inline in the QML file onFragmentShaderFilenameChanged: - fragmentShader = d.fragmentShaderCommon + fileReader.readFile(fragmentShaderFilename) + fragmentShader = d.fragmentShaderCommon + fileReader.readFile(":shaders/" + fragmentShaderFilename) onVertexShaderFilenameChanged: vertexShader = fileReader.readFile(vertexShaderFilename) } diff --git a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectBillboard.qml b/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectBillboard.qml index 124a2a17e..4a458b735 100644 --- a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectBillboard.qml +++ b/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectBillboard.qml @@ -55,5 +55,5 @@ Effect { property real step_x: 0.0015625 property real step_y: targetHeight ? (step_x * targetWidth / targetHeight) : 0.0 - fragmentShaderFilename: "shaders/billboard.fsh" + fragmentShaderFilename: "billboard.fsh" } diff --git a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectBlackAndWhite.qml b/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectBlackAndWhite.qml index 37a3b6e0d..0660e9185 100644 --- a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectBlackAndWhite.qml +++ b/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectBlackAndWhite.qml @@ -52,5 +52,5 @@ Effect { // Transform slider values, and bind result to shader uniforms property real threshold: parameters.get(0).value - fragmentShaderFilename: "shaders/blackandwhite.fsh" + fragmentShaderFilename: "blackandwhite.fsh" } diff --git a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectEmboss.qml b/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectEmboss.qml index 4bf57718d..a71b30ec5 100644 --- a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectEmboss.qml +++ b/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectEmboss.qml @@ -42,5 +42,5 @@ import QtQuick 2.0 Effect { - fragmentShaderFilename: "shaders/emboss.fsh" + fragmentShaderFilename: "emboss.fsh" } diff --git a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectGaussianBlur.qml b/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectGaussianBlur.qml index b804e903b..a3ef8749a 100644 --- a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectGaussianBlur.qml +++ b/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectGaussianBlur.qml @@ -63,7 +63,7 @@ Item { anchors.fill: parent dividerValue: parent.dividerValue property real blurSize: 4.0 * parent.parameters.get(0).value / targetHeight - fragmentShaderFilename: "shaders/gaussianblur_v.fsh" + fragmentShaderFilename: "gaussianblur_v.fsh" } Effect { @@ -71,7 +71,7 @@ Item { anchors.fill: parent dividerValue: parent.dividerValue property real blurSize: 4.0 * parent.parameters.get(0).value / parent.targetWidth - fragmentShaderFilename: "shaders/gaussianblur_h.fsh" + fragmentShaderFilename: "gaussianblur_h.fsh" source: horizontalShaderSource ShaderEffectSource { diff --git a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectGlow.qml b/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectGlow.qml index d6e987db2..5b3ae41b0 100644 --- a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectGlow.qml +++ b/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectGlow.qml @@ -42,5 +42,5 @@ import QtQuick 2.0 Effect { - fragmentShaderFilename: "shaders/glow.fsh" + fragmentShaderFilename: "glow.fsh" } diff --git a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectIsolate.qml b/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectIsolate.qml index 2425a2580..d81c7930c 100644 --- a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectIsolate.qml +++ b/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectIsolate.qml @@ -57,5 +57,5 @@ Effect { property real targetHue: parameters.get(0).value * 360 property real windowWidth: parameters.get(1).value * 60 - fragmentShaderFilename: "shaders/isolate.fsh" + fragmentShaderFilename: "isolate.fsh" } diff --git a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectMagnify.qml b/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectMagnify.qml index 5a207f95e..4a37a0ad1 100644 --- a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectMagnify.qml +++ b/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectMagnify.qml @@ -84,7 +84,7 @@ Effect { d.oldTargetHeight = targetHeight } - fragmentShaderFilename: "shaders/magnify.fsh" + fragmentShaderFilename: "magnify.fsh" MouseArea { anchors.fill: parent diff --git a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectPageCurl.qml b/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectPageCurl.qml index 7724bfa9b..862c2673c 100644 --- a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectPageCurl.qml +++ b/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectPageCurl.qml @@ -53,5 +53,5 @@ Effect { // Transform slider values, and bind result to shader uniforms property real curlExtent: 1.0 - parameters.get(0).value - fragmentShaderFilename: "shaders/pagecurl.fsh" + fragmentShaderFilename: "pagecurl.fsh" } diff --git a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectPixelate.qml b/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectPixelate.qml index 71f7da965..11281f777 100644 --- a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectPixelate.qml +++ b/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectPixelate.qml @@ -52,5 +52,5 @@ Effect { // Transform slider values, and bind result to shader uniforms property real granularity: parameters.get(0).value * 20 - fragmentShaderFilename: "shaders/pixelate.fsh" + fragmentShaderFilename: "pixelate.fsh" } diff --git a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectPosterize.qml b/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectPosterize.qml index 0cf16a0dc..c70a0c10f 100644 --- a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectPosterize.qml +++ b/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectPosterize.qml @@ -54,5 +54,5 @@ Effect { property real numColors: 8.0 - fragmentShaderFilename: "shaders/posterize.fsh" + fragmentShaderFilename: "posterize.fsh" } diff --git a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectRipple.qml b/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectRipple.qml index 0b7c48cbc..0ec0d13a3 100644 --- a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectRipple.qml +++ b/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectRipple.qml @@ -60,5 +60,5 @@ Effect { property real time: 0 NumberAnimation on time { loops: Animation.Infinite; from: 0; to: Math.PI * 2; duration: 600 } - fragmentShaderFilename: "shaders/ripple.fsh" + fragmentShaderFilename: "ripple.fsh" } diff --git a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectSepia.qml b/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectSepia.qml index 446e7790b..2b42e68c6 100644 --- a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectSepia.qml +++ b/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectSepia.qml @@ -42,5 +42,5 @@ import QtQuick 2.0 Effect { - fragmentShaderFilename: "shaders/sepia.fsh" + fragmentShaderFilename: "sepia.fsh" } diff --git a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectSharpen.qml b/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectSharpen.qml index 99ece3cd8..2c69378d7 100644 --- a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectSharpen.qml +++ b/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectSharpen.qml @@ -52,5 +52,5 @@ Effect { // Transform slider values, and bind result to shader uniforms property real amount: parameters.get(0).value * 18 - fragmentShaderFilename: "shaders/sharpen.fsh" + fragmentShaderFilename: "sharpen.fsh" } diff --git a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectShockwave.qml b/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectShockwave.qml index fe91781ba..7716bf672 100644 --- a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectShockwave.qml +++ b/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectShockwave.qml @@ -76,5 +76,5 @@ Effect { } } - fragmentShaderFilename: "shaders/shockwave.fsh" + fragmentShaderFilename: "shockwave.fsh" } diff --git a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectSobelEdgeDetection1.qml b/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectSobelEdgeDetection1.qml index 189d5d385..78b908549 100644 --- a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectSobelEdgeDetection1.qml +++ b/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectSobelEdgeDetection1.qml @@ -55,5 +55,5 @@ Effect { property real resS: targetSize property real resT: targetSize - fragmentShaderFilename: "shaders/sobeledgedetection1.fsh" + fragmentShaderFilename: "sobeledgedetection1.fsh" } diff --git a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectSobelEdgeDetection2.qml b/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectSobelEdgeDetection2.qml index 4bcc6efaa..94d87b43e 100644 --- a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectSobelEdgeDetection2.qml +++ b/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectSobelEdgeDetection2.qml @@ -52,5 +52,5 @@ Effect { // Transform slider values, and bind result to shader uniforms property real weight: parameters.get(0).value - fragmentShaderFilename: "shaders/sobeledgedetection2.fsh" + fragmentShaderFilename: "sobeledgedetection2.fsh" } diff --git a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectTiltShift.qml b/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectTiltShift.qml index b1f214b07..b8097a6c2 100644 --- a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectTiltShift.qml +++ b/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectTiltShift.qml @@ -42,5 +42,5 @@ import QtQuick 2.0 Effect { - fragmentShaderFilename: "shaders/tiltshift.fsh" + fragmentShaderFilename: "tiltshift.fsh" } diff --git a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectToon.qml b/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectToon.qml index 08f184997..31d8869b8 100644 --- a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectToon.qml +++ b/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectToon.qml @@ -59,5 +59,5 @@ Effect { property real magTol: 0.3 property real quantize: 8.0 - fragmentShaderFilename: "shaders/toon.fsh" + fragmentShaderFilename: "toon.fsh" } diff --git a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectVignette.qml b/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectVignette.qml index 11201616c..be868e285 100644 --- a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectVignette.qml +++ b/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectVignette.qml @@ -42,5 +42,5 @@ import QtQuick 2.0 Effect { - fragmentShaderFilename: "shaders/vignette.fsh" + fragmentShaderFilename: "vignette.fsh" } diff --git a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectWarhol.qml b/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectWarhol.qml index e96d0524d..0592507e5 100644 --- a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectWarhol.qml +++ b/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectWarhol.qml @@ -42,5 +42,5 @@ import QtQuick 2.0 Effect { - fragmentShaderFilename: "shaders/warhol.fsh" + fragmentShaderFilename: "warhol.fsh" } diff --git a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectWobble.qml b/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectWobble.qml index 4cccf48b8..191eb9386 100644 --- a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectWobble.qml +++ b/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectWobble.qml @@ -57,5 +57,5 @@ Effect { NumberAnimation on time { loops: Animation.Infinite; from: 0; to: Math.PI * 2; duration: 600 } - fragmentShaderFilename: "shaders/wobble.fsh" + fragmentShaderFilename: "wobble.fsh" } diff --git a/examples/multimedia/video/qmlvideofx/qmlvideofx.pro b/examples/multimedia/video/qmlvideofx/qmlvideofx.pro index 629c0bdce..d62ade86d 100644 --- a/examples/multimedia/video/qmlvideofx/qmlvideofx.pro +++ b/examples/multimedia/video/qmlvideofx/qmlvideofx.pro @@ -3,16 +3,12 @@ TARGET = qmlvideofx QT += quick -LOCAL_SOURCES = filereader.cpp main.cpp -LOCAL_HEADERS = filereader.h trace.h - -SOURCES += $$LOCAL_SOURCES -HEADERS += $$LOCAL_HEADERS +SOURCES += filereader.cpp main.cpp +HEADERS += filereader.h trace.h RESOURCES += qmlvideofx.qrc -SNIPPETS_PATH = ../snippets -include($$SNIPPETS_PATH/performancemonitor/performancemonitordeclarative.pri) +include($$PWD/../snippets/performancemonitor/performancemonitordeclarative.pri) maemo6: { DEFINES += SMALL_SCREEN_LAYOUT diff --git a/examples/multimedia/video/qmlvideofx/qmlvideofx.qrc b/examples/multimedia/video/qmlvideofx/qmlvideofx.qrc index 0b39099a1..93cb4f1f5 100644 --- a/examples/multimedia/video/qmlvideofx/qmlvideofx.qrc +++ b/examples/multimedia/video/qmlvideofx/qmlvideofx.qrc @@ -44,5 +44,28 @@ <file>qml/qmlvideofx/main-smallscreen.qml</file> <file>qml/qmlvideofx/ParameterPanel.qml</file> <file>qml/qmlvideofx/Slider.qml</file> + <file>shaders/billboard.fsh</file> + <file>shaders/blackandwhite.fsh</file> + <file>shaders/emboss.fsh</file> + <file>shaders/gaussianblur_h.fsh</file> + <file>shaders/gaussianblur_v.fsh</file> + <file>shaders/glow.fsh</file> + <file>shaders/isolate.fsh</file> + <file>shaders/magnify.fsh</file> + <file>shaders/pagecurl.fsh</file> + <file>shaders/pixelate.fsh</file> + <file>shaders/posterize.fsh</file> + <file>shaders/ripple.fsh</file> + <file>shaders/selectionpanel.fsh</file> + <file>shaders/sepia.fsh</file> + <file>shaders/sharpen.fsh</file> + <file>shaders/shockwave.fsh</file> + <file>shaders/sobeledgedetection1.fsh</file> + <file>shaders/sobeledgedetection2.fsh</file> + <file>shaders/tiltshift.fsh</file> + <file>shaders/toon.fsh</file> + <file>shaders/vignette.fsh</file> + <file>shaders/warhol.fsh</file> + <file>shaders/wobble.fsh</file> </qresource> </RCC> diff --git a/examples/multimedia/video/qmlvideofx/trace.h b/examples/multimedia/video/qmlvideofx/trace.h index 73095f595..c5332d5da 100644 --- a/examples/multimedia/video/qmlvideofx/trace.h +++ b/examples/multimedia/video/qmlvideofx/trace.h @@ -42,7 +42,7 @@ #ifndef TRACE_H #define TRACE_H -#include <QtCore/QDebug> +#include <QDebug> #define ENABLE_TRACE //#define VERBOSE_TRACE @@ -53,7 +53,7 @@ class NullDebug { public: template <typename T> - NullDebug& operator<<(const T&) { return *this; } + NullDebug &operator<<(const T &) { return *this; } }; inline NullDebug nullDebug() { return NullDebug(); } @@ -68,18 +68,12 @@ struct PtrWrapper } // namespace Trace template <typename T> -inline QDebug& operator<<(QDebug &debug, const Trace::PtrWrapper<T> &wrapper) +inline QDebug &operator<<(QDebug &debug, const Trace::PtrWrapper<T> &wrapper) { debug.nospace() << "[" << (void*)wrapper.m_ptr << "]"; return debug.space(); } -template<typename T> -inline const void *qtVoidPtr(const T *ptr) -{ return static_cast<const void *>(ptr); } - -#define qtThisPtr() qtVoidPtr(this) - #ifdef ENABLE_TRACE inline QDebug qtTrace() { return qDebug() << "[qmlvideofx]"; } # ifdef VERBOSE_TRACE diff --git a/examples/multimedia/video/snippets/frequencymonitor/frequencymonitor.cpp b/examples/multimedia/video/snippets/frequencymonitor/frequencymonitor.cpp index 1d44f1297..568bbc79f 100644 --- a/examples/multimedia/video/snippets/frequencymonitor/frequencymonitor.cpp +++ b/examples/multimedia/video/snippets/frequencymonitor/frequencymonitor.cpp @@ -40,11 +40,11 @@ ****************************************************************************/ #include "frequencymonitor.h" -#include <QtCore/QDebug> -#include <QtCore/QElapsedTimer> -#include <QtCore/QString> -#include <QtCore/QTime> -#include <QtCore/QTimer> +#include <QDebug> +#include <QElapsedTimer> +#include <QString> +#include <QTime> +#include <QTimer> //#define VERBOSE_TRACE @@ -61,6 +61,7 @@ static const int DefaultTraceInterval = 0; class FrequencyMonitorPrivate : public QObject { Q_OBJECT + public: FrequencyMonitorPrivate(FrequencyMonitor *parent); void calculateInstantaneousFrequency(); @@ -116,16 +117,16 @@ void FrequencyMonitorPrivate::calculateInstantaneousFrequency() m_stalledTimer->start(3 * ms); if (m_instantaneousFrequency) q_ptr->setActive(true); - q_ptr->emit instantaneousFrequencyChanged(m_instantaneousFrequency); - q_ptr->emit frequencyChanged(); + 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; - q_ptr->emit averageFrequencyChanged(m_averageFrequency); - q_ptr->emit frequencyChanged(); + emit q_ptr->averageFrequencyChanged(m_averageFrequency); + emit q_ptr->frequencyChanged(); m_count = 0; } @@ -134,14 +135,13 @@ void FrequencyMonitorPrivate::stalled() if (m_instantaneousFrequency) { qtVerboseTrace() << "FrequencyMonitor::stalled"; m_instantaneousFrequency = 0; - q_ptr->emit instantaneousFrequencyChanged(m_instantaneousFrequency); - q_ptr->emit frequencyChanged(); + emit q_ptr->instantaneousFrequencyChanged(m_instantaneousFrequency); + emit q_ptr->frequencyChanged(); } } FrequencyMonitor::FrequencyMonitor(QObject *parent) : QObject(parent) -, d_ptr(0) { d_ptr = new FrequencyMonitorPrivate(this); qtTrace() << "FrequencyMonitor::FrequencyMonitor"; @@ -152,7 +152,7 @@ FrequencyMonitor::~FrequencyMonitor() } -const QString &FrequencyMonitor::label() const +QString FrequencyMonitor::label() const { return d_func()->m_label; } diff --git a/examples/multimedia/video/snippets/frequencymonitor/frequencymonitor.h b/examples/multimedia/video/snippets/frequencymonitor/frequencymonitor.h index 1efd8b3ad..f34646f9e 100644 --- a/examples/multimedia/video/snippets/frequencymonitor/frequencymonitor.h +++ b/examples/multimedia/video/snippets/frequencymonitor/frequencymonitor.h @@ -42,8 +42,8 @@ #ifndef FREQUENCYMONITOR_H #define FREQUENCYMONITOR_H -#include <QtCore/QObject> -#include <QtCore/QTimer> +#include <QObject> +#include <QTimer> class FrequencyMonitorPrivate; @@ -64,13 +64,14 @@ class FrequencyMonitor : public QObject 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(); - const QString &label() const; + QString label() const; bool active() const; int samplingInterval() const; int traceInterval() const; diff --git a/examples/multimedia/video/snippets/performancemonitor/performancemonitor.cpp b/examples/multimedia/video/snippets/performancemonitor/performancemonitor.cpp index 9a7e060b7..07c83485b 100644 --- a/examples/multimedia/video/snippets/performancemonitor/performancemonitor.cpp +++ b/examples/multimedia/video/snippets/performancemonitor/performancemonitor.cpp @@ -43,27 +43,27 @@ namespace PerformanceMonitor { - bool parseArgument(const QString &arg, State &state) - { - bool result = false; - if ("-log-perf" == arg) { - state.logging = true; - state.valid = true; - result = true; - } else if ("-no-log-perf" == arg) { - state.logging = false; - state.valid = true; - result = true; - } else if ("-show-perf" == arg) { - state.visible = true; - state.valid = true; - result = true; - } else if ("-hide-perf" == arg) { - state.visible = false; - state.valid = true; - result = true; - } - return result; +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 index d87d71eac..f1a443e0b 100644 --- a/examples/multimedia/video/snippets/performancemonitor/performancemonitor.h +++ b/examples/multimedia/video/snippets/performancemonitor/performancemonitor.h @@ -42,24 +42,27 @@ #ifndef PERFORMANCEMONITOR_H #define PERFORMANCEMONITOR_H -#include <QtCore/QString> +#include <QByteArray> namespace PerformanceMonitor { - struct State { - bool valid; - bool logging; - bool visible; - 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; } - }; +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 QString &arg, State &state); -} + bool parseArgument(const QByteArray &arg); + + bool valid; + bool logging; + bool visible; +}; + +} // namespace PerformanceMonitor #endif // PERFORMANCEMONITOR_H |