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