summaryrefslogtreecommitdiffstats
path: root/src/plugins/graphicssystems/trace/qgraphicssystem_trace.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/graphicssystems/trace/qgraphicssystem_trace.cpp')
-rw-r--r--src/plugins/graphicssystems/trace/qgraphicssystem_trace.cpp60
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()