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
68
72
74 QString sourceDir;
75
77 bool isUserEffect = false;
78
80 QString previewPath;
81
82 // ── Multipass / advanced features (opt-in, matching overlay ShaderInfo) ──
83
87 QStringList bufferShaderPaths;
88
94 bool isMultipass = false;
95
99 bool useWallpaper = false;
100
103 bool bufferFeedback = false;
104
108 qreal bufferScale = 1.0;
109
113 QString bufferWrap;
114
117 QStringList bufferWraps;
118
122
125 QStringList bufferFilters;
126
129 bool useDepthBuffer = false;
130
153 enum class FboExtentKind {
154 Anchor,
155 Surface,
156 };
157 FboExtentKind fboExtentKind = FboExtentKind::Anchor;
158
167 static constexpr qreal kMinBufferScale = 0.125;
168 static constexpr qreal kMaxBufferScale = 1.0;
169 static_assert(kMinBufferScale > 0.0 && kMinBufferScale < kMaxBufferScale,
170 "kMinBufferScale must be positive and strictly less than kMaxBufferScale");
171
185 {
186 QString id;
187 QString name;
188 QString type;
189 QString description;
190 QString group;
191 QVariant defaultValue;
192 QVariant minValue;
193 QVariant maxValue;
194 QVariant stepValue;
195 };
196 QList<ParameterInfo> parameters;
197
219 {
220 QString path;
221 QString
223
224 bool operator==(const TextureSlot& other) const
225 {
226 return path == other.path && wrap == other.wrap;
227 }
228 bool operator!=(const TextureSlot& other) const
229 {
230 return !(*this == other);
231 }
232 };
233 QList<TextureSlot> textures;
234
235 bool isValid() const
236 {
237 return !id.isEmpty() && !fragmentShaderPath.isEmpty();
238 }
239
240 QJsonObject toJson() const;
241 static AnimationShaderEffect fromJson(const QJsonObject& obj);
242
243 bool operator==(const AnimationShaderEffect& other) const;
244 bool operator!=(const AnimationShaderEffect& other) const
245 {
246 return !(*this == other);
247 }
248};
249
250} // namespace PhosphorAnimationShaders
251
252// Mark TextureSlot as relocatable so QList can move-construct entries
253// in-place during reallocation rather than running the copy/move ctor
254// per element. The struct is two QStrings; QString itself is already
255// Q_RELOCATABLE_TYPE, so the aggregate is safely bitwise-relocatable.
256// Must sit at file scope outside the namespace per Qt convention.
Q_DECLARE_TYPEINFO(PhosphorAnimationShaders::AnimationShaderEffect::TextureSlot, Q_RELOCATABLE_TYPE)
Definition AnimationAppRule.h:17
Declared shader inputs beyond the standard set (iTime, iFrame, etc.).
Definition AnimationShaderEffect.h:185
QVariant maxValue
JSON/QML key: max.
Definition AnimationShaderEffect.h:193
QString name
Definition AnimationShaderEffect.h:187
QString description
Optional one-line tooltip for the settings UI.
Definition AnimationShaderEffect.h:189
QVariant minValue
JSON/QML key: min.
Definition AnimationShaderEffect.h:192
QVariant stepValue
Optional slider step; JSON/QML key: step. QML falls back to (max-min)/200.
Definition AnimationShaderEffect.h:194
QString group
Optional accordion group name for the settings UI.
Definition AnimationShaderEffect.h:190
QVariant defaultValue
JSON/QML key: default.
Definition AnimationShaderEffect.h:191
QString id
Definition AnimationShaderEffect.h:186
QString type
"float", "int", "bool", "color"
Definition AnimationShaderEffect.h:188
User texture slot.
Definition AnimationShaderEffect.h:219
QString wrap
"clamp" / "repeat" / "mirror"; empty = runtime default. Other values are rejected by fromJson.
Definition AnimationShaderEffect.h:222
bool operator!=(const TextureSlot &other) const
Definition AnimationShaderEffect.h:228
QString path
Filename relative to the effect's sourceDir.
Definition AnimationShaderEffect.h:220
bool operator==(const TextureSlot &other) const
Definition AnimationShaderEffect.h:224
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:153
QString fragmentShaderPath
Path to the fragment shader (relative to the effect dir).
Definition AnimationShaderEffect.h:67
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:121
QList< TextureSlot > textures
Definition AnimationShaderEffect.h:233
QStringList bufferShaderPaths
Buffer-pass shader paths (relative to effect dir).
Definition AnimationShaderEffect.h:87
QString id
Stable identifier — lookup key in the registry.
Definition AnimationShaderEffect.h:47
bool operator!=(const AnimationShaderEffect &other) const
Definition AnimationShaderEffect.h:244
bool operator==(const AnimationShaderEffect &other) const
QString sourceDir
Resolved absolute directory containing this effect's assets.
Definition AnimationShaderEffect.h:74
QString name
Human-readable display name (localizable by the consumer).
Definition AnimationShaderEffect.h:50
QList< ParameterInfo > parameters
Definition AnimationShaderEffect.h:196
QString bufferWrap
Default wrap mode for all buffer samplers.
Definition AnimationShaderEffect.h:113
QStringList bufferWraps
Per-buffer wrap-mode overrides; index aligns with bufferShaderPaths.
Definition AnimationShaderEffect.h:117
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:125
bool isValid() const
Definition AnimationShaderEffect.h:235
QString previewPath
Preview image path (relative to the effect dir). For settings UI.
Definition AnimationShaderEffect.h:80
QString vertexShaderPath
Path to the vertex shader (relative to the effect dir).
Definition AnimationShaderEffect.h:71