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