Phosphor
Qt6 / Wayland library suite for window-management tools
Loading...
Searching...
No Matches
SurfaceShaderRegistry.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 <PhosphorSurface/phosphorsurface_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
23namespace PhosphorSurfaceShaders {
24
79class PHOSPHORSURFACE_EXPORT SurfaceShaderRegistry : 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 SurfaceShaderEffect& effect() const
106 {
107 return m_effect;
108 }
109
110 private:
111 SurfaceShaderEffect m_effect;
112 };
113
114 explicit SurfaceShaderRegistry(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<SurfaceShaderEffect> availableEffects() const;
129 SurfaceShaderEffect effect(const QString& id) const;
130 bool hasEffect(const QString& id) const;
131 QStringList effectIds() const;
132
171 QVariantMap translateSurfaceParams(const QString& effectId, const QVariantMap& friendlyParams) const;
172
177 static QVariantMap translateSurfaceParams(const SurfaceShaderEffect& effect, const QVariantMap& friendlyParams);
178
191
204 static QString surfaceEntryPrologue();
205 static QList<PhosphorShaders::EntryCandidate> surfaceEntryCandidates();
206
222 static bool isBuiltinBufferShader(const QString& token);
223 static QString resolveBuiltinBufferShader(const QString& token, const QString& effectDir);
224
236 [[nodiscard]] static QString compositorVertexSource();
237
243 [[nodiscard]] static QString compositorBufferVertexSource();
244
250 [[nodiscard]] static QString compositorPresentVertexSource();
251
252Q_SIGNALS:
254
255private:
256 // Generic id-keyed storage + change-notify for the discovered effect
257 // packs. m_loader (below) populates it from disk; the lookup methods
258 // read it. Declared before m_loader so it is destroyed AFTER the loader:
259 // the loader holds a borrowed Registry pointer (used during live rescans
260 // in reconcile(), not at teardown), which must stay valid for the loader's
261 // whole lifetime.
263 // On-disk scan + hot-reload. Parses each pack's metadata.json into a
264 // SurfacePack and reconciles m_registry; its onCommitted hook
265 // re-emits effectsChanged.
266 std::unique_ptr<PhosphorRegistry::MetadataPackLoader<SurfacePack>> m_loader;
267};
268
269} // namespace PhosphorSurfaceShaders
Definition IFactoryBase.h:27
Definition Registry.h:88
QString id() const override
Definition SurfaceShaderRegistry.h:97
const SurfaceShaderEffect & effect() const
Definition SurfaceShaderRegistry.h:105
SurfacePack(SurfaceShaderEffect effect)
Definition SurfaceShaderRegistry.h:93
QString displayName() const override
Definition SurfaceShaderRegistry.h:101
static QString compositorBufferVertexSource()
The vertex stage of every surface BUFFER pass on the compositor: a unit quad already in clip space (n...
static QString resolveBuiltinBufferShader(const QString &token, const QString &effectDir)
void addSearchPath(const QString &path, PhosphorFsLoader::LiveReload liveReload=PhosphorFsLoader::LiveReload::On)
QList< SurfaceShaderEffect > availableEffects() const
void addSearchPaths(const QStringList &paths, PhosphorFsLoader::LiveReload liveReload=PhosphorFsLoader::LiveReload::On, PhosphorFsLoader::RegistrationOrder order=PhosphorFsLoader::RegistrationOrder::LowestPriorityFirst)
static bool isBuiltinBufferShader(const QString &token)
Resolve a builtin: buffer-shader token (e.g.
bool hasEffect(const QString &id) const
static QString surfaceEntryPrologue()
Entry-point scaffold, matching the overlay (pZone/pImage) and animation (pTransition/pIn+pOut) catego...
static QList< PhosphorShaders::EntryCandidate > surfaceEntryCandidates()
static QString compositorVertexSource()
The vertex stage the COMPOSITOR compiles for every surface pack that declares none of its own (the bu...
SurfaceShaderRegistry(QObject *parent=nullptr)
SurfaceShaderEffect effect(const QString &id) const
static QString compositorPresentVertexSource()
The vertex stage of the decoration PRESENT shader, the passthrough that samples a decorated window's ...
QVariantMap translateSurfaceParams(const QString &effectId, const QVariantMap &friendlyParams) const
Translate a friendly parameter map into the canonical slot keys consumed by both runtimes that drive ...
static QVariantMap translateSurfaceParams(const SurfaceShaderEffect &effect, const QVariantMap &friendlyParams)
Static counterpart for callers that already hold the resolved SurfaceShaderEffect (e....
static QString paramPreamble(const SurfaceShaderEffect &effect)
Build the generated #define p_<id> <glsl-accessor> preamble for effect's declared parameters so autho...
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
Definition DecorationProfile.h:31
Metadata for a single surface shader effect.
Definition SurfaceShaderEffect.h:81