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 <QtWidgets/qwidget.h>
20#include <private/qwidget_p.h>
21#include <QtGui/qbackingstore.h>
22
23QT_BEGIN_NAMESPACE
24
25class QPlatformTextureList;
26class QPlatformTextureListWatcher;
27class QWidgetRepaintManager;
28
29class Q_WIDGETS_EXPORT QWidgetRepaintManager
30{
31 Q_GADGET
32public:
33 enum UpdateTime {
34 UpdateNow,
35 UpdateLater
36 };
37 Q_ENUM(UpdateTime)
38
39 enum BufferState{
40 BufferValid,
41 BufferInvalid
42 };
43 Q_ENUM(BufferState)
44
45 QWidgetRepaintManager(QWidget *t);
46 ~QWidgetRepaintManager();
47
48 QBackingStore *backingStore() const { return store; }
49 void setBackingStore(QBackingStore *backingStore) { store = backingStore; }
50
51 template <class T>
52 void markDirty(const T &r, QWidget *widget, UpdateTime updateTime = UpdateLater,
53 BufferState bufferState = BufferValid);
54
55 void removeDirtyWidget(QWidget *w);
56
57 void sync(QWidget *exposedWidget, const QRegion &exposedRegion);
58 void sync();
59
60 void markNeedsFlush(QWidget *widget, const QRegion &region, const QPoint &topLevelOffset);
61
62 void addStaticWidget(QWidget *widget);
63 void moveStaticWidgets(QWidget *reparented);
64 void removeStaticWidget(QWidget *widget);
65 QRegion staticContents(QWidget *widget = nullptr, const QRect &withinClipRect = QRect()) const;
66 QRegion dirtyRegion() const { return dirty; }
67 QList<QWidget *> dirtyWidgetList() const { return dirtyWidgets; }
68 bool isDirty() const;
69
70 bool bltRect(const QRect &rect, int dx, int dy, QWidget *widget);
71
72private:
73 void updateLists(QWidget *widget);
74
75 void addDirtyWidget(QWidget *widget, const QRegion &rgn);
76 void resetWidget(QWidget *widget);
77
78 void addDirtyRenderToTextureWidget(QWidget *widget);
79
80 void sendUpdateRequest(QWidget *widget, UpdateTime updateTime);
81
82 bool syncAllowed();
83 void paintAndFlush();
84
85 void markNeedsFlush(QWidget *widget, const QRegion &region = QRegion());
86
87 void flush();
88 void flush(QWidget *widget, const QRegion &region, QPlatformTextureList *widgetTextures);
89
90 bool hasStaticContents() const;
91 void updateStaticContentsSize();
92
93 QWidget *tlw = nullptr;
94 QBackingStore *store = nullptr;
95
96 QRegion dirty; // needsRepaint
97 QList<QWidget *> dirtyWidgets;
98 QList<QWidget *> dirtyRenderToTextureWidgets;
99
100 QRegion topLevelNeedsFlush;
101 QList<QWidget *> needsFlushWidgets;
102
103 QList<QWidget *> staticWidgets;
104
105 QPlatformTextureListWatcher *textureListWatcher = nullptr;
106
107 bool updateRequestSent = false;
108
109 QElapsedTimer perfTime;
110 int perfFrames = 0;
111
112 Q_DISABLE_COPY_MOVE(QWidgetRepaintManager)
113};
114
115QT_END_NAMESPACE
116
117#endif // QWIDGETREPAINTMANAGER_P_H
118

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