summaryrefslogtreecommitdiffstats
path: root/src/render/backend/rendershaderdata.cpp
diff options
context:
space:
mode:
authorPaul Lemire <paul.lemire.ecortex@kdab.com>2014-12-03 09:46:03 +0100
committerSean Harmer <sean.harmer@kdab.com>2014-12-12 14:17:38 +0100
commit634285f5e0c2555bd108f5f8ed979a0a18505429 (patch)
tree8a636c9ebb4e88a047449973856510786c582401 /src/render/backend/rendershaderdata.cpp
parent6bf131dc207ed34f7f5cf8c6edb5554c821cf2df (diff)
Quick3DShaderData for QJSValue handling
Quick3DShaderData subclasses QShaderData. QShaderData now provides a PropertyReaderInterface that returns a correct QVariant from the QVariant return when reading a QProperty. That way Quick3DShaderData properties (var) can be transformed to a QVariantList that the Renderer can use without introducing a QtQml dependency in core. RenderShaderData was updated to use propertyReader as well on creation and NodeUpdated events. A QJSValue -> QVariantList QMetatype converter was introduced to ease that process. Change-Id: Ifde5e7b85a1a84342846cd0ac0f047bd2c6ec4ef Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src/render/backend/rendershaderdata.cpp')
-rw-r--r--src/render/backend/rendershaderdata.cpp29
1 files changed, 17 insertions, 12 deletions
diff --git a/src/render/backend/rendershaderdata.cpp b/src/render/backend/rendershaderdata.cpp
index 1ebf22c90..59e49a972 100644
--- a/src/render/backend/rendershaderdata.cpp
+++ b/src/render/backend/rendershaderdata.cpp
@@ -41,6 +41,7 @@
#include "rendershaderdata_p.h"
#include "qshaderdata.h"
+#include "qshaderdata_p.h"
#include <QMetaProperty>
#include <QMetaObject>
#include <Qt3DCore/qscenepropertychange.h>
@@ -69,15 +70,20 @@ void RenderShaderData::updateFromPeer(QNode *peer)
{
m_properties.clear();
const QShaderData *shaderData = static_cast<const QShaderData *>(peer);
- const QMetaObject *metaObject = shaderData->metaObject();
- const int propertyOffset = QShaderData::staticMetaObject.propertyOffset();
- const int propertyCount = metaObject->propertyCount();
-
- for (int i = propertyOffset; i < propertyCount; ++i) {
- const QMetaProperty property = metaObject->property(i);
- if (strcmp(property.name(), "data") == 0 || strcmp(property.name(), "childNodes") == 0) // We don't handle default Node properties
- continue;
- m_properties.insert(QString::fromLatin1(property.name()), shaderData->property(property.name()));
+ m_propertyReader = shaderData->propertyReader();
+ if (!m_propertyReader.isNull()) {
+ const QMetaObject *metaObject = shaderData->metaObject();
+ const int propertyOffset = QShaderData::staticMetaObject.propertyOffset();
+ const int propertyCount = metaObject->propertyCount();
+
+ for (int i = propertyOffset; i < propertyCount; ++i) {
+ const QMetaProperty property = metaObject->property(i);
+ if (strcmp(property.name(), "data") == 0 || strcmp(property.name(), "childNodes") == 0) // We don't handle default Node properties
+ continue;
+ // We should be making clones of inner QShaderData properties
+ m_properties.insert(QString::fromLatin1(property.name()),
+ m_propertyReader->readProperty(shaderData->property(property.name())));
+ }
}
}
@@ -113,7 +119,6 @@ void RenderShaderData::updateUniformBuffer(QGraphicsContext *ctx)
// Upload the whole buffer to GPU for the first time
m_ubo.update(ctx, m_data.constData(), m_block.m_size);
}
-
Q_FOREACH (const QString &property, m_updatedProperties) {
uniformsIt = m_activeProperties.begin();
while (uniformsIt != uniformsEnd) {
@@ -146,13 +151,13 @@ void RenderShaderData::apply(QGraphicsContext *ctx, int bindingPoint)
// AspectThread / Job thread for transformed properties
void RenderShaderData::sceneChangeEvent(const QSceneChangePtr &e)
{
- if (e->type() == NodeUpdated) {
+ if (!m_propertyReader.isNull() && e->type() == NodeUpdated) {
QScenePropertyChangePtr propertyChange = qSharedPointerCast<QScenePropertyChange>(e);
QString propertyName = QString::fromLatin1(propertyChange->propertyName());
QMutexLocker lock(m_mutex);
// lock to update m_properties;
if (m_properties.contains(propertyName)) {
- m_properties.insert(propertyName, propertyChange->value());
+ m_properties.insert(propertyName, m_propertyReader->readProperty(propertyChange->value()));
m_updatedProperties.append(propertyName);
m_needsBufferUpdate.fetchAndStoreOrdered(1);
}