Avoid pass painting state by value.
Change-Id: I86529ee7357b6cadbaa941b296d7ad025977f2aa
Reviewed-by: Martin Jones <martin.jones@nokia.com>
}
}
-QPen QQuickContext2DCommandBuffer::makePen(QQuickContext2D::State state)
+QPen QQuickContext2DCommandBuffer::makePen(const QQuickContext2D::State& state)
{
QPen pen;
pen.setWidthF(state.lineWidth);
return pen;
}
-void QQuickContext2DCommandBuffer::setPainterState(QPainter* p, QQuickContext2D::State state, const QPen& pen)
+void QQuickContext2DCommandBuffer::setPainterState(QPainter* p, const QQuickContext2D::State& state, const QPen& pen)
{
p->setTransform(state.matrix * p->transform());
p->setCompositionMode(state.globalCompositeOperation);
}
-QQuickContext2D::State QQuickContext2DCommandBuffer::replay(QPainter* p, QQuickContext2D::State state)
+void QQuickContext2DCommandBuffer::replay(QPainter* p, QQuickContext2D::State& state)
{
if (!p)
- return state;
+ return;
reset();
}
p->end();
- return state;
}
QQuickContext2DCommandBuffer::QQuickContext2DCommandBuffer()
inline QColor takeColor() { return colors[colorIdx++]; }
inline QBrush takeBrush() { return brushes[brushIdx++]; }
- QQuickContext2D::State replay(QPainter* painter, QQuickContext2D::State state);
+ void replay(QPainter* painter, QQuickContext2D::State& state);
private:
- QPen makePen(QQuickContext2D::State state);
- void setPainterState(QPainter* painter, QQuickContext2D::State state, const QPen& pen);
+ QPen makePen(const QQuickContext2D::State& state);
+ void setPainterState(QPainter* painter, const QQuickContext2D::State& state, const QPen& pen);
int cmdIdx;
int intIdx;
int boolIdx;
p.setRenderHints(QPainter::Antialiasing | QPainter::HighQualityAntialiasing
| QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform, false);
p.setCompositionMode(QPainter::CompositionMode_SourceOver);
- m_state = ccb->replay(&p, m_state);
+ ccb->replay(&p, m_state);
ccb->clear();
markDirtyTexture();
if (!m_tiledCanvas) {
paintWithoutTiles();
} else {
- QQuickContext2D::State oldState = m_state;
- QQuickContext2DCommandBuffer* ccb = m_context->buffer();
-
lock();
QRect tiledRegion = createTiles(m_canvasWindow.intersected(QRect(QPoint(0, 0), m_canvasSize)));
unlock();
}
if (beginPainting()) {
+ QQuickContext2D::State oldState = m_state;
+ QQuickContext2DCommandBuffer* ccb = m_context->buffer();
foreach (QQuickContext2DTile* tile, m_tiles) {
bool dirtyTile = false, dirtyCanvas = false, smooth = false;
endPainting();
return;
} else if (dirtyTile) {
- m_state = ccb->replay(tile->createPainter(smooth), oldState);
+ ccb->replay(tile->createPainter(smooth), oldState);
tile->drawFinished();
lock();
tile->markDirty(false);
}
ccb->clear();
endPainting();
+ m_state = oldState;
markDirtyTexture();
}
}