summaryrefslogtreecommitdiffstats
path: root/gpu
diff options
context:
space:
mode:
authoralokp@chromium.org <alokp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-12 20:46:57 +0000
committeralokp@chromium.org <alokp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-12 20:46:57 +0000
commit00eb49ab9fb5623d9b45b01878687b667698c609 (patch)
tree3607b4a7847893a52cd50b1cd3e1f095f3610fde /gpu
parent480b4e3889ff11f3cd0b066f433907a818c8dcdb (diff)
downloadchromium_src-00eb49ab9fb5623d9b45b01878687b667698c609.zip
chromium_src-00eb49ab9fb5623d9b45b01878687b667698c609.tar.gz
chromium_src-00eb49ab9fb5623d9b45b01878687b667698c609.tar.bz2
Properly fixing crash due to out-of-order call of ShInitialize and ShFinalize.
Review URL: http://codereview.chromium.org/3122009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@55935 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu')
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder.cc26
1 files changed, 18 insertions, 8 deletions
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc
index 0450a5c..ab36100 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc
@@ -14,6 +14,7 @@
#include "app/gfx/gl/gl_context.h"
#include "app/gfx/gl/gl_implementation.h"
+#include "base/at_exit.h"
#include "base/callback.h"
#include "base/scoped_ptr.h"
#include "base/weak_ptr.h"
@@ -270,6 +271,21 @@ class FrameBuffer {
GLuint id_;
DISALLOW_COPY_AND_ASSIGN(FrameBuffer);
};
+
+#if defined(GLES2_GPU_SERVICE_TRANSLATE_SHADER)
+void FinalizeShaderTranslator(void*) {
+ ShFinalize();
+}
+
+bool InitializeShaderTranslator() {
+ static bool initialized = false;
+ if (!initialized && ShInitialize()) {
+ base::AtExitManager::RegisterCallback(&FinalizeShaderTranslator, NULL);
+ initialized = true;
+ }
+ return initialized;
+}
+#endif // GLES2_GPU_SERVICE_TRANSLATE_SHADER
// } // anonymous namespace.
GLES2Decoder::GLES2Decoder(ContextGroup* group)
@@ -1661,9 +1677,8 @@ bool GLES2DecoderImpl::Initialize(gfx::GLContext* context,
}
#if defined(GLES2_GPU_SERVICE_TRANSLATE_SHADER)
- // Initialize GLSL ES to GLSL translator.
- if (!ShInitialize()) {
- DLOG(ERROR) << "Could not initialize GLSL translator.";
+ if (!InitializeShaderTranslator()) {
+ DLOG(ERROR) << "Could not initialize shader translator.";
Destroy();
return false;
}
@@ -1694,7 +1709,6 @@ bool GLES2DecoderImpl::Initialize(gfx::GLContext* context,
Destroy();
return false;
}
-
#endif // GLES2_GPU_SERVICE_TRANSLATE_SHADER
return true;
@@ -2031,10 +2045,6 @@ void GLES2DecoderImpl::Destroy() {
ShDestruct(fragment_compiler_);
fragment_compiler_ = NULL;
}
- // TODO(alokp): Move ShInitialize/ShFinalize where they are called only
- // once per process. Currently they get called out-of-order leading to
- // crashes.
- // ShFinalize();
#endif // GLES2_GPU_SERVICE_TRANSLATE_SHADER)
if (context_.get()) {