diff options
author | Paul Lemire <paul.lemire.ecortex@kdab.com> | 2014-11-21 14:23:11 +0100 |
---|---|---|
committer | Sean Harmer <sean.harmer@kdab.com> | 2014-12-12 14:17:17 +0100 |
commit | 9bbaac2768530acc2619f53dac6553e390f2baf3 (patch) | |
tree | 48cf4a032c30d49d8202b6f238e68e13ef2f1b10 /src/render/backend/rendershaderdata.cpp | |
parent | 958cef1d4633d90364e4fb25ed7a9a0dc204a745 (diff) |
RenderShaderData: index properties by QString instead of char*
This is easier for comparing key values.
Also use QShaderData::staticMetaObject for introspection in updateFromPeer
otherwise, if QShaderData is subclassed, we will be missing the properties
defined in the subclass.
Change-Id: I1fd09c2a19c6581a544d78a120e34ef7dec5826c
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src/render/backend/rendershaderdata.cpp')
-rw-r--r-- | src/render/backend/rendershaderdata.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/render/backend/rendershaderdata.cpp b/src/render/backend/rendershaderdata.cpp index 4617caf2a..8f02635e8 100644 --- a/src/render/backend/rendershaderdata.cpp +++ b/src/render/backend/rendershaderdata.cpp @@ -64,14 +64,14 @@ void RenderShaderData::updateFromPeer(QNode *peer) m_properties.clear(); const QShaderData *shaderData = static_cast<const QShaderData *>(peer); const QMetaObject *metaObject = shaderData->metaObject(); - const int propertyOffset = metaObject->propertyOffset(); + 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(property.name(), shaderData->property(property.name())); + m_properties.insert(QString::fromLatin1(property.name()), shaderData->property(property.name())); } } @@ -86,7 +86,7 @@ void RenderShaderData::initialize(const ShaderUniformBlock &block) m_needsBufferUpdate = true; } -void RenderShaderData::appendActiveProperty(const char *propertyName, const ShaderUniform &description) +void RenderShaderData::appendActiveProperty(const QString &propertyName, const ShaderUniform &description) { m_activeProperties.insert(propertyName, description); } @@ -99,8 +99,8 @@ void RenderShaderData::updateUniformBuffer(QGraphicsContext *ctx) } // TO DO: Only update values that have changed rather than the whole buffer - QHash<const char *, ShaderUniform>::const_iterator uniformsIt = m_activeProperties.begin(); - const QHash<const char *, ShaderUniform>::const_iterator uniformsEnd = m_activeProperties.end(); + QHash<QString, ShaderUniform>::const_iterator uniformsIt = m_activeProperties.begin(); + const QHash<QString, ShaderUniform>::const_iterator uniformsEnd = m_activeProperties.end(); while (uniformsIt != uniformsEnd) { ctx->buildUniformBuffer(m_properties.value(uniformsIt.key()), uniformsIt.value(), m_data); @@ -124,8 +124,9 @@ void RenderShaderData::sceneChangeEvent(const QSceneChangePtr &e) { if (e->type() == NodeUpdated) { QScenePropertyChangePtr propertyChange = qSharedPointerCast<QScenePropertyChange>(e); - if (m_properties.contains(propertyChange->propertyName())) { - m_properties.insert(propertyChange->propertyName(), propertyChange->value()); + QString propertyName = QString::fromLatin1(propertyChange->propertyName()); + if (m_properties.contains(propertyName)) { + m_properties.insert(propertyName, propertyChange->value()); m_needsBufferUpdate = true; } } |