diff options
Diffstat (limited to 'tools/qttracereplay')
-rw-r--r-- | tools/qttracereplay/main.cpp | 52 |
1 files changed, 12 insertions, 40 deletions
diff --git a/tools/qttracereplay/main.cpp b/tools/qttracereplay/main.cpp index 970531b..34508e2 100644 --- a/tools/qttracereplay/main.cpp +++ b/tools/qttracereplay/main.cpp @@ -45,12 +45,6 @@ #include <private/qpaintengineex_p.h> #include <private/qpaintbuffer_p.h> -struct Frame -{ - QRegion updateRegion; - QPaintBuffer *buffer; -}; - class ReplayWidget : public QWidget { Q_OBJECT @@ -63,7 +57,9 @@ public slots: void updateRect(); private: - QList<Frame> frames; + QList<QRegion> updates; + QPaintBuffer buffer; + int currentFrame; int currentIteration; QTime timer; @@ -74,7 +70,7 @@ private: void ReplayWidget::updateRect() { - update(frames.at(currentFrame).updateRegion); + update(updates.at(currentFrame)); } void ReplayWidget::paintEvent(QPaintEvent *) @@ -83,10 +79,10 @@ void ReplayWidget::paintEvent(QPaintEvent *) // p.setClipRegion(frames.at(currentFrame).updateRegion); - frames.at(currentFrame).buffer->draw(&p); + buffer.draw(&p, currentFrame); ++currentFrame; - if (currentFrame >= frames.size()) { + if (currentFrame >= buffer.numFrames()) { currentFrame = 0; ++currentIteration; @@ -116,15 +112,13 @@ void ReplayWidget::paintEvent(QPaintEvent *) stddev = qSqrt(stddev / iterationTimes.size()); qSort(iterationTimes.begin(), iterationTimes.end()); - qreal median = iterationTimes.at(iterationTimes.size() / 2); - if ((iterationTimes.size() % 1) == 1) - median = (median + iterationTimes.at(iterationTimes.size() / 2 - 1)) * 0.5; + uint median = iterationTimes.at(iterationTimes.size() / 2); stddev = 100 * stddev / mean; if (iterationTimes.size() >= 10 || stddev < 4) { - printf("%s, iterations: %d, frames: %d, min(ms): %d, median(ms): %f, stddev: %f %%, max(fps): %f\n", qPrintable(filename), - iterationTimes.size(), frames.size(), min, median, stddev, 1000. * frames.size() / min); + 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); deleteLater(); return; } @@ -146,34 +140,12 @@ ReplayWidget::ReplayWidget(const QString &filename_) QRect bounds; if (file.open(QIODevice::ReadOnly)) { QDataStream in(&file); - - while (true) { - int frameId; - in >> frameId; - - if (in.status() != QDataStream::Ok) - break; - - qulonglong windowId; - QRegion rgn; - - in >> windowId; - - Frame frame; - frame.buffer = new QPaintBuffer; - - in >> bounds; - - in >> frame.updateRegion; - in >> *frame.buffer; - - frames << frame; - } + in >> buffer >> updates; } - qDebug() << "Read" << frames.size() << "frames"; + qDebug() << "Read paint buffer with" << buffer.numFrames() << "frames"; - resize(bounds.size()); + resize(buffer.boundingRect().size().toSize()); setAutoFillBackground(false); setAttribute(Qt::WA_NoSystemBackground); |