summaryrefslogtreecommitdiffstats
path: root/tools/qttracereplay
diff options
context:
space:
mode:
authorSamuel Rødal <sroedal@trolltech.com>2009-09-04 15:08:44 +0200
committerSamuel Rødal <sroedal@trolltech.com>2009-09-04 16:29:01 +0200
commitf0b0ab1291dec59ae2fe1e88a3b20d173772e175 (patch)
tree2d9e186581a7ece5fdd3e6a15b72796b6424b24b /tools/qttracereplay
parent57447242994a16e30d3cb199eefaf625f0088f9f (diff)
Added multiple frames to QPaintBuffer.
This lets us stream a single QPaintBuffer instead of one QPaintBuffer per frame in the trace graphicssystem, which leads to not streaming pixmaps / images once per frame. Performance when doing a trace is also a lot better for painting heavy applications. Reviewed-by: Trond
Diffstat (limited to 'tools/qttracereplay')
-rw-r--r--tools/qttracereplay/main.cpp52
1 files changed, 12 insertions, 40 deletions
diff --git a/tools/qttracereplay/main.cpp b/tools/qttracereplay/main.cpp
index 970531bba4..34508e234e 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);