/src/qtbase/src/gui/painting/qplatformbackingstore.h
Line | Count | Source |
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 | | // Qt-Security score:significant reason:default |
4 | | |
5 | | #ifndef QPLATFORMBACKINGSTORE_H |
6 | | #define QPLATFORMBACKINGSTORE_H |
7 | | |
8 | | // |
9 | | // W A R N I N G |
10 | | // ------------- |
11 | | // |
12 | | // This file is part of the QPA API and is not meant to be used |
13 | | // in applications. Usage of this API may make your code |
14 | | // source and binary incompatible with future versions of Qt. |
15 | | // |
16 | | |
17 | | #include <QtGui/qtguiglobal.h> |
18 | | #include <QtCore/qloggingcategory.h> |
19 | | #include <QtCore/qrect.h> |
20 | | #include <QtCore/qobject.h> |
21 | | |
22 | | #include <QtGui/qwindow.h> |
23 | | #include <QtGui/qregion.h> |
24 | | |
25 | | QT_BEGIN_NAMESPACE |
26 | | |
27 | | QT_DECLARE_EXPORTED_QT_LOGGING_CATEGORY(lcQpaBackingStore, Q_GUI_EXPORT) |
28 | | |
29 | | class QRegion; |
30 | | class QRect; |
31 | | class QPoint; |
32 | | class QImage; |
33 | | class QPlatformBackingStorePrivate; |
34 | | class QPlatformTextureList; |
35 | | class QPlatformTextureListPrivate; |
36 | | class QPlatformGraphicsBuffer; |
37 | | class QRhi; |
38 | | class QRhiTexture; |
39 | | class QRhiResourceUpdateBatch; |
40 | | |
41 | | struct Q_GUI_EXPORT QPlatformBackingStoreRhiConfig |
42 | | { |
43 | | Q_GADGET |
44 | | public: |
45 | | enum Api { |
46 | | OpenGL, |
47 | | Metal, |
48 | | Vulkan, |
49 | | D3D11, |
50 | | D3D12, |
51 | | Null |
52 | | }; |
53 | 0 | Q_ENUM(Api) Unexecuted instantiation: qt_getEnumMetaObject(QPlatformBackingStoreRhiConfig::Api) Unexecuted instantiation: qt_getEnumName(QPlatformBackingStoreRhiConfig::Api) |
54 | 0 |
|
55 | 0 | QPlatformBackingStoreRhiConfig() |
56 | 0 | : m_enable(false) |
57 | 0 | { } |
58 | | |
59 | | QPlatformBackingStoreRhiConfig(Api api) |
60 | | : m_enable(true), |
61 | | m_api(api) |
62 | 0 | { } |
63 | | |
64 | 0 | bool isEnabled() const { return m_enable; } |
65 | 0 | void setEnabled(bool enable) { m_enable = enable; } |
66 | | |
67 | 0 | Api api() const { return m_api; } |
68 | 0 | void setApi(Api api) { m_api = api; } |
69 | | |
70 | 0 | bool isDebugLayerEnabled() const { return m_debugLayer; } |
71 | 0 | void setDebugLayer(bool enable) { m_debugLayer = enable; } |
72 | | |
73 | | private: |
74 | | bool m_enable; |
75 | | Api m_api = Null; |
76 | | bool m_debugLayer = false; |
77 | | friend bool operator==(const QPlatformBackingStoreRhiConfig &a, const QPlatformBackingStoreRhiConfig &b); |
78 | | }; |
79 | | |
80 | | inline bool operator==(const QPlatformBackingStoreRhiConfig &a, const QPlatformBackingStoreRhiConfig &b) |
81 | 0 | { |
82 | 0 | return a.m_enable == b.m_enable |
83 | 0 | && a.m_api == b.m_api |
84 | 0 | && a.m_debugLayer == b.m_debugLayer; |
85 | 0 | } |
86 | | |
87 | | inline bool operator!=(const QPlatformBackingStoreRhiConfig &a, const QPlatformBackingStoreRhiConfig &b) |
88 | 0 | { |
89 | 0 | return !(a == b); |
90 | 0 | } |
91 | | |
92 | | class Q_GUI_EXPORT QPlatformTextureList : public QObject |
93 | | { |
94 | 0 | Q_OBJECT |
95 | 0 | Q_DECLARE_PRIVATE(QPlatformTextureList) Unexecuted instantiation: QPlatformTextureList::d_func() Unexecuted instantiation: QPlatformTextureList::d_func() const |
96 | 0 | public: |
97 | 0 | enum Flag { |
98 | 0 | StacksOnTop = 0x01, |
99 | 0 | TextureIsSrgb = 0x02, |
100 | 0 | NeedsPremultipliedAlphaBlending = 0x04, |
101 | 0 | MirrorVertically = 0x08 |
102 | 0 | }; |
103 | 0 | Q_DECLARE_FLAGS(Flags, Flag) |
104 | 0 |
|
105 | 0 | explicit QPlatformTextureList(QObject *parent = nullptr); |
106 | 0 | ~QPlatformTextureList(); |
107 | 0 |
|
108 | 0 | int count() const; |
109 | 0 | bool isEmpty() const { return count() == 0; } |
110 | | QRhiTexture *texture(int index) const; |
111 | | QRhiTexture *textureExtra(int index) const; |
112 | | QRect geometry(int index) const; |
113 | | QRect clipRect(int index) const; |
114 | | void *source(int index); |
115 | | Flags flags(int index) const; |
116 | | void lock(bool on); |
117 | | bool isLocked() const; |
118 | | |
119 | | void appendTexture(void *source, QRhiTexture *texture, const QRect &geometry, |
120 | | const QRect &clipRect = QRect(), Flags flags = { }); |
121 | | |
122 | | void appendTexture(void *source, QRhiTexture *textureLeft, QRhiTexture *textureRight, const QRect &geometry, |
123 | | const QRect &clipRect = QRect(), Flags flags = { }); |
124 | | void clear(); |
125 | | |
126 | | Q_SIGNALS: |
127 | | void locked(bool); |
128 | | }; |
129 | 0 | Q_DECLARE_OPERATORS_FOR_FLAGS(QPlatformTextureList::Flags) Unexecuted instantiation: operator|(QPlatformTextureList::Flag, QPlatformTextureList::Flag) Unexecuted instantiation: operator|(QPlatformTextureList::Flag, QFlags<QPlatformTextureList::Flag>) Unexecuted instantiation: operator&(QPlatformTextureList::Flag, QPlatformTextureList::Flag) Unexecuted instantiation: operator&(QPlatformTextureList::Flag, QFlags<QPlatformTextureList::Flag>) Unexecuted instantiation: operator^(QPlatformTextureList::Flag, QPlatformTextureList::Flag) Unexecuted instantiation: operator^(QPlatformTextureList::Flag, QFlags<QPlatformTextureList::Flag>) Unexecuted instantiation: operator|(QPlatformTextureList::Flag, int) |
130 | 0 |
|
131 | 0 | class Q_GUI_EXPORT QPlatformBackingStore |
132 | 0 | { |
133 | 0 | public: |
134 | 0 | enum FlushResult { |
135 | 0 | FlushSuccess, |
136 | 0 | FlushFailed, |
137 | 0 | FlushFailedDueToLostDevice |
138 | 0 | }; |
139 | 0 |
|
140 | 0 | explicit QPlatformBackingStore(QWindow *window); |
141 | 0 | virtual ~QPlatformBackingStore(); |
142 | 0 |
|
143 | 0 | QWindow *window() const; |
144 | 0 | QBackingStore *backingStore() const; |
145 | 0 |
|
146 | 0 | virtual QPaintDevice *paintDevice() = 0; |
147 | 0 |
|
148 | 0 | virtual void flush(QWindow *window, const QRegion ®ion, const QPoint &offset); |
149 | 0 |
|
150 | 0 | virtual FlushResult rhiFlush(QWindow *window, |
151 | 0 | qreal sourceDevicePixelRatio, |
152 | 0 | const QRegion ®ion, |
153 | 0 | const QPoint &offset, |
154 | 0 | QPlatformTextureList *textures, |
155 | 0 | bool translucentBackground, |
156 | 0 | qreal sourceTransformFactor = 0); |
157 | 0 |
|
158 | 0 | virtual QImage toImage() const; |
159 | 0 |
|
160 | 0 | enum TextureFlag { |
161 | 0 | TextureSwizzle = 0x01, |
162 | 0 | TextureFlip = 0x02, |
163 | 0 | TexturePremultiplied = 0x04 |
164 | 0 | }; |
165 | 0 | Q_DECLARE_FLAGS(TextureFlags, TextureFlag) |
166 | 0 | virtual QRhiTexture *toTexture(QRhiResourceUpdateBatch *resourceUpdates, |
167 | 0 | const QRegion &dirtyRegion, |
168 | 0 | TextureFlags *flags) const; |
169 | 0 |
|
170 | 0 | virtual QPlatformGraphicsBuffer *graphicsBuffer() const; |
171 | 0 |
|
172 | 0 | virtual void resize(const QSize &size, const QRegion &staticContents) = 0; |
173 | 0 |
|
174 | 0 | virtual bool scroll(const QRegion &area, int dx, int dy); |
175 | 0 |
|
176 | 0 | virtual void beginPaint(const QRegion &); |
177 | 0 | virtual void endPaint(); |
178 | 0 |
|
179 | 0 | void createRhi(QWindow *window, QPlatformBackingStoreRhiConfig config); |
180 | 0 | QRhi *rhi(QWindow *window) const; |
181 | 0 | void surfaceAboutToBeDestroyed(); |
182 | 0 | void graphicsDeviceReportedLost(QWindow *window); |
183 | 0 |
|
184 | 0 | private: |
185 | 0 | QPlatformBackingStorePrivate *d_ptr; |
186 | 0 |
|
187 | 0 | void setBackingStore(QBackingStore *); |
188 | 0 | friend class QBackingStore; |
189 | 0 | }; |
190 | 0 |
|
191 | | Q_DECLARE_OPERATORS_FOR_FLAGS(QPlatformBackingStore::TextureFlags) Unexecuted instantiation: operator|(QPlatformBackingStore::TextureFlag, QPlatformBackingStore::TextureFlag) Unexecuted instantiation: operator|(QPlatformBackingStore::TextureFlag, QFlags<QPlatformBackingStore::TextureFlag>) Unexecuted instantiation: operator&(QPlatformBackingStore::TextureFlag, QPlatformBackingStore::TextureFlag) Unexecuted instantiation: operator&(QPlatformBackingStore::TextureFlag, QFlags<QPlatformBackingStore::TextureFlag>) Unexecuted instantiation: operator^(QPlatformBackingStore::TextureFlag, QPlatformBackingStore::TextureFlag) Unexecuted instantiation: operator^(QPlatformBackingStore::TextureFlag, QFlags<QPlatformBackingStore::TextureFlag>) Unexecuted instantiation: operator|(QPlatformBackingStore::TextureFlag, int) |
192 | | |
193 | | QT_END_NAMESPACE |
194 | | |
195 | | #endif // QPLATFORMBACKINGSTORE_H |