aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/scenegraph/util/qsgatlastexture.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/util/qsgatlastexture.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/util/qsgatlastexture.cpp')
-rw-r--r--src/quick/scenegraph/util/qsgatlastexture.cpp16
1 files changed, 4 insertions, 12 deletions
diff --git a/src/quick/scenegraph/util/qsgatlastexture.cpp b/src/quick/scenegraph/util/qsgatlastexture.cpp
index 8c649fb6bd..8e8e870505 100644
--- a/src/quick/scenegraph/util/qsgatlastexture.cpp
+++ b/src/quick/scenegraph/util/qsgatlastexture.cpp
@@ -54,21 +54,13 @@ QT_BEGIN_NAMESPACE
#define GL_BGRA 0x80E1
#endif
+int qt_sg_envInt(const char *name, int defaultValue);
static QElapsedTimer qsg_renderer_timer;
namespace QSGAtlasTexture
{
-static int qsg_envInt(const char *name, int defaultValue)
-{
- QByteArray content = qgetenv(name);
-
- bool ok = false;
- int value = content.toInt(&ok);
- return ok ? value : defaultValue;
-}
-
Manager::Manager()
: m_atlas(0)
{
@@ -79,8 +71,8 @@ Manager::Manager()
int max;
gl->functions()->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &max);
- int w = qMin(max, qsg_envInt("QSG_ATLAS_WIDTH", qMax(512U, qNextPowerOfTwo(surfaceSize.width() - 1))));
- int h = qMin(max, qsg_envInt("QSG_ATLAS_HEIGHT", qMax(512U, qNextPowerOfTwo(surfaceSize.height() - 1))));
+ int w = qMin(max, qt_sg_envInt("QSG_ATLAS_WIDTH", qMax(512U, qNextPowerOfTwo(surfaceSize.width() - 1))));
+ int h = qMin(max, qt_sg_envInt("QSG_ATLAS_HEIGHT", qMax(512U, qNextPowerOfTwo(surfaceSize.height() - 1))));
if (surface->surfaceClass() == QSurface::Window) {
QWindow *window = static_cast<QWindow *>(surface);
@@ -91,7 +83,7 @@ Manager::Manager()
}
}
- m_atlas_size_limit = qsg_envInt("QSG_ATLAS_SIZE_LIMIT", qMax(w, h) / 2);
+ m_atlas_size_limit = qt_sg_envInt("QSG_ATLAS_SIZE_LIMIT", qMax(w, h) / 2);
m_atlas_size = QSize(w, h);
qCDebug(QSG_LOG_INFO, "texture atlas dimensions: %dx%d", w, h);