diff options
author | Laszlo Agocs <laszlo.agocs@qt.io> | 2020-06-16 13:57:10 +0200 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@qt.io> | 2020-06-18 10:23:17 +0200 |
commit | b976a12940b52c4a5c20972802828fc50674f60f (patch) | |
tree | 77ac9d9ee622cb1521b127620b276936db90ebb9 /src/quick/scenegraph/qsgrhishadereffectnode.cpp | |
parent | d62f11f1d04851ac07491aa3994e20607b2e2adc (diff) |
ShaderEffect: vertexShader and fragmentShader are now URLs
..and so fully compatible in behavior with properties like Image.source.
The main improvement here is that unlike with the old code, which incorrectly
handled local file URLs, one can now write fragmentShader: "myshader.frag.qsb"
which leads to picking up the file relative to the component (the .qml file),
as expected.
Existing code (that uses file: or qrc: URLs) will continue to work
as-is.
Change-Id: I89dd84b998b59ae6d5b6cb3d8a6353961ee8bb4a
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
Reviewed-by: Christian Strømme <christian.stromme@qt.io>
Diffstat (limited to 'src/quick/scenegraph/qsgrhishadereffectnode.cpp')
-rw-r--r-- | src/quick/scenegraph/qsgrhishadereffectnode.cpp | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/quick/scenegraph/qsgrhishadereffectnode.cpp b/src/quick/scenegraph/qsgrhishadereffectnode.cpp index 8ba307bca6..5c756721f0 100644 --- a/src/quick/scenegraph/qsgrhishadereffectnode.cpp +++ b/src/quick/scenegraph/qsgrhishadereffectnode.cpp @@ -793,15 +793,14 @@ QSGGuiThreadShaderEffectManager::Status QSGRhiGuiThreadShaderEffectManager::stat return m_status; } -void QSGRhiGuiThreadShaderEffectManager::prepareShaderCode(ShaderInfo::Type typeHint, const QByteArray &src, ShaderInfo *result) +void QSGRhiGuiThreadShaderEffectManager::prepareShaderCode(ShaderInfo::Type typeHint, const QUrl &src, ShaderInfo *result) { - QUrl srcUrl(QString::fromUtf8(src)); - if (!srcUrl.scheme().compare(QLatin1String("qrc"), Qt::CaseInsensitive) || srcUrl.isLocalFile()) { + if (!src.scheme().compare(QLatin1String("qrc"), Qt::CaseInsensitive) || src.isLocalFile()) { if (!m_fileSelector) { m_fileSelector = new QFileSelector(this); m_fileSelector->setExtraSelectors(QStringList() << QStringLiteral("qsb")); } - const QString fn = m_fileSelector->select(QQmlFile::urlToLocalFileOrQrc(srcUrl)); + const QString fn = m_fileSelector->select(QQmlFile::urlToLocalFileOrQrc(src)); QFile f(fn); if (!f.open(QIODevice::ReadOnly)) { qWarning("ShaderEffect: Failed to read %s", qPrintable(fn)); |