Phosphor
Qt6 / Wayland library suite for window-management tools
Loading...
Searching...
No Matches
SurfaceShaderItem.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
7#include <PhosphorSurfaceQuick/phosphorsurfacequick_export.h>
8
9#include <QPointF>
10#include <QRectF>
11#include <QSizeF>
12#include <qqmlregistration.h>
13
14QT_BEGIN_NAMESPACE
15class QSGNode;
16QT_END_NAMESPACE
17
19
58class PHOSPHORSURFACEQUICK_EXPORT SurfaceShaderItem : public PhosphorRendering::ShaderEffect
59{
60 Q_OBJECT
61 QML_NAMED_ELEMENT(SurfaceShaderItem)
62
63
71 Q_PROPERTY(qreal surfaceOpacity READ surfaceOpacity WRITE setSurfaceOpacity NOTIFY surfaceOpacityChanged FINAL)
74 Q_PROPERTY(qreal surfaceScale READ surfaceScale WRITE setSurfaceScale NOTIFY surfaceScaleChanged FINAL)
77 Q_PROPERTY(bool surfaceFocused READ surfaceFocused WRITE setSurfaceFocused NOTIFY surfaceFocusedChanged FINAL)
79 Q_PROPERTY(QSizeF surfaceSize READ surfaceSize WRITE setSurfaceSize NOTIFY surfaceSizeChanged FINAL)
81 Q_PROPERTY(QPointF surfaceFrameTopLeft READ surfaceFrameTopLeft WRITE setSurfaceFrameTopLeft NOTIFY
84 Q_PROPERTY(
86
87
89 Q_PROPERTY(QRectF backdropScreenRect READ backdropScreenRect WRITE setBackdropScreenRect NOTIFY
93 Q_PROPERTY(QRectF backdropSurfaceRect READ backdropSurfaceRect WRITE setBackdropSurfaceRect NOTIFY
95
96public:
97 explicit SurfaceShaderItem(QQuickItem* parent = nullptr);
99
113 static QStringList surfaceIncludePaths();
114
115 // Note: setEntryScaffold is inherited and PUBLIC, but this override never delegates to
116 // ShaderEffect::updatePaintNode, the only site that pushes the item's own scaffold, so
117 // the scaffold a host sets is never read for rendering. A call that CHANGES the scaffold
118 // is not inert: the base setter raises shaderDirty and calls update() unconditionally,
119 // and sets Status::Loading when a shaderSource is set, so it forces a reload and a
120 // statusChanged round trip. A call passing the SAME scaffold early-returns and IS inert,
121 // which includes the identity call on a fresh item, since the default is the empty pair.
122 // No in-tree host makes either, and none can from QML: setEntryScaffold is not
123 // Q_INVOKABLE and both items are QML-instantiated. The ZoneShaderItem twin carries the
124 // same note.
125 //
126 // Note: shaderSource, paramPreamble, shaderParams, iTime, and the
127 // customParams / customColors slots are inherited Q_PROPERTYs from
128 // PhosphorRendering::ShaderEffect — the QML host binds them directly. The
129 // base setShaderParams already maps `customParamsN_<xyzw>` / `customColorN`
130 // keys (the slot form SurfaceShaderRegistry::translateSurfaceParams emits)
131 // onto the UBO, so no surface-specific param plumbing is needed here.
132
133 qreal surfaceOpacity() const
134 {
135 return m_surfaceOpacity;
136 }
137 void setSurfaceOpacity(qreal opacity);
138
139 qreal surfaceScale() const
140 {
141 return m_surfaceScale;
142 }
143 void setSurfaceScale(qreal scale);
144
145 bool surfaceFocused() const
146 {
147 return m_surfaceFocused;
148 }
149 void setSurfaceFocused(bool focused);
150
151 QSizeF surfaceSize() const
152 {
153 return m_surfaceSize;
154 }
155 void setSurfaceSize(const QSizeF& size);
156
157 QPointF surfaceFrameTopLeft() const
158 {
159 return m_surfaceFrameTopLeft;
160 }
161 void setSurfaceFrameTopLeft(const QPointF& topLeft);
162
163 QSizeF surfaceFrameSize() const
164 {
165 return m_surfaceFrameSize;
166 }
167 void setSurfaceFrameSize(const QSizeF& size);
168
169 QRectF backdropScreenRect() const
170 {
171 return m_backdropScreenRect;
172 }
173 void setBackdropScreenRect(const QRectF& rect);
174
175 QRectF backdropSurfaceRect() const
176 {
177 return m_backdropSurfaceRect;
178 }
179 void setBackdropSurfaceRect(const QRectF& rect);
180
181Q_SIGNALS:
190
191protected:
201
212 QSGNode* updatePaintNode(QSGNode* oldNode, UpdatePaintNodeData* data) override;
213
214private:
215 // Surface-state inputs mirroring the UboFrameState surface-only field
216 // defaults (an identity decoration: opaque, full scale, unfocused, zero
217 // geometry).
218 qreal m_surfaceOpacity = 1.0;
219 qreal m_surfaceScale = 1.0;
220 bool m_surfaceFocused = false;
221 QSizeF m_surfaceSize;
222 QPointF m_surfaceFrameTopLeft;
223 QSizeF m_surfaceFrameSize;
224
228 QRectF m_backdropScreenRect;
229 QRectF m_backdropSurfaceRect;
230
237 void syncBackdropRect(PhosphorRendering::ShaderNodeRhi* node) const;
238};
239
240} // namespace PhosphorSurfaceQuick
QQuickItem that renders a fullscreen fragment shader via Qt RHI.
Definition ShaderEffect.h:83
QSGRenderNode for fullscreen-quad shader rendering via Qt RHI (Vulkan / OpenGL).
Definition ShaderNodeRhi.h:158
void setBackdropSurfaceRect(const QRectF &rect)
QRectF backdropSurfaceRect() const
Definition SurfaceShaderItem.h:175
QSizeF surfaceFrameSize() const
Definition SurfaceShaderItem.h:163
static QStringList surfaceIncludePaths()
The canonical surface-shader include-path list, highest priority first: every XDG data dir's copy of ...
QSizeF surfaceSize() const
Definition SurfaceShaderItem.h:151
PhosphorRendering::ShaderNodeRhi * createShaderNode() override
Create the render node with the surface UBO profile.
void setSurfaceSize(const QSizeF &size)
QPointF surfaceFrameTopLeft() const
Definition SurfaceShaderItem.h:157
bool surfaceFocused() const
Definition SurfaceShaderItem.h:145
qreal surfaceOpacity() const
Definition SurfaceShaderItem.h:133
QSGNode * updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *data) override
Create or update the scene graph node for rendering.
SurfaceShaderItem(QQuickItem *parent=nullptr)
Host fade factor for the decoration's output, 0..1.
void setBackdropScreenRect(const QRectF &rect)
qreal surfaceScale() const
Definition SurfaceShaderItem.h:139
void setSurfaceFrameSize(const QSizeF &size)
QRectF backdropScreenRect() const
Definition SurfaceShaderItem.h:169
void setSurfaceFrameTopLeft(const QPointF &topLeft)
Definition SurfaceShaderItem.h:18