1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QWIDGETREPAINTMANAGER_P_H
5#define QWIDGETREPAINTMANAGER_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtWidgets/private/qtwidgetsglobal_p.h>
19#include <QDebug>
20#include <QtWidgets/qwidget.h>
21#include <private/qwidget_p.h>
22#include <QtGui/qbackingstore.h>
23
24QT_BEGIN_NAMESPACE
25
26class QPlatformTextureList;
27class QPlatformTextureListWatcher;
28class QWidgetRepaintManager;
29class QRhi;
30class QRhiSwapChain;
31
32class Q_WIDGETS_EXPORT QWidgetRepaintManager
33{
34 Q_GADGET
35public:
36 enum UpdateTime {
37 UpdateNow,
38 UpdateLater
39 };
40 Q_ENUM(UpdateTime)
41
42 enum BufferState{
43 BufferValid,
44 BufferInvalid
45 };
46 Q_ENUM(BufferState)
47
48 QWidgetRepaintManager(QWidget *t);
49 ~QWidgetRepaintManager();
50
51 QBackingStore *backingStore() const { return store; }
52 void setBackingStore(QBackingStore *backingStore) { store = backingStore; }
53
54 template <class T>
55 void markDirty(const T &r, QWidget *widget, UpdateTime updateTime = UpdateLater,
56 BufferState bufferState = BufferValid);
57
58 void removeDirtyWidget(QWidget *w);
59
60 void sync(QWidget *exposedWidget, const QRegion &exposedRegion);
61 void sync();
62
63 void markNeedsFlush(QWidget *widget, const QRegion &region, const QPoint &topLevelOffset);
64
65 void addStaticWidget(QWidget *widget);
66 void moveStaticWidgets(QWidget *reparented);
67 void removeStaticWidget(QWidget *widget);
68 QRegion staticContents(QWidget *widget = nullptr, const QRect &withinClipRect = QRect()) const;
69 QRegion dirtyRegion() const { return dirty; }
70 QList<QWidget *> dirtyWidgetList() const { return dirtyWidgets; }
71 bool isDirty() const;
72
73 bool bltRect(const QRect &rect, int dx, int dy, QWidget *widget);
74
75 QRhi *rhi() const;
76
77private:
78 void updateLists(QWidget *widget);
79
80 void addDirtyWidget(QWidget *widget, const QRegion &rgn);
81 void resetWidget(QWidget *widget);
82
83 void addDirtyRenderToTextureWidget(QWidget *widget);
84
85 void sendUpdateRequest(QWidget *widget, UpdateTime updateTime);
86
87 bool syncAllowed();
88 void paintAndFlush();
89
90 void markNeedsFlush(QWidget *widget, const QRegion &region = QRegion());
91
92 void flush();
93 void flush(QWidget *widget, const QRegion &region, QPlatformTextureList *widgetTextures);
94
95 bool hasStaticContents() const;
96 void updateStaticContentsSize();
97
98 QWidget *tlw = nullptr;
99 QBackingStore *store = nullptr;
100
101 QRegion dirty; // needsRepaint
102 QList<QWidget *> dirtyWidgets;
103 QList<QWidget *> dirtyRenderToTextureWidgets;
104
105 QRegion topLevelNeedsFlush;
106 QList<QWidget *> needsFlushWidgets;
107
108 QList<QWidget *> staticWidgets;
109
110 QPlatformTextureListWatcher *textureListWatcher = nullptr;
111
112 bool updateRequestSent = false;
113
114 QElapsedTimer perfTime;
115 int perfFrames = 0;
116
117 Q_DISABLE_COPY_MOVE(QWidgetRepaintManager)
118};
119
120QT_END_NAMESPACE
121
122#endif // QWIDGETREPAINTMANAGER_P_H
123

source code of qtbase/src/widgets/kernel/qwidgetrepaintmanager_p.h