blob: 78bfb9fe4bf3320341c36607312b362f27f37c6a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QQUICKRHIITEM_H
#define QQUICKRHIITEM_H
#include <QtQuick/QQuickItem>
QT_BEGIN_NAMESPACE
class QQuickRhiItem;
class QQuickRhiItemPrivate;
class QQuickRhiItemNode;
class QRhi;
class QRhiCommandBuffer;
class QRhiTexture;
class QRhiRenderBuffer;
class QRhiRenderTarget;
class Q_QUICK_EXPORT QQuickRhiItemRenderer
{
public:
QQuickRhiItemRenderer();
virtual ~QQuickRhiItemRenderer();
protected:
virtual void initialize(QRhiCommandBuffer *cb) = 0;
virtual void synchronize(QQuickRhiItem *item) = 0;
virtual void render(QRhiCommandBuffer *cb) = 0;
void update();
QRhi *rhi() const;
QRhiTexture *colorTexture() const;
QRhiRenderBuffer *msaaColorBuffer() const;
QRhiTexture *resolveTexture() const;
QRhiRenderBuffer *depthStencilBuffer() const;
QRhiRenderTarget *renderTarget() const;
private:
QQuickRhiItemNode *node;
friend class QQuickRhiItem;
friend class QQuickRhiItemNode;
Q_DISABLE_COPY_MOVE(QQuickRhiItemRenderer)
};
class Q_QUICK_EXPORT QQuickRhiItem : public QQuickItem
{
Q_OBJECT
Q_DECLARE_PRIVATE(QQuickRhiItem)
Q_PROPERTY(int sampleCount READ sampleCount WRITE setSampleCount NOTIFY sampleCountChanged FINAL)
Q_PROPERTY(TextureFormat colorBufferFormat READ colorBufferFormat WRITE setColorBufferFormat NOTIFY colorBufferFormatChanged FINAL)
Q_PROPERTY(bool mirrorVertically READ isMirrorVerticallyEnabled WRITE setMirrorVertically NOTIFY mirrorVerticallyChanged FINAL)
Q_PROPERTY(bool alphaBlending READ alphaBlending WRITE setAlphaBlending NOTIFY alphaBlendingChanged FINAL)
Q_PROPERTY(int fixedColorBufferWidth READ fixedColorBufferWidth WRITE setFixedColorBufferWidth NOTIFY fixedColorBufferWidthChanged FINAL)
Q_PROPERTY(int fixedColorBufferHeight READ fixedColorBufferHeight WRITE setFixedColorBufferHeight NOTIFY fixedColorBufferHeightChanged FINAL)
Q_PROPERTY(QSize effectiveColorBufferSize READ effectiveColorBufferSize NOTIFY effectiveColorBufferSizeChanged FINAL)
public:
enum class TextureFormat {
RGBA8,
RGBA16F,
RGBA32F,
RGB10A2
};
Q_ENUM(TextureFormat)
explicit QQuickRhiItem(QQuickItem *parent = nullptr);
~QQuickRhiItem() override;
int sampleCount() const;
void setSampleCount(int samples);
TextureFormat colorBufferFormat() const;
void setColorBufferFormat(TextureFormat format);
bool isMirrorVerticallyEnabled() const;
void setMirrorVertically(bool enable);
bool alphaBlending() const;
void setAlphaBlending(bool enable);
int fixedColorBufferWidth() const;
void setFixedColorBufferWidth(int width);
int fixedColorBufferHeight() const;
void setFixedColorBufferHeight(int height);
QSize effectiveColorBufferSize() const;
bool isTextureProvider() const override;
QSGTextureProvider *textureProvider() const override;
Q_SIGNALS:
void sampleCountChanged();
void colorBufferFormatChanged();
void autoRenderTargetChanged();
void mirrorVerticallyChanged();
void alphaBlendingChanged();
void fixedColorBufferWidthChanged();
void fixedColorBufferHeightChanged();
void effectiveColorBufferSizeChanged();
protected:
virtual QQuickRhiItemRenderer *createRenderer() = 0;
bool isAutoRenderTargetEnabled() const;
void setAutoRenderTarget(bool enabled);
QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *) override;
bool event(QEvent *) override;
void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) override;
void releaseResources() override;
private Q_SLOTS:
void invalidateSceneGraph();
friend class QQuickRhiItemNode;
};
QT_END_NAMESPACE
#endif // QQUICKRHIITEM_H
|