summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Lemire <paul.lemire@kdab.com>2020-07-03 10:57:24 +0200
committerPaul Lemire <paul.lemire@kdab.com>2020-07-07 08:58:23 +0200
commitfaaa5dfe296729cb3fe4ac100de39902bd9a5d57 (patch)
treecfef6acf333cb08685e313d8b475d72af3a979c9
parent872966f3205682ecc8c1e9353b64c04c59adf0b6 (diff)
OpenGL Renderer: replace std::find by Qt3DCore::contains
More concise and easier to read Change-Id: I67d93ff213842cfcc0263e244d89ba1e9a73982b Reviewed-by: Mike Krus <mike.krus@kdab.com>
-rw-r--r--src/plugins/renderers/opengl/jobs/renderviewjobutils.cpp4
-rw-r--r--src/plugins/renderers/opengl/renderer/glshader.cpp9
-rw-r--r--src/plugins/renderers/opengl/renderer/renderer.cpp18
-rw-r--r--src/plugins/renderers/opengl/renderer/renderview.cpp8
-rw-r--r--src/render/backend/apishadermanager_p.h5
-rw-r--r--src/render/materialsystem/techniquemanager.cpp5
6 files changed, 19 insertions, 30 deletions
diff --git a/src/plugins/renderers/opengl/jobs/renderviewjobutils.cpp b/src/plugins/renderers/opengl/jobs/renderviewjobutils.cpp
index 3758d959c..7065641c1 100644
--- a/src/plugins/renderers/opengl/jobs/renderviewjobutils.cpp
+++ b/src/plugins/renderers/opengl/jobs/renderviewjobutils.cpp
@@ -494,7 +494,7 @@ void UniformBlockValueBuilder::buildActiveUniformNameValueMapHelper(const Shader
}
}
} else { // Array of scalar/vec qmlPropertyName[0]
- if (std::find(m_uniformNamesIds.begin(), m_uniformNamesIds.end(), propertyInBlockNameId) != m_uniformNamesIds.end()) {
+ if (Qt3DCore::contains(m_uniformNamesIds, propertyInBlockNameId)) {
activeUniformNamesToValue.insert(propertyInBlockNameId, value->value);
}
}
@@ -509,7 +509,7 @@ void UniformBlockValueBuilder::buildActiveUniformNameValueMapHelper(const Shader
activeUniformNamesToValue.insert(propertyInBlockNameId, value->value);
}
} else { // Scalar / Vec
- if (std::find(m_uniformNamesIds.begin(), m_uniformNamesIds.end(), propertyInBlockNameId) != m_uniformNamesIds.end()) {
+ if (Qt3DCore::contains(m_uniformNamesIds, propertyInBlockNameId)) {
// If the property needs to be transformed, we transform it here as
// the shaderdata cannot hold transformed properties for multiple
// thread contexts at once
diff --git a/src/plugins/renderers/opengl/renderer/glshader.cpp b/src/plugins/renderers/opengl/renderer/glshader.cpp
index f9f2a99b8..bd7119522 100644
--- a/src/plugins/renderers/opengl/renderer/glshader.cpp
+++ b/src/plugins/renderers/opengl/renderer/glshader.cpp
@@ -43,6 +43,7 @@
#include <graphicscontext_p.h>
#include <logging_p.h>
#include <gllights_p.h>
+#include <Qt3DCore/private/vector_helper_p.h>
QT_BEGIN_NAMESPACE
@@ -225,9 +226,7 @@ GLShader::ParameterKind GLShader::categorizeVariable(int nameId) const noexcept
bool GLShader::hasUniform(int nameId) const noexcept
{
- return std::find(m_uniformsNamesIds.begin(),
- m_uniformsNamesIds.end(),
- nameId) != m_uniformsNamesIds.end();
+ return Qt3DCore::contains(m_uniformsNamesIds, nameId);
}
void GLShader::prepareUniforms(ShaderParameterPack &pack)
@@ -312,9 +311,9 @@ void GLShader::initializeUniforms(const std::vector<ShaderUniform> &uniformsDesc
m_uniforms[i].m_nameId = nameId;
// Is the uniform a Qt3D "Standard" uniform, a light uniform or a user defined one?
- if (std::find(standardUniformNameIds.begin(), standardUniformNameIds.end(), nameId) != standardUniformNameIds.end())
+ if (Qt3DCore::contains(standardUniformNameIds, nameId))
m_standardUniformNamesIds.push_back(nameId);
- else if (std::find(lightUniformNameIds.begin(), lightUniformNameIds.end(), nameId) != lightUniformNameIds.end())
+ else if (Qt3DCore::contains(lightUniformNameIds, nameId))
m_lightUniformsNamesIds.push_back(nameId);
else
m_uniformsNamesIds.push_back(nameId);
diff --git a/src/plugins/renderers/opengl/renderer/renderer.cpp b/src/plugins/renderers/opengl/renderer/renderer.cpp
index 2b4504d3f..770578fc2 100644
--- a/src/plugins/renderers/opengl/renderer/renderer.cpp
+++ b/src/plugins/renderers/opengl/renderer/renderer.cpp
@@ -389,7 +389,7 @@ QOpenGLContext *Renderer::shareContext() const
void Renderer::loadShader(Shader *shader, HShader shaderHandle)
{
Q_UNUSED(shader);
- if (std::find(m_dirtyShaders.begin(), m_dirtyShaders.end(), shaderHandle) == m_dirtyShaders.end())
+ if (!Qt3DCore::contains(m_dirtyShaders, shaderHandle))
m_dirtyShaders.push_back(shaderHandle);
}
@@ -1603,9 +1603,7 @@ Renderer::ViewSubmissionResultData Renderer::submitRenderViews(const std::vector
static_cast<Render::RenderCapture*>(m_nodesManager->frameGraphManager()->lookupNode(renderView->renderCaptureNodeId()));
renderCapture->addRenderCapture(request.captureId, image);
const QNodeId renderCaptureId = renderView->renderCaptureNodeId();
- if (std::find(m_pendingRenderCaptureSendRequests.begin(),
- m_pendingRenderCaptureSendRequests.end(),
- renderCaptureId) == m_pendingRenderCaptureSendRequests.end())
+ if (!Qt3DCore::contains(m_pendingRenderCaptureSendRequests, renderCaptureId))
m_pendingRenderCaptureSendRequests.push_back(renderView->renderCaptureNodeId());
}
@@ -1835,9 +1833,7 @@ std::vector<Qt3DCore::QAspectJobPtr> Renderer::renderBinJobs()
// Remove leaf nodes that no longer exist from cache
const QList<FrameGraphNode *> keys = m_cache.leafNodeCache.keys();
for (FrameGraphNode *leafNode : keys) {
- if (std::find(m_frameGraphLeaves.begin(),
- m_frameGraphLeaves.end(),
- leafNode) == m_frameGraphLeaves.end())
+ if (!Qt3DCore::contains(m_frameGraphLeaves, leafNode))
m_cache.leafNodeCache.remove(leafNode);
}
@@ -2154,9 +2150,7 @@ bool Renderer::updateVAOWithAttributes(Geometry *geometry,
if ((attributeWasDirty = attribute->isDirty()) == true || forceUpdate)
m_submissionContext->specifyIndices(buffer);
// Vertex Attribute
- } else if (std::find(command->m_activeAttributes.begin(),
- command->m_activeAttributes.end(),
- attribute->nameId()) != command->m_activeAttributes.end()) {
+ } else if (Qt3DCore::contains(command->m_activeAttributes, attribute->nameId())) {
if ((attributeWasDirty = attribute->isDirty()) == true || forceUpdate) {
// Find the location for the attribute
const std::vector<ShaderAttribute> &shaderAttributes = shader->attributes();
@@ -2201,9 +2195,7 @@ bool Renderer::requiresVAOAttributeUpdate(Geometry *geometry,
continue;
if ((attribute->attributeType() == QAttribute::IndexAttribute && attribute->isDirty()) ||
- (std::find(command->m_activeAttributes.begin(),
- command->m_activeAttributes.end(),
- attribute->nameId()) != command->m_activeAttributes.end() &&
+ (Qt3DCore::contains(command->m_activeAttributes, attribute->nameId()) &&
attribute->isDirty()))
return true;
}
diff --git a/src/plugins/renderers/opengl/renderer/renderview.cpp b/src/plugins/renderers/opengl/renderer/renderview.cpp
index 24766dab0..a13726fca 100644
--- a/src/plugins/renderers/opengl/renderer/renderview.cpp
+++ b/src/plugins/renderers/opengl/renderer/renderview.cpp
@@ -1134,12 +1134,12 @@ void RenderView::updateLightUniforms(RenderCommand *command, const Entity *entit
break;
// Note: implicit conversion of values to UniformValue
- if (std::find(lightUniformNamesIds.begin(), lightUniformNamesIds.end(), GLLights::LIGHT_TYPE_NAMES[lightIdx]) != lightUniformNamesIds.end()) {
+ if (Qt3DCore::contains(lightUniformNamesIds, GLLights::LIGHT_TYPE_NAMES[lightIdx])) {
setUniformValue(command->m_parameterPack, GLLights::LIGHT_POSITION_NAMES[lightIdx], worldPos);
setUniformValue(command->m_parameterPack, GLLights::LIGHT_TYPE_NAMES[lightIdx], int(QAbstractLight::PointLight));
setUniformValue(command->m_parameterPack, GLLights::LIGHT_COLOR_NAMES[lightIdx], Vector3D(1.0f, 1.0f, 1.0f));
setUniformValue(command->m_parameterPack, GLLights::LIGHT_INTENSITY_NAMES[lightIdx], 0.5f);
- } else if (std::find(lightUniformNamesIds.begin(), lightUniformNamesIds.end(), GLLights::LIGHT_TYPE_UNROLL_NAMES[lightIdx]) != lightUniformNamesIds.end()) {
+ } else if (Qt3DCore::contains(lightUniformNamesIds, GLLights::LIGHT_TYPE_UNROLL_NAMES[lightIdx])) {
setUniformValue(command->m_parameterPack, GLLights::LIGHT_POSITION_UNROLL_NAMES[lightIdx], worldPos);
setUniformValue(command->m_parameterPack, GLLights::LIGHT_TYPE_UNROLL_NAMES[lightIdx], int(QAbstractLight::PointLight));
setUniformValue(command->m_parameterPack, GLLights::LIGHT_COLOR_UNROLL_NAMES[lightIdx], Vector3D(1.0f, 1.0f, 1.0f));
@@ -1164,12 +1164,12 @@ void RenderView::updateLightUniforms(RenderCommand *command, const Entity *entit
// If no active light sources and no environment light, add a default light
if (m_lightSources.empty() && !m_environmentLight) {
// Note: implicit conversion of values to UniformValue
- if (std::find(lightUniformNamesIds.begin(), lightUniformNamesIds.end(), GLLights::LIGHT_TYPE_NAMES[lightIdx]) != lightUniformNamesIds.end()) {
+ if (Qt3DCore::contains(lightUniformNamesIds, GLLights::LIGHT_TYPE_NAMES[lightIdx])) {
setUniformValue(command->m_parameterPack, GLLights::LIGHT_POSITION_NAMES[0], Vector3D(10.0f, 10.0f, 0.0f));
setUniformValue(command->m_parameterPack, GLLights::LIGHT_TYPE_NAMES[0], int(QAbstractLight::PointLight));
setUniformValue(command->m_parameterPack, GLLights::LIGHT_COLOR_NAMES[0], Vector3D(1.0f, 1.0f, 1.0f));
setUniformValue(command->m_parameterPack, GLLights::LIGHT_INTENSITY_NAMES[0], 0.5f);
- } else if (std::find(lightUniformNamesIds.begin(), lightUniformNamesIds.end(), GLLights::LIGHT_TYPE_UNROLL_NAMES[lightIdx]) != lightUniformNamesIds.end()) {
+ } else if (Qt3DCore::contains(lightUniformNamesIds, GLLights::LIGHT_TYPE_UNROLL_NAMES[lightIdx])) {
setUniformValue(command->m_parameterPack, GLLights::LIGHT_POSITION_UNROLL_NAMES[0], Vector3D(10.0f, 10.0f, 0.0f));
setUniformValue(command->m_parameterPack, GLLights::LIGHT_TYPE_UNROLL_NAMES[0], int(QAbstractLight::PointLight));
setUniformValue(command->m_parameterPack, GLLights::LIGHT_COLOR_UNROLL_NAMES[0], Vector3D(1.0f, 1.0f, 1.0f));
diff --git a/src/render/backend/apishadermanager_p.h b/src/render/backend/apishadermanager_p.h
index d8820d12f..eb938c9c8 100644
--- a/src/render/backend/apishadermanager_p.h
+++ b/src/render/backend/apishadermanager_p.h
@@ -55,6 +55,7 @@
#include <Qt3DCore/qnodeid.h>
#include <Qt3DRender/private/shader_p.h>
#include <QtCore/QReadLocker>
+#include <Qt3DCore/private/vector_helper_p.h>
QT_BEGIN_NAMESPACE
@@ -147,9 +148,7 @@ public:
QWriteLocker lock(&m_readWriteLock);
auto &shaderIds = m_apiShaders[apiShader];
- if (std::find(shaderIds.begin(),
- shaderIds.end(),
- shader->peerId()) == shaderIds.end()) {
+ if (!Qt3DCore::contains(shaderIds, shader->peerId())) {
shaderIds.push_back(shader->peerId());
m_nodeIdToAPIShader.insert(shader->peerId(), apiShader);
}
diff --git a/src/render/materialsystem/techniquemanager.cpp b/src/render/materialsystem/techniquemanager.cpp
index 2ecb5c3b3..08c31a32a 100644
--- a/src/render/materialsystem/techniquemanager.cpp
+++ b/src/render/materialsystem/techniquemanager.cpp
@@ -38,6 +38,7 @@
****************************************************************************/
#include "techniquemanager_p.h"
+#include <Qt3DCore/private/vector_helper_p.h>
QT_BEGIN_NAMESPACE
@@ -52,9 +53,7 @@ TechniqueManager::TechniqueManager()
// AspectThread
void TechniqueManager::addDirtyTechnique(Qt3DCore::QNodeId techniqueId)
{
- if (std::find(m_dirtyTechniques.begin(),
- m_dirtyTechniques.end(),
- techniqueId) == m_dirtyTechniques.end())
+ if (!Qt3DCore::contains(m_dirtyTechniques, techniqueId))
m_dirtyTechniques.push_back(techniqueId);
}