Registry of available animation shader transition effects. More...
#include <phosphor-animation/include/PhosphorAnimation/AnimationShaderRegistry.h>
Signals | |
| void | effectsChanged () |
Public Member Functions | |
| AnimationShaderRegistry (QObject *parent=nullptr) | |
| ~AnimationShaderRegistry () override | |
| QList< AnimationShaderEffect > | availableEffects () const |
| AnimationShaderEffect | effect (const QString &id) const |
| bool | hasEffect (const QString &id) const |
| QStringList | effectIds () const |
| 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 animation shaders. | |
Public Member Functions inherited from PhosphorFsLoader::MetadataPackRegistryBase | |
| ~MetadataPackRegistryBase () override | |
| void | addSearchPath (const QString &path, LiveReload liveReload=LiveReload::On) |
| Add a single search-path directory. | |
| void | addSearchPaths (const QStringList &paths, LiveReload liveReload=LiveReload::On, RegistrationOrder order=RegistrationOrder::LowestPriorityFirst) |
| Add multiple search-path directories in one shot. | |
| QStringList | searchPaths () const |
| Currently-registered search paths in registration order. | |
| void | setUserPath (const QString &path) |
Mark path as the user-data root for isUser classification on discovered packs. | |
| void | refresh () |
| Synchronous rescan — re-walks every search path on the calling stack, replaces the strategy's pack map, and fires the consumer's content-changed signal if the strategy reports a signature change. | |
Static Public Member Functions | |
| static QVariantMap | translateAnimationParams (const AnimationShaderEffect &effect, const QVariantMap &friendlyParams) |
Static counterpart for callers that already hold the resolved AnimationShaderEffect (e.g. | |
Protected Member Functions | |
| void | onUserPathChanged (const QString &path) override |
Hook invoked from setUserPath when the path actually changes. | |
Protected Member Functions inherited from PhosphorFsLoader::MetadataPackRegistryBase | |
| MetadataPackRegistryBase (const QLoggingCategory &logCat, std::unique_ptr< IScanStrategy > strategy, QObject *parent=nullptr) | |
Construct the base, taking ownership of strategy. | |
| IScanStrategy * | strategy () const |
| Strategy accessor for subclasses. | |
| WatchedDirectorySet * | watcher () const |
| Watcher accessor for subclasses that need direct ops not covered by the base API (e.g. | |
Registry of available animation shader transition effects.
Discovers shader packs from configured search paths. Each pack is a subdirectory containing a metadata.json describing the effect plus the shader source files it references.
The subdirectory name is decorative — the id field in metadata.json is the registry key. This matches PhosphorShaders::ShaderRegistry's convention for zone shaders.
Search-path management (addSearchPath, addSearchPaths, searchPaths, setUserPath, refresh) is inherited from PhosphorFsLoader::MetadataPackRegistryBase. The first addSearchPath[s] call with LiveReload::On (the default) installs a QFileSystemWatcher with the standard 50 ms debounce, parent-watch promotion for missing user-data dirs, per-file watches re-armed on every rescan, and rescan-during-rescan race protection. Forbidden roots ($HOME, /, XDG data/config/cache/temp/runtime, Documents, Downloads) are refused.
effectsChanged is gated on a SHA-1 signature change inside the strategy — emits exactly when the discovered set or any payload fingerprint actually differs from the previous scan, including any metadata.json field edit (the strategy mixes the metadata file's size+mtime into the per-rescan signature).
GUI-thread only for both reads and mutations. The pack map lives inside the strategy and is rebuilt on the GUI thread inside the rescan; the public lookup methods read it without synchronisation.
searchPaths() is the one exception: it returns a by-value snapshot of an implicitly-shared QStringList, so a GUI-thread caller can snapshot it and propagate the result to worker threads. Calling it from a worker thread concurrently with a GUI-thread mutation is a data race; snapshot on the GUI thread first.
|
explicit |
|
override |
| QList< AnimationShaderEffect > PhosphorAnimationShaders::AnimationShaderRegistry::availableEffects | ( | ) | const |
| AnimationShaderEffect PhosphorAnimationShaders::AnimationShaderRegistry::effect | ( | const QString & | id | ) | const |
| QStringList PhosphorAnimationShaders::AnimationShaderRegistry::effectIds | ( | ) | const |
|
signal |
| bool PhosphorAnimationShaders::AnimationShaderRegistry::hasEffect | ( | const QString & | id | ) | const |
|
overrideprotectedvirtual |
Hook invoked from setUserPath when the path actually changes.
Subclass forwards the new value into the typed strategy (m_strategy->setUserPath(path)). The base then triggers a rescan if any directories are registered.
Implements PhosphorFsLoader::MetadataPackRegistryBase.
|
static |
Static counterpart for callers that already hold the resolved AnimationShaderEffect (e.g.
the kwin-effect's per-frame translation). Same slot-allocation contract as the registry-keyed overload.
| QVariantMap PhosphorAnimationShaders::AnimationShaderRegistry::translateAnimationParams | ( | const QString & | effectId, |
| const QVariantMap & | friendlyParams | ||
| ) | const |
Translate a friendly parameter map into the canonical slot keys consumed by both runtimes that drive animation shaders.
Two independent allocators advance in metadata declaration order:
• Float / int / bool parameters fill customParams<N>_<x|y|z|w> — the first declared param lands in customParams1_x, the second in customParams1_y, …, the fifth in customParams2_x, up to 32 slots (AnimationShaderContract::kMaxParameterSlots).
• Color parameters fill customColor<N> — the first declared color lands in customColor1, the second in customColor2, up to 16 slots (AnimationShaderContract::kMaxCustomColors). Color values are coerced to QColor at this boundary — anything QColor::QColor(QString) accepts is accepted here too (the common cases are "#rgb", "#rrggbb", and "#aarrggbb" with alpha FIRST per Qt's convention; the parser also recognises higher-bit-depth "#rrrgggbbb" / "#rrrrggggbbbb", SVG colour names like "red", and the "transparent" keyword) — alongside QColor instances. Everything else falls back to the declared default, then Qt::transparent. CSS-style "#rrggbbaa" (alpha LAST, 9 chars) is NOT accepted — any 9-char hex string is ambiguous between Qt-form and CSS-form, so a rewrite would silently corrupt configs that already use Qt's order; settings UI / config writers MUST emit Qt-form.
The two allocators advance independently — a color parameter does NOT consume a customParams sub-slot, so a [color, float] declaration produces customColor1 + customParams1_x, not customColor1 + customParams1_y.
Bool values become 0.0 or 1.0. Missing float keys fall back to the metadata-declared default, then to 0.0. Unknown parameter ids in friendlyParams are silently ignored. Slot-budget overflows log a warning and drop the offending parameter.
Returns an empty map when effectId resolves to no registered effect or when the effect declares no parameters.