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/gui | |
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/gui')
-rw-r--r-- | src/gui/painting/qpaintbuffer.cpp | 26 | ||||
-rw-r--r-- | src/gui/painting/qpaintbuffer_p.h | 8 |
2 files changed, 27 insertions, 7 deletions
diff --git a/src/gui/painting/qpaintbuffer.cpp b/src/gui/painting/qpaintbuffer.cpp index 7de9063..f9cb108 100644 --- a/src/gui/painting/qpaintbuffer.cpp +++ b/src/gui/painting/qpaintbuffer.cpp @@ -239,7 +239,7 @@ bool QPaintBuffer::isEmpty() const -void QPaintBuffer::draw(QPainter *painter) const +void QPaintBuffer::draw(QPainter *painter, int frame) const { #ifdef QPAINTBUFFER_DEBUG_DRAW qDebug() << "QPaintBuffer::draw() --------------------------------"; @@ -270,10 +270,10 @@ void QPaintBuffer::draw(QPainter *painter) const ? (QPaintEngineEx *) painter->paintEngine() : 0; if (xengine) { QPaintEngineExReplayer player; - player.draw(*this, painter); + player.draw(*this, painter, frame); } else { QPainterReplayer player; - player.draw(*this, painter); + player.draw(*this, painter, frame); } #ifdef QPAINTBUFFER_DEBUG_DRAW @@ -1035,17 +1035,31 @@ void QPainterReplayer::setupTransform(QPainter *_painter) painter->setTransform(m_world_matrix); } -void QPainterReplayer::draw(const QPaintBuffer &buffer, QPainter *_painter) +void QPainterReplayer::draw(const QPaintBuffer &buffer, QPainter *_painter, int frame) { d = buffer.d_ptr; setupTransform(_painter); - for (int cmdIndex=0; cmdIndex<d->commands.size(); ++cmdIndex) { + int frameStart = (frame == 0) ? 0 : d->frames.at(frame-1); + int frameEnd = (frame == d->frames.size()) ? d->commands.size() : d->frames.at(frame); + + for (int cmdIndex=frameStart; cmdIndex<frameEnd; ++cmdIndex) { const QPaintBufferCommand &cmd = d->commands.at(cmdIndex); process(cmd); } } +void QPaintBuffer::beginNewFrame() +{ + if (!d_ptr->commands.isEmpty()) + d_ptr->frames << d_ptr->commands.size(); +} + +int QPaintBuffer::numFrames() const +{ + return d_ptr->frames.size() + 1; +} + void QPainterReplayer::process(const QPaintBufferCommand &cmd) { switch (cmd.id) { @@ -1783,6 +1797,7 @@ QDataStream &operator<<(QDataStream &stream, const QPaintBuffer &buffer) stream << variants; stream << buffer.d_ptr->commands; stream << buffer.d_ptr->boundingRect; + stream << buffer.d_ptr->frames; return stream; } @@ -1800,6 +1815,7 @@ QDataStream &operator>>(QDataStream &stream, QPaintBuffer &buffer) stream >> buffer.d_ptr->variants; stream >> buffer.d_ptr->commands; stream >> buffer.d_ptr->boundingRect; + stream >> buffer.d_ptr->frames; QVector<QVariant> &variants = buffer.d_ptr->variants; for (int i = 0; i < variants.size(); ++i) { diff --git a/src/gui/painting/qpaintbuffer_p.h b/src/gui/painting/qpaintbuffer_p.h index b360279..2cb1d7c 100644 --- a/src/gui/painting/qpaintbuffer_p.h +++ b/src/gui/painting/qpaintbuffer_p.h @@ -71,7 +71,10 @@ public: bool isEmpty() const; - void draw(QPainter *painter) const; + void beginNewFrame(); + int numFrames() const; + + void draw(QPainter *painter, int frame = 0) const; void setBoundingRect(const QRectF &rect); QRectF boundingRect() const; @@ -270,6 +273,7 @@ public: QVector<QVariant> variants; QVector<QPaintBufferCommand> commands; + QList<int> frames; QPaintBufferEngine *engine; QRectF boundingRect; @@ -306,7 +310,7 @@ public: void setupTransform(QPainter *painter); void process(const QPaintBufferCommand &cmd); - void draw(const QPaintBuffer &buffer, QPainter *painter); + void draw(const QPaintBuffer &buffer, QPainter *painter, int frame); protected: QPaintBufferPrivate *d; |