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

IUniformExtension implementation for zone data. More...

#include <phosphor-rendering/include/PhosphorRendering/ZoneUniformExtension.h>

Inheritance diagram for PhosphorRendering::ZoneUniformExtension:
[legend]

Public Member Functions

 ZoneUniformExtension ()
 
int extensionSize () const override
 Size in bytes of the extension region (must respect std140 alignment).
 
void write (char *buffer, int offset) const override
 Write extension data into buffer starting at offset.
 
bool isDirty () const override
 Whether the extension data has changed since the last write.
 
void clearDirty () override
 Mark as clean after a successful write.
 
void updateFromZones (const QVector< ZoneData > &zones)
 Update zone data from a vector of ZoneData.
 
bool setScale (float scale)
 Set the logical-to-device scale the shader applies to the lengths in zoneParams (corner radius, border width).
 
- Public Member Functions inherited from PhosphorShaders::IUniformExtension
virtual ~IUniformExtension ()=default
 
virtual bool requiresPhysicalResolution () const
 Whether iResolution in this extension's UBO should be uploaded in PHYSICAL pixels (DPR-scaled, matches gl_FragCoord) or LOGICAL pixels (matches the QQuickItem's bounds and Qt's auto-interpolated vTexCoord).
 

Detailed Description

IUniformExtension implementation for zone data.

Appends zone arrays (zoneRects, zoneFillColors, zoneBorderColors, zoneParams) plus the trailing zoneScale scalar after BaseUniforms in the UBO. Total extension size is kZoneExtensionBytes (ZoneShaderCommon.h): the four arrays, plus the scalar and the 12 pad bytes std140 needs to close the block on a 16-byte boundary.

The zone data layout matches the GLSL UBO declaration in common.glsl exactly, and is binary-compatible with the zone region of ZoneShaderUniforms.

Threading
write() runs on the render thread during prepare(); updateFromZones() runs during the sync phase (updatePaintNode), which is ALSO the render thread, with the GUI thread blocked — not the GUI thread, despite the name. Sync is meant to block, but some Qt render loops can advance through prepare() before the next sync fires, so m_mutex serialises reads and writes of m_data to prevent torn copies.

Constructor & Destructor Documentation

◆ ZoneUniformExtension()

PhosphorRendering::ZoneUniformExtension::ZoneUniformExtension ( )
inline

Member Function Documentation

◆ clearDirty()

void PhosphorRendering::ZoneUniformExtension::clearDirty ( )
inlineoverridevirtual

Mark as clean after a successful write.

Implements PhosphorShaders::IUniformExtension.

◆ extensionSize()

int PhosphorRendering::ZoneUniformExtension::extensionSize ( ) const
inlineoverridevirtual

Size in bytes of the extension region (must respect std140 alignment).

Must be stable for the lifetime of the extension instance: the render node sizes the UBO and its staging buffer once when the extension is installed (via setUniformExtension) and reuses both across frames. A changing size silently bypasses the resize path and risks UBO write overruns. To change the size, install a fresh IUniformExtension instance with the new size — that triggers UBO recreation.

Implements PhosphorShaders::IUniformExtension.

◆ isDirty()

bool PhosphorRendering::ZoneUniformExtension::isDirty ( ) const
inlineoverridevirtual

Whether the extension data has changed since the last write.

Implements PhosphorShaders::IUniformExtension.

◆ setScale()

bool PhosphorRendering::ZoneUniformExtension::setScale ( float  scale)
inline

Set the logical-to-device scale the shader applies to the lengths in zoneParams (corner radius, border width).

Called from the item's updatePaintNode sync phase with the same device-pixel ratio the node's resolution is scaled by, so radius * uZoneScale lands in the same device-px space as iResolution and vFragCoord.

Separate from updateFromZones() because the two change on different clocks: zone contents churn per drag frame, the scale only when the overlay moves to a differently-scaled screen. Guarded by the same mutex and only marks dirty on an actual change, so a per-frame call from the sync phase costs nothing.

Returns
false if scale was rejected as out of contract, true otherwise (including a no-op re-set of the current value). Rejection keeps the last good scale, which renders correctly but is indistinguishable from working code, so the caller is expected to report it. The check cannot log here: this library's logging category is private to its src/ tree, and the caller owns a category that names the actual subsystem anyway.

◆ updateFromZones()

void PhosphorRendering::ZoneUniformExtension::updateFromZones ( const QVector< ZoneData > &  zones)
inline

Update zone data from a vector of ZoneData.

Called from the sync phase (updatePaintNode), which runs on the render thread with the GUI thread blocked. Mutex-guarded against a concurrent write() — see the class Threading note for why blocking is not sufficient on its own.

◆ write()

void PhosphorRendering::ZoneUniformExtension::write ( char *  buffer,
int  offset 
) const
inlineoverridevirtual

Write extension data into buffer starting at offset.

Called on the render thread during prepare().

Implements PhosphorShaders::IUniformExtension.


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