diff options
author | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2015-01-29 18:27:31 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2015-02-05 14:30:24 +0000 |
commit | 91ee17dce350790b53653c197ebafef670150f8e (patch) | |
tree | 84e88d9e010971d6e309bc896e798be6d61ac2a2 | |
parent | 3430e7ce7787cf1c1b1472a0ce0e8770dbff0a7c (diff) |
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 <gunnar@sletta.org>
-rw-r--r-- | src/gui/painting/qpainter.cpp | 17 |
1 files 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; |