IUniformExtension that appends PointerUniformsTail after PhosphorShaders::BaseUniforms in the preview runtime's UBO. More...
#include <PhosphorPointer/PointerUniformExtension.h>
Public Member Functions | |
| PointerUniformExtension () | |
| 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 | setVelocity (const QVector2D &velocity, double filteredSpeed) |
uPointerVelocity: .xy = velocity in device px/s, .z its length, .w = filteredSpeed (PointerFrameState::filteredSpeed). | |
| void | setPress (const QPointF &pos, double secondsSince, int button) |
| uPointerPress: canvas px, seconds since the press, button code. | |
| void | setRelease (const QPointF &pos, double secondsSince, int button) |
| uPointerRelease: same shape as setPress. | |
| void | setState (int buttonsMask, double idleSeconds, double scale) |
| uPointerState.xyz: pressed-button bitmask, seconds since the last motion, logical-to-device scale. | |
| void | setCursorRect (const QRectF &rect) |
| uCursorRect in canvas px. | |
| void | setHasCursorSprite (bool has) |
| uPointerFlags.x. Leaves .y (the reach) alone. | |
| void | setReachLogicalPx (double reach) |
| The pack's resolved reach in LOGICAL px, as resolvedReach() gives it. | |
| void | setTrail (std::span< const QVector4D > trail) |
| uPointerTrail (truncated to kMaxTrailPoints, the rest zeroed) and uPointerState.w = the count actually filled. | |
| void | apply (const PointerFrameState &state) |
| Push a whole frame at once. | |
| 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). | |
IUniformExtension that appends PointerUniformsTail after PhosphorShaders::BaseUniforms in the preview runtime's UBO.
Modelled on PhosphorAnimation::AnimationUniformExtension: a mutex serialises the GUI-thread setters against the render thread's write, and an atomic dirty flag tells the node when to re-upload the tail.
requiresPhysicalResolution() keeps the default (true): the pointer canvas is the output in device px, so iResolution must be device px too.
| PhosphorPointerShaders::PointerUniformExtension::PointerUniformExtension | ( | ) |
| void PhosphorPointerShaders::PointerUniformExtension::apply | ( | const PointerFrameState & | state | ) |
Push a whole frame at once.
Atomic with respect to write: the mutex is held for the whole frame, so the render thread copies either the previous frame's tail or this one, never a mix of the two.
|
overridevirtual |
Mark as clean after a successful write.
Implements PhosphorShaders::IUniformExtension.
|
overridevirtual |
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.
|
overridevirtual |
Whether the extension data has changed since the last write.
Implements PhosphorShaders::IUniformExtension.
| void PhosphorPointerShaders::PointerUniformExtension::setCursorRect | ( | const QRectF & | rect | ) |
uCursorRect in canvas px.
| void PhosphorPointerShaders::PointerUniformExtension::setHasCursorSprite | ( | bool | has | ) |
uPointerFlags.x. Leaves .y (the reach) alone.
| void PhosphorPointerShaders::PointerUniformExtension::setPress | ( | const QPointF & | pos, |
| double | secondsSince, | ||
| int | button ) |
uPointerPress: canvas px, seconds since the press, button code.
| void PhosphorPointerShaders::PointerUniformExtension::setReachLogicalPx | ( | double | reach | ) |
The pack's resolved reach in LOGICAL px, as resolvedReach() gives it.
Held here rather than passed per frame because it changes with the pack or its parameters, not with the pointer; apply multiplies it by the frame's scale on the way to uPointerFlags.y.
| void PhosphorPointerShaders::PointerUniformExtension::setRelease | ( | const QPointF & | pos, |
| double | secondsSince, | ||
| int | button ) |
uPointerRelease: same shape as setPress.
| void PhosphorPointerShaders::PointerUniformExtension::setState | ( | int | buttonsMask, |
| double | idleSeconds, | ||
| double | scale ) |
uPointerState.xyz: pressed-button bitmask, seconds since the last motion, logical-to-device scale.
.w (trail count) is owned by setTrail.
| void PhosphorPointerShaders::PointerUniformExtension::setTrail | ( | std::span< const QVector4D > | trail | ) |
uPointerTrail (truncated to kMaxTrailPoints, the rest zeroed) and uPointerState.w = the count actually filled.
trail is newest first, as PointerFrameState::trail holds it.
| void PhosphorPointerShaders::PointerUniformExtension::setVelocity | ( | const QVector2D & | velocity, |
| double | filteredSpeed ) |
uPointerVelocity: .xy = velocity in device px/s, .z its length, .w = filteredSpeed (PointerFrameState::filteredSpeed).
filteredSpeed is required rather than defaulted. It is the lane pointerFilteredSpeed() reads, and every speed gate in the pack family is built on it, so a caller that omitted it would silently gate every pack shut instead of failing to compile.
|
overridevirtual |
Write extension data into buffer starting at offset.
Called on the render thread during prepare().
Implements PhosphorShaders::IUniformExtension.