widgets: Share more code in appendDirtyOnScreenWidget

Change-Id: I0ed936c7d8b004d498a8956b1ba246ade41ce43d
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
This commit is contained in:
Tor Arne Vestbø 2019-08-22 17:11:56 +02:00
parent 655e8b6eab
commit ca3b48539d
2 changed files with 12 additions and 17 deletions

View File

@ -922,9 +922,6 @@ void QWidgetRepaintManager::paintAndFlush()
if (hasPlatformWindow(w) || (npw && npw != tlw)) { if (hasPlatformWindow(w) || (npw && npw != tlw)) {
if (!hasPlatformWindow(w)) if (!hasPlatformWindow(w))
w = npw; w = npw;
QWidgetPrivate *wPrivate = w->d_func();
if (!wPrivate->needsFlush)
wPrivate->needsFlush = new QRegion;
appendDirtyOnScreenWidget(w); appendDirtyOnScreenWidget(w);
} }
} }
@ -1039,29 +1036,27 @@ void QWidgetRepaintManager::markDirtyOnScreen(const QRegion &region, QWidget *wi
return; return;
} }
// Alien widgets with native parent != tlw. // Alien widgets with native parent != tlw
QWidgetPrivate *nativeParentPrivate = nativeParent->d_func();
if (!nativeParentPrivate->needsFlush)
nativeParentPrivate->needsFlush = new QRegion;
const QPoint nativeParentOffset = widget->mapTo(nativeParent, QPoint()); const QPoint nativeParentOffset = widget->mapTo(nativeParent, QPoint());
*nativeParentPrivate->needsFlush += region.translated(nativeParentOffset); appendDirtyOnScreenWidget(nativeParent, region.translated(nativeParentOffset));
appendDirtyOnScreenWidget(nativeParent);
return; return;
} }
// Native child widgets. // Native child widgets
QWidgetPrivate *widgetPrivate = widget->d_func(); appendDirtyOnScreenWidget(widget, region);
if (!widgetPrivate->needsFlush)
widgetPrivate->needsFlush = new QRegion;
*widgetPrivate->needsFlush += region;
appendDirtyOnScreenWidget(widget);
} }
void QWidgetRepaintManager::appendDirtyOnScreenWidget(QWidget *widget) void QWidgetRepaintManager::appendDirtyOnScreenWidget(QWidget *widget, const QRegion &region)
{ {
if (!widget) if (!widget)
return; return;
auto *widgetPrivate = qt_widget_private(widget);
if (!widgetPrivate->needsFlush)
widgetPrivate->needsFlush = new QRegion;
*widgetPrivate->needsFlush += region;
if (!dirtyOnScreenWidgets.contains(widget)) if (!dirtyOnScreenWidgets.contains(widget))
dirtyOnScreenWidgets.append(widget); dirtyOnScreenWidgets.append(widget);
} }

View File

@ -113,7 +113,7 @@ private:
bool syncAllowed(); bool syncAllowed();
void paintAndFlush(); void paintAndFlush();
void appendDirtyOnScreenWidget(QWidget *widget); void appendDirtyOnScreenWidget(QWidget *widget, const QRegion &region = QRegion());
void flush(QWidget *widget = nullptr); void flush(QWidget *widget = nullptr);
void flush(QWidget *widget, const QRegion &region, QPlatformTextureList *widgetTextures); void flush(QWidget *widget, const QRegion &region, QPlatformTextureList *widgetTextures);