From 91ee17dce350790b53653c197ebafef670150f8e Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Thu, 29 Jan 2015 18:27:31 +0100 Subject: [PATCH] Don't replace IntersectClip with ReplaceClip on a QPicture QPainter should not try to be smart and optimize IntersectClip with ReplaceClip when working on a QPicture paint device. Doing so will change the end result as the actually state when replayed might be different from the one it was recorded in. [ChangeLog][QtGui][QPainter] QPainter will no longer try to replace IntersectClip with ReplaceClip if the paint engine is a QPicture. Task-number: QTBUG-35830 Change-Id: I0693d932f037336b960c34bb8fe840e8afe04fe6 Reviewed-by: Gunnar Sletta --- src/gui/painting/qpainter.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index 4ff334a6d6..39e2285cd3 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -2720,13 +2720,14 @@ void QPainter::setClipRect(const QRectF &rect, Qt::ClipOperation op) Q_D(QPainter); if (d->extended) { - if ((!d->state->clipEnabled && op != Qt::NoClip)) - op = Qt::ReplaceClip; - if (!d->engine) { qWarning("QPainter::setClipRect: Painter not active"); return; } + bool simplifyClipOp = (paintEngine()->type() != QPaintEngine::Picture); + if (simplifyClipOp && (!d->state->clipEnabled && op != Qt::NoClip)) + op = Qt::ReplaceClip; + qreal right = rect.x() + rect.width(); qreal bottom = rect.y() + rect.height(); qreal pts[] = { rect.x(), rect.y(), @@ -2777,8 +2778,9 @@ void QPainter::setClipRect(const QRect &rect, Qt::ClipOperation op) qWarning("QPainter::setClipRect: Painter not active"); return; } + bool simplifyClipOp = (paintEngine()->type() != QPaintEngine::Picture); - if ((!d->state->clipEnabled && op != Qt::NoClip)) + if (simplifyClipOp && (!d->state->clipEnabled && op != Qt::NoClip)) op = Qt::ReplaceClip; if (d->extended) { @@ -2791,7 +2793,7 @@ void QPainter::setClipRect(const QRect &rect, Qt::ClipOperation op) return; } - if (d->state->clipOperation == Qt::NoClip && op == Qt::IntersectClip) + if (simplifyClipOp && d->state->clipOperation == Qt::NoClip && op == Qt::IntersectClip) op = Qt::ReplaceClip; d->state->clipRegion = rect; @@ -2835,8 +2837,9 @@ void QPainter::setClipRegion(const QRegion &r, Qt::ClipOperation op) qWarning("QPainter::setClipRegion: Painter not active"); return; } + bool simplifyClipOp = (paintEngine()->type() != QPaintEngine::Picture); - if ((!d->state->clipEnabled && op != Qt::NoClip)) + if (simplifyClipOp && (!d->state->clipEnabled && op != Qt::NoClip)) op = Qt::ReplaceClip; if (d->extended) { @@ -2849,7 +2852,7 @@ void QPainter::setClipRegion(const QRegion &r, Qt::ClipOperation op) return; } - if (d->state->clipOperation == Qt::NoClip && op == Qt::IntersectClip) + if (simplifyClipOp && d->state->clipOperation == Qt::NoClip && op == Qt::IntersectClip) op = Qt::ReplaceClip; d->state->clipRegion = r;