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
10
11#include <QJsonObject>
12#include <QList>
13#include <QString>
14#include <QStringList>
15#include <QVariant>
16
18
46struct PHOSPHORANIMATION_EXPORT AnimationShaderEffect
47{
49 QString id;
50
52 QString name;
53
55 QString description;
56
58 QString author;
59
61 QString version;
62
64 QString category;
65
89 QStringList appliesTo;
90
95
99
101 QString sourceDir;
102
104 bool isUserEffect = false;
105
107 QString previewPath;
108
109 // ── Multipass / advanced features (opt-in, matching overlay ShaderInfo) ──
110
114 QStringList bufferShaderPaths;
115
121 bool isMultipass = false;
122
126 bool useWallpaper = false;
127
130 bool bufferFeedback = false;
131
135 qreal bufferScale = 1.0;
136
140 QString bufferWrap;
141
144 QStringList bufferWraps;
145
149
152 QStringList bufferFilters;
153
156 bool useDepthBuffer = false;
157
172 bool useAudio = false;
173
196 enum class FboExtentKind {
197 Anchor,
198 Surface,
199 };
201
215
225 static_assert(kMinBufferScale > 0.0 && kMinBufferScale < kMaxBufferScale,
226 "kMinBufferScale must be positive and strictly less than kMaxBufferScale");
227
234 static constexpr int kMaxGeometryGridSubdivisions = 128;
235
249 {
250 QString id;
251 QString name;
252 QString type;
253 QString description;
254 QString group;
255 QVariant defaultValue;
256 QVariant minValue;
257 QVariant maxValue;
258 QVariant stepValue;
259 };
260 QList<ParameterInfo> parameters;
261
283 {
284 QString path;
285 QString
287
288 bool operator==(const TextureSlot& other) const
289 {
290 return path == other.path && wrap == other.wrap;
291 }
292 bool operator!=(const TextureSlot& other) const
293 {
294 return !(*this == other);
295 }
296 };
297 QList<TextureSlot> textures;
298
309
310 bool isValid() const
311 {
312 return !id.isEmpty() && !fragmentShaderPath.isEmpty();
313 }
314
315 QJsonObject toJson() const;
316 static AnimationShaderEffect fromJson(const QJsonObject& obj);
317
318 bool operator==(const AnimationShaderEffect& other) const;
319 bool operator!=(const AnimationShaderEffect& other) const
320 {
321 return !(*this == other);
322 }
323};
324
348PHOSPHORANIMATION_EXPORT bool shaderEffectAppliesToEventPath(const AnimationShaderEffect& effect, const QString& path);
349
374PHOSPHORANIMATION_EXPORT bool shaderEffectIsCompositorOnly(const AnimationShaderEffect& effect);
375
376} // namespace PhosphorAnimationShaders
377
378// Mark TextureSlot as relocatable so QList can move-construct entries
379// in-place during reallocation rather than running the copy/move ctor
380// per element. The struct is two QStrings; QString itself is already
381// Q_RELOCATABLE_TYPE, so the aggregate is safely bitwise-relocatable.
382// 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:37
constexpr double kMinBufferScale
Lower / upper bounds on a multipass bufferScale (FBO downscale factor).
Definition CustomParamsKey.h:36
QMap< QString, QVariantMap > PackPresets
Pack-declared named parameter presets: preset name → { paramId → value }.
Definition ShaderPresetParse.h:32
Declared shader inputs beyond the standard set (iTime, iFrame, etc.).
Definition AnimationShaderEffect.h:249
QVariant maxValue
JSON/QML key: max.
Definition AnimationShaderEffect.h:257
QString name
Definition AnimationShaderEffect.h:251
QString description
Optional one-line tooltip for the settings UI.
Definition AnimationShaderEffect.h:253
QVariant minValue
JSON/QML key: min.
Definition AnimationShaderEffect.h:256
QVariant stepValue
Optional slider step; JSON/QML key: step. QML falls back to (max-min)/200.
Definition AnimationShaderEffect.h:258
QString group
Optional accordion group name for the settings UI.
Definition AnimationShaderEffect.h:254
QVariant defaultValue
JSON/QML key: default.
Definition AnimationShaderEffect.h:255
QString id
Definition AnimationShaderEffect.h:250
QString type
"float", "int", "bool", "color"
Definition AnimationShaderEffect.h:252
User texture slot.
Definition AnimationShaderEffect.h:283
QString wrap
"clamp" / "repeat" / "mirror"; empty = runtime default. Other values are rejected by fromJson.
Definition AnimationShaderEffect.h:286
bool operator!=(const TextureSlot &other) const
Definition AnimationShaderEffect.h:292
QString path
Filename relative to the effect's sourceDir.
Definition AnimationShaderEffect.h:284
bool operator==(const TextureSlot &other) const
Definition AnimationShaderEffect.h:288
Metadata for a single animation shader effect (transition).
Definition AnimationShaderEffect.h:47
QString version
Semantic version of this effect pack.
Definition AnimationShaderEffect.h:61
FboExtentKind
How wide the shader effect's render target is — relative to its anchor (default), or filling the surf...
Definition AnimationShaderEffect.h:196
bool useDepthBuffer
Allocate a depth buffer alongside the colour FBO so the shader can sample window depth.
Definition AnimationShaderEffect.h:156
QString fragmentShaderPath
Path to the fragment shader (relative to the effect dir).
Definition AnimationShaderEffect.h:94
QString author
Author attribution.
Definition AnimationShaderEffect.h:58
bool isMultipass
Opt-in multipass mode.
Definition AnimationShaderEffect.h:121
static AnimationShaderEffect fromJson(const QJsonObject &obj)
QString category
Category for settings-UI grouping (e.g. "Fade", "Geometric", "Glitch").
Definition AnimationShaderEffect.h:64
int geometryGridSubdivisions
Per-axis subdivision count for geometry shaders that deform the drawn quad in the vertex stage (e....
Definition AnimationShaderEffect.h:214
QString bufferFilter
Default filter mode for all buffer samplers.
Definition AnimationShaderEffect.h:148
PhosphorShaders::PackPresets presets
Pack-declared named parameter presets: preset name -> { paramId -> value }.
Definition AnimationShaderEffect.h:308
QList< TextureSlot > textures
Definition AnimationShaderEffect.h:297
bool isUserEffect
Whether this effect was loaded from a user-local directory.
Definition AnimationShaderEffect.h:104
QStringList bufferShaderPaths
Buffer-pass shader paths (relative to effect dir).
Definition AnimationShaderEffect.h:114
QString id
Stable identifier — lookup key in the registry.
Definition AnimationShaderEffect.h:49
bool operator!=(const AnimationShaderEffect &other) const
Definition AnimationShaderEffect.h:319
bool operator==(const AnimationShaderEffect &other) const
QString sourceDir
Resolved absolute directory containing this effect's assets.
Definition AnimationShaderEffect.h:101
QString name
Human-readable display name (localizable by the consumer).
Definition AnimationShaderEffect.h:52
QList< ParameterInfo > parameters
Definition AnimationShaderEffect.h:260
bool useAudio
Audio-reactive opt-in (JSON key audio, matching the surface pack vocabulary).
Definition AnimationShaderEffect.h:172
QString bufferWrap
Default wrap mode for all buffer samplers.
Definition AnimationShaderEffect.h:140
static constexpr qreal kMaxBufferScale
Definition AnimationShaderEffect.h:224
QStringList bufferWraps
Per-buffer wrap-mode overrides; index aligns with bufferShaderPaths.
Definition AnimationShaderEffect.h:144
QString description
One-line description for settings UI tooltips.
Definition AnimationShaderEffect.h:55
QStringList bufferFilters
Per-buffer filter-mode overrides; index aligns with bufferShaderPaths.
Definition AnimationShaderEffect.h:152
bool isValid() const
Definition AnimationShaderEffect.h:310
qreal bufferScale
Render-target scale relative to the surface size.
Definition AnimationShaderEffect.h:135
FboExtentKind fboExtentKind
Definition AnimationShaderEffect.h:200
static constexpr qreal kMinBufferScale
Lower / upper bounds on bufferScale (multipass FBO downscale factor) — forwarders onto the cross-libr...
Definition AnimationShaderEffect.h:223
static constexpr int kMaxGeometryGridSubdivisions
Upper bound for geometryGridSubdivisions.
Definition AnimationShaderEffect.h:234
QString previewPath
Preview image path (relative to the effect dir). For settings UI.
Definition AnimationShaderEffect.h:107
QString vertexShaderPath
Path to the vertex shader (relative to the effect dir).
Definition AnimationShaderEffect.h:98
bool bufferFeedback
Enable per-pass feedback (last frame's buffer is sampleable as iChannel<N>).
Definition AnimationShaderEffect.h:130
QStringList appliesTo
Event-class tokens this effect is meaningful on.
Definition AnimationShaderEffect.h:89
bool useWallpaper
Bind the user's wallpaper as a sampler.
Definition AnimationShaderEffect.h:126