From 52a83658c3e930e4b751ea2546baf9b13b1fce5b Mon Sep 17 00:00:00 2001 From: ChunLin Wang Date: Tue, 8 Feb 2022 17:25:51 +0800 Subject: 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. QPainter will no longer try to replace IntersectClip with ReplaceClip if the paint engine is a QPicture.Consistent with QPainter::setClipRect and QPainter::setClipRegion. Fixes: QTBUG-100420 Pick-to: 6.2 6.3 Change-Id: I1e0ebbc2d6e1ffd98b9f3f537e83893579606a4b Reviewed-by: Eirik Aavitsland --- src/gui/painting/qpainter.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/gui/painting/qpainter.cpp') diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index 0ebc6253db..f1b02f3e9b 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -3048,7 +3048,8 @@ void QPainter::setClipPath(const QPainterPath &path, Qt::ClipOperation op) return; } - if ((!d->state->clipEnabled && op != Qt::NoClip)) + bool simplifyClipOp = (paintEngine()->type() != QPaintEngine::Picture); + if (simplifyClipOp && (!d->state->clipEnabled && op != Qt::NoClip)) op = Qt::ReplaceClip; if (d->extended) { @@ -3062,7 +3063,7 @@ void QPainter::setClipPath(const QPainterPath &path, 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->clipPath = path; -- cgit v1.2.3