summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@qt.io>2018-01-23 15:40:13 +0100
committerLaszlo Agocs <laszlo.agocs@qt.io>2018-01-23 15:50:01 +0000
commit764851ff6c0f567f8373642bf258a4ab5b95d9ef (patch)
tree8436e4974ad0190e5b32933a4f79de1e501cf064
parent6d719bdf252c569e40b8c3d9791f0f549de559b7 (diff)
Store the converted blend func in pass commands
While we are at it, be nice and make desc optional as well since it only makes sense when reader is given as well. Change-Id: I6e65882f62f9bbda8fa99e6c37f02f2467c05783 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
-rw-r--r--src/runtime/q3dscustommaterial.cpp4
-rw-r--r--src/runtime/q3dseffect.cpp4
-rw-r--r--src/runtime/q3dsmaterial.h18
-rw-r--r--tests/auto/materialparser/tst_q3dscustommaterialparser.cpp4
4 files changed, 16 insertions, 14 deletions
diff --git a/src/runtime/q3dscustommaterial.cpp b/src/runtime/q3dscustommaterial.cpp
index ea79590..e73e354 100644
--- a/src/runtime/q3dscustommaterial.cpp
+++ b/src/runtime/q3dscustommaterial.cpp
@@ -460,9 +460,9 @@ void Q3DSCustomMaterialParser::parsePass()
Q3DSMaterial::PassCommand blending(Q3DSMaterial::PassCommand::BlendingType);
for (auto attribute : r->attributes()) {
if (attribute.name() == QStringLiteral("source"))
- blending.data()->source = attribute.value().toString();
+ Q3DSMaterial::convertToBlendFunc(attribute.value(), &blending.data()->blendSource, "source blend mode", r);
else if (attribute.name() == QStringLiteral("dest"))
- blending.data()->destination = attribute.value().toString();
+ Q3DSMaterial::convertToBlendFunc(attribute.value(), &blending.data()->blendDestination, "destination blend mode", r);
}
pass.commands.append(blending);
m_material.m_hasTransparency = true; // if we have blending we have transparency
diff --git a/src/runtime/q3dseffect.cpp b/src/runtime/q3dseffect.cpp
index bdc609c..b313dcb 100644
--- a/src/runtime/q3dseffect.cpp
+++ b/src/runtime/q3dseffect.cpp
@@ -341,9 +341,9 @@ void Q3DSEffectParser::parsePass(Q3DSEffect &effect)
Q3DSMaterial::PassCommand blending(Q3DSMaterial::PassCommand::BlendingType);
for (auto attribute : r->attributes()) {
if (attribute.name() == QStringLiteral("source"))
- blending.data()->source = attribute.value().toString();
+ Q3DSMaterial::convertToBlendFunc(attribute.value(), &blending.data()->blendSource, "source blend mode", r);
else if (attribute.name() == QStringLiteral("dest"))
- blending.data()->destination = attribute.value().toString();
+ Q3DSMaterial::convertToBlendFunc(attribute.value(), &blending.data()->blendDestination, "destination blend mode", r);
}
pass.commands.append(blending);
while (r->readNextStartElement())
diff --git a/src/runtime/q3dsmaterial.h b/src/runtime/q3dsmaterial.h
index e157b08..29cb556 100644
--- a/src/runtime/q3dsmaterial.h
+++ b/src/runtime/q3dsmaterial.h
@@ -310,6 +310,8 @@ public:
bool sync = false;
QString source;
QString destination;
+ BlendFunc blendSource = One;
+ BlendFunc blendDestination = One;
QString name;
QString bufferName;
quint32 stencilValue = 0;
@@ -355,14 +357,14 @@ void combineShaderCode(Shader *shader,
const QString &sharedFragmentShaderCode);
Buffer parseBuffer(QXmlStreamReader *r);
-bool convertToUsageType(const QStringRef &value, Q3DSMaterial::UsageType *type, const char *desc, QXmlStreamReader *reader = nullptr);
-bool convertToFilterType(const QStringRef &value, Q3DSMaterial::FilterType *type, const char *desc, QXmlStreamReader *reader = nullptr);
-bool convertToClampType(const QStringRef &value, Q3DSMaterial::ClampType *type, const char *desc, QXmlStreamReader *reader = nullptr);
-bool convertToBoolOp(const QStringRef &value, Q3DSMaterial::BoolOp *type, const char *desc, QXmlStreamReader *reader = nullptr);
-bool convertToStencilOp(const QStringRef &value, Q3DSMaterial::StencilOp *type, const char *desc, QXmlStreamReader *reader = nullptr);
-bool convertToTextureFormat(const QStringRef &value, const QString &typeValue, Q3DSMaterial::TextureFormat *type, const char *desc, QXmlStreamReader *reader = nullptr);
-bool convertToBlendFunc(const QStringRef &value, Q3DSMaterial::BlendFunc *type, const char *desc, QXmlStreamReader *reader = nullptr);
-bool convertToImageAccess(const QStringRef &value, Q3DSMaterial::ImageAccess *type, const char *desc, QXmlStreamReader *reader = nullptr);
+bool convertToUsageType(const QStringRef &value, Q3DSMaterial::UsageType *type, const char *desc = nullptr, QXmlStreamReader *reader = nullptr);
+bool convertToFilterType(const QStringRef &value, Q3DSMaterial::FilterType *type, const char *desc = nullptr, QXmlStreamReader *reader = nullptr);
+bool convertToClampType(const QStringRef &value, Q3DSMaterial::ClampType *type, const char *desc = nullptr, QXmlStreamReader *reader = nullptr);
+bool convertToBoolOp(const QStringRef &value, Q3DSMaterial::BoolOp *type, const char *desc = nullptr, QXmlStreamReader *reader = nullptr);
+bool convertToStencilOp(const QStringRef &value, Q3DSMaterial::StencilOp *type, const char *desc = nullptr, QXmlStreamReader *reader = nullptr);
+bool convertToTextureFormat(const QStringRef &value, const QString &typeValue, Q3DSMaterial::TextureFormat *type, const char *desc = nullptr, QXmlStreamReader *reader = nullptr);
+bool convertToBlendFunc(const QStringRef &value, Q3DSMaterial::BlendFunc *type, const char *desc = nullptr, QXmlStreamReader *reader = nullptr);
+bool convertToImageAccess(const QStringRef &value, Q3DSMaterial::ImageAccess *type, const char *desc = nullptr, QXmlStreamReader *reader = nullptr);
}
Q_DECLARE_TYPEINFO(Q3DSMaterial::PropertyElement, Q_MOVABLE_TYPE);
diff --git a/tests/auto/materialparser/tst_q3dscustommaterialparser.cpp b/tests/auto/materialparser/tst_q3dscustommaterialparser.cpp
index 573f586..0e43ab9 100644
--- a/tests/auto/materialparser/tst_q3dscustommaterialparser.cpp
+++ b/tests/auto/materialparser/tst_q3dscustommaterialparser.cpp
@@ -237,8 +237,8 @@ void tst_Q3DSCustomMaterialParser::testCommands()
QCOMPARE(cmd.data()->param, QLatin1String("refractiveTexture"));
cmd = passes[4].commands[1];
QCOMPARE(cmd.type(), Q3DSMaterial::PassCommand::BlendingType);
- QCOMPARE(cmd.data()->source, QLatin1String("SrcAlpha"));
- QCOMPARE(cmd.data()->destination, QLatin1String("OneMinusSrcAlpha"));
+ QCOMPARE(cmd.data()->blendSource, Q3DSMaterial::SrcAlpha);
+ QCOMPARE(cmd.data()->blendDestination, Q3DSMaterial::OneMinusSrcAlpha);
}
void tst_Q3DSCustomMaterialParser::testBuffers()