Widgets: Use effect region bounds when drawing with repaint manager

When drawing widgets with graphics effect using repaint manager,
if we do not combine the effect region some child widgets are not
affected by the graphics effect since they are not included in the dirty
region. However always using region bounds breaks the referenced bug use case.

Fixes: QTBUG-102374
Pick-to: 6.3 6.2 5.15
Change-Id: Iaf4eaba34db863500a0600b344e5062f2b36b9bf
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
bb10
Antti Määttä 2022-05-10 08:51:52 +03:00
parent b576d7f6d1
commit a382134a40
3 changed files with 6 additions and 3 deletions

View File

@ -5461,7 +5461,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP
QWidgetEffectSourcePrivate *sourced = static_cast<QWidgetEffectSourcePrivate *>
(source->d_func());
if (!sourced->context) {
const QRegion effectRgn(rgn.boundingRect());
const QRegion effectRgn((flags & UseEffectRegionBounds) ? rgn.boundingRect() : rgn);
QWidgetPaintContext context(pdev, effectRgn, offset, flags, sharedPainter, repaintManager);
sourced->context = &context;
if (!sharedPainter) {
@ -5493,6 +5493,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP
}
}
#endif // QT_CONFIG(graphicseffect)
flags = flags & ~UseEffectRegionBounds;
const bool alsoOnScreen = flags & DrawPaintOnScreen;
const bool recursive = flags & DrawRecursive;

View File

@ -189,7 +189,8 @@ public:
DontSubtractOpaqueChildren = 0x10,
DontDrawOpaqueChildren = 0x20,
DontDrawNativeChildren = 0x40,
DontSetCompositionMode = 0x80
DontSetCompositionMode = 0x80,
UseEffectRegionBounds = 0x100
};
Q_DECLARE_FLAGS(DrawWidgetFlags, DrawWidgetFlag)
Q_FLAG(DrawWidgetFlags)

View File

@ -897,7 +897,8 @@ void QWidgetRepaintManager::paintAndFlush()
// Paint the rest with composition.
if (repaintAllWidgets || !dirtyCopy.isEmpty()) {
QWidgetPrivate::DrawWidgetFlags flags = QWidgetPrivate::DrawAsRoot | QWidgetPrivate::DrawRecursive;
QWidgetPrivate::DrawWidgetFlags flags = QWidgetPrivate::DrawAsRoot | QWidgetPrivate::DrawRecursive
| QWidgetPrivate::UseEffectRegionBounds;
tlw->d_func()->drawWidget(store->paintDevice(), dirtyCopy, QPoint(), flags, nullptr, this);
}