Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qbackingstoredefaultcompositor_p.h
Go to the documentation of this file.
1// Copyright (C) 2021 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 QBACKINGSTOREDEFAULTCOMPOSITOR_P_H
5#define QBACKINGSTOREDEFAULTCOMPOSITOR_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <qpa/qplatformbackingstore.h>
19#include <rhi/qrhi.h>
20
22
24{
25public:
27
28 void reset();
29
30 QRhiTexture *toTexture(const QPlatformBackingStore *backingStore,
31 QRhi *rhi,
32 QRhiResourceUpdateBatch *resourceUpdates,
33 const QRegion &dirtyRegion,
34 QPlatformBackingStore::TextureFlags *flags) const;
35
37 QRhi *rhi,
38 QRhiSwapChain *swapchain,
40 qreal sourceDevicePixelRatio,
41 const QRegion &region,
42 const QPoint &offset,
44 bool translucentBackground);
45
46private:
47 enum UpdateUniformOption {
48 NoOption = 0x00,
49 NeedsRedBlueSwap = 0x01,
50 NeedsAlphaRotate = 0x02,
51 };
52
53 void ensureResources(QRhiSwapChain *swapchain, QRhiResourceUpdateBatch *resourceUpdates);
55 QRhi *rhi,
56 QRhiResourceUpdateBatch *resourceUpdates,
57 const QRegion &dirtyRegion,
58 QPlatformBackingStore::TextureFlags *flags) const;
59
60 mutable QRhi *m_rhi = nullptr;
61 mutable QRhiTexture *m_texture = nullptr;
62
63 QRhiBuffer *m_vbuf = nullptr;
64 QRhiSampler *m_sampler = nullptr;
65 QRhiGraphicsPipeline *m_psNoBlend = nullptr;
66 QRhiGraphicsPipeline *m_psBlend = nullptr;
67 QRhiGraphicsPipeline *m_psPremulBlend = nullptr;
68
69 struct PerQuadData {
70 QRhiBuffer *ubuf = nullptr;
71 // All srbs are layout-compatible.
72 QRhiShaderResourceBindings *srb = nullptr;
73 QRhiShaderResourceBindings *srbExtra = nullptr; // may be null (used for stereo)
74 QRhiTexture *lastUsedTexture = nullptr;
75 QRhiTexture *lastUsedTextureExtra = nullptr; // may be null (used for stereo)
76 bool isValid() const { return ubuf && srb; }
77 void reset() {
78 delete ubuf;
79 ubuf = nullptr;
80 delete srb;
81 srb = nullptr;
82 if (srbExtra) {
83 delete srbExtra;
84 srbExtra = nullptr;
85 }
86 lastUsedTexture = nullptr;
87 lastUsedTextureExtra = nullptr;
88 }
89 };
90 PerQuadData m_widgetQuadData;
91 QVarLengthArray<PerQuadData, 8> m_textureQuadData;
92
93 PerQuadData createPerQuadData(QRhiTexture *texture, QRhiTexture *textureExtra = nullptr);
94 void updatePerQuadData(PerQuadData *d, QRhiTexture *texture, QRhiTexture *textureExtra = nullptr);
95 void updateUniforms(PerQuadData *d, QRhiResourceUpdateBatch *resourceUpdates,
96 const QMatrix4x4 &target, const QMatrix3x3 &source, UpdateUniformOption option);
97};
98
100
101#endif // QBACKINGSTOREDEFAULTCOMPOSITOR_P_H
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)
\inmodule QtGui
Definition qimage.h:37
The QMatrix4x4 class represents a 4x4 transformation matrix in 3D space.
Definition qmatrix4x4.h:25
The QPlatformBackingStore class provides the drawing area for top-level windows.
\inmodule QtCore\reentrant
Definition qpoint.h:23
The QRegion class specifies a clip region for a painter.
Definition qregion.h:27
\inmodule QtGui
Definition qrhi.h:834
\inmodule QtGui
Definition qrhi.h:1241
\inmodule QtGui
Definition qrhi.h:1694
\inmodule QtGui
Definition qrhi.h:1007
\inmodule QtGui
Definition qrhi.h:1190
\inmodule QtGui
Definition qrhi.h:1513
\inmodule QtGui
Definition qrhi.h:883
\inmodule QtGui
Definition qrhi.h:1767
\inmodule QtGui
Definition qwindow.h:63
Combined button and popup list for selecting options.
Definition image.cpp:4
GLuint const GLuint GLuint const GLuint * textures
GLenum target
GLbitfield flags
GLenum GLuint texture
GLenum GLuint GLintptr offset
GLsizei GLsizei GLchar * source
GLboolean reset
GLuint GLenum option
double qreal
Definition qtypes.h:92
aWidget window() -> setWindowTitle("New Window Title")
[2]