summaryrefslogtreecommitdiffstats
path: root/tools/qttracereplay/main.cpp
diff options
context:
space:
mode:
authorJustin McPherson <justin.mcpherson@nokia.com>2010-02-05 05:24:23 (GMT)
committerJustin McPherson <justin.mcpherson@nokia.com>2010-02-05 05:24:23 (GMT)
commit9f43d4aafeb16c81bc1a161c99dee2df19772e42 (patch)
tree081f5c2323f6fadf49f2d1fada8a7c0cb4bc953c /tools/qttracereplay/main.cpp
parentf14e3b86e6b7b496017ddd462821325bdb40c779 (diff)
parent7474ad656269aec1352d166bb5a4435086d48482 (diff)
downloadQt-9f43d4aafeb16c81bc1a161c99dee2df19772e42.zip
Qt-9f43d4aafeb16c81bc1a161c99dee2df19772e42.tar.gz
Qt-9f43d4aafeb16c81bc1a161c99dee2df19772e42.tar.bz2
Merge branch 'master' of git@scm.dev.nokia.troll.no:qt/qt
Diffstat (limited to 'tools/qttracereplay/main.cpp')
-rw-r--r--tools/qttracereplay/main.cpp28
1 files changed, 22 insertions, 6 deletions
diff --git a/tools/qttracereplay/main.cpp b/tools/qttracereplay/main.cpp
index 85e9b12..a932d72 100644
--- a/tools/qttracereplay/main.cpp
+++ b/tools/qttracereplay/main.cpp
@@ -52,6 +52,7 @@ public:
ReplayWidget(const QString &filename);
void paintEvent(QPaintEvent *event);
+ void resizeEvent(QResizeEvent *event);
public slots:
void updateRect();
@@ -64,14 +65,15 @@ public:
int currentIteration;
QTime timer;
+ QList<uint> visibleUpdates;
QList<uint> iterationTimes;
QString filename;
};
void ReplayWidget::updateRect()
{
- if (!updates.isEmpty())
- update(updates.at(currentFrame));
+ if (!visibleUpdates.isEmpty())
+ update(updates.at(visibleUpdates.at(currentFrame)));
}
void ReplayWidget::paintEvent(QPaintEvent *)
@@ -80,10 +82,10 @@ void ReplayWidget::paintEvent(QPaintEvent *)
// p.setClipRegion(frames.at(currentFrame).updateRegion);
- buffer.draw(&p, currentFrame);
+ buffer.draw(&p, visibleUpdates.at(currentFrame));
++currentFrame;
- if (currentFrame >= buffer.numFrames()) {
+ if (currentFrame >= visibleUpdates.size()) {
currentFrame = 0;
++currentIteration;
@@ -119,7 +121,7 @@ void ReplayWidget::paintEvent(QPaintEvent *)
if (iterationTimes.size() >= 10 || stddev < 4) {
printf("%s, iterations: %d, frames: %d, min(ms): %d, median(ms): %d, stddev: %f %%, max(fps): %f\n", qPrintable(filename),
- iterationTimes.size(), updates.size(), min, median, stddev, 1000. * updates.size() / min);
+ iterationTimes.size(), visibleUpdates.size(), min, median, stddev, 1000. * visibleUpdates.size() / min);
deleteLater();
return;
}
@@ -130,6 +132,21 @@ void ReplayWidget::paintEvent(QPaintEvent *)
QTimer::singleShot(0, this, SLOT(updateRect()));
}
+void ReplayWidget::resizeEvent(QResizeEvent *event)
+{
+ visibleUpdates.clear();
+
+ QRect bounds = rect();
+ for (int i = 0; i < updates.size(); ++i) {
+ if (updates.at(i).intersects(bounds))
+ visibleUpdates << i;
+ }
+
+ if (visibleUpdates.size() != updates.size())
+ printf("Warning: skipped %d frames due to limited resolution\n", updates.size() - visibleUpdates.size());
+
+}
+
ReplayWidget::ReplayWidget(const QString &filename_)
: currentFrame(0)
, currentIteration(0)
@@ -138,7 +155,6 @@ ReplayWidget::ReplayWidget(const QString &filename_)
setWindowTitle(filename);
QFile file(filename);
- QRect bounds;
if (!file.open(QIODevice::ReadOnly)) {
printf("Failed to load input file '%s'\n", qPrintable(filename_));
return;