Phosphor
Qt6 / Wayland library suite for window-management tools
 
Loading...
Searching...
No Matches
PhosphorShaders::ShaderRegistry Class Reference

Registry of available shader effects. More...

#include <phosphor-shaders/include/PhosphorShaders/ShaderRegistry.h>

Inheritance diagram for PhosphorShaders::ShaderRegistry:
[legend]

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< ShaderInfoavailableShaders () 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 &params) const
 
QVariantMap validateAndCoerceParams (const QString &id, const QVariantMap &params) 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.
 
IScanStrategystrategy () const
 Strategy accessor for subclasses.
 
WatchedDirectorySetwatcher () const
 Watcher accessor for subclasses that need direct ops not covered by the base API (e.g.
 

Detailed Description

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.

Thread safety

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.

Constructor & Destructor Documentation

◆ ShaderRegistry()

PhosphorShaders::ShaderRegistry::ShaderRegistry ( QObject *  parent = nullptr)
explicit

◆ ~ShaderRegistry()

PhosphorShaders::ShaderRegistry::~ShaderRegistry ( )
override

Member Function Documentation

◆ availableShaders()

QList< ShaderInfo > PhosphorShaders::ShaderRegistry::availableShaders ( ) const

◆ availableShadersVariant()

QVariantList PhosphorShaders::ShaderRegistry::availableShadersVariant ( ) const

◆ computeWallpaperCropRect()

static QRect PhosphorShaders::ShaderRegistry::computeWallpaperCropRect ( QSize  wpSize,
const QRect &  physGeom,
const QRect &  subGeom 
)
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.

◆ defaultParams()

QVariantMap PhosphorShaders::ShaderRegistry::defaultParams ( const QString &  id) const

◆ invalidateWallpaperCache()

static void PhosphorShaders::ShaderRegistry::invalidateWallpaperCache ( )
static

◆ isNoneShader()

static bool PhosphorShaders::ShaderRegistry::isNoneShader ( const QString &  id)
static

◆ loadWallpaperImage() [1/2]

static QImage PhosphorShaders::ShaderRegistry::loadWallpaperImage ( )
static

◆ loadWallpaperImage() [2/2]

static QImage PhosphorShaders::ShaderRegistry::loadWallpaperImage ( const QRect &  subGeom,
const QRect &  physGeom 
)
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.

◆ noneShaderUuid()

static QString PhosphorShaders::ShaderRegistry::noneShaderUuid ( )
static

◆ onUserPathChanged()

void PhosphorShaders::ShaderRegistry::onUserPathChanged ( const QString &  path)
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.

◆ presetParams()

QVariantMap PhosphorShaders::ShaderRegistry::presetParams ( const QString &  shaderId,
const QString &  presetName 
) const

◆ reportShaderBakeFinished()

void PhosphorShaders::ShaderRegistry::reportShaderBakeFinished ( const QString &  shaderId,
bool  success,
const QString &  error 
)

◆ reportShaderBakeStarted()

void PhosphorShaders::ShaderRegistry::reportShaderBakeStarted ( const QString &  shaderId)

◆ shader()

ShaderInfo PhosphorShaders::ShaderRegistry::shader ( const QString &  id) const

◆ shaderCompilationFinished

void PhosphorShaders::ShaderRegistry::shaderCompilationFinished ( const QString &  shaderId,
bool  success,
const QString &  error 
)
signal

◆ shaderCompilationStarted

void PhosphorShaders::ShaderRegistry::shaderCompilationStarted ( const QString &  shaderId)
signal

◆ shaderInfo()

QVariantMap PhosphorShaders::ShaderRegistry::shaderInfo ( const QString &  id) const

◆ shaderPresetNames()

QStringList PhosphorShaders::ShaderRegistry::shaderPresetNames ( const QString &  shaderId) const

◆ shaderPresetsVariant()

QVariantList PhosphorShaders::ShaderRegistry::shaderPresetsVariant ( const QString &  shaderId) const

◆ shadersChanged

void PhosphorShaders::ShaderRegistry::shadersChanged ( )
signal

◆ shadersEnabled()

bool PhosphorShaders::ShaderRegistry::shadersEnabled ( ) const
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.

◆ shaderUrl()

QUrl PhosphorShaders::ShaderRegistry::shaderUrl ( const QString &  id) const

◆ translateParamsToUniforms()

QVariantMap PhosphorShaders::ShaderRegistry::translateParamsToUniforms ( const QString &  shaderId,
const QVariantMap &  storedParams 
) const

◆ validateAndCoerceParams()

QVariantMap PhosphorShaders::ShaderRegistry::validateAndCoerceParams ( const QString &  id,
const QVariantMap &  params 
) const

◆ validateParams()

bool PhosphorShaders::ShaderRegistry::validateParams ( const QString &  id,
const QVariantMap &  params 
) const

◆ wallpaperPath()

static QString PhosphorShaders::ShaderRegistry::wallpaperPath ( )
static

The documentation for this class was generated from the following file: