OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "gpu/command_buffer/service/shader_translator.h" | 5 #include "gpu/command_buffer/service/shader_translator.h" |
6 | 6 |
7 #include <string.h> | 7 #include <string.h> |
8 #include <algorithm> | 8 #include <algorithm> |
9 | 9 |
10 #include "base/at_exit.h" | 10 #include "base/at_exit.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 | 12 |
13 namespace { | 13 namespace { |
14 | 14 |
15 using gpu::gles2::ShaderTranslator; | 15 using gpu::gles2::ShaderTranslator; |
16 | 16 |
17 static bool g_shader_initalized_ = false; | |
Paweł Hajdan Jr.
2013/05/08 16:32:25
nit: No underscore at the end for global variables
Robert Sesek
2013/05/08 16:42:11
Done.
| |
18 | |
17 void FinalizeShaderTranslator(void* /* dummy */) { | 19 void FinalizeShaderTranslator(void* /* dummy */) { |
18 ShFinalize(); | 20 ShFinalize(); |
21 g_shader_initalized_ = false; | |
Paweł Hajdan Jr.
2013/05/08 16:32:25
Let's DCHECK before it that g_shader_initialized i
Robert Sesek
2013/05/08 16:42:11
Done.
| |
19 } | 22 } |
20 | 23 |
21 bool InitializeShaderTranslator() { | 24 bool InitializeShaderTranslator() { |
22 static bool initialized = false; | 25 if (!g_shader_initalized_ && ShInitialize()) { |
23 if (!initialized && ShInitialize()) { | |
24 base::AtExitManager::RegisterCallback(&FinalizeShaderTranslator, NULL); | 26 base::AtExitManager::RegisterCallback(&FinalizeShaderTranslator, NULL); |
25 initialized = true; | 27 g_shader_initalized_ = true; |
26 } | 28 } |
27 return initialized; | 29 return g_shader_initalized_; |
28 } | 30 } |
29 | 31 |
30 #if !defined(ANGLE_SH_VERSION) || ANGLE_SH_VERSION < 108 | 32 #if !defined(ANGLE_SH_VERSION) || ANGLE_SH_VERSION < 108 |
31 typedef int ANGLEGetInfoType; | 33 typedef int ANGLEGetInfoType; |
32 #else | 34 #else |
33 typedef size_t ANGLEGetInfoType; | 35 typedef size_t ANGLEGetInfoType; |
34 #endif | 36 #endif |
35 | 37 |
36 void GetVariableInfo(ShHandle compiler, ShShaderInfo var_type, | 38 void GetVariableInfo(ShHandle compiler, ShShaderInfo var_type, |
37 ShaderTranslator::VariableMap* var_map) { | 39 ShaderTranslator::VariableMap* var_map) { |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
235 translated_shader_.reset(); | 237 translated_shader_.reset(); |
236 info_log_.reset(); | 238 info_log_.reset(); |
237 attrib_map_.clear(); | 239 attrib_map_.clear(); |
238 uniform_map_.clear(); | 240 uniform_map_.clear(); |
239 name_map_.clear(); | 241 name_map_.clear(); |
240 } | 242 } |
241 | 243 |
242 } // namespace gles2 | 244 } // namespace gles2 |
243 } // namespace gpu | 245 } // namespace gpu |
244 | 246 |
OLD | NEW |