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
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// Qt-Security score:significant reason:default
4
5#ifndef QBACKINGSTOREDEFAULTCOMPOSITOR_P_H
6#define QBACKINGSTOREDEFAULTCOMPOSITOR_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <qpa/qplatformbackingstore.h>
20#include <rhi/qrhi.h>
21
23
25{
26public:
28
29 void reset();
30
31 QRhiTexture *toTexture(const QPlatformBackingStore *backingStore,
32 QRhi *rhi,
33 QRhiResourceUpdateBatch *resourceUpdates,
34 const QRegion &dirtyRegion,
35 QPlatformBackingStore::TextureFlags *flags) const;
36
37 QPlatformBackingStore::FlushResult flush(QPlatformBackingStore *backingStore,
38 QRhi *rhi,
39 QRhiSwapChain *swapchain,
40 QWindow *window,
41 qreal sourceDevicePixelRatio,
42 const QRegion &region,
43 const QPoint &offset,
44 QPlatformTextureList *textures,
45 bool translucentBackground,
46 qreal sourceTransformFactor);
47
48private:
49 enum UpdateUniformOption {
50 NeedsRedBlueSwap = 1 << 0,
51 NeedsAlphaRotate = 1 << 1
52 };
53 Q_DECLARE_FLAGS(UpdateUniformOptions, UpdateUniformOption)
56 };
57 Q_DECLARE_FLAGS(UpdateQuadDataOptions, UpdateQuadDataOption)
58
60 QRhiTexture *toTexture(const QImage &image,
61 QRhi *rhi,
62 QRhiResourceUpdateBatch *resourceUpdates,
63 const QRegion &dirtyRegion,
64 QPlatformBackingStore::TextureFlags *flags) const;
65
66 mutable QRhi *m_rhi = nullptr;
67 mutable std::unique_ptr<QRhiTexture> m_texture;
68
69 std::unique_ptr<QRhiBuffer> m_vbuf;
70 std::unique_ptr<QRhiSampler> m_samplerNearest;
71 std::unique_ptr<QRhiSampler> m_samplerLinear;
72 std::unique_ptr<QRhiGraphicsPipeline> m_psNoBlend;
73 std::unique_ptr<QRhiGraphicsPipeline> m_psBlend;
74 std::unique_ptr<QRhiGraphicsPipeline> m_psPremulBlend;
75
76 struct PerQuadData {
77 QRhiBuffer *ubuf = nullptr;
78 // All srbs are layout-compatible.
79 QRhiShaderResourceBindings *srb = nullptr;
80 QRhiShaderResourceBindings *srbExtra = nullptr; // may be null (used for stereo)
81 QRhiTexture *lastUsedTexture = nullptr;
82 QRhiTexture *lastUsedTextureExtra = nullptr; // may be null (used for stereo)
83 QRhiSampler::Filter lastUsedFilter = QRhiSampler::None;
84 bool isValid() const { return ubuf && srb; }
85 void reset() {
86 delete ubuf;
87 ubuf = nullptr;
88 delete srb;
89 srb = nullptr;
90 if (srbExtra) {
91 delete srbExtra;
92 srbExtra = nullptr;
93 }
94 lastUsedTexture = nullptr;
95 lastUsedTextureExtra = nullptr;
96 lastUsedFilter = QRhiSampler::None;
97 }
98 };
99 PerQuadData m_widgetQuadData;
100 QVarLengthArray<PerQuadData, 8> m_textureQuadData;
101
102 PerQuadData createPerQuadData(QRhiTexture *texture, QRhiTexture *textureExtra = nullptr);
103 void updatePerQuadData(PerQuadData *d, QRhiTexture *texture, QRhiTexture *textureExtra = nullptr,
104 UpdateQuadDataOptions options = {});
105 void updateUniforms(PerQuadData *d, QRhiResourceUpdateBatch *resourceUpdates,
106 const QMatrix4x4 &target, const QMatrix3x3 &source,
107 UpdateUniformOptions options = {});
108};
109
110QT_END_NAMESPACE
111
112#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, qreal sourceTransformFactor)
\inmodule QtGuiPrivate \inheaderfile rhi/qrhi.h
Definition qrhi.h:662
\inmodule QtGuiPrivate \inheaderfile rhi/qrhi.h
Definition qrhi.h:722
\inmodule QtGuiPrivate \inheaderfile rhi/qrhi.h
Definition qrhi.h:323
Combined button and popup list for selecting options.
static QMatrix4x4 targetTransform(const QRectF &target, const QRect &viewport, bool invertY)
static QRect scaledRect(const QRect &rect, qreal factor)
static QMatrix3x3 sourceTransform(const QRectF &subTexture, const QSize &textureSize, SourceTransformOrigin origin)
static void updateMatrix3x3(QRhiResourceUpdateBatch *resourceUpdates, QRhiBuffer *ubuf, const QMatrix3x3 &m)
static QRect toBottomLeftRect(const QRect &topLeftRect, int windowHeight)
static QShader getShader(const QString &name)
static QPoint scaledOffset(const QPoint &pt, qreal factor)
static bool prepareDrawForRenderToTextureWidget(const QPlatformTextureList *textures, int idx, QWindow *window, const QRect &deviceWindowRect, const QPoint &offset, bool invertTargetY, bool invertSource, QMatrix4x4 *target, QMatrix3x3 *source)
static const int UBUF_SIZE
static QRhiGraphicsPipeline * createGraphicsPipeline(QRhi *rhi, QRhiShaderResourceBindings *srb, QRhiRenderPassDescriptor *rpDesc, PipelineBlend blend)
static QRegion scaledDirtyRegion(const QRegion &region, qreal factor, const QPoint &offset)