diff options
author | Eike Ziller <eike.ziller@nokia.com> | 2012-02-03 11:54:47 +0100 |
---|---|---|
committer | Eike Ziller <eike.ziller@nokia.com> | 2012-02-03 13:03:39 +0100 |
commit | dc0b11db17d6b21f173d22e0764f2fbff9dd68e0 (patch) | |
tree | f68ad42437ec9bde0bbaff2b0d28fbeecc413d06 /src/plugins/glsleditor/glsleditorplugin.cpp | |
parent | da34e80edee983f47867cbd724c445c28336df76 (diff) |
Don't parse GLSL init files at startup.
Can easily be done when they are actually requested.
Change-Id: I2022b2b97ea13725ed62ed2657f99cb505553c45
Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com>
Diffstat (limited to 'src/plugins/glsleditor/glsleditorplugin.cpp')
-rw-r--r-- | src/plugins/glsleditor/glsleditorplugin.cpp | 47 |
1 files changed, 30 insertions, 17 deletions
diff --git a/src/plugins/glsleditor/glsleditorplugin.cpp b/src/plugins/glsleditor/glsleditorplugin.cpp index c0c62860592..55668acf70a 100644 --- a/src/plugins/glsleditor/glsleditorplugin.cpp +++ b/src/plugins/glsleditor/glsleditorplugin.cpp @@ -81,7 +81,13 @@ GLSLEditorPlugin::InitFile::~InitFile() GLSLEditorPlugin::GLSLEditorPlugin() : m_editor(0), - m_actionHandler(0) + m_actionHandler(0), + m_glsl_120_frag(0), + m_glsl_120_vert(0), + m_glsl_120_common(0), + m_glsl_es_100_frag(0), + m_glsl_es_100_vert(0), + m_glsl_es_100_common(0) { m_instance = this; } @@ -90,6 +96,12 @@ GLSLEditorPlugin::~GLSLEditorPlugin() { removeObject(m_editor); delete m_actionHandler; + delete m_glsl_120_frag; + delete m_glsl_120_vert; + delete m_glsl_120_common; + delete m_glsl_es_100_frag; + delete m_glsl_es_100_vert; + delete m_glsl_es_100_common; m_instance = 0; } @@ -110,14 +122,6 @@ bool GLSLEditorPlugin::initialize(const QStringList & /*arguments*/, QString *er if (!Core::ICore::mimeDatabase()->addMimeTypes(QLatin1String(":/glsleditor/GLSLEditor.mimetypes.xml"), errorMessage)) return false; - parseGlslFile(QLatin1String("glsl_120.frag"), &m_glsl_120_frag); - parseGlslFile(QLatin1String("glsl_120.vert"), &m_glsl_120_vert); - parseGlslFile(QLatin1String("glsl_120_common.glsl"), &m_glsl_120_common); - parseGlslFile(QLatin1String("glsl_es_100.frag"), &m_glsl_es_100_frag); - parseGlslFile(QLatin1String("glsl_es_100.vert"), &m_glsl_es_100_vert); - parseGlslFile(QLatin1String("glsl_es_100_common.glsl"), &m_glsl_es_100_common); - - // m_modelManager = new ModelManager(this); // addAutoReleasedObject(m_modelManager); @@ -251,7 +255,16 @@ Core::Command *GLSLEditorPlugin::addToolAction(QAction *a, Core::ActionManager * return command; } -QByteArray GLSLEditorPlugin::glslFile(const QString &fileName) +GLSLEditorPlugin::InitFile *GLSLEditorPlugin::getInitFile(const QString &fileName, InitFile **initFile) const +{ + if (*initFile) + return *initFile; + *initFile = new GLSLEditorPlugin::InitFile; + parseGlslFile(fileName, *initFile); + return *initFile; +} + +QByteArray GLSLEditorPlugin::glslFile(const QString &fileName) const { QString path = Core::ICore::resourcePath(); path += QLatin1String("/glsl/"); @@ -262,7 +275,7 @@ QByteArray GLSLEditorPlugin::glslFile(const QString &fileName) return QByteArray(); } -void GLSLEditorPlugin::parseGlslFile(const QString &fileName, InitFile *initFile) +void GLSLEditorPlugin::parseGlslFile(const QString &fileName, InitFile *initFile) const { // Parse the builtins for any langugage variant so we can use all keywords. const unsigned variant = GLSL::Lexer::Variant_All; @@ -276,25 +289,25 @@ void GLSLEditorPlugin::parseGlslFile(const QString &fileName, InitFile *initFile const GLSLEditorPlugin::InitFile *GLSLEditorPlugin::fragmentShaderInit(int variant) const { if (variant & GLSL::Lexer::Variant_GLSL_120) - return &m_glsl_120_frag; + return getInitFile(QLatin1String("glsl_120.frag"), &m_glsl_120_frag); else - return &m_glsl_es_100_frag; + return getInitFile(QLatin1String("glsl_es_100.frag"), &m_glsl_es_100_frag); } const GLSLEditorPlugin::InitFile *GLSLEditorPlugin::vertexShaderInit(int variant) const { if (variant & GLSL::Lexer::Variant_GLSL_120) - return &m_glsl_120_vert; + return getInitFile(QLatin1String("glsl_120.vert"), &m_glsl_120_vert); else - return &m_glsl_es_100_vert; + return getInitFile(QLatin1String("glsl_es_100.vert"), &m_glsl_es_100_vert); } const GLSLEditorPlugin::InitFile *GLSLEditorPlugin::shaderInit(int variant) const { if (variant & GLSL::Lexer::Variant_GLSL_120) - return &m_glsl_120_common; + return getInitFile(QLatin1String("glsl_120_common.glsl"), &m_glsl_120_common); else - return &m_glsl_es_100_common; + return getInitFile(QLatin1String("glsl_es_100_common.glsl"), &m_glsl_es_100_common); } Q_EXPORT_PLUGIN(GLSLEditorPlugin) |