Phosphor
Qt6 / Wayland library suite for window-management tools
Loading...
Searching...
No Matches
AnimationShaderRegistry.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
7#include <PhosphorAnimation/phosphoranimation_export.h>
8
12
14
15#include <QList>
16#include <QObject>
17#include <QString>
18#include <QStringList>
19#include <QVariantMap>
20
21#include <memory>
22
24
79class PHOSPHORANIMATION_EXPORT AnimationShaderRegistry : public QObject
80{
81 Q_OBJECT
82
83public:
91 {
92 public:
94 : m_effect(std::move(effect))
95 {
96 }
97 [[nodiscard]] QString id() const override
98 {
99 return m_effect.id;
100 }
101 [[nodiscard]] QString displayName() const override
102 {
103 return m_effect.name;
104 }
105 [[nodiscard]] const AnimationShaderEffect& effect() const
106 {
107 return m_effect;
108 }
109
110 private:
111 AnimationShaderEffect m_effect;
112 };
113
114 explicit AnimationShaderRegistry(QObject* parent = nullptr);
116
117 // ── Search paths (forwarded to the internal MetadataPackLoader) ───
120 const QStringList& paths, PhosphorFsLoader::LiveReload liveReload = PhosphorFsLoader::LiveReload::On,
122 [[nodiscard]] QStringList searchPaths() const;
123 void setUserPath(const QString& path);
124 void refresh();
125
126 // Lookup -------------------------------------------------------------------
127
128 QList<AnimationShaderEffect> availableEffects() const;
129 AnimationShaderEffect effect(const QString& id) const;
130 bool hasEffect(const QString& id) const;
131 QStringList effectIds() const;
132
171 QVariantMap translateAnimationParams(const QString& effectId, const QVariantMap& friendlyParams) const;
172
177 static QVariantMap translateAnimationParams(const AnimationShaderEffect& effect, const QVariantMap& friendlyParams);
178
191
198 static QString animationEntryPrologue();
199
209 static QList<PhosphorShaders::EntryCandidate> animationEntryCandidates();
210
223 [[nodiscard]] static QString compositorVertexSource();
224
236 [[nodiscard]] static QString compositorScreenVertexSource();
237
259 [[nodiscard]] QStringList sharedIncludePaths() const;
260
270 [[nodiscard]] QString defaultVertexShaderPath() const;
271
272Q_SIGNALS:
274
275private:
276 // Generic id-keyed storage + change-notify for the discovered effect
277 // packs. m_loader (below) populates it from disk; the lookup methods
278 // read it. Declared before m_loader so it is destroyed AFTER the loader:
279 // the loader holds a borrowed Registry pointer (used during live rescans
280 // in reconcile(), not at teardown), which must stay valid for the loader's
281 // whole lifetime.
283 // On-disk scan + hot-reload. Parses each pack's metadata.json into an
284 // AnimationPack and reconciles m_registry; its onCommitted hook
285 // re-emits effectsChanged.
286 std::unique_ptr<PhosphorRegistry::MetadataPackLoader<AnimationPack>> m_loader;
287};
288
289} // namespace PhosphorAnimationShaders
QString displayName() const override
Definition AnimationShaderRegistry.h:101
QString id() const override
Definition AnimationShaderRegistry.h:97
AnimationPack(AnimationShaderEffect effect)
Definition AnimationShaderRegistry.h:93
const AnimationShaderEffect & effect() const
Definition AnimationShaderRegistry.h:105
QString defaultVertexShaderPath() const
The shared animation.vert a pack that declares no vertex stage falls back to: the first one that exis...
static QString compositorVertexSource()
The vertex stage the COMPOSITOR compiles for every per-window animation pack that declares none of it...
void addSearchPaths(const QStringList &paths, PhosphorFsLoader::LiveReload liveReload=PhosphorFsLoader::LiveReload::On, PhosphorFsLoader::RegistrationOrder order=PhosphorFsLoader::RegistrationOrder::LowestPriorityFirst)
QVariantMap translateAnimationParams(const QString &effectId, const QVariantMap &friendlyParams) const
Translate a friendly parameter map into the canonical slot keys consumed by both runtimes that drive ...
static QString compositorScreenVertexSource()
The vertex stage of the SCREEN-level passes (desktop switch and strip), which draw one full-output qu...
static QList< PhosphorShaders::EntryCandidate > animationEntryCandidates()
The direction-dispatched entry candidates (T1.5), in priority order: • vec4 pTransition(vec2 uv,...
static QString animationEntryPrologue()
The T1.4/T1.5 entry-point prologue for animation shaders: #version, the animation_uniforms....
QList< AnimationShaderEffect > availableEffects() const
QStringList sharedIncludePaths() const
The shared subdirectory of every search path that has one, in PRIORITY order: the user directory firs...
void addSearchPath(const QString &path, PhosphorFsLoader::LiveReload liveReload=PhosphorFsLoader::LiveReload::On)
static QString paramPreamble(const AnimationShaderEffect &effect)
Build the generated #define p_<id> <glsl-accessor> preamble for effect's declared parameters so autho...
AnimationShaderEffect effect(const QString &id) const
static QVariantMap translateAnimationParams(const AnimationShaderEffect &effect, const QVariantMap &friendlyParams)
Static counterpart for callers that already hold the resolved AnimationShaderEffect (e....
Definition IFactoryBase.h:27
Definition Registry.h:88
Definition AnimationShaderContract.h:10
RegistrationOrder
Caller's declared priority direction for registerDirectories / setDirectories input.
Definition WatchedDirectorySet.h:64
@ LowestPriorityFirst
[sys-lowest, ..., sys-highest, user] — the canonical strategy view.
Definition WatchedDirectorySet.h:69
LiveReload
Opt-in policy for directory watching.
Definition WatchedDirectorySet.h:40
@ On
Definition WatchedDirectorySet.h:42
Metadata for a single animation shader effect (transition).
Definition AnimationShaderEffect.h:47