Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qplatformbackingstore.cpp
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
5#include <qwindow.h>
6#include <qpixmap.h>
7#include <private/qbackingstorerhisupport_p.h>
8#include <private/qbackingstoredefaultcompositor_p.h>
9#include <private/qwindow_p.h>
10
11#include <QtCore/private/qobject_p.h>
12
14
15Q_LOGGING_CATEGORY(lcQpaBackingStore, "qt.qpa.backingstore", QtWarningMsg);
16
18{
19public:
25
28
29 // The order matters. if it needs to be rearranged in the future, call
30 // reset() explicitly from the dtor in the correct order.
31 // (first the compositor, then the rhiSupport)
34};
35
37{
38 void *source; // may be null
43 QPlatformTextureList::Flags flags;
44};
45
47
49{
50public:
55
56 QList<QBackingstoreTextureInfo> textures;
57 bool locked;
58};
59
64
68
70{
71 Q_D(const QPlatformTextureList);
72 return d->textures.size();
73}
74
76{
77 Q_D(const QPlatformTextureList);
78 return d->textures.at(index).texture;
79}
80
82{
83 Q_D(const QPlatformTextureList);
84 return d->textures.at(index).textureExtra;
85}
86
88{
89 Q_D(const QPlatformTextureList);
90 return d->textures.at(index).source;
91}
92
93QPlatformTextureList::Flags QPlatformTextureList::flags(int index) const
94{
95 Q_D(const QPlatformTextureList);
96 return d->textures.at(index).flags;
97}
98
100{
101 Q_D(const QPlatformTextureList);
102 return d->textures.at(index).rect;
103}
104
106{
107 Q_D(const QPlatformTextureList);
108 return d->textures.at(index).clipRect;
109}
110
112{
114 if (on != d->locked) {
115 d->locked = on;
116 emit locked(on);
117 }
118}
119
121{
122 Q_D(const QPlatformTextureList);
123 return d->locked;
124}
125
127 const QRect &clipRect, Flags flags)
128{
131 bi.source = source;
132 bi.texture = texture;
133 bi.textureExtra = nullptr;
134 bi.rect = geometry;
135 bi.clipRect = clipRect;
136 bi.flags = flags;
137 d->textures.append(bi);
138}
139
140void QPlatformTextureList::appendTexture(void *source, QRhiTexture *textureLeft, QRhiTexture *textureRight, const QRect &geometry,
141 const QRect &clipRect, Flags flags)
142{
144
146 bi.source = source;
147 bi.texture = textureLeft;
148 bi.textureExtra = textureRight;
149 bi.rect = geometry;
150 bi.clipRect = clipRect;
151 bi.flags = flags;
152 d->textures.append(bi);
153}
154
156{
158 d->textures.clear();
159}
160
186{
188 Q_UNUSED(region);
190}
191
207 qreal sourceDevicePixelRatio,
208 const QRegion &region,
209 const QPoint &offset,
211 bool translucentBackground)
212{
213 return d_ptr->compositor.flush(this, d_ptr->rhiSupport.rhi(), d_ptr->rhiSupport.swapChainForWindow(window),
214 window, sourceDevicePixelRatio, region, offset, textures, translucentBackground);
215}
216
230{
231 return QImage();
232}
233
261 const QRegion &dirtyRegion,
262 TextureFlags *flags) const
263{
264 return d_ptr->compositor.toTexture(this, d_ptr->rhiSupport.rhi(), resourceUpdates, dirtyRegion, flags);
265}
266
280
288
294{
295 return d_ptr->window;
296}
297
301void QPlatformBackingStore::setBackingStore(QBackingStore *backingStore)
302{
303 d_ptr->backingStore = backingStore;
304}
305
314
325
335
343
350bool QPlatformBackingStore::scroll(const QRegion &area, int dx, int dy)
351{
352 Q_UNUSED(area);
353 Q_UNUSED(dx);
354 Q_UNUSED(dy);
355
356 return false;
357}
358
360{
361 if (!config.isEnabled())
362 return;
363
365 d_ptr->rhiSupport.setWindow(d_ptr->window);
366 d_ptr->rhiSupport.setFormat(d_ptr->window->format());
367 d_ptr->rhiSupport.create();
368}
369
371{
372 // Returning null is valid, and means this is not a QRhi-capable backingstore.
373 return d_ptr->rhiSupport.rhi();
374}
375
377{
378 if (!d_ptr->rhiSupport.rhi())
379 return;
380
381 qWarning("Rhi backingstore: graphics device lost, attempting to reinitialize");
382 d_ptr->compositor.reset();
383 d_ptr->rhiSupport.reset();
384 d_ptr->rhiSupport.create();
385 if (!d_ptr->rhiSupport.rhi())
386 qWarning("Rhi backingstore: failed to reinitialize after losing the device");
387}
388
390
391#include "moc_qplatformbackingstore.cpp"
QRhiTexture * toTexture(const QPlatformBackingStore *backingStore, QRhi *rhi, QRhiResourceUpdateBatch *resourceUpdates, const QRegion &dirtyRegion, QPlatformBackingStore::TextureFlags *flags) const
QPlatformBackingStore::FlushResult flush(QPlatformBackingStore *backingStore, QRhi *rhi, QRhiSwapChain *swapchain, QWindow *window, qreal sourceDevicePixelRatio, const QRegion &region, const QPoint &offset, QPlatformTextureList *textures, bool translucentBackground)
void setConfig(const QPlatformBackingStoreRhiConfig &config)
void setFormat(const QSurfaceFormat &format)
QRhiSwapChain * swapChainForWindow(QWindow *window)
The QBackingStore class provides a drawing area for QWindow.
\inmodule QtGui
Definition qimage.h:37
\inmodule QtCore
Definition qobject.h:103
QBackingStoreDefaultCompositor compositor
virtual void endPaint()
This function is called after painting onto the surface has ended.
QBackingStore * backingStore() const
Returns a pointer to the backing store associated with this surface.
virtual QImage toImage() const
Implemented in subclasses to return the content of the backingstore as a QImage.
QPlatformBackingStore(QWindow *window)
Constructs an empty surface for the given top-level window.
virtual ~QPlatformBackingStore()
Destroys this surface.
void setRhiConfig(const QPlatformBackingStoreRhiConfig &config)
virtual void beginPaint(const QRegion &)
This function is called before painting onto the surface begins, with the region in which the paintin...
virtual void flush(QWindow *window, const QRegion &region, const QPoint &offset)
Flushes the given region from the specified window.
virtual QPlatformGraphicsBuffer * graphicsBuffer() const
Accessor for a backingstores graphics buffer abstraction.
QWindow * window() const
Returns a pointer to the top-level window associated with this surface.
virtual FlushResult rhiFlush(QWindow *window, qreal sourceDevicePixelRatio, const QRegion &region, const QPoint &offset, QPlatformTextureList *textures, bool translucentBackground)
Flushes the given region from the specified window, and compositing it with the specified textures li...
virtual bool scroll(const QRegion &area, int dx, int dy)
Scrolls the given area dx pixels to the right and dy downward; both dx and dy may be negative.
virtual QRhiTexture * toTexture(QRhiResourceUpdateBatch *resourceUpdates, const QRegion &dirtyRegion, TextureFlags *flags) const
May be reimplemented in subclasses to return the content of the backingstore as an QRhiTexture.
QList< QBackingstoreTextureInfo > textures
QRhiTexture * textureExtra(int index) const
QRect geometry(int index) const
QRhiTexture * texture(int index) const
QRect clipRect(int index) const
QPlatformTextureList(QObject *parent=nullptr)
Flags flags(int index) const
void appendTexture(void *source, QRhiTexture *texture, const QRect &geometry, const QRect &clipRect=QRect(), Flags flags={ })
\inmodule QtCore\reentrant
Definition qpoint.h:25
\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:1731
\inmodule QtGui
Definition qrhi.h:895
\inmodule QtGuiPrivate \inheaderfile rhi/qrhi.h
Definition qrhi.h:1804
\inmodule QtGui
Definition qwindow.h:63
QSurfaceFormat format() const override
Returns the actual format of this window.
Definition qwindow.cpp:946
Combined button and popup list for selecting options.
EGLConfig config
Flags
static int area(const QSize &s)
Definition qicon.cpp:153
@ QtWarningMsg
Definition qlogging.h:31
#define qWarning
Definition qlogging.h:166
#define Q_LOGGING_CATEGORY(name,...)
GLfloat GLfloat GLfloat w
[0]
GLuint index
[2]
GLuint const GLuint GLuint const GLuint * textures
GLbitfield flags
GLenum GLuint texture
GLenum GLuint GLintptr offset
GLsizei GLsizei GLchar * source
#define emit
#define Q_UNUSED(x)
@ Q_RELOCATABLE_TYPE
Definition qtypeinfo.h:158
#define Q_DECLARE_TYPEINFO(TYPE, FLAGS)
Definition qtypeinfo.h:180
double qreal
Definition qtypes.h:187
QObject::connect nullptr
aWidget window() -> setWindowTitle("New Window Title")
[2]
QPlatformTextureList::Flags flags