aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/scenegraph/qsgcontext.cpp
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@digia.com>2013-06-10 10:01:12 +0200
committerFrederik Gladhorn <frederik.gladhorn@digia.com>2013-06-10 10:01:27 +0200
commit8a793defa79bd332742cadeabfe05cbaa5516877 (patch)
tree85f28038d29452fae858723dc7b7e5f0df9dcb42 /src/quick/scenegraph/qsgcontext.cpp
parentcbc86ae4d4af719f201e5f62aa07ef4a763eecee (diff)
parente4fc75edaedead3092aace3a29a0aafdd0e86a77 (diff)
Merge remote-tracking branch 'origin/release' into stable
Diffstat (limited to 'src/quick/scenegraph/qsgcontext.cpp')
-rw-r--r--src/quick/scenegraph/qsgcontext.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/quick/scenegraph/qsgcontext.cpp b/src/quick/scenegraph/qsgcontext.cpp
index c47250662b..6d327b8d80 100644
--- a/src/quick/scenegraph/qsgcontext.cpp
+++ b/src/quick/scenegraph/qsgcontext.cpp
@@ -47,7 +47,9 @@
#include <QtQuick/private/qsgdefaultimagenode_p.h>
#include <QtQuick/private/qsgdefaultglyphnode_p.h>
#include <QtQuick/private/qsgdistancefieldglyphnode_p.h>
+#include <QtQuick/private/qsgdistancefieldglyphnode_p_p.h>
#include <QtQuick/private/qsgshareddistancefieldglyphcache_p.h>
+#include <QtQuick/QSGFlatColorMaterial>
#include <QtQuick/private/qsgtexture_p.h>
#include <QtQuick/private/qquickpixmapcache_p.h>
@@ -261,9 +263,35 @@ void QSGContext::initialize(QOpenGLContext *context)
Q_ASSERT(!d->gl);
d->gl = context;
+ precompileMaterials();
+
emit initialized();
}
+#define QSG_PRECOMPILE_MATERIAL(name) { name m; prepareMaterial(&m); }
+
+/*
+ * Some glsl compilers take their time compiling materials, and
+ * the way the scene graph is being processed, these materials
+ * get compiled when they are first taken into use. This can
+ * easily lead to skipped frames. By precompiling the most
+ * common materials, we potentially add a few milliseconds to the
+ * start up, and reduce the chance of avoiding skipped frames
+ * later on.
+ */
+void QSGContext::precompileMaterials()
+{
+ if (qEnvironmentVariableIsEmpty("QSG_NO_MATERIAL_PRELOADING")) {
+ QSG_PRECOMPILE_MATERIAL(QSGVertexColorMaterial);
+ QSG_PRECOMPILE_MATERIAL(QSGFlatColorMaterial);
+ QSG_PRECOMPILE_MATERIAL(QSGOpaqueTextureMaterial);
+ QSG_PRECOMPILE_MATERIAL(QSGTextureMaterial);
+ QSG_PRECOMPILE_MATERIAL(SmoothTextureMaterial);
+ QSG_PRECOMPILE_MATERIAL(SmoothColorMaterial);
+ QSG_PRECOMPILE_MATERIAL(QSGDistanceFieldTextMaterial);
+ }
+}
+
/*!
Returns if the scene graph context is ready or not, meaning that it has a valid