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
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
4#ifndef QQUICKRHIITEM_H
5#define QQUICKRHIITEM_H
6
7#include <QtQuick/QQuickItem>
8
10
11class QQuickRhiItem;
14class QRhi;
16class QRhiTexture;
19
20class Q_QUICK_EXPORT QQuickRhiItemRenderer
21{
22public:
24 virtual ~QQuickRhiItemRenderer();
25
26protected:
27 virtual void initialize(QRhiCommandBuffer *cb) = 0;
28 virtual void synchronize(QQuickRhiItem *item) = 0;
29 virtual void render(QRhiCommandBuffer *cb) = 0;
30
31 void update();
32
33 QRhi *rhi() const;
34 QRhiTexture *colorTexture() const;
35 QRhiRenderBuffer *msaaColorBuffer() const;
36 QRhiTexture *resolveTexture() const;
37 QRhiRenderBuffer *depthStencilBuffer() const;
38 QRhiRenderTarget *renderTarget() const;
39
40private:
42 friend class QQuickRhiItem;
43 friend class QQuickRhiItemNode;
44
45 Q_DISABLE_COPY_MOVE(QQuickRhiItemRenderer)
46};
47
48class Q_QUICK_EXPORT QQuickRhiItem : public QQuickItem
49{
51 Q_DECLARE_PRIVATE(QQuickRhiItem)
52
53 Q_PROPERTY(int sampleCount READ sampleCount WRITE setSampleCount NOTIFY sampleCountChanged FINAL)
54 Q_PROPERTY(TextureFormat colorBufferFormat READ colorBufferFormat WRITE setColorBufferFormat NOTIFY colorBufferFormatChanged FINAL)
55 Q_PROPERTY(bool mirrorVertically READ isMirrorVerticallyEnabled WRITE setMirrorVertically NOTIFY mirrorVerticallyChanged FINAL)
56 Q_PROPERTY(bool alphaBlending READ alphaBlending WRITE setAlphaBlending NOTIFY alphaBlendingChanged FINAL)
57 Q_PROPERTY(int fixedColorBufferWidth READ fixedColorBufferWidth WRITE setFixedColorBufferWidth NOTIFY fixedColorBufferWidthChanged FINAL)
58 Q_PROPERTY(int fixedColorBufferHeight READ fixedColorBufferHeight WRITE setFixedColorBufferHeight NOTIFY fixedColorBufferHeightChanged FINAL)
59 Q_PROPERTY(QSize effectiveColorBufferSize READ effectiveColorBufferSize NOTIFY effectiveColorBufferSizeChanged FINAL)
60
61public:
62 enum class TextureFormat {
63 RGBA8,
64 RGBA16F,
65 RGBA32F,
66 RGB10A2
67 };
68 Q_ENUM(TextureFormat)
69
70 explicit QQuickRhiItem(QQuickItem *parent = nullptr);
71 ~QQuickRhiItem() override;
72
73 int sampleCount() const;
74 void setSampleCount(int samples);
75
76 TextureFormat colorBufferFormat() const;
77 void setColorBufferFormat(TextureFormat format);
78
79 bool isMirrorVerticallyEnabled() const;
80 void setMirrorVertically(bool enable);
81
82 bool alphaBlending() const;
83 void setAlphaBlending(bool enable);
84
85 int fixedColorBufferWidth() const;
86 void setFixedColorBufferWidth(int width);
87 int fixedColorBufferHeight() const;
88 void setFixedColorBufferHeight(int height);
89
90 QSize effectiveColorBufferSize() const;
91
92 bool isTextureProvider() const override;
93 QSGTextureProvider *textureProvider() const override;
94
104
105protected:
107
108 bool isAutoRenderTargetEnabled() const;
109 void setAutoRenderTarget(bool enabled);
110
111 QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *) override;
112 bool event(QEvent *) override;
113 void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) override;
114 void releaseResources() override;
115
116private Q_SLOTS:
117 void invalidateSceneGraph();
118
119 friend class QQuickRhiItemNode;
120};
121
123
124#endif // QQUICKRHIITEM_H
\inmodule QtCore
Definition qcoreevent.h:45
The QQuickItem class provides the most basic of all visual items in \l {Qt Quick}.
Definition qquickitem.h:63
\inmodule QtQuick
virtual void synchronize(QQuickRhiItem *item)=0
This function is called on the render thread, if there is one, while the main/GUI thread is blocked.
virtual void initialize(QRhiCommandBuffer *cb)=0
Called when the item is initialized for the first time, when the associated texture's size,...
virtual void render(QRhiCommandBuffer *cb)=0
Called when the backing color buffer's contents needs updating.
\inmodule QtQuick
void autoRenderTargetChanged()
void colorBufferFormatChanged()
void alphaBlendingChanged()
void effectiveColorBufferSizeChanged()
void fixedColorBufferHeightChanged()
void mirrorVerticallyChanged()
void sampleCountChanged()
void fixedColorBufferWidthChanged()
virtual QQuickRhiItemRenderer * createRenderer()=0
Reimplement this function to create and return a new instance of a QQuickRhiItemRenderer subclass.
\inmodule QtCore\reentrant
Definition qrect.h:484
\inmodule QtGui
Definition qrhi.h:1651
\inmodule QtGui
Definition qrhi.h:1094
\inmodule QtGui
Definition qrhi.h:1158
\inmodule QtGui
Definition qrhi.h:895
\inmodule QtGuiPrivate \inheaderfile rhi/qrhi.h
Definition qrhi.h:1804
\group qtquick-scenegraph-nodes \title Qt Quick Scene Graph Node classes
Definition qsgnode.h:37
The QSGTextureProvider class encapsulates texture based entities in QML.
\inmodule QtCore
Definition qsize.h:25
Combined button and popup list for selecting options.
GLsizei samples
GLint GLsizei GLsizei height
GLenum GLenum GLsizei const GLuint GLboolean enabled
GLint GLsizei width
GLboolean enable
GLint GLsizei GLsizei GLenum format
struct _cl_event * event
SSL_CTX int(* cb)(SSL *ssl, unsigned char **out, unsigned char *outlen, const unsigned char *in, unsigned int inlen, void *arg)
#define Q_ENUM(x)
#define Q_PROPERTY(...)
#define Q_OBJECT
#define Q_SLOTS
#define Q_SIGNALS
QGraphicsItem * item