Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qplatformbackingstore.h
Go to the documentation of this file.
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
26
28
29class QRegion;
30class QRect;
31class QPoint;
32class QImage;
34class QPlatformTextureList;
36class QPlatformGraphicsBuffer;
37class QRhi;
38class QRhiTexture;
39class QRhiResourceUpdateBatch;
40
42{
43 Q_GADGET
44public:
45 enum Api {
46 OpenGL,
47 Metal,
48 Vulkan,
49 D3D11,
50 D3D12,
51 Null
52 };
53 Q_ENUM(Api)
54
55 QPlatformBackingStoreRhiConfig()
56 : m_enable(false)
57 { }
58
59 QPlatformBackingStoreRhiConfig(Api api)
60 : m_enable(true),
61 m_api(api)
62 { }
63
64 bool isEnabled() const { return m_enable; }
65 void setEnabled(bool enable) { m_enable = enable; }
66
67 Api api() const { return m_api; }
68 void setApi(Api api) { m_api = api; }
69
70 bool isDebugLayerEnabled() const { return m_debugLayer; }
71 void setDebugLayer(bool enable) { m_debugLayer = enable; }
72
73private:
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
80inline bool operator==(const QPlatformBackingStoreRhiConfig &a, const QPlatformBackingStoreRhiConfig &b)
81{
82 return a.m_enable == b.m_enable
83 && a.m_api == b.m_api
84 && a.m_debugLayer == b.m_debugLayer;
85}
86
87inline bool operator!=(const QPlatformBackingStoreRhiConfig &a, const QPlatformBackingStoreRhiConfig &b)
88{
89 return !(a == b);
90}
91
92class Q_GUI_EXPORT QPlatformTextureList : public QObject
93{
94 Q_OBJECT
95 Q_DECLARE_PRIVATE(QPlatformTextureList)
96public:
97 enum Flag {
98 StacksOnTop = 0x01,
99 TextureIsSrgb = 0x02,
100 NeedsPremultipliedAlphaBlending = 0x04,
101 MirrorVertically = 0x08
102 };
103 Q_DECLARE_FLAGS(Flags, Flag)
104
105 explicit QPlatformTextureList(QObject *parent = nullptr);
106 ~QPlatformTextureList();
107
108 int count() const;
109 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};
129Q_DECLARE_OPERATORS_FOR_FLAGS(QPlatformTextureList::Flags)
130
131class Q_GUI_EXPORT QPlatformBackingStore
132{
133public:
134 enum FlushResult {
135 FlushSuccess,
136 FlushFailed,
137 FlushFailedDueToLostDevice
138 };
139
140 explicit QPlatformBackingStore(QWindow *window);
141 virtual ~QPlatformBackingStore();
142
143 QWindow *window() const;
144 QBackingStore *backingStore() const;
145
146 virtual QPaintDevice *paintDevice() = 0;
147
148 virtual void flush(QWindow *window, const QRegion &region, const QPoint &offset);
149
150 virtual FlushResult rhiFlush(QWindow *window,
151 qreal sourceDevicePixelRatio,
152 const QRegion &region,
153 const QPoint &offset,
154 QPlatformTextureList *textures,
155 bool translucentBackground,
156 qreal sourceTransformFactor = 0);
157
158 virtual QImage toImage() const;
159
160 enum TextureFlag {
161 TextureSwizzle = 0x01,
162 TextureFlip = 0x02,
163 TexturePremultiplied = 0x04
164 };
165 Q_DECLARE_FLAGS(TextureFlags, TextureFlag)
166 virtual QRhiTexture *toTexture(QRhiResourceUpdateBatch *resourceUpdates,
167 const QRegion &dirtyRegion,
168 TextureFlags *flags) const;
169
170 virtual QPlatformGraphicsBuffer *graphicsBuffer() const;
171
172 virtual void resize(const QSize &size, const QRegion &staticContents) = 0;
173
174 virtual bool scroll(const QRegion &area, int dx, int dy);
175
176 virtual void beginPaint(const QRegion &);
177 virtual void endPaint();
178
179 void createRhi(QWindow *window, QPlatformBackingStoreRhiConfig config);
180 QRhi *rhi(QWindow *window) const;
181 void surfaceAboutToBeDestroyed();
182 void graphicsDeviceReportedLost(QWindow *window);
183
184private:
185 QPlatformBackingStorePrivate *d_ptr;
186
187 void setBackingStore(QBackingStore *);
188 friend class QBackingStore;
189};
190
191Q_DECLARE_OPERATORS_FOR_FLAGS(QPlatformBackingStore::TextureFlags)
192
193QT_END_NAMESPACE
194
195#endif // QPLATFORMBACKINGSTORE_H
friend bool operator==(const QByteArray::FromBase64Result &lhs, const QByteArray::FromBase64Result &rhs) noexcept
Returns true if lhs and rhs are equal, otherwise returns false.
Definition qbytearray.h:807
friend bool operator!=(const QByteArray::FromBase64Result &lhs, const QByteArray::FromBase64Result &rhs) noexcept
Returns true if lhs and rhs are different, otherwise returns false.
Definition qbytearray.h:818
std::unordered_map< QSurface::SurfaceType, SurfaceSupport > surfaceSupport
QList< QBackingstoreTextureInfo > textures
\inmodule QtCore\reentrant
Definition qpoint.h:30
Q_LOGGING_CATEGORY(lcEventDispatcher, "qt.eventdispatcher")
Q_DECLARE_TYPEINFO(QBackingstoreTextureInfo, Q_RELOCATABLE_TYPE)
QT_BEGIN_NAMESPACE QT_DECLARE_EXPORTED_QT_LOGGING_CATEGORY(lcAotCompiler, Q_QMLCOMPILER_EXPORT)
QPlatformTextureList::Flags flags