Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qquickshadereffect_p_p.h
Go to the documentation of this file.
1// Copyright (C) 2022 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5#ifndef QQUICKSHADEREFFECT_P_P_H
6#define QQUICKSHADEREFFECT_P_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <private/qtquickglobal_p.h>
20
22
23#include <private/qquickshadereffect_p.h>
24#include <private/qquickitem_p.h>
25#include <private/qquickshadereffectmesh_p.h>
26
27QT_BEGIN_NAMESPACE
28
29namespace QtPrivate {
31}
32
34{
35 Q_DECLARE_PUBLIC(QQuickShaderEffect)
36
37public:
40
42
43 QUrl fragmentShader() const { return m_fragShader; }
44 void setFragmentShader(const QUrl &fileUrl);
45
46 QUrl vertexShader() const { return m_vertShader; }
47 void setVertexShader(const QUrl &fileUrl);
48
49 bool blending() const { return m_blending; }
50 void setBlending(bool enable);
51
52 QVariant mesh() const;
53 void setMesh(const QVariant &mesh);
54
57
58 QString log() const;
60
61 bool supportsAtlasTextures() const { return m_supportsAtlasTextures; }
62 void setSupportsAtlasTextures(bool supports);
63
65
66 void handleEvent(QEvent *);
67 void handleGeometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry);
68 QSGNode *handleUpdatePaintNode(QSGNode *, QQuickItem::UpdatePaintNodeData *);
70 void handleItemChange(QQuickItem::ItemChange change, const QQuickItem::ItemChangeData &value);
71 void maybeUpdateShaders();
72 bool updateUniformValue(const QByteArray &name, const QVariant &value,
73 QSGShaderEffectNode *node);
74
75 void propertyChanged(int mappedId);
76 void sourceDestroyed(QObject *object);
79 void shaderCodePrepared(bool ok, QSGGuiThreadShaderEffectManager::ShaderInfo::Type typeHint,
80 const QUrl &loadUrl, QSGGuiThreadShaderEffectManager::ShaderInfo *result);
81
82private:
83 QSGGuiThreadShaderEffectManager *shaderEffectManager() const;
84
85 enum Shader {
86 Vertex,
87 Fragment,
88
89 NShader
90 };
91 bool updateShader(Shader shaderType, const QUrl &fileUrl);
92 void updateShaderVars(Shader shaderType);
93 void disconnectSignals(Shader shaderType);
94 void clearMappers(Shader shaderType);
95 std::optional<int> findMappedShaderVariableId(const QByteArray &name) const;
96 std::optional<int> findMappedShaderVariableId(const QByteArray &name, Shader shaderType) const;
97 bool sourceIsUnique(QQuickItem *source, Shader typeToSkip, int indexToSkip) const;
98
99 bool inDestructor = false;
100 const QMetaObject *m_itemMetaObject = nullptr;
101 QSize m_meshResolution;
102 QQuickShaderEffectMesh *m_mesh;
103 QMetaObject::Connection m_meshConnection;
104 QQuickGridMesh m_defaultMesh;
106 bool m_blending;
107 bool m_supportsAtlasTextures;
108 mutable QSGGuiThreadShaderEffectManager *m_mgr;
109 QUrl m_fragShader;
110 bool m_fragNeedsUpdate;
111 QUrl m_vertShader;
112 bool m_vertNeedsUpdate;
113
114 QSGShaderEffectNode::ShaderData m_shaders[NShader];
115 QSGShaderEffectNode::DirtyShaderFlags m_dirty;
116 QSet<int> m_dirtyConstants[NShader];
117 QSet<int> m_dirtyTextures[NShader];
118 QSGGuiThreadShaderEffectManager::ShaderInfo *m_inProgress[NShader];
119
120 QVector<QtPrivate::EffectSlotMapper *> m_mappers[NShader];
121
122 QHash<QQuickItem *, QMetaObject::Connection> m_destroyedConnections;
123};
124
125QT_END_NAMESPACE
126
127#endif // QQUICKSHADEREFFECT_P_P_H
void setVertexShader(const QUrl &fileUrl)
void shaderCodePrepared(bool ok, QSGGuiThreadShaderEffectManager::ShaderInfo::Type typeHint, const QUrl &loadUrl, QSGGuiThreadShaderEffectManager::ShaderInfo *result)
QSGNode * handleUpdatePaintNode(QSGNode *, QQuickItem::UpdatePaintNodeData *)
void setMesh(const QVariant &mesh)
void setSupportsAtlasTextures(bool supports)
bool updateUniformValue(const QByteArray &name, const QVariant &value, QSGShaderEffectNode *node)
void setFragmentShader(const QUrl &fileUrl)
void handleGeometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
void sourceDestroyed(QObject *object)
void handleItemChange(QQuickItem::ItemChange change, const QQuickItem::ItemChangeData &value)
QT_REQUIRE_CONFIG(quick_shadereffect)