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_cache.h" | 5 #include "gpu/command_buffer/service/shader_translator_cache.h" |
6 | 6 |
7 namespace gpu { | 7 namespace gpu { |
8 namespace gles2 { | 8 namespace gles2 { |
9 | 9 |
10 ShaderTranslatorCache* ShaderTranslatorCache::GetInstance() { | 10 ShaderTranslatorCache* ShaderTranslatorCache::GetInstance() { |
(...skipping 16 matching lines...) Expand all Loading... |
27 it++; | 27 it++; |
28 } | 28 } |
29 } | 29 } |
30 | 30 |
31 scoped_refptr<ShaderTranslator> ShaderTranslatorCache::GetTranslator( | 31 scoped_refptr<ShaderTranslator> ShaderTranslatorCache::GetTranslator( |
32 ShShaderType shader_type, | 32 ShShaderType shader_type, |
33 ShShaderSpec shader_spec, | 33 ShShaderSpec shader_spec, |
34 const ShBuiltInResources* resources, | 34 const ShBuiltInResources* resources, |
35 ShaderTranslatorInterface::GlslImplementationType | 35 ShaderTranslatorInterface::GlslImplementationType |
36 glsl_implementation_type, | 36 glsl_implementation_type, |
37 ShaderTranslatorInterface::GlslBuiltInFunctionBehavior | 37 ShCompileOptions driver_bug_workarounds) { |
38 glsl_built_in_function_behavior) { | |
39 ShaderTranslatorInitParams params(shader_type, | 38 ShaderTranslatorInitParams params(shader_type, |
40 shader_spec, | 39 shader_spec, |
41 *resources, | 40 *resources, |
42 glsl_implementation_type, | 41 glsl_implementation_type, |
43 glsl_built_in_function_behavior); | 42 driver_bug_workarounds); |
44 | 43 |
45 Cache::iterator it = cache_.find(params); | 44 Cache::iterator it = cache_.find(params); |
46 if (it != cache_.end()) | 45 if (it != cache_.end()) |
47 return it->second; | 46 return it->second; |
48 | 47 |
49 ShaderTranslator* translator = new ShaderTranslator(); | 48 ShaderTranslator* translator = new ShaderTranslator(); |
50 if (translator->Init(shader_type, shader_spec, resources, | 49 if (translator->Init(shader_type, shader_spec, resources, |
51 glsl_implementation_type, | 50 glsl_implementation_type, |
52 glsl_built_in_function_behavior)) { | 51 driver_bug_workarounds)) { |
53 cache_[params] = translator; | 52 cache_[params] = translator; |
54 translator->AddDestructionObserver(this); | 53 translator->AddDestructionObserver(this); |
55 return translator; | 54 return translator; |
56 } else { | 55 } else { |
57 return NULL; | 56 return NULL; |
58 } | 57 } |
59 } | 58 } |
60 | 59 |
61 } // namespace gles2 | 60 } // namespace gles2 |
62 } // namespace gpu | 61 } // namespace gpu |
OLD | NEW |