widgets: Don't rely on QWidget friending QWidgetRepaintManager

Change-Id: Id9fc28eb62103d38eaa51261f61a2294db85e0d6
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
This commit is contained in:
Tor Arne Vestbø 2019-08-21 15:16:22 +02:00
parent c937f80fe5
commit 68cc2c2779
2 changed files with 55 additions and 56 deletions

View File

@ -11840,9 +11840,9 @@ void QWidget::setBackingStore(QBackingStore *store)
return;
if (isTopLevel()) {
if (repaintManager->store != oldStore && repaintManager->store != store)
delete repaintManager->store;
repaintManager->store = store;
if (repaintManager->backingStore() != oldStore && repaintManager->backingStore() != store)
delete repaintManager->backingStore();
repaintManager->setBackingStore(store);
}
}
@ -11859,7 +11859,7 @@ QBackingStore *QWidget::backingStore() const
return extra->backingStore;
QWidgetRepaintManager *repaintManager = d->maybeRepaintManager();
return repaintManager ? repaintManager->store : nullptr;
return repaintManager ? repaintManager->backingStore() : nullptr;
}
void QWidgetPrivate::getLayoutItemMargins(int *left, int *top, int *right, int *bottom) const

View File

@ -100,19 +100,58 @@ public:
void sync(QWidget *exposedWidget, const QRegion &exposedRegion);
void sync();
void flush(QWidget *widget = nullptr);
QBackingStore *backingStore() const { return store; }
inline bool isDirty() const
{
return !(dirtyWidgets.isEmpty() && dirty.isEmpty() && dirtyRenderToTextureWidgets.isEmpty());
}
void setBackingStore(QBackingStore *backingStore) { store = backingStore; }
template <class T>
void markDirty(const T &r, QWidget *widget, UpdateTime updateTime = UpdateLater,
BufferState bufferState = BufferValid);
void removeDirtyWidget(QWidget *w);
inline void addStaticWidget(QWidget *widget)
{
if (!widget)
return;
Q_ASSERT(widget->testAttribute(Qt::WA_StaticContents));
if (!staticWidgets.contains(widget))
staticWidgets.append(widget);
}
// Move the reparented widget and all its static children from this backing store
// to the new backing store if reparented into another top-level / backing store.
inline void moveStaticWidgets(QWidget *reparented)
{
Q_ASSERT(reparented);
QWidgetRepaintManager *newPaintManager = reparented->d_func()->maybeRepaintManager();
if (newPaintManager == this)
return;
int i = 0;
while (i < staticWidgets.size()) {
QWidget *w = staticWidgets.at(i);
if (reparented == w || reparented->isAncestorOf(w)) {
staticWidgets.removeAt(i);
if (newPaintManager)
newPaintManager->addStaticWidget(w);
} else {
++i;
}
}
}
inline void removeStaticWidget(QWidget *widget)
{
staticWidgets.removeAll(widget);
}
QRegion staticContents(QWidget *widget = nullptr, const QRect &withinClipRect = QRect()) const;
void markDirtyOnScreen(const QRegion &dirtyOnScreen, QWidget *widget, const QPoint &topLevelOffset);
bool bltRect(const QRect &rect, int dx, int dy, QWidget *widget);
private:
QWidget *tlw;
QRegion dirtyOnScreen; // needsFlush
@ -131,20 +170,19 @@ private:
void sendUpdateRequest(QWidget *widget, UpdateTime updateTime);
void flush(QWidget *widget, const QRegion &region, QPlatformTextureList *widgetTextures);
inline bool isDirty() const
{
return !(dirtyWidgets.isEmpty() && dirty.isEmpty() && dirtyRenderToTextureWidgets.isEmpty());
}
void doSync();
bool bltRect(const QRect &rect, int dx, int dy, QWidget *widget);
void flush(QWidget *widget = nullptr);
void flush(QWidget *widget, const QRegion &region, QPlatformTextureList *widgetTextures);
void beginPaint(QRegion &toClean, QBackingStore *backingStore);
void endPaint(QBackingStore *backingStore);
QRegion dirtyRegion(QWidget *widget = nullptr) const;
QRegion staticContents(QWidget *widget = nullptr, const QRect &withinClipRect = QRect()) const;
void markDirtyOnScreen(const QRegion &dirtyOnScreen, QWidget *widget, const QPoint &topLevelOffset);
void removeDirtyWidget(QWidget *w);
void updateLists(QWidget *widget);
@ -175,41 +213,6 @@ private:
}
}
inline void addStaticWidget(QWidget *widget)
{
if (!widget)
return;
Q_ASSERT(widget->testAttribute(Qt::WA_StaticContents));
if (!staticWidgets.contains(widget))
staticWidgets.append(widget);
}
inline void removeStaticWidget(QWidget *widget)
{ staticWidgets.removeAll(widget); }
// Move the reparented widget and all its static children from this backing store
// to the new backing store if reparented into another top-level / backing store.
inline void moveStaticWidgets(QWidget *reparented)
{
Q_ASSERT(reparented);
QWidgetRepaintManager *newPaintManager = reparented->d_func()->maybeRepaintManager();
if (newPaintManager == this)
return;
int i = 0;
while (i < staticWidgets.size()) {
QWidget *w = staticWidgets.at(i);
if (reparented == w || reparented->isAncestorOf(w)) {
staticWidgets.removeAt(i);
if (newPaintManager)
newPaintManager->addStaticWidget(w);
} else {
++i;
}
}
}
inline QRect topLevelRect() const
{
return tlw->data->crect;
@ -253,10 +256,6 @@ private:
#endif
}
friend class QWidgetPrivate;
friend class QWidget;
friend class QBackingStore;
Q_DISABLE_COPY_MOVE(QWidgetRepaintManager)
};