From e35209c6a31e8c7de01143466ceb458b4cb002cf Mon Sep 17 00:00:00 2001 From: Armin Berres Date: Mon, 6 Dec 2010 16:51:23 +0100 Subject: Changes: Add benchmark to measure FPS during rotation. RevBy: Stanislav Ionascu Details: The timedemo also measures the fps when animation from landscape to portrait and portrait to landscape. Merged with minor code layout fixes. --- demos/widgetsgallery/panningbenchmark.cpp | 19 ++++++++ demos/widgetsgallery/panningbenchmark.h | 19 ++++++++ demos/widgetsgallery/rotationbenchmark.cpp | 68 ++++++++++++++++++++++++++++ demos/widgetsgallery/rotationbenchmark.h | 49 ++++++++++++++++++++ demos/widgetsgallery/staticpagebenchmark.cpp | 19 ++++++++ demos/widgetsgallery/staticpagebenchmark.h | 19 ++++++++ demos/widgetsgallery/timedemopage.cpp | 7 +++ demos/widgetsgallery/widgetsgallery.pro | 2 + 8 files changed, 202 insertions(+) create mode 100644 demos/widgetsgallery/rotationbenchmark.cpp create mode 100644 demos/widgetsgallery/rotationbenchmark.h (limited to 'demos') diff --git a/demos/widgetsgallery/panningbenchmark.cpp b/demos/widgetsgallery/panningbenchmark.cpp index db297694..d3985614 100644 --- a/demos/widgetsgallery/panningbenchmark.cpp +++ b/demos/widgetsgallery/panningbenchmark.cpp @@ -1,3 +1,22 @@ +/*************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (directui@nokia.com) +** +** This file is part of libmeegotouch. +** +** If you have questions regarding the use of this file, please contact +** Nokia at directui@nokia.com. +** +** This library is free software; you can redistribute it and/or +** modify it under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation +** and appearing in the file LICENSE.LGPL included in the packaging +** of this file. +** +****************************************************************************/ + #include "panningbenchmark.h" #include "timedemo.h" diff --git a/demos/widgetsgallery/panningbenchmark.h b/demos/widgetsgallery/panningbenchmark.h index 5e04a693..2acb9934 100644 --- a/demos/widgetsgallery/panningbenchmark.h +++ b/demos/widgetsgallery/panningbenchmark.h @@ -1,3 +1,22 @@ +/*************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (directui@nokia.com) +** +** This file is part of libmeegotouch. +** +** If you have questions regarding the use of this file, please contact +** Nokia at directui@nokia.com. +** +** This library is free software; you can redistribute it and/or +** modify it under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation +** and appearing in the file LICENSE.LGPL included in the packaging +** of this file. +** +****************************************************************************/ + #ifndef PANNINGBENCHMARK_H #define PANNINGBENCHMARK_H diff --git a/demos/widgetsgallery/rotationbenchmark.cpp b/demos/widgetsgallery/rotationbenchmark.cpp new file mode 100644 index 00000000..dcb6fafd --- /dev/null +++ b/demos/widgetsgallery/rotationbenchmark.cpp @@ -0,0 +1,68 @@ +/*************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (directui@nokia.com) +** +** This file is part of libmeegotouch. +** +** If you have questions regarding the use of this file, please contact +** Nokia at directui@nokia.com. +** +** This library is free software; you can redistribute it and/or +** modify it under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation +** and appearing in the file LICENSE.LGPL included in the packaging +** of this file. +** +****************************************************************************/ + +#include "rotationbenchmark.h" +#include "timedemo.h" + +#include +#include + +#include + +RotationBenchmark::RotationBenchmark(MApplicationPage *applicationPage, Timedemo *timedemo, M::OrientationAngle targetOrientationAngle) + : TimedemoBenchmark(applicationPage, timedemo) + , targetOrientationAngle(targetOrientationAngle) +{ +} + +QString RotationBenchmark::name() +{ + return QString("RotationBenchmark (%1)").arg(QString::number(targetOrientationAngle)); +} + +void RotationBenchmark::start() +{ + if (!applicationPage->isOnDisplay()) { + connect(applicationPage, SIGNAL(appeared()), this, SLOT(stabilizeFps())); + applicationPage->appear(MApplication::activeWindow()); + verifyAppearanceTimer->start(5000); + } else { + QTimer::singleShot(0, this, SLOT(stabilizeFps())); + } +} + +void RotationBenchmark::stabilizeFps() { + verifyAppearanceTimer->stop(); + QTimer::singleShot(1000, this, SLOT(rotate())); +} + +void RotationBenchmark::rotate() +{ + timedemo->startTiming(this); + MApplication::activeWindow()->setOrientationAngle(targetOrientationAngle); + MApplication::activeWindow()->setOrientationAngleLocked(true); + connect(MApplication::activeWindow(), SIGNAL(orientationChangeFinished(M::Orientation)), this, SLOT(terminateBenchmark())); +} + +void RotationBenchmark::terminateBenchmark() +{ + timedemo->stopTiming(this); + disconnect(MApplication::activeWindow(), SIGNAL(orientationChangeFinished(M::Orientation)), this, SLOT(terminateBenchmark())); + emit finished(); +} diff --git a/demos/widgetsgallery/rotationbenchmark.h b/demos/widgetsgallery/rotationbenchmark.h new file mode 100644 index 00000000..00ad02b6 --- /dev/null +++ b/demos/widgetsgallery/rotationbenchmark.h @@ -0,0 +1,49 @@ +/*************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (directui@nokia.com) +** +** This file is part of libmeegotouch. +** +** If you have questions regarding the use of this file, please contact +** Nokia at directui@nokia.com. +** +** This library is free software; you can redistribute it and/or +** modify it under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation +** and appearing in the file LICENSE.LGPL included in the packaging +** of this file. +** +****************************************************************************/ + +#ifndef ROTATIONBENCHMARK_H +#define ROTATIONBENCHMARK_H + +#include "timedemobenchmark.h" + +#include + +/** + * Rotate from the current angle to the given one and measures + * the FPS while doing the rotation. + */ +class RotationBenchmark : public TimedemoBenchmark +{ + Q_OBJECT +public: + RotationBenchmark(MApplicationPage *applicationPage, Timedemo *timedemo, M::OrientationAngle targetOrientationAngle); + + QString name(); + void start(); + +private slots: + void stabilizeFps(); + void rotate(); + void terminateBenchmark(); + +private: + M::OrientationAngle targetOrientationAngle; +}; + +#endif // ROTATIONBENCHMARK_H diff --git a/demos/widgetsgallery/staticpagebenchmark.cpp b/demos/widgetsgallery/staticpagebenchmark.cpp index 9bd81988..399af427 100644 --- a/demos/widgetsgallery/staticpagebenchmark.cpp +++ b/demos/widgetsgallery/staticpagebenchmark.cpp @@ -1,3 +1,22 @@ +/*************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (directui@nokia.com) +** +** This file is part of libmeegotouch. +** +** If you have questions regarding the use of this file, please contact +** Nokia at directui@nokia.com. +** +** This library is free software; you can redistribute it and/or +** modify it under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation +** and appearing in the file LICENSE.LGPL included in the packaging +** of this file. +** +****************************************************************************/ + #include "staticpagebenchmark.h" #include "timedemo.h" diff --git a/demos/widgetsgallery/staticpagebenchmark.h b/demos/widgetsgallery/staticpagebenchmark.h index 21393816..82a1aa3b 100644 --- a/demos/widgetsgallery/staticpagebenchmark.h +++ b/demos/widgetsgallery/staticpagebenchmark.h @@ -1,3 +1,22 @@ +/*************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (directui@nokia.com) +** +** This file is part of libmeegotouch. +** +** If you have questions regarding the use of this file, please contact +** Nokia at directui@nokia.com. +** +** This library is free software; you can redistribute it and/or +** modify it under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation +** and appearing in the file LICENSE.LGPL included in the packaging +** of this file. +** +****************************************************************************/ + #ifndef STATICPAGEBENCHMARK_H #define STATICPAGEBENCHMARK_H diff --git a/demos/widgetsgallery/timedemopage.cpp b/demos/widgetsgallery/timedemopage.cpp index 6fda3288..6f224f58 100644 --- a/demos/widgetsgallery/timedemopage.cpp +++ b/demos/widgetsgallery/timedemopage.cpp @@ -3,6 +3,7 @@ #include "staticpagebenchmark.h" #include "panningbenchmark.h" +#include "rotationbenchmark.h" TimedemoPage::TimedemoPage(QGraphicsItem *parent) : MApplicationPage(parent), @@ -20,11 +21,17 @@ void TimedemoPage::createBenchmarks(Timedemo *timedemo) benchmark = QSharedPointer(new PanningBenchmark(this, timedemo)); m_benchmarks.append(benchmark); + benchmark = QSharedPointer(new RotationBenchmark(this, timedemo, M::Angle90)); + m_benchmarks.append(benchmark); + benchmark = QSharedPointer(new StaticPageBenchmark(this, timedemo, M::Angle90)); m_benchmarks.append(benchmark); benchmark = QSharedPointer(new PanningBenchmark(this, timedemo, M::Angle90)); m_benchmarks.append(benchmark); + + benchmark = QSharedPointer(new RotationBenchmark(this, timedemo, M::Angle0)); + m_benchmarks.append(benchmark); } QVector > TimedemoPage::benchmarks() diff --git a/demos/widgetsgallery/widgetsgallery.pro b/demos/widgetsgallery/widgetsgallery.pro index a8b7c71e..dea0fac3 100644 --- a/demos/widgetsgallery/widgetsgallery.pro +++ b/demos/widgetsgallery/widgetsgallery.pro @@ -77,6 +77,7 @@ SOURCES += main.cpp \ drilldownlistitem.cpp \ customnavigationbarpage.cpp \ mynavbarcontent.cpp \ + rotationbenchmark.cpp \ HEADERS += templatepage.h \ mainpage.h \ @@ -126,6 +127,7 @@ HEADERS += templatepage.h \ drilldownlistitem.h \ customnavigationbarpage.h \ mynavbarcontent.h \ + rotationbenchmark.h \ # theme include(theme/theme.pri) -- cgit v1.2.3