Qt 6.x
The Qt SDK
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
26Q_DECLARE_EXPORTED_LOGGING_CATEGORY(lcQpaBackingStore, Q_GUI_EXPORT)
27
28class QRegion;
29class QRect;
30class QPoint;
31class QImage;
36class QRhi;
37class QRhiTexture;
39class QRhiSwapChain;
40
42{
43 enum Api {
49 Null
50 };
51
53 : m_enable(false)
54 { }
55
57 : m_enable(true),
58 m_api(api)
59 { }
60
61 bool isEnabled() const { return m_enable; }
62 void setEnabled(bool enable) { m_enable = enable; }
63
64 Api api() const { return m_api; }
65 void setApi(Api api) { m_api = api; }
66
67 bool isDebugLayerEnabled() const { return m_debugLayer; }
68 void setDebugLayer(bool enable) { m_debugLayer = enable; }
69
70private:
71 bool m_enable;
72 Api m_api = Null;
73 bool m_debugLayer = false;
75};
76
78{
79 return a.m_enable == b.m_enable
80 && a.m_api == b.m_api
81 && a.m_debugLayer == b.m_debugLayer;
82}
83
85{
86 return !(a == b);
87}
88
89class Q_GUI_EXPORT QPlatformTextureList : public QObject
90{
92 Q_DECLARE_PRIVATE(QPlatformTextureList)
93public:
94 enum Flag {
95 StacksOnTop = 0x01,
96 TextureIsSrgb = 0x02,
97 NeedsPremultipliedAlphaBlending = 0x04
98 };
100
101 explicit QPlatformTextureList(QObject *parent = nullptr);
103
104 int count() const;
105 bool isEmpty() const { return count() == 0; }
106 QRhiTexture *texture(int index) const;
107 QRhiTexture *textureExtra(int index) const;
108 QRect geometry(int index) const;
109 QRect clipRect(int index) const;
110 void *source(int index);
111 Flags flags(int index) const;
112 void lock(bool on);
113 bool isLocked() const;
114
115 void appendTexture(void *source, QRhiTexture *texture, const QRect &geometry,
116 const QRect &clipRect = QRect(), Flags flags = { });
117
118 void appendTexture(void *source, QRhiTexture *textureLeft, QRhiTexture *textureRight, const QRect &geometry,
119 const QRect &clipRect = QRect(), Flags flags = { });
120 void clear();
121
122 Q_SIGNALS:
123 void locked(bool);
124};
125Q_DECLARE_OPERATORS_FOR_FLAGS(QPlatformTextureList::Flags)
126
127class Q_GUI_EXPORT QPlatformBackingStore
128{
129public:
133 FlushFailedDueToLostDevice
134 };
135
137 virtual ~QPlatformBackingStore();
138
139 QWindow *window() const;
140 QBackingStore *backingStore() const;
141
142 virtual QPaintDevice *paintDevice() = 0;
143
144 virtual void flush(QWindow *window, const QRegion &region, const QPoint &offset);
145
146 virtual FlushResult rhiFlush(QWindow *window,
147 qreal sourceDevicePixelRatio,
148 const QRegion &region,
149 const QPoint &offset,
151 bool translucentBackground);
152
153 virtual QImage toImage() const;
154
156 TextureSwizzle = 0x01,
157 TextureFlip = 0x02,
158 TexturePremultiplied = 0x04
159 };
160 Q_DECLARE_FLAGS(TextureFlags, TextureFlag)
161 virtual QRhiTexture *toTexture(QRhiResourceUpdateBatch *resourceUpdates,
162 const QRegion &dirtyRegion,
163 TextureFlags *flags) const;
164
165 virtual QPlatformGraphicsBuffer *graphicsBuffer() const;
166
167 virtual void resize(const QSize &size, const QRegion &staticContents) = 0;
168
169 virtual bool scroll(const QRegion &area, int dx, int dy);
170
171 virtual void beginPaint(const QRegion &);
172 virtual void endPaint();
173
174 void setRhiConfig(const QPlatformBackingStoreRhiConfig &config);
175 QRhi *rhi() const;
178 void graphicsDeviceReportedLost();
179
180private:
182
183 void setBackingStore(QBackingStore *);
184 friend class QBackingStore;
185};
186
187Q_DECLARE_OPERATORS_FOR_FLAGS(QPlatformBackingStore::TextureFlags)
188
190
191#endif // QPLATFORMBACKINGSTORE_H
The QBackingStore class provides a drawing area for QWindow.
\inmodule QtGui
Definition qimage.h:37
\inmodule QtCore
Definition qobject.h:90
The QPlatformBackingStore class provides the drawing area for top-level windows.
QRhiSwapChain * rhiSwapChain() const
virtual QPaintDevice * paintDevice()=0
Implement this function to return the appropriate paint device.
void surfaceAboutToBeDestroyed()
virtual void resize(const QSize &size, const QRegion &staticContents)=0
\inmodule QtCore\reentrant
Definition qpoint.h:23
\inmodule QtCore\reentrant
Definition qrect.h:30
The QRegion class specifies a clip region for a painter.
Definition qregion.h:27
\inmodule QtGui
Definition qrhi.h:1694
\inmodule QtGui
Definition qrhi.h:1513
\inmodule QtGui
Definition qrhi.h:883
\inmodule QtGui
Definition qrhi.h:1767
\inmodule QtCore
Definition qsize.h:25
\inmodule QtGui
Definition qwindow.h:63
b clear()
Combined button and popup list for selecting options.
EGLConfig config
#define Q_DECLARE_FLAGS(Flags, Enum)
Definition qflags.h:174
#define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags)
Definition qflags.h:194
Flags
static int area(const QSize &s)
Definition qicon.cpp:152
#define Q_DECLARE_EXPORTED_LOGGING_CATEGORY(name, export_macro)
GLboolean GLboolean GLboolean b
GLboolean GLboolean GLboolean GLboolean a
[7]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLuint index
[2]
GLuint const GLuint GLuint const GLuint * textures
GLenum GLenum GLsizei count
GLbitfield flags
GLboolean enable
GLenum GLuint texture
GLenum GLuint GLintptr offset
GLsizei GLsizei GLchar * source
bool operator!=(const QPlatformBackingStoreRhiConfig &a, const QPlatformBackingStoreRhiConfig &b)
bool operator==(const QPlatformBackingStoreRhiConfig &a, const QPlatformBackingStoreRhiConfig &b)
bool operator==(const QRandomGenerator &rng1, const QRandomGenerator &rng2)
Definition qrandom.cpp:1219
#define Q_OBJECT
#define Q_SIGNALS
double qreal
Definition qtypes.h:92
QReadWriteLock lock
[0]
aWidget window() -> setWindowTitle("New Window Title")
[2]
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent