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
9
10#include <QJsonObject>
11#include <QList>
12#include <QString>
13#include <QStringList>
14#include <QVariant>
15
17
45struct PHOSPHORANIMATION_EXPORT AnimationShaderEffect
46{
48 QString id;
49
51 QString name;
52
54 QString description;
55
57 QString author;
58
60 QString version;
61
63 QString category;
64
86 QStringList appliesTo;
87
92
96
98 QString sourceDir;
99
101 bool isUserEffect = false;
102
104 QString previewPath;
105
106 // ── Multipass / advanced features (opt-in, matching overlay ShaderInfo) ──
107
111 QStringList bufferShaderPaths;
112
118 bool isMultipass = false;
119
123 bool useWallpaper = false;
124
127 bool bufferFeedback = false;
128
132 qreal bufferScale = 1.0;
133
137 QString bufferWrap;
138
141 QStringList bufferWraps;
142
146
149 QStringList bufferFilters;
150
153 bool useDepthBuffer = false;
154
164 bool useAudio = false;
165
188 enum class FboExtentKind {
189 Anchor,
190 Surface,
191 };
192 FboExtentKind fboExtentKind = FboExtentKind::Anchor;
193
206 int geometryGridSubdivisions = 0;
207
214 static constexpr qreal kMinBufferScale = PhosphorShaders::kMinBufferScale;
215 static constexpr qreal kMaxBufferScale = PhosphorShaders::kMaxBufferScale;
216 static_assert(kMinBufferScale > 0.0 && kMinBufferScale < kMaxBufferScale,
217 "kMinBufferScale must be positive and strictly less than kMaxBufferScale");
218
225 static constexpr int kMaxGeometryGridSubdivisions = 128;
226
240 {
241 QString id;
242 QString name;
243 QString type;
244 QString description;
245 QString group;
246 QVariant defaultValue;
247 QVariant minValue;
248 QVariant maxValue;
249 QVariant stepValue;
250 };
251 QList<ParameterInfo> parameters;
252
274 {
275 QString path;
276 QString
278
279 bool operator==(const TextureSlot& other) const
280 {
281 return path == other.path && wrap == other.wrap;
282 }
283 bool operator!=(const TextureSlot& other) const
284 {
285 return !(*this == other);
286 }
287 };
288 QList<TextureSlot> textures;
289
290 bool isValid() const
291 {
292 return !id.isEmpty() && !fragmentShaderPath.isEmpty();
293 }
294
295 QJsonObject toJson() const;
296 static AnimationShaderEffect fromJson(const QJsonObject& obj);
297
298 bool operator==(const AnimationShaderEffect& other) const;
299 bool operator!=(const AnimationShaderEffect& other) const
300 {
301 return !(*this == other);
302 }
303};
304
328PHOSPHORANIMATION_EXPORT bool shaderEffectAppliesToEventPath(const AnimationShaderEffect& effect, const QString& path);
329
355PHOSPHORANIMATION_EXPORT bool shaderEffectIsCompositorOnly(const AnimationShaderEffect& effect);
356
357} // namespace PhosphorAnimationShaders
358
359// Mark TextureSlot as relocatable so QList can move-construct entries
360// in-place during reallocation rather than running the copy/move ctor
361// per element. The struct is two QStrings; QString itself is already
362// Q_RELOCATABLE_TYPE, so the aggregate is safely bitwise-relocatable.
363// 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.
PHOSPHORANIMATION_EXPORT bool shaderEffectIsCompositorOnly(const AnimationShaderEffect &effect)
True iff effect can ONLY execute on the compositor (kwin-effect) runtime and never on the daemon's ov...
constexpr double kMaxBufferScale
Definition CustomParamsKey.h:20
constexpr double kMinBufferScale
Lower / upper bounds on a multipass bufferScale (FBO downscale factor).
Definition CustomParamsKey.h:19
Declared shader inputs beyond the standard set (iTime, iFrame, etc.).
Definition AnimationShaderEffect.h:240
QVariant maxValue
JSON/QML key: max.
Definition AnimationShaderEffect.h:248
QString name
Definition AnimationShaderEffect.h:242
QString description
Optional one-line tooltip for the settings UI.
Definition AnimationShaderEffect.h:244
QVariant minValue
JSON/QML key: min.
Definition AnimationShaderEffect.h:247
QVariant stepValue
Optional slider step; JSON/QML key: step. QML falls back to (max-min)/200.
Definition AnimationShaderEffect.h:249
QString group
Optional accordion group name for the settings UI.
Definition AnimationShaderEffect.h:245
QVariant defaultValue
JSON/QML key: default.
Definition AnimationShaderEffect.h:246
QString id
Definition AnimationShaderEffect.h:241
QString type
"float", "int", "bool", "color"
Definition AnimationShaderEffect.h:243
User texture slot.
Definition AnimationShaderEffect.h:274
QString wrap
"clamp" / "repeat" / "mirror"; empty = runtime default. Other values are rejected by fromJson.
Definition AnimationShaderEffect.h:277
bool operator!=(const TextureSlot &other) const
Definition AnimationShaderEffect.h:283
QString path
Filename relative to the effect's sourceDir.
Definition AnimationShaderEffect.h:275
bool operator==(const TextureSlot &other) const
Definition AnimationShaderEffect.h:279
Metadata for a single animation shader effect (transition).
Definition AnimationShaderEffect.h:46
QString version
Semantic version of this effect pack.
Definition AnimationShaderEffect.h:60
FboExtentKind
How wide the shader effect's render target is — relative to its anchor (default), or filling the surf...
Definition AnimationShaderEffect.h:188
QString fragmentShaderPath
Path to the fragment shader (relative to the effect dir).
Definition AnimationShaderEffect.h:91
QString author
Author attribution.
Definition AnimationShaderEffect.h:57
static AnimationShaderEffect fromJson(const QJsonObject &obj)
QString category
Category for settings-UI grouping (e.g. "Fade", "Geometric", "Glitch").
Definition AnimationShaderEffect.h:63
QString bufferFilter
Default filter mode for all buffer samplers.
Definition AnimationShaderEffect.h:145
QList< TextureSlot > textures
Definition AnimationShaderEffect.h:288
QStringList bufferShaderPaths
Buffer-pass shader paths (relative to effect dir).
Definition AnimationShaderEffect.h:111
QString id
Stable identifier — lookup key in the registry.
Definition AnimationShaderEffect.h:48
bool operator!=(const AnimationShaderEffect &other) const
Definition AnimationShaderEffect.h:299
bool operator==(const AnimationShaderEffect &other) const
QString sourceDir
Resolved absolute directory containing this effect's assets.
Definition AnimationShaderEffect.h:98
QString name
Human-readable display name (localizable by the consumer).
Definition AnimationShaderEffect.h:51
QList< ParameterInfo > parameters
Definition AnimationShaderEffect.h:251
QString bufferWrap
Default wrap mode for all buffer samplers.
Definition AnimationShaderEffect.h:137
QStringList bufferWraps
Per-buffer wrap-mode overrides; index aligns with bufferShaderPaths.
Definition AnimationShaderEffect.h:141
QString description
One-line description for settings UI tooltips.
Definition AnimationShaderEffect.h:54
QStringList bufferFilters
Per-buffer filter-mode overrides; index aligns with bufferShaderPaths.
Definition AnimationShaderEffect.h:149
bool isValid() const
Definition AnimationShaderEffect.h:290
QString previewPath
Preview image path (relative to the effect dir). For settings UI.
Definition AnimationShaderEffect.h:104
QString vertexShaderPath
Path to the vertex shader (relative to the effect dir).
Definition AnimationShaderEffect.h:95
QStringList appliesTo
Event-class tokens this effect is meaningful on.
Definition AnimationShaderEffect.h:86