Phosphor
Qt6 / Wayland library suite for window-management tools
Loading...
Searching...
No Matches
PointerUniformExtension.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2026 fuddlesworth
2// SPDX-License-Identifier: LGPL-2.1-or-later
3
4#pragma once
5
8#include <PhosphorPointer/phosphorpointer_export.h>
9
11
12#include <QMutex>
13#include <QPointF>
14#include <QRectF>
15#include <QVector2D>
16#include <QVector4D>
17
18#include <atomic>
19#include <span>
20
21namespace PhosphorPointerShaders {
22
32{
33public:
35
36 int extensionSize() const override;
37 void write(char* buffer, int offset) const override;
38 bool isDirty() const override;
39 void clearDirty() override;
40
48 void setVelocity(const QVector2D& velocity, double filteredSpeed);
49
51 void setPress(const QPointF& pos, double secondsSince, int button);
52
54 void setRelease(const QPointF& pos, double secondsSince, int button);
55
59 void setState(int buttonsMask, double idleSeconds, double scale);
60
62 void setCursorRect(const QRectF& rect);
63
65 void setHasCursorSprite(bool has);
66
71 void setReachLogicalPx(double reach);
72
76 void setTrail(std::span<const QVector4D> trail);
77
81 void apply(const PointerFrameState& state);
82
83private:
84 // The *Locked helpers carry the setter bodies and expect m_mutex held.
85 // The public setters lock around one of them; apply() locks once around
86 // all of them.
87 void setVec4Locked(float (&dst)[4], float x, float y, float z, float w);
88 void setVelocityLocked(const QVector2D& velocity, double filteredSpeed);
89 void setPressLocked(const QPointF& pos, double secondsSince, int button);
90 void setReleaseLocked(const QPointF& pos, double secondsSince, int button);
91 void setStateLocked(int buttonsMask, double idleSeconds, double scale);
92 void setCursorRectLocked(const QRectF& rect);
93 void setFlagsLocked(bool hasSprite, double scale);
94 void setTrailLocked(std::span<const QVector4D> trail);
95
97 double m_reachLogicalPx = 0.0;
98 mutable QMutex m_mutex;
99 std::atomic<bool> m_dirty{true};
100};
101
102} // namespace PhosphorPointerShaders
void setCursorRect(const QRectF &rect)
uCursorRect in canvas px.
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...
void setState(int buttonsMask, double idleSeconds, double scale)
uPointerState.xyz: pressed-button bitmask, seconds since the last motion, logical-to-device scale.
bool isDirty() const override
Whether the extension data has changed since the last write.
void apply(const PointerFrameState &state)
Push a whole frame at once.
void write(char *buffer, int offset) const override
Write extension data into buffer starting at offset.
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 setTrail(std::span< const QVector4D > trail)
uPointerTrail (truncated to kMaxTrailPoints, the rest zeroed) and uPointerState.w = the count actuall...
void setReachLogicalPx(double reach)
The pack's resolved reach in LOGICAL px, as resolvedReach() gives it.
int extensionSize() const override
Size in bytes of the extension region (must respect std140 alignment).
void setHasCursorSprite(bool has)
uPointerFlags.x. Leaves .y (the reach) alone.
Interface for appending custom uniform data after the base UBO layout.
Definition IUniformExtension.h:18
Definition PointerFrameState.h:16
Plain-data snapshot of everything the pointer contract's tail carries for one frame.
Definition PointerFrameState.h:27
C++ mirror of the POINTER contract's UBO tail.
Definition PointerShaderUniforms.h:31