diff options
author | Samuel Rødal <sroedal@trolltech.com> | 2009-09-04 13:08:44 (GMT) |
---|---|---|
committer | Samuel Rødal <sroedal@trolltech.com> | 2009-09-04 14:29:01 (GMT) |
commit | f0b0ab1291dec59ae2fe1e88a3b20d173772e175 (patch) | |
tree | 2d9e186581a7ece5fdd3e6a15b72796b6424b24b /src/plugins/graphicssystems | |
parent | 57447242994a16e30d3cb199eefaf625f0088f9f (diff) | |
download | Qt-f0b0ab1291dec59ae2fe1e88a3b20d173772e175.zip Qt-f0b0ab1291dec59ae2fe1e88a3b20d173772e175.tar.gz Qt-f0b0ab1291dec59ae2fe1e88a3b20d173772e175.tar.bz2 |
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 'src/plugins/graphicssystems')
-rw-r--r-- | src/plugins/graphicssystems/trace/qgraphicssystem_trace.cpp | 60 |
1 files changed, 35 insertions, 25 deletions
diff --git a/src/plugins/graphicssystems/trace/qgraphicssystem_trace.cpp b/src/plugins/graphicssystems/trace/qgraphicssystem_trace.cpp index 36a8df1..bbb6536 100644 --- a/src/plugins/graphicssystems/trace/qgraphicssystem_trace.cpp +++ b/src/plugins/graphicssystems/trace/qgraphicssystem_trace.cpp @@ -57,30 +57,35 @@ public: ~QTraceWindowSurface(); QPaintDevice *paintDevice(); + void beginPaint(const QRegion &rgn); void endPaint(const QRegion &rgn); + bool scroll(const QRegion &area, int dx, int dy); + private: QPaintBuffer *buffer; + QList<QRegion> updates; - QFile *outputFile; - QDataStream *out; - - int frameId; + qulonglong winId; }; QTraceWindowSurface::QTraceWindowSurface(QWidget *widget) : QRasterWindowSurface(widget) , buffer(0) - , outputFile(0) - , out(0) - , frameId(0) + , winId(0) { } QTraceWindowSurface::~QTraceWindowSurface() { - delete out; - delete outputFile; + if (buffer) { + QFile outputFile(QString(QLatin1String("qtgraphics-%0.trace")).arg(winId)); + if (outputFile.open(QIODevice::WriteOnly)) { + QDataStream out(&outputFile); + out << *buffer << updates; + } + delete buffer; + } } QPaintDevice *QTraceWindowSurface::paintDevice() @@ -92,28 +97,33 @@ QPaintDevice *QTraceWindowSurface::paintDevice() return buffer; } -void QTraceWindowSurface::endPaint(const QRegion &rgn) +void QTraceWindowSurface::beginPaint(const QRegion &rgn) { - if (!out) { - outputFile = new QFile(QString(QLatin1String("qtgraphics-%0.trace")).arg((qulonglong)window()->winId())); - if (outputFile->open(QIODevice::WriteOnly)) - out = new QDataStream(outputFile); - } + // ensure paint buffer is created + paintDevice(); + buffer->beginNewFrame(); + + QRasterWindowSurface::beginPaint(rgn); +} +void QTraceWindowSurface::endPaint(const QRegion &rgn) +{ QPainter p(QRasterWindowSurface::paintDevice()); - buffer->draw(&p); + buffer->draw(&p, buffer->numFrames()-1); p.end(); - if (out) { - *out << frameId++; - *out << (qulonglong)window()->winId(); - *out << geometry(); - *out << rgn; - *out << *buffer; - } + winId = (qulonglong)window()->winId(); + + updates << rgn; - delete buffer; - buffer = 0; + QRasterWindowSurface::endPaint(rgn); +} + +bool QTraceWindowSurface::scroll(const QRegion &, int, int) +{ + // TODO: scrolling should also be streamed and replayed + // to test scrolling performance + return false; } QTraceGraphicsSystem::QTraceGraphicsSystem() |