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

View File

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