1// Copyright (C) 2016 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 QSGRENDERNODE_H
5#define QSGRENDERNODE_H
6
7#include <QtQuick/qsgnode.h>
8
9QT_BEGIN_NAMESPACE
10
11class QSGRenderNodePrivate;
12class QRhiRenderTarget;
13class QRhiCommandBuffer;
14
15class Q_QUICK_EXPORT QSGRenderNode : public QSGNode
16{
17public:
18 enum StateFlag {
19 DepthState = 0x01,
20 StencilState = 0x02,
21 ScissorState = 0x04,
22 ColorState = 0x08,
23 BlendState = 0x10,
24 CullState = 0x20,
25 ViewportState = 0x40,
26 RenderTargetState = 0x80
27 };
28 Q_DECLARE_FLAGS(StateFlags, StateFlag)
29
30 enum RenderingFlag {
31 BoundedRectRendering = 0x01,
32 DepthAwareRendering = 0x02,
33 OpaqueRendering = 0x04,
34 NoExternalRendering = 0x08
35 };
36 Q_DECLARE_FLAGS(RenderingFlags, RenderingFlag)
37
38 struct Q_QUICK_EXPORT RenderState {
39 virtual ~RenderState();
40 virtual const QMatrix4x4 *projectionMatrix() const = 0;
41 virtual QRect scissorRect() const = 0;
42 virtual bool scissorEnabled() const = 0;
43 virtual int stencilValue() const = 0;
44 virtual bool stencilEnabled() const = 0;
45 virtual const QRegion *clipRegion() const = 0;
46 virtual void *get(const char *state) const;
47 };
48
49 QSGRenderNode();
50 ~QSGRenderNode() override;
51
52 virtual StateFlags changedStates() const;
53 virtual void prepare();
54 virtual void render(const RenderState *state) = 0;
55 virtual void releaseResources();
56 virtual RenderingFlags flags() const;
57 virtual QRectF rect() const;
58
59 const QMatrix4x4 *projectionMatrix() const;
60 const QMatrix4x4 *matrix() const;
61 const QSGClipNode *clipList() const;
62 qreal inheritedOpacity() const;
63 QRhiRenderTarget *renderTarget() const;
64 QRhiCommandBuffer *commandBuffer() const;
65
66private:
67 QSGRenderNodePrivate *d;
68 friend class QSGRenderNodePrivate;
69};
70
71Q_DECLARE_OPERATORS_FOR_FLAGS(QSGRenderNode::StateFlags)
72Q_DECLARE_OPERATORS_FOR_FLAGS(QSGRenderNode::RenderingFlags)
73
74QT_END_NAMESPACE
75
76#endif
77

source code of qtdeclarative/src/quick/scenegraph/coreapi/qsgrendernode.h