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 QQUICKSHADEREFFECT_P_H |
5 | #define QQUICKSHADEREFFECT_P_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 <private/qtquickglobal_p.h> |
19 | |
20 | QT_REQUIRE_CONFIG(quick_shadereffect); |
21 | |
22 | #include <QtQuick/qquickitem.h> |
23 | #include <private/qtquickglobal_p.h> |
24 | #include <private/qsgadaptationlayer_p.h> |
25 | |
26 | QT_BEGIN_NAMESPACE |
27 | |
28 | class QQuickShaderEffectPrivate; |
29 | |
30 | class Q_QUICK_PRIVATE_EXPORT QQuickShaderEffect : public QQuickItem |
31 | { |
32 | Q_OBJECT |
33 | Q_PROPERTY(QUrl fragmentShader READ fragmentShader WRITE setFragmentShader NOTIFY fragmentShaderChanged FINAL) |
34 | Q_PROPERTY(QUrl vertexShader READ vertexShader WRITE setVertexShader NOTIFY vertexShaderChanged FINAL) |
35 | Q_PROPERTY(bool blending READ blending WRITE setBlending NOTIFY blendingChanged FINAL) |
36 | Q_PROPERTY(QVariant mesh READ mesh WRITE setMesh NOTIFY meshChanged FINAL) |
37 | Q_PROPERTY(CullMode cullMode READ cullMode WRITE setCullMode NOTIFY cullModeChanged FINAL) |
38 | Q_PROPERTY(QString log READ log NOTIFY logChanged FINAL) |
39 | Q_PROPERTY(Status status READ status NOTIFY statusChanged FINAL) |
40 | Q_PROPERTY(bool supportsAtlasTextures READ supportsAtlasTextures WRITE setSupportsAtlasTextures NOTIFY supportsAtlasTexturesChanged REVISION(2, 4) FINAL) |
41 | QML_NAMED_ELEMENT(ShaderEffect) |
42 | QML_ADDED_IN_VERSION(2, 0) |
43 | |
44 | public: |
45 | enum CullMode { |
46 | NoCulling, |
47 | BackFaceCulling, |
48 | FrontFaceCulling |
49 | }; |
50 | Q_ENUM(CullMode) |
51 | |
52 | enum Status { |
53 | Compiled, |
54 | Uncompiled, |
55 | Error |
56 | }; |
57 | Q_ENUM(Status) |
58 | |
59 | QQuickShaderEffect(QQuickItem *parent = nullptr); |
60 | ~QQuickShaderEffect() override; |
61 | |
62 | QUrl fragmentShader() const; |
63 | void setFragmentShader(const QUrl &fileUrl); |
64 | |
65 | QUrl vertexShader() const; |
66 | void setVertexShader(const QUrl &fileUrl); |
67 | |
68 | bool blending() const; |
69 | void setBlending(bool enable); |
70 | |
71 | QVariant mesh() const; |
72 | void setMesh(const QVariant &mesh); |
73 | |
74 | CullMode cullMode() const; |
75 | void setCullMode(CullMode face); |
76 | |
77 | bool supportsAtlasTextures() const; |
78 | void setSupportsAtlasTextures(bool supports); |
79 | |
80 | QString log() const; |
81 | Status status() const; |
82 | |
83 | bool isComponentComplete() const; |
84 | |
85 | bool updateUniformValue(const QByteArray &name, const QVariant &value); |
86 | |
87 | Q_SIGNALS: |
88 | void fragmentShaderChanged(); |
89 | void vertexShaderChanged(); |
90 | void blendingChanged(); |
91 | void meshChanged(); |
92 | void cullModeChanged(); |
93 | void logChanged(); |
94 | void statusChanged(); |
95 | void supportsAtlasTexturesChanged(); |
96 | |
97 | protected: |
98 | bool event(QEvent *e) override; |
99 | void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) override; |
100 | QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *updatePaintNodeData) override; |
101 | void componentComplete() override; |
102 | void itemChange(ItemChange change, const ItemChangeData &value) override; |
103 | |
104 | private: |
105 | Q_DECLARE_PRIVATE(QQuickShaderEffect) |
106 | }; |
107 | |
108 | QT_END_NAMESPACE |
109 | |
110 | #endif // QQUICKSHADEREFFECT_P_H |
111 | |