summaryrefslogtreecommitdiffstats
path: root/src/widgets/kernel
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@qt.io>2019-08-21 15:16:22 +0200
committerTor Arne Vestbø <tor.arne.vestbo@qt.io>2019-08-22 09:44:20 +0200
commit68cc2c2779aa8f75c14415ecbd19a9c6fdee6ac5 (patch)
treecc3066f01d5c55bc965abb2deb06cd7c7a6e461c /src/widgets/kernel
parentc937f80fe5f8c13ef99882ba96b11fbea0cba156 (diff)
widgets: Don't rely on QWidget friending QWidgetRepaintManager
Change-Id: Id9fc28eb62103d38eaa51261f61a2294db85e0d6 Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
Diffstat (limited to 'src/widgets/kernel')
-rw-r--r--src/widgets/kernel/qwidget.cpp8
-rw-r--r--src/widgets/kernel/qwidgetrepaintmanager_p.h103
2 files changed, 55 insertions, 56 deletions
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp
index 00d91a13c9..d098d9cc04 100644
--- a/src/widgets/kernel/qwidget.cpp
+++ b/src/widgets/kernel/qwidget.cpp
@@ -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
diff --git a/src/widgets/kernel/qwidgetrepaintmanager_p.h b/src/widgets/kernel/qwidgetrepaintmanager_p.h
index 0620ab99e2..ac671c18c0 100644
--- a/src/widgets/kernel/qwidgetrepaintmanager_p.h
+++ b/src/widgets/kernel/qwidgetrepaintmanager_p.h
@@ -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)
};