QmlDesigner: Add core uniforms and features for shaders

Task-number: QDS-10499
Change-Id: I12b39d29133accd012ac019def0c4a34ee84d8e5
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
This commit is contained in:
Amr Essam
2023-08-30 13:43:24 +03:00
committed by Amr Elsayed
parent 2f2d8bf9e8
commit a5a5b00f58
10 changed files with 254 additions and 2 deletions

View File

@@ -84,6 +84,21 @@ void CompositionNode::parse(const QString &qenPath)
QJsonArray jsonProps = json.value("properties").toArray();
for (const auto /*QJsonValueRef*/ &prop : jsonProps)
m_unifomrsModel.addUniform(new Uniform(prop.toObject()));
// Seek through code to get tags
QStringList shaderCodeLines;
shaderCodeLines += m_vertexCode.split('\n');
shaderCodeLines += m_fragmentCode.split('\n');
for (const QString &codeLine : std::as_const(shaderCodeLines)) {
QString trimmedLine = codeLine.trimmed();
if (trimmedLine.startsWith("@requires")) {
// Get the required node, remove "@requires"
QString l = trimmedLine.sliced(9).trimmed();
QString nodeName = trimmedLine.sliced(10);
if (!nodeName.isEmpty() && !m_requiredNodes.contains(nodeName))
m_requiredNodes << nodeName;
}
}
}
} // namespace QmlDesigner