aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@theqtcompany.com>2015-10-22 12:36:18 +0200
committerFriedemann Kleint <Friedemann.Kleint@theqtcompany.com>2015-10-26 10:26:02 +0000
commitf9fae251ca07401ee1b0039edc6ea6b7a522b5a7 (patch)
tree2dff3c7006f5a00ab6791a0e932109807a217ab4 /src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp
parent901b88c6ae6c476a8ad9825d9020325a9a58ab61 (diff)
Quick: Sanitize reading environment variables.
Where possible, use qEnvironmentVariableIsSet()/ qEnvironmentVariableIsEmpty() instead of checking on the return value of qgetenv(). Where the value is required, add a check using one of qEnvironmentVariableIsSet()/Empty(). Move QSGAtlasTexture::qsg_envInt() to qsgrenderer.cpp for reuse as qt_sg_envInt() and add qt_sg_envFloat(). Change-Id: I4c93f16c228d4f537154f389a0fa1427654485f7 Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
Diffstat (limited to 'src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp')
-rw-r--r--src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp35
1 files changed, 12 insertions, 23 deletions
diff --git a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp
index 60ada14c32..66a8f6fbd3 100644
--- a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp
+++ b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp
@@ -61,6 +61,8 @@ QT_BEGIN_NAMESPACE
extern QByteArray qsgShaderRewriter_insertZAttributes(const char *input, QSurfaceFormat::OpenGLContextProfile profile);
+int qt_sg_envInt(const char *name, int defaultValue);
+
namespace QSGBatchRenderer
{
@@ -785,30 +787,17 @@ Renderer::Renderer(QSGRenderContext *ctx)
}
m_bufferStrategy = GL_STATIC_DRAW;
- QByteArray strategy = qgetenv("QSG_RENDERER_BUFFER_STRATEGY");
- if (strategy == "dynamic") {
- m_bufferStrategy = GL_DYNAMIC_DRAW;
- } else if (strategy == "stream") {
- m_bufferStrategy = GL_STREAM_DRAW;
- }
-
- m_batchNodeThreshold = 64;
- QByteArray alternateThreshold = qgetenv("QSG_RENDERER_BATCH_NODE_THRESHOLD");
- if (alternateThreshold.length() > 0) {
- bool ok = false;
- int threshold = alternateThreshold.toInt(&ok);
- if (ok)
- m_batchNodeThreshold = threshold;
- }
-
- m_batchVertexThreshold = 1024;
- alternateThreshold = qgetenv("QSG_RENDERER_BATCH_VERTEX_THRESHOLD");
- if (alternateThreshold.length() > 0) {
- bool ok = false;
- int threshold = alternateThreshold.toInt(&ok);
- if (ok)
- m_batchVertexThreshold = threshold;
+ if (Q_UNLIKELY(qEnvironmentVariableIsSet("QSG_RENDERER_BUFFER_STRATEGY"))) {
+ const QByteArray strategy = qgetenv("QSG_RENDERER_BUFFER_STRATEGY");
+ if (strategy == "dynamic")
+ m_bufferStrategy = GL_DYNAMIC_DRAW;
+ else if (strategy == "stream")
+ m_bufferStrategy = GL_STREAM_DRAW;
}
+
+ m_batchNodeThreshold = qt_sg_envInt("QSG_RENDERER_BATCH_NODE_THRESHOLD", 64);
+ m_batchVertexThreshold = qt_sg_envInt("QSG_RENDERER_BATCH_VERTEX_THRESHOLD", 1024);
+
if (Q_UNLIKELY(debug_build() || debug_render())) {
qDebug() << "Batch thresholds: nodes:" << m_batchNodeThreshold << " vertices:" << m_batchVertexThreshold;
qDebug() << "Using buffer strategy:" << (m_bufferStrategy == GL_STATIC_DRAW ? "static" : (m_bufferStrategy == GL_DYNAMIC_DRAW ? "dynamic" : "stream"));