Share QWidget update and repaint code for QRect and QRegion
QWidgetBackingStore::markDirty has an optimization for QRect, so we don't want to unify these two functions by calling update/repaint(QRegion(rect)). Change-Id: Id2a42f478f71863da45697041e0ab0130c74b9d2 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>bb10
parent
3d65284b60
commit
d48c502ce5
|
|
@ -11012,21 +11012,7 @@ void QWidget::repaint(int x, int y, int w, int h)
|
|||
void QWidget::repaint(const QRect &rect)
|
||||
{
|
||||
Q_D(QWidget);
|
||||
|
||||
if (testAttribute(Qt::WA_WState_ConfigPending)) {
|
||||
update(rect);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isVisible() || !updatesEnabled() || rect.isEmpty())
|
||||
return;
|
||||
|
||||
QTLWExtra *tlwExtra = window()->d_func()->maybeTopData();
|
||||
if (tlwExtra && !tlwExtra->inTopLevelResize && tlwExtra->backingStore) {
|
||||
tlwExtra->inRepaint = true;
|
||||
tlwExtra->backingStoreTracker->markDirty(rect, this, QWidgetBackingStore::UpdateNow);
|
||||
tlwExtra->inRepaint = false;
|
||||
}
|
||||
d->repaint(rect);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
@ -11037,19 +11023,21 @@ void QWidget::repaint(const QRect &rect)
|
|||
void QWidget::repaint(const QRegion &rgn)
|
||||
{
|
||||
Q_D(QWidget);
|
||||
d->repaint(rgn);
|
||||
}
|
||||
|
||||
if (testAttribute(Qt::WA_WState_ConfigPending)) {
|
||||
update(rgn);
|
||||
return;
|
||||
}
|
||||
template <typename T>
|
||||
void QWidgetPrivate::repaint(T r)
|
||||
{
|
||||
Q_Q(QWidget);
|
||||
|
||||
if (!isVisible() || !updatesEnabled() || rgn.isEmpty())
|
||||
if (!q->isVisible() || !q->updatesEnabled() || r.isEmpty())
|
||||
return;
|
||||
|
||||
QTLWExtra *tlwExtra = window()->d_func()->maybeTopData();
|
||||
QTLWExtra *tlwExtra = q->window()->d_func()->maybeTopData();
|
||||
if (tlwExtra && !tlwExtra->inTopLevelResize && tlwExtra->backingStore) {
|
||||
tlwExtra->inRepaint = true;
|
||||
tlwExtra->backingStoreTracker->markDirty(rgn, this, QWidgetBackingStore::UpdateNow);
|
||||
tlwExtra->backingStoreTracker->markDirty(r, q, QWidgetBackingStore::UpdateNow);
|
||||
tlwExtra->inRepaint = false;
|
||||
}
|
||||
}
|
||||
|
|
@ -11091,22 +11079,8 @@ void QWidget::update()
|
|||
*/
|
||||
void QWidget::update(const QRect &rect)
|
||||
{
|
||||
if (!isVisible() || !updatesEnabled())
|
||||
return;
|
||||
|
||||
QRect r = rect & QWidget::rect();
|
||||
|
||||
if (r.isEmpty())
|
||||
return;
|
||||
|
||||
if (testAttribute(Qt::WA_WState_InPaintEvent)) {
|
||||
QApplication::postEvent(this, new QUpdateLaterEvent(r));
|
||||
return;
|
||||
}
|
||||
|
||||
QTLWExtra *tlwExtra = window()->d_func()->maybeTopData();
|
||||
if (tlwExtra && !tlwExtra->inTopLevelResize && tlwExtra->backingStore)
|
||||
tlwExtra->backingStoreTracker->markDirty(r, this);
|
||||
Q_D(QWidget);
|
||||
d->update(rect);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
@ -11116,25 +11090,33 @@ void QWidget::update(const QRect &rect)
|
|||
*/
|
||||
void QWidget::update(const QRegion &rgn)
|
||||
{
|
||||
if (!isVisible() || !updatesEnabled())
|
||||
Q_D(QWidget);
|
||||
d->update(rgn);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void QWidgetPrivate::update(T r)
|
||||
{
|
||||
Q_Q(QWidget);
|
||||
|
||||
if (!q->isVisible() || !q->updatesEnabled())
|
||||
return;
|
||||
|
||||
QRegion r = rgn & QWidget::rect();
|
||||
T clipped = r & q->rect();
|
||||
|
||||
if (r.isEmpty())
|
||||
if (clipped.isEmpty())
|
||||
return;
|
||||
|
||||
if (testAttribute(Qt::WA_WState_InPaintEvent)) {
|
||||
QApplication::postEvent(this, new QUpdateLaterEvent(r));
|
||||
if (q->testAttribute(Qt::WA_WState_InPaintEvent)) {
|
||||
QApplication::postEvent(q, new QUpdateLaterEvent(clipped));
|
||||
return;
|
||||
}
|
||||
|
||||
QTLWExtra *tlwExtra = window()->d_func()->maybeTopData();
|
||||
QTLWExtra *tlwExtra = q->window()->d_func()->maybeTopData();
|
||||
if (tlwExtra && !tlwExtra->inTopLevelResize && tlwExtra->backingStore)
|
||||
tlwExtra->backingStoreTracker->markDirty(r, this);
|
||||
tlwExtra->backingStoreTracker->markDirty(clipped, q);
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
\internal
|
||||
|
||||
|
|
|
|||
|
|
@ -342,6 +342,13 @@ public:
|
|||
QPainter *sharedPainter() const;
|
||||
void setSharedPainter(QPainter *painter);
|
||||
QWidgetBackingStore *maybeBackingStore() const;
|
||||
|
||||
template <typename T>
|
||||
void repaint(T t);
|
||||
|
||||
template <typename T>
|
||||
void update(T t);
|
||||
|
||||
void init(QWidget *desktopWidget, Qt::WindowFlags f);
|
||||
void create_sys(WId window, bool initializeWindow, bool destroyOldWindow);
|
||||
void createRecursively();
|
||||
|
|
|
|||
Loading…
Reference in New Issue