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
qquickrhiitem.h
Go to the documentation of this file.
1// Copyright (C) 2023 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 QQUICKRHIITEM_H
6#define QQUICKRHIITEM_H
7
8#include <QtQuick/QQuickItem>
9
10QT_BEGIN_NAMESPACE
11
12class QQuickRhiItem;
15class QRhi;
16class QRhiCommandBuffer;
17class QRhiTexture;
18class QRhiRenderBuffer;
19class QRhiRenderTarget;
20
21class Q_QUICK_EXPORT QQuickRhiItemRenderer
22{
23public:
24 QQuickRhiItemRenderer();
25 virtual ~QQuickRhiItemRenderer();
26
27protected:
28 virtual void initialize(QRhiCommandBuffer *cb) = 0;
29 virtual void synchronize(QQuickRhiItem *item) = 0;
30 virtual void render(QRhiCommandBuffer *cb) = 0;
31
32 void update();
33
34 QRhi *rhi() const;
35 QRhiTexture *colorTexture() const;
36 QRhiRenderBuffer *msaaColorBuffer() const;
37 QRhiTexture *resolveTexture() const;
38 QRhiRenderBuffer *depthStencilBuffer() const;
39 QRhiRenderTarget *renderTarget() const;
40
41private:
42 QQuickRhiItemNode *node;
43 friend class QQuickRhiItem;
44 friend class QQuickRhiItemNode;
45
46 Q_DISABLE_COPY_MOVE(QQuickRhiItemRenderer)
47};
48
49class Q_QUICK_EXPORT QQuickRhiItem : public QQuickItem
50{
51 Q_OBJECT
52 Q_DECLARE_PRIVATE(QQuickRhiItem)
53
54 Q_PROPERTY(int sampleCount READ sampleCount WRITE setSampleCount NOTIFY sampleCountChanged FINAL)
55 Q_PROPERTY(TextureFormat colorBufferFormat READ colorBufferFormat WRITE setColorBufferFormat NOTIFY colorBufferFormatChanged FINAL)
56 Q_PROPERTY(bool mirrorVertically READ isMirrorVerticallyEnabled WRITE setMirrorVertically NOTIFY mirrorVerticallyChanged FINAL)
57 Q_PROPERTY(bool alphaBlending READ alphaBlending WRITE setAlphaBlending NOTIFY alphaBlendingChanged FINAL)
58 Q_PROPERTY(int fixedColorBufferWidth READ fixedColorBufferWidth WRITE setFixedColorBufferWidth NOTIFY fixedColorBufferWidthChanged FINAL)
59 Q_PROPERTY(int fixedColorBufferHeight READ fixedColorBufferHeight WRITE setFixedColorBufferHeight NOTIFY fixedColorBufferHeightChanged FINAL)
60 Q_PROPERTY(QSize effectiveColorBufferSize READ effectiveColorBufferSize NOTIFY effectiveColorBufferSizeChanged FINAL)
61
62public:
63 enum class TextureFormat {
64 RGBA8,
65 RGBA16F,
66 RGBA32F,
67 RGB10A2
68 };
69 Q_ENUM(TextureFormat)
70
71 explicit QQuickRhiItem(QQuickItem *parent = nullptr);
72 ~QQuickRhiItem() override;
73
74 int sampleCount() const;
75 void setSampleCount(int samples);
76
77 TextureFormat colorBufferFormat() const;
78 void setColorBufferFormat(TextureFormat format);
79
80 bool isMirrorVerticallyEnabled() const;
81 void setMirrorVertically(bool enable);
82
83 bool alphaBlending() const;
84 void setAlphaBlending(bool enable);
85
86 int fixedColorBufferWidth() const;
87 void setFixedColorBufferWidth(int width);
88 int fixedColorBufferHeight() const;
89 void setFixedColorBufferHeight(int height);
90
91 QSize effectiveColorBufferSize() const;
92
93 bool isTextureProvider() const override;
94 QSGTextureProvider *textureProvider() const override;
95
96Q_SIGNALS:
97 void sampleCountChanged();
98 void colorBufferFormatChanged();
99 void autoRenderTargetChanged();
100 void mirrorVerticallyChanged();
101 void alphaBlendingChanged();
102 void fixedColorBufferWidthChanged();
103 void fixedColorBufferHeightChanged();
104 void effectiveColorBufferSizeChanged();
105
106protected:
107 explicit QQuickRhiItem(QQuickRhiItemPrivate &dd, QQuickItem *parent = nullptr);
108
109 virtual QQuickRhiItemRenderer *createRenderer() = 0;
110
111 bool isAutoRenderTargetEnabled() const;
112 void setAutoRenderTarget(bool enabled);
113
114 QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *) override;
115 bool event(QEvent *) override;
116 void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) override;
117 void releaseResources() override;
118
119private Q_SLOTS:
120 void invalidateSceneGraph();
121
122 friend class QQuickRhiItemNode;
123};
124
125QT_END_NAMESPACE
126
127#endif // QQUICKRHIITEM_H
QRhiTexture * m_colorTexture
QQuickRhiItem * m_item
QRhiCommandBuffer * queryCommandBuffer()
std::unique_ptr< QRhiTextureRenderTarget > m_renderTarget
std::unique_ptr< QRhiRenderPassDescriptor > m_renderPassDescriptor
std::unique_ptr< QQuickRhiItemRenderer > m_renderer
QQuickWindow * m_window
std::unique_ptr< QRhiRenderBuffer > m_depthStencilBuffer
std::unique_ptr< QSGTexture > m_sgTexture
bool isValid() const
QSGTexture * texture() const override
Returns a pointer to the texture object.
void setRenderer(QQuickRhiItemRenderer *r)
std::unique_ptr< QRhiRenderBuffer > m_msaaColorBuffer
bool hasRenderer() const
QRhiTexture * m_resolveTexture
QRhiTexture::Format rhiTextureFormat
QQuickRhiItem::TextureFormat itemTextureFormat
\inmodule QtQuick
\inmodule QtQuick
\inmodule QtGuiPrivate \inheaderfile rhi/qrhi.h
Definition qrhi.h:577
\inmodule QtGuiPrivate \inheaderfile rhi/qrhi.h
Definition qrhi.h:621
Combined button and popup list for selecting options.
QGraphicsItem * item