summaryrefslogtreecommitdiffstats
path: root/tools/qttracereplay
diff options
context:
space:
mode:
authorSamuel Rødal <sroedal@trolltech.com>2010-01-25 14:14:52 +0100
committerSamuel Rødal <sroedal@trolltech.com>2010-02-18 13:48:55 +0100
commit204df42586c1b0fef24d1a72f51302ad4f719e0d (patch)
treee3eb54a92dc4e497d3718ef3364033706e2e13d2 /tools/qttracereplay
parentf07d97150549f6817c351643e1c8b0ff163803ac (diff)
Added --range and --single arguments to qttracereplay.
Makes it easy to split a large trace into several sub-traces by running the qttracereplay with -graphicssystem trace. Reviewed-by: Gunnar Sletta
Diffstat (limited to 'tools/qttracereplay')
-rw-r--r--tools/qttracereplay/main.cpp72
1 files changed, 63 insertions, 9 deletions
diff --git a/tools/qttracereplay/main.cpp b/tools/qttracereplay/main.cpp
index a932d72a8c..82373f7402 100644
--- a/tools/qttracereplay/main.cpp
+++ b/tools/qttracereplay/main.cpp
@@ -49,7 +49,7 @@ class ReplayWidget : public QWidget
{
Q_OBJECT
public:
- ReplayWidget(const QString &filename);
+ ReplayWidget(const QString &filename, int from, int to, bool single);
void paintEvent(QPaintEvent *event);
void resizeEvent(QResizeEvent *event);
@@ -68,6 +68,11 @@ public:
QList<uint> visibleUpdates;
QList<uint> iterationTimes;
QString filename;
+
+ int from;
+ int to;
+
+ bool single;
};
void ReplayWidget::updateRect()
@@ -89,6 +94,11 @@ void ReplayWidget::paintEvent(QPaintEvent *)
currentFrame = 0;
++currentIteration;
+ if (single) {
+ deleteLater();
+ return;
+ }
+
if (currentIteration == 3)
timer.start();
else if (currentIteration > 3) {
@@ -137,20 +147,28 @@ void ReplayWidget::resizeEvent(QResizeEvent *event)
visibleUpdates.clear();
QRect bounds = rect();
- for (int i = 0; i < updates.size(); ++i) {
+
+ int first = qMax(0, from);
+ int last = qMin(unsigned(to), unsigned(updates.size()));
+ for (int i = first; i < last; ++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());
+ int range = last - first;
+
+ if (visibleUpdates.size() != range)
+ printf("Warning: skipped %d frames due to limited resolution\n", range - visibleUpdates.size());
}
-ReplayWidget::ReplayWidget(const QString &filename_)
+ReplayWidget::ReplayWidget(const QString &filename_, int from_, int to_, bool single_)
: currentFrame(0)
, currentIteration(0)
, filename(filename_)
+ , from(from_)
+ , to(to_)
+ , single(single_)
{
setWindowTitle(filename);
QFile file(filename);
@@ -189,17 +207,53 @@ int main(int argc, char **argv)
if (argc <= 1 || qstrcmp(argv[1], "-h") == 0 || qstrcmp(argv[1], "--help") == 0) {
printf("Replays a tracefile generated with '-graphicssystem trace'\n");
- printf("Usage:\n > %s [traceFile]\n", argv[0]);
+ printf("Usage:\n > %s [OPTIONS] [traceFile]\n", argv[0]);
+ printf("OPTIONS\n"
+ " --range=from-to to specify a frame range.\n"
+ " --singlerun to do only one run (without statistics)\n");
return 1;
}
- QFile file(argv[1]);
+ QFile file(app.arguments().last());
if (!file.exists()) {
- printf("%s does not exist\n", argv[1]);
+ printf("%s does not exist\n", qPrintable(app.arguments().last()));
return 1;
}
- ReplayWidget *widget = new ReplayWidget(argv[1]);
+ bool single = false;
+
+ int from = 0;
+ int to = -1;
+ for (int i = 1; i < app.arguments().size() - 1; ++i) {
+ QString arg = app.arguments().at(i);
+ if (arg.startsWith(QLatin1String("--range="))) {
+ QString rest = arg.mid(8);
+ QStringList components = rest.split(QLatin1Char('-'));
+
+ bool ok1 = false;
+ bool ok2 = false;
+ int fromCandidate = 0;
+ int toCandidate = 0;
+ if (components.size() == 2) {
+ fromCandidate = components.first().toInt(&ok1);
+ toCandidate = components.last().toInt(&ok2);
+ }
+
+ if (ok1 && ok2) {
+ from = fromCandidate;
+ to = toCandidate;
+ } else {
+ printf("ERROR: malformed syntax in argument %s\n", qPrintable(arg));
+ }
+ } else if (arg == QLatin1String("--singlerun")) {
+ single = true;
+ } else {
+ printf("Unrecognized argument: %s\n", qPrintable(arg));
+ return 1;
+ }
+ }
+
+ ReplayWidget *widget = new ReplayWidget(app.arguments().last(), from, to, single);
if (!widget->updates.isEmpty()) {
widget->show();