Phosphor
Qt6 / Wayland library suite for window-management tools
 
Loading...
Searching...
No Matches
AnimationShaderEffect.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2026 fuddlesworth
2// SPDX-License-Identifier: LGPL-2.1-or-later
3
4#pragma once
5
6#include <PhosphorAnimation/phosphoranimation_export.h>
7
8#include <QJsonObject>
9#include <QList>
10#include <QString>
11#include <QStringList>
12#include <QUrl>
13#include <QVariantMap>
14
16
44struct PHOSPHORANIMATION_EXPORT AnimationShaderEffect
45{
47 QString id;
48
50 QString name;
51
53 QString description;
54
56 QString author;
57
59 QString version;
60
62 QString category;
63
79 QStringList appliesTo;
80
85
89
91 QString sourceDir;
92
94 bool isUserEffect = false;
95
97 QString previewPath;
98
99 // ── Multipass / advanced features (opt-in, matching overlay ShaderInfo) ──
100
104 QStringList bufferShaderPaths;
105
111 bool isMultipass = false;
112
116 bool useWallpaper = false;
117
120 bool bufferFeedback = false;
121
125 qreal bufferScale = 1.0;
126
130 QString bufferWrap;
131
134 QStringList bufferWraps;
135
139
142 QStringList bufferFilters;
143
146 bool useDepthBuffer = false;
147
170 enum class FboExtentKind {
171 Anchor,
172 Surface,
173 };
174 FboExtentKind fboExtentKind = FboExtentKind::Anchor;
175
188 int geometryGridSubdivisions = 0;
189
198 static constexpr qreal kMinBufferScale = 0.125;
199 static constexpr qreal kMaxBufferScale = 1.0;
200 static_assert(kMinBufferScale > 0.0 && kMinBufferScale < kMaxBufferScale,
201 "kMinBufferScale must be positive and strictly less than kMaxBufferScale");
202
216 {
217 QString id;
218 QString name;
219 QString type;
220 QString description;
221 QString group;
222 QVariant defaultValue;
223 QVariant minValue;
224 QVariant maxValue;
225 QVariant stepValue;
226 };
227 QList<ParameterInfo> parameters;
228
250 {
251 QString path;
252 QString
254
255 bool operator==(const TextureSlot& other) const
256 {
257 return path == other.path && wrap == other.wrap;
258 }
259 bool operator!=(const TextureSlot& other) const
260 {
261 return !(*this == other);
262 }
263 };
264 QList<TextureSlot> textures;
265
266 bool isValid() const
267 {
268 return !id.isEmpty() && !fragmentShaderPath.isEmpty();
269 }
270
271 QJsonObject toJson() const;
272 static AnimationShaderEffect fromJson(const QJsonObject& obj);
273
274 bool operator==(const AnimationShaderEffect& other) const;
275 bool operator!=(const AnimationShaderEffect& other) const
276 {
277 return !(*this == other);
278 }
279};
280
296PHOSPHORANIMATION_EXPORT bool shaderEffectAppliesToEventPath(const AnimationShaderEffect& effect, const QString& path);
297
298} // namespace PhosphorAnimationShaders
299
300// Mark TextureSlot as relocatable so QList can move-construct entries
301// in-place during reallocation rather than running the copy/move ctor
302// per element. The struct is two QStrings; QString itself is already
303// Q_RELOCATABLE_TYPE, so the aggregate is safely bitwise-relocatable.
304// Must sit at file scope outside the namespace per Qt convention.
Q_DECLARE_TYPEINFO(PhosphorAnimationShaders::AnimationShaderEffect::TextureSlot, Q_RELOCATABLE_TYPE)
Definition AnimationShaderContract.h:10
PHOSPHORANIMATION_EXPORT bool shaderEffectAppliesToEventPath(const AnimationShaderEffect &effect, const QString &path)
True iff effect may meaningfully run on event path.
Declared shader inputs beyond the standard set (iTime, iFrame, etc.).
Definition AnimationShaderEffect.h:216
QVariant maxValue
JSON/QML key: max.
Definition AnimationShaderEffect.h:224
QString name
Definition AnimationShaderEffect.h:218
QString description
Optional one-line tooltip for the settings UI.
Definition AnimationShaderEffect.h:220
QVariant minValue
JSON/QML key: min.
Definition AnimationShaderEffect.h:223
QVariant stepValue
Optional slider step; JSON/QML key: step. QML falls back to (max-min)/200.
Definition AnimationShaderEffect.h:225
QString group
Optional accordion group name for the settings UI.
Definition AnimationShaderEffect.h:221
QVariant defaultValue
JSON/QML key: default.
Definition AnimationShaderEffect.h:222
QString id
Definition AnimationShaderEffect.h:217
QString type
"float", "int", "bool", "color"
Definition AnimationShaderEffect.h:219
User texture slot.
Definition AnimationShaderEffect.h:250
QString wrap
"clamp" / "repeat" / "mirror"; empty = runtime default. Other values are rejected by fromJson.
Definition AnimationShaderEffect.h:253
bool operator!=(const TextureSlot &other) const
Definition AnimationShaderEffect.h:259
QString path
Filename relative to the effect's sourceDir.
Definition AnimationShaderEffect.h:251
bool operator==(const TextureSlot &other) const
Definition AnimationShaderEffect.h:255
Metadata for a single animation shader effect (transition).
Definition AnimationShaderEffect.h:45
QString version
Semantic version of this effect pack.
Definition AnimationShaderEffect.h:59
FboExtentKind
How wide the shader effect's render target is — relative to its anchor (default), or filling the surf...
Definition AnimationShaderEffect.h:170
QString fragmentShaderPath
Path to the fragment shader (relative to the effect dir).
Definition AnimationShaderEffect.h:84
QString author
Author attribution.
Definition AnimationShaderEffect.h:56
static AnimationShaderEffect fromJson(const QJsonObject &obj)
QString category
Category for settings-UI grouping (e.g. "Fade", "Geometric", "Glitch").
Definition AnimationShaderEffect.h:62
QString bufferFilter
Default filter mode for all buffer samplers.
Definition AnimationShaderEffect.h:138
QList< TextureSlot > textures
Definition AnimationShaderEffect.h:264
QStringList bufferShaderPaths
Buffer-pass shader paths (relative to effect dir).
Definition AnimationShaderEffect.h:104
QString id
Stable identifier — lookup key in the registry.
Definition AnimationShaderEffect.h:47
bool operator!=(const AnimationShaderEffect &other) const
Definition AnimationShaderEffect.h:275
bool operator==(const AnimationShaderEffect &other) const
QString sourceDir
Resolved absolute directory containing this effect's assets.
Definition AnimationShaderEffect.h:91
QString name
Human-readable display name (localizable by the consumer).
Definition AnimationShaderEffect.h:50
QList< ParameterInfo > parameters
Definition AnimationShaderEffect.h:227
QString bufferWrap
Default wrap mode for all buffer samplers.
Definition AnimationShaderEffect.h:130
QStringList bufferWraps
Per-buffer wrap-mode overrides; index aligns with bufferShaderPaths.
Definition AnimationShaderEffect.h:134
QString description
One-line description for settings UI tooltips.
Definition AnimationShaderEffect.h:53
QStringList bufferFilters
Per-buffer filter-mode overrides; index aligns with bufferShaderPaths.
Definition AnimationShaderEffect.h:142
bool isValid() const
Definition AnimationShaderEffect.h:266
QString previewPath
Preview image path (relative to the effect dir). For settings UI.
Definition AnimationShaderEffect.h:97
QString vertexShaderPath
Path to the vertex shader (relative to the effect dir).
Definition AnimationShaderEffect.h:88
QStringList appliesTo
Event-class tokens this effect is meaningful on.
Definition AnimationShaderEffect.h:79