| 1 | // Copyright (C) 2022 The Qt Company Ltd. |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 3 | |
| 4 | #ifndef SHADERFEATURES_H |
| 5 | #define SHADERFEATURES_H |
| 6 | |
| 7 | #include <QFlags> |
| 8 | #include <QString> |
| 9 | |
| 10 | class ShaderFeatures |
| 11 | { |
| 12 | public: |
| 13 | enum Feature { |
| 14 | Time = 1 << 0, |
| 15 | Frame = 1 << 1, |
| 16 | Resolution = 1 << 2, |
| 17 | Source = 1 << 3, |
| 18 | Mouse = 1 << 4, |
| 19 | FragCoord = 1 << 5, |
| 20 | GridMesh = 1 << 6, |
| 21 | BlurSources = 1 << 7 |
| 22 | }; |
| 23 | Q_DECLARE_FLAGS(Features, Feature) |
| 24 | |
| 25 | ShaderFeatures(); |
| 26 | void update(const QString &vs, const QString &fs, const QString &qml); |
| 27 | |
| 28 | bool enabled(ShaderFeatures::Feature feature) const { |
| 29 | return m_enabledFeatures.testFlag(flag: feature); |
| 30 | } |
| 31 | private: |
| 32 | friend class EffectManager; |
| 33 | void checkLine(const QString &line, ShaderFeatures::Features &features); |
| 34 | ShaderFeatures::Features m_enabledFeatures; |
| 35 | int m_gridMeshWidth = 1; |
| 36 | int m_gridMeshHeight = 1; |
| 37 | }; |
| 38 | |
| 39 | Q_DECLARE_OPERATORS_FOR_FLAGS(ShaderFeatures::Features) |
| 40 | |
| 41 | #endif // SHADERFEATURES_H |
| 42 | |