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