1// Copyright (C) 2020 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4#ifndef QQUICK3DEFFECT_H
5#define QQUICK3DEFFECT_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtQuick3D/qtquick3dglobal.h>
19#include <QtQuick3D/private/qquick3dobject_p.h>
20#include <QtQuick3D/private/qquick3dtexture_p.h>
21
22#include <QtQuick3DUtils/private/qssgrenderbasetypes_p.h>
23
24#include <QtQuick3DRuntimeRender/private/qssgrendercommands_p.h>
25
26#include <QtCore/qvector.h>
27
28#include <QtQuick3D/private/qquick3dshaderutils_p.h>
29
30QT_BEGIN_NAMESPACE
31
32class Q_QUICK3D_EXPORT QQuick3DEffect : public QQuick3DObject
33{
34 Q_OBJECT
35 Q_PROPERTY(QQmlListProperty<QQuick3DShaderUtilsRenderPass> passes READ passes)
36
37 QML_NAMED_ELEMENT(Effect)
38public:
39 explicit QQuick3DEffect(QQuick3DObject *parent = nullptr);
40
41 QQmlListProperty<QQuick3DShaderUtilsRenderPass> passes();
42
43 // Passes
44 static void qmlAppendPass(QQmlListProperty<QQuick3DShaderUtilsRenderPass> *list,
45 QQuick3DShaderUtilsRenderPass *pass);
46 static QQuick3DShaderUtilsRenderPass *qmlPassAt(QQmlListProperty<QQuick3DShaderUtilsRenderPass> *list,
47 qsizetype index);
48 static qsizetype qmlPassCount(QQmlListProperty<QQuick3DShaderUtilsRenderPass> *list);
49 static void qmlPassClear(QQmlListProperty<QQuick3DShaderUtilsRenderPass> *list);
50
51 void effectChainDirty();
52
53protected:
54 QSSGRenderGraphObject *updateSpatialNode(QSSGRenderGraphObject *node) override;
55 void itemChange(QQuick3DObject::ItemChange , const QQuick3DObject::ItemChangeData &) override;
56
57private Q_SLOTS:
58 void onPropertyDirty();
59 void onTextureDirty();
60 void onPassDirty();
61
62private:
63 friend class QQuick3DShaderUtilsTextureInput;
64 friend class QQuick3DSceneRenderer;
65
66 enum Dirty {
67 TextureDirty = 0x1,
68 PropertyDirty = 0x2,
69 EffectChainDirty = 0x4
70 };
71
72 void setDynamicTextureMap(QQuick3DShaderUtilsTextureInput *textureMap);
73 void markDirty(QQuick3DEffect::Dirty type);
74
75 quint32 m_dirtyAttributes = 0xffffffff;
76
77 void updateSceneManager(QQuick3DSceneManager *sceneManager);
78
79 QVector<QQuick3DShaderUtilsRenderPass *> m_passes;
80 QSet<QQuick3DShaderUtilsTextureInput *> m_dynamicTextureMaps;
81};
82
83QT_END_NAMESPACE
84
85#endif // QQUICK3DEFFECT_H
86

source code of qtquick3d/src/quick3d/qquick3deffect_p.h