Registry of available shader effects. More...
#include <phosphor-shaders/include/PhosphorShaders/ShaderRegistry.h>
Classes | |
| struct | ParameterInfo |
| struct | ShaderInfo |
Signals | |
| void | shadersChanged () |
| void | shaderCompilationStarted (const QString &shaderId) |
| void | shaderCompilationFinished (const QString &shaderId, bool success, const QString &error) |
Public Member Functions | |
| ShaderRegistry (QObject *parent=nullptr) | |
| ~ShaderRegistry () override | |
| QList< ShaderInfo > | availableShaders () const |
| QVariantList | availableShadersVariant () const |
| ShaderInfo | shader (const QString &id) const |
| QVariantMap | shaderInfo (const QString &id) const |
| QUrl | shaderUrl (const QString &id) const |
| QVariantMap | defaultParams (const QString &id) const |
| bool | validateParams (const QString &id, const QVariantMap ¶ms) const |
| QVariantMap | validateAndCoerceParams (const QString &id, const QVariantMap ¶ms) const |
| QVariantMap | translateParamsToUniforms (const QString &shaderId, const QVariantMap &storedParams) const |
| QVariantMap | presetParams (const QString &shaderId, const QString &presetName) const |
| QStringList | shaderPresetNames (const QString &shaderId) const |
| QVariantList | shaderPresetsVariant (const QString &shaderId) const |
| bool | shadersEnabled () const |
Always true — once a ShaderRegistry is constructed, shader discovery and metadata are functional (the registry is purely a metadata-pack walker; actual shader compilation lives in the phosphor-rendering library which carries the Qt6::ShaderTools dependency). | |
| void | reportShaderBakeStarted (const QString &shaderId) |
| void | reportShaderBakeFinished (const QString &shaderId, bool success, const QString &error) |
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 QString | noneShaderUuid () |
| static bool | isNoneShader (const QString &id) |
| static QString | wallpaperPath () |
| static QImage | loadWallpaperImage () |
| static QImage | loadWallpaperImage (const QRect &subGeom, const QRect &physGeom) |
Return the wallpaper image cropped to the portion that a sub-region (subGeom) occupies on a physical screen (physGeom), assuming "cover" scaling (aspect-correct fill, centered, overflow cropped) — the same placement model the wallpaperUv GLSL helper uses. | |
| static QRect | computeWallpaperCropRect (QSize wpSize, const QRect &physGeom, const QRect &subGeom) |
Pure geometry helper: compute the pixel rect inside a wallpaper of size wpSize that corresponds to subGeom when the wallpaper covers physGeom under the same "cover" placement used by wallpaperUv. | |
| static void | invalidateWallpaperCache () |
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 shader effects.
Discovers shaders from configured search paths, validates metadata, manages parameter presets, and watches for file changes.
Composition roots own a per-process instance and register search paths explicitly — there is no library-level singleton. Tests construct a per-fixture registry; downstream consumers (PlasmaZones shell, future plugin compositors) instantiate their own.
Search-path management (addSearchPath, addSearchPaths, searchPaths, setUserPath, refresh) is inherited from PhosphorFsLoader::MetadataPackRegistryBase.
GUI-thread only for both reads and mutations. The shader map lives inside the strategy and is rebuilt on the GUI thread inside the rescan; the public lookup methods (availableShaders, shader, shaderInfo, shaderUrl) 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 (this is the shader-warming path's contract). Calling searchPaths() from a worker thread concurrently with a GUI-thread mutation is a data race; snapshot on the GUI thread first.
|
explicit |
|
override |
| QList< ShaderInfo > PhosphorShaders::ShaderRegistry::availableShaders | ( | ) | const |
| QVariantList PhosphorShaders::ShaderRegistry::availableShadersVariant | ( | ) | const |
|
static |
Pure geometry helper: compute the pixel rect inside a wallpaper of size wpSize that corresponds to subGeom when the wallpaper covers physGeom under the same "cover" placement used by wallpaperUv.
Returns an invalid rect if inputs are degenerate or if subGeom fully covers physGeom (caller should use the full image in that case). Exposed for unit testing.
| QVariantMap PhosphorShaders::ShaderRegistry::defaultParams | ( | const QString & | id | ) | const |
|
static |
|
static |
|
static |
|
static |
Return the wallpaper image cropped to the portion that a sub-region (subGeom) occupies on a physical screen (physGeom), assuming "cover" scaling (aspect-correct fill, centered, overflow cropped) — the same placement model the wallpaperUv GLSL helper uses.
Returns the full (uncropped) wallpaper when either rect is invalid or when subGeom covers all of physGeom.
Virtual screens that share a physical monitor need this so each VS samples the wallpaper portion it occupies on the monitor, instead of each getting the center-cropped wallpaper as if it were a full screen.
The result is memoized keyed on (subGeom, physGeom, wallpaper mtime), so repeated calls for the same VS return the same QImage (stable cacheKey()) and avoid re-uploading to the GPU each frame.
|
static |
|
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.
| QVariantMap PhosphorShaders::ShaderRegistry::presetParams | ( | const QString & | shaderId, |
| const QString & | presetName | ||
| ) | const |
| void PhosphorShaders::ShaderRegistry::reportShaderBakeFinished | ( | const QString & | shaderId, |
| bool | success, | ||
| const QString & | error | ||
| ) |
| void PhosphorShaders::ShaderRegistry::reportShaderBakeStarted | ( | const QString & | shaderId | ) |
| ShaderInfo PhosphorShaders::ShaderRegistry::shader | ( | const QString & | id | ) | const |
|
signal |
|
signal |
| QVariantMap PhosphorShaders::ShaderRegistry::shaderInfo | ( | const QString & | id | ) | const |
| QStringList PhosphorShaders::ShaderRegistry::shaderPresetNames | ( | const QString & | shaderId | ) | const |
| QVariantList PhosphorShaders::ShaderRegistry::shaderPresetsVariant | ( | const QString & | shaderId | ) | const |
|
signal |
|
inline |
Always true — once a ShaderRegistry is constructed, shader discovery and metadata are functional (the registry is purely a metadata-pack walker; actual shader compilation lives in the phosphor-rendering library which carries the Qt6::ShaderTools dependency).
Kept as Q_INVOKABLE because QML callers historically used it as a feature gate from the era when the build had an opt-out for shader support; new code can omit the check.
| QUrl PhosphorShaders::ShaderRegistry::shaderUrl | ( | const QString & | id | ) | const |
| QVariantMap PhosphorShaders::ShaderRegistry::translateParamsToUniforms | ( | const QString & | shaderId, |
| const QVariantMap & | storedParams | ||
| ) | const |
| QVariantMap PhosphorShaders::ShaderRegistry::validateAndCoerceParams | ( | const QString & | id, |
| const QVariantMap & | params | ||
| ) | const |
| bool PhosphorShaders::ShaderRegistry::validateParams | ( | const QString & | id, |
| const QVariantMap & | params | ||
| ) | const |
|
static |