diff options
Diffstat (limited to 'src/render/materialsystem')
22 files changed, 42 insertions, 72 deletions
diff --git a/src/render/materialsystem/qeffect.h b/src/render/materialsystem/qeffect.h index 0a65311ba..decae6f39 100644 --- a/src/render/materialsystem/qeffect.h +++ b/src/render/materialsystem/qeffect.h @@ -51,7 +51,7 @@ class QParameter; class QTechnique; class QEffectPrivate; -class QT3DRENDERSHARED_EXPORT QEffect : public Qt3DCore::QNode +class Q_3DRENDERSHARED_EXPORT QEffect : public Qt3DCore::QNode { Q_OBJECT public: diff --git a/src/render/materialsystem/qeffect_p.h b/src/render/materialsystem/qeffect_p.h index 39c7d1ecc..c1fe22ec0 100644 --- a/src/render/materialsystem/qeffect_p.h +++ b/src/render/materialsystem/qeffect_p.h @@ -63,7 +63,7 @@ class QEffect; class QParameter; class QTechnique; -class QT3DRENDERSHARED_PRIVATE_EXPORT QEffectPrivate : public Qt3DCore::QNodePrivate +class Q_3DRENDERSHARED_PRIVATE_EXPORT QEffectPrivate : public Qt3DCore::QNodePrivate { public : QEffectPrivate(); diff --git a/src/render/materialsystem/qfilterkey.h b/src/render/materialsystem/qfilterkey.h index 23c2dd342..d7dd470db 100644 --- a/src/render/materialsystem/qfilterkey.h +++ b/src/render/materialsystem/qfilterkey.h @@ -50,7 +50,7 @@ namespace Qt3DRender { class QFilterKeyPrivate; -class QT3DRENDERSHARED_EXPORT QFilterKey : public Qt3DCore::QNode +class Q_3DRENDERSHARED_EXPORT QFilterKey : public Qt3DCore::QNode { Q_OBJECT Q_PROPERTY(QVariant value READ value WRITE setValue NOTIFY valueChanged) diff --git a/src/render/materialsystem/qfilterkey_p.h b/src/render/materialsystem/qfilterkey_p.h index 4050bc295..2174841a3 100644 --- a/src/render/materialsystem/qfilterkey_p.h +++ b/src/render/materialsystem/qfilterkey_p.h @@ -59,7 +59,7 @@ QT_BEGIN_NAMESPACE namespace Qt3DRender { -class QT3DRENDERSHARED_PRIVATE_EXPORT QFilterKeyPrivate : public Qt3DCore::QNodePrivate +class Q_3DRENDERSHARED_PRIVATE_EXPORT QFilterKeyPrivate : public Qt3DCore::QNodePrivate { public: QFilterKeyPrivate(); diff --git a/src/render/materialsystem/qgraphicsapifilter.h b/src/render/materialsystem/qgraphicsapifilter.h index 08b30b1f7..337193673 100644 --- a/src/render/materialsystem/qgraphicsapifilter.h +++ b/src/render/materialsystem/qgraphicsapifilter.h @@ -51,7 +51,7 @@ namespace Qt3DRender { class QGraphicsApiFilterPrivate; -class QT3DRENDERSHARED_EXPORT QGraphicsApiFilter : public QObject +class Q_3DRENDERSHARED_EXPORT QGraphicsApiFilter : public QObject { Q_OBJECT Q_PROPERTY(Qt3DRender::QGraphicsApiFilter::Api api READ api WRITE setApi NOTIFY apiChanged) diff --git a/src/render/materialsystem/qgraphicsapifilter_p.h b/src/render/materialsystem/qgraphicsapifilter_p.h index f4581ac05..3961d4f93 100644 --- a/src/render/materialsystem/qgraphicsapifilter_p.h +++ b/src/render/materialsystem/qgraphicsapifilter_p.h @@ -59,7 +59,7 @@ QT_BEGIN_NAMESPACE namespace Qt3DRender { -struct QT3DRENDERSHARED_PRIVATE_EXPORT GraphicsApiFilterData +struct Q_3DRENDERSHARED_PRIVATE_EXPORT GraphicsApiFilterData { GraphicsApiFilterData(); @@ -75,7 +75,7 @@ struct QT3DRENDERSHARED_PRIVATE_EXPORT GraphicsApiFilterData bool operator <(const GraphicsApiFilterData &other) const; }; -class QT3DRENDERSHARED_PRIVATE_EXPORT QGraphicsApiFilterPrivate : public QObjectPrivate +class Q_3DRENDERSHARED_PRIVATE_EXPORT QGraphicsApiFilterPrivate : public QObjectPrivate { public: QGraphicsApiFilterPrivate() diff --git a/src/render/materialsystem/qmaterial.h b/src/render/materialsystem/qmaterial.h index 9d1895294..d7d40f138 100644 --- a/src/render/materialsystem/qmaterial.h +++ b/src/render/materialsystem/qmaterial.h @@ -54,7 +54,7 @@ class QParameter; class QMaterialPrivate; class QEffect; -class QT3DRENDERSHARED_EXPORT QMaterial : public Qt3DCore::QComponent +class Q_3DRENDERSHARED_EXPORT QMaterial : public Qt3DCore::QComponent { Q_OBJECT Q_PROPERTY(Qt3DRender::QEffect *effect READ effect WRITE setEffect NOTIFY effectChanged) diff --git a/src/render/materialsystem/qmaterial_p.h b/src/render/materialsystem/qmaterial_p.h index 9fb8d5de9..273e044e2 100644 --- a/src/render/materialsystem/qmaterial_p.h +++ b/src/render/materialsystem/qmaterial_p.h @@ -61,7 +61,7 @@ namespace Qt3DRender { class QParameter; class QEffect; -class QT3DRENDERSHARED_PRIVATE_EXPORT QMaterialPrivate : public Qt3DCore::QComponentPrivate +class Q_3DRENDERSHARED_PRIVATE_EXPORT QMaterialPrivate : public Qt3DCore::QComponentPrivate { public: QMaterialPrivate(); diff --git a/src/render/materialsystem/qparameter.h b/src/render/materialsystem/qparameter.h index 169543e24..8d56bcbe7 100644 --- a/src/render/materialsystem/qparameter.h +++ b/src/render/materialsystem/qparameter.h @@ -51,7 +51,7 @@ namespace Qt3DRender { class QParameterPrivate; class QAbstractTexture; -class QT3DRENDERSHARED_EXPORT QParameter : public Qt3DCore::QNode +class Q_3DRENDERSHARED_EXPORT QParameter : public Qt3DCore::QNode { Q_OBJECT Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) diff --git a/src/render/materialsystem/qparameter_p.h b/src/render/materialsystem/qparameter_p.h index a56a63af4..e8d74ac91 100644 --- a/src/render/materialsystem/qparameter_p.h +++ b/src/render/materialsystem/qparameter_p.h @@ -60,7 +60,7 @@ namespace Qt3DRender { class QParameter; -class QT3DRENDERSHARED_PRIVATE_EXPORT QParameterPrivate : public Qt3DCore::QNodePrivate +class Q_3DRENDERSHARED_PRIVATE_EXPORT QParameterPrivate : public Qt3DCore::QNodePrivate { public: QParameterPrivate(); diff --git a/src/render/materialsystem/qrenderpass.h b/src/render/materialsystem/qrenderpass.h index 14bd34b37..b82a0d973 100644 --- a/src/render/materialsystem/qrenderpass.h +++ b/src/render/materialsystem/qrenderpass.h @@ -59,7 +59,7 @@ typedef QVector<QParameter*> ParameterList; class QRenderPassPrivate; -class QT3DRENDERSHARED_EXPORT QRenderPass : public Qt3DCore::QNode +class Q_3DRENDERSHARED_EXPORT QRenderPass : public Qt3DCore::QNode { Q_OBJECT Q_PROPERTY(Qt3DRender::QShaderProgram *shaderProgram READ shaderProgram WRITE setShaderProgram NOTIFY shaderProgramChanged) diff --git a/src/render/materialsystem/qshaderdata.h b/src/render/materialsystem/qshaderdata.h index 5e57d11a4..eda009c6a 100644 --- a/src/render/materialsystem/qshaderdata.h +++ b/src/render/materialsystem/qshaderdata.h @@ -50,7 +50,7 @@ namespace Qt3DRender { class QShaderDataPrivate; -class QT3DRENDERSHARED_EXPORT PropertyReaderInterface +class Q_3DRENDERSHARED_EXPORT PropertyReaderInterface { public: virtual ~PropertyReaderInterface(); @@ -59,7 +59,7 @@ public: typedef QSharedPointer<PropertyReaderInterface> PropertyReaderInterfacePtr; -class QT3DRENDERSHARED_EXPORT QShaderData : public Qt3DCore::QComponent +class Q_3DRENDERSHARED_EXPORT QShaderData : public Qt3DCore::QComponent { Q_OBJECT public: diff --git a/src/render/materialsystem/qshaderdata_p.h b/src/render/materialsystem/qshaderdata_p.h index 258c962ee..18890aec9 100644 --- a/src/render/materialsystem/qshaderdata_p.h +++ b/src/render/materialsystem/qshaderdata_p.h @@ -86,7 +86,7 @@ class QShaderDataPropertyReader: public PropertyReaderInterface } }; -class QT3DRENDERSHARED_PRIVATE_EXPORT QShaderDataPrivate : public Qt3DCore::QComponentPrivate +class Q_3DRENDERSHARED_PRIVATE_EXPORT QShaderDataPrivate : public Qt3DCore::QComponentPrivate { public: QShaderDataPrivate(); diff --git a/src/render/materialsystem/qshaderprogram.cpp b/src/render/materialsystem/qshaderprogram.cpp index 0ca8a9947..c4e14ea2c 100644 --- a/src/render/materialsystem/qshaderprogram.cpp +++ b/src/render/materialsystem/qshaderprogram.cpp @@ -635,7 +635,7 @@ QShaderProgram::Status QShaderProgram::status() const return d->m_status; } -static QByteArray deincludify(const QString &filePath) +QByteArray QShaderProgramPrivate::deincludify(const QString &filePath) { QFile f(filePath); if (!f.open(QIODevice::ReadOnly | QIODevice::Text)) { @@ -644,20 +644,27 @@ static QByteArray deincludify(const QString &filePath) } QByteArray contents = f.readAll(); + return deincludify(contents, filePath); +} + +QByteArray QShaderProgramPrivate::deincludify(const QByteArray &contents, const QString &filePath) +{ QByteArrayList lines = contents.split('\n'); const QByteArray includeDirective = QByteArrayLiteral("#pragma include"); for (int i = 0; i < lines.count(); ++i) { - if (lines[i].startsWith(includeDirective)) { - QString includeFileName = QFileInfo(filePath).absolutePath() - + QLatin1Char('/') - + QString::fromUtf8(lines[i].mid(includeDirective.count() + 1)); + const auto line = lines[i].simplified(); + if (line.startsWith(includeDirective)) { + const QString includePartialPath = QString::fromUtf8(line.mid(includeDirective.count() + 1)); + + QString includePath = QFileInfo(includePartialPath).isAbsolute() ? includePartialPath + : QFileInfo(filePath).absolutePath() + QLatin1Char('/') + includePartialPath; if (qEnvironmentVariableIsSet("QT3D_GLSL100_WORKAROUND")) { - QString candidate = includeFileName + QLatin1String("100"); + QString candidate = includePath + QLatin1String("100"); if (QFile::exists(candidate)) - includeFileName = candidate; + includePath = candidate; } lines.removeAt(i); - QByteArray includedContents = deincludify(includeFileName); + QByteArray includedContents = deincludify(includePath); lines.insert(i, includedContents); QString lineDirective = QString(QStringLiteral("#line %1")).arg(i + 2); lines.insert(i + 1, lineDirective.toUtf8()); @@ -678,7 +685,7 @@ static QByteArray deincludify(const QString &filePath) QByteArray QShaderProgram::loadSource(const QUrl &sourceUrl) { // TO DO: Handle remote path - return deincludify(Qt3DRender::QUrlHelper::urlToLocalFileOrQrc(sourceUrl)); + return QShaderProgramPrivate::deincludify(Qt3DRender::QUrlHelper::urlToLocalFileOrQrc(sourceUrl)); } Qt3DCore::QNodeCreatedChangeBasePtr QShaderProgram::createNodeCreationChange() const diff --git a/src/render/materialsystem/qshaderprogram.h b/src/render/materialsystem/qshaderprogram.h index efcfa792e..49c1076e5 100644 --- a/src/render/materialsystem/qshaderprogram.h +++ b/src/render/materialsystem/qshaderprogram.h @@ -49,7 +49,7 @@ namespace Qt3DRender { class QShaderProgramPrivate; -class QT3DRENDERSHARED_EXPORT QShaderProgram : public Qt3DCore::QNode +class Q_3DRENDERSHARED_EXPORT QShaderProgram : public Qt3DCore::QNode { Q_OBJECT Q_PROPERTY(QByteArray vertexShaderCode READ vertexShaderCode WRITE setVertexShaderCode NOTIFY vertexShaderCodeChanged) diff --git a/src/render/materialsystem/qshaderprogram_p.h b/src/render/materialsystem/qshaderprogram_p.h index 92520c3c8..f09b2a30e 100644 --- a/src/render/materialsystem/qshaderprogram_p.h +++ b/src/render/materialsystem/qshaderprogram_p.h @@ -75,6 +75,9 @@ public: void setLog(const QString &log); void setStatus(QShaderProgram::Status status); + + static QByteArray deincludify(const QByteArray &contents, const QString &filePath); + static QByteArray deincludify(const QString &filePath); }; struct QShaderProgramData diff --git a/src/render/materialsystem/qshaderprogrambuilder.h b/src/render/materialsystem/qshaderprogrambuilder.h index 33966b708..184093730 100644 --- a/src/render/materialsystem/qshaderprogrambuilder.h +++ b/src/render/materialsystem/qshaderprogrambuilder.h @@ -52,7 +52,7 @@ namespace Qt3DRender { class QShaderProgram; class QShaderProgramBuilderPrivate; -class QT3DRENDERSHARED_EXPORT QShaderProgramBuilder : public Qt3DCore::QNode +class Q_3DRENDERSHARED_EXPORT QShaderProgramBuilder : public Qt3DCore::QNode { Q_OBJECT Q_PROPERTY(Qt3DRender::QShaderProgram* shaderProgram READ shaderProgram WRITE setShaderProgram NOTIFY shaderProgramChanged) diff --git a/src/render/materialsystem/qtechnique.h b/src/render/materialsystem/qtechnique.h index c0c0d0ade..7711cd67f 100644 --- a/src/render/materialsystem/qtechnique.h +++ b/src/render/materialsystem/qtechnique.h @@ -55,7 +55,7 @@ class QParameter; class QTechniquePrivate; class QGraphicsApiFilter; -class QT3DRENDERSHARED_EXPORT QTechnique : public Qt3DCore::QNode +class Q_3DRENDERSHARED_EXPORT QTechnique : public Qt3DCore::QNode { Q_OBJECT Q_PROPERTY(Qt3DRender::QGraphicsApiFilter *graphicsApiFilter READ graphicsApiFilter CONSTANT) diff --git a/src/render/materialsystem/shaderbuilder.cpp b/src/render/materialsystem/shaderbuilder.cpp index e0683332f..c1ec7f75a 100644 --- a/src/render/materialsystem/shaderbuilder.cpp +++ b/src/render/materialsystem/shaderbuilder.cpp @@ -41,6 +41,7 @@ #include <Qt3DRender/private/qshaderprogrambuilder_p.h> #include <Qt3DRender/qshaderprogram.h> +#include <Qt3DRender/private/qshaderprogram_p.h> #include <Qt3DRender/private/qurlhelper_p.h> #include <QtGui/private/qshaderformat_p.h> @@ -234,47 +235,6 @@ bool ShaderBuilder::isShaderCodeDirty(ShaderBuilder::ShaderType type) const return m_dirtyTypes.contains(type); } -static QByteArray deincludify(const QByteArray &contents, const QString &filePath); - -static QByteArray deincludify(const QString &filePath) -{ - QFile f(filePath); - if (!f.open(QIODevice::ReadOnly | QIODevice::Text)) { - qWarning() << "Could not read shader source file:" << f.fileName(); - return QByteArray(); - } - - QByteArray contents = f.readAll(); - return deincludify(contents, filePath); -} - -static QByteArray deincludify(const QByteArray &contents, const QString &filePath) -{ - QByteArrayList lines = contents.split('\n'); - const QByteArray includeDirective = QByteArrayLiteral("#pragma include"); - for (int i = 0; i < lines.count(); ++i) { - const auto line = lines[i].simplified(); - if (line.startsWith(includeDirective)) { - const QString includePartialPath = QString::fromUtf8(line.mid(includeDirective.count() + 1)); - - QString includePath = QFileInfo(includePartialPath).isAbsolute() ? includePartialPath - : QFileInfo(filePath).absolutePath() + QLatin1Char('/') + includePartialPath; - if (qEnvironmentVariableIsSet("QT3D_GLSL100_WORKAROUND")) { - QString candidate = includePath + QLatin1String("100"); - if (QFile::exists(candidate)) - includePath = candidate; - } - lines.removeAt(i); - QByteArray includedContents = deincludify(includePath); - lines.insert(i, includedContents); - QString lineDirective = QString(QStringLiteral("#line %1")).arg(i + 2); - lines.insert(i + 1, lineDirective.toUtf8()); - } - } - - return lines.join('\n'); -} - void ShaderBuilder::generateCode(ShaderBuilder::ShaderType type) { const auto graphPath = QUrlHelper::urlToLocalFileOrQrc(shaderGraph(type)); @@ -308,7 +268,7 @@ void ShaderBuilder::generateCode(ShaderBuilder::ShaderType type) generator.graph = graph; const auto code = generator.createShaderCode(m_enabledLayers); - m_codes.insert(type, deincludify(code, graphPath + QStringLiteral(".glsl"))); + m_codes.insert(type, QShaderProgramPrivate::deincludify(code, graphPath + QStringLiteral(".glsl"))); m_dirtyTypes.remove(type); // Send notification to the frontend diff --git a/src/render/materialsystem/shaderbuilder_p.h b/src/render/materialsystem/shaderbuilder_p.h index e9378e3c5..00c4e1c28 100644 --- a/src/render/materialsystem/shaderbuilder_p.h +++ b/src/render/materialsystem/shaderbuilder_p.h @@ -61,7 +61,7 @@ namespace Qt3DRender { namespace Render { -class QT3DRENDERSHARED_PRIVATE_EXPORT ShaderBuilder : public BackendNode +class Q_3DRENDERSHARED_PRIVATE_EXPORT ShaderBuilder : public BackendNode { public: enum ShaderType { diff --git a/src/render/materialsystem/shadercache_p.h b/src/render/materialsystem/shadercache_p.h index bda629ee5..40b88b53e 100644 --- a/src/render/materialsystem/shadercache_p.h +++ b/src/render/materialsystem/shadercache_p.h @@ -66,7 +66,7 @@ namespace Render { class tst_ShaderCache; #endif -class QT3DRENDERSHARED_PRIVATE_EXPORT ShaderCache +class Q_3DRENDERSHARED_PRIVATE_EXPORT ShaderCache { public: ~ShaderCache(); diff --git a/src/render/materialsystem/technique_p.h b/src/render/materialsystem/technique_p.h index 0ca9d3ae9..d885c1b87 100644 --- a/src/render/materialsystem/technique_p.h +++ b/src/render/materialsystem/technique_p.h @@ -73,7 +73,7 @@ namespace Render { class TechniqueManager; -class QT3DRENDERSHARED_PRIVATE_EXPORT Technique : public BackendNode +class Q_3DRENDERSHARED_PRIVATE_EXPORT Technique : public BackendNode { public: Technique(); |