| 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" |
| 6 |
| 5 #include <GLES2/gl2.h> | 7 #include <GLES2/gl2.h> |
| 6 | 8 |
| 7 #include "gpu/command_buffer/service/shader_translator_cache.h" | 9 #include "gpu/command_buffer/service/gpu_preferences.h" |
| 8 | 10 |
| 9 namespace gpu { | 11 namespace gpu { |
| 10 namespace gles2 { | 12 namespace gles2 { |
| 11 | 13 |
| 12 ShaderTranslatorCache::ShaderTranslatorCache() { | 14 ShaderTranslatorCache::ShaderTranslatorCache( |
| 15 const GpuPreferences& gpu_preferences) |
| 16 : gpu_preferences_(gpu_preferences) { |
| 13 } | 17 } |
| 14 | 18 |
| 15 ShaderTranslatorCache::~ShaderTranslatorCache() { | 19 ShaderTranslatorCache::~ShaderTranslatorCache() { |
| 16 DCHECK(cache_.empty()); | 20 DCHECK(cache_.empty()); |
| 17 } | 21 } |
| 18 | 22 |
| 19 void ShaderTranslatorCache::OnDestruct(ShaderTranslator* translator) { | 23 void ShaderTranslatorCache::OnDestruct(ShaderTranslator* translator) { |
| 20 Cache::iterator it = cache_.begin(); | 24 Cache::iterator it = cache_.begin(); |
| 21 while (it != cache_.end()) { | 25 while (it != cache_.end()) { |
| 22 if (it->second == translator) { | 26 if (it->second == translator) { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 36 ShaderTranslatorInitParams params(shader_type, shader_spec, *resources, | 40 ShaderTranslatorInitParams params(shader_type, shader_spec, *resources, |
| 37 shader_output_language, | 41 shader_output_language, |
| 38 driver_bug_workarounds); | 42 driver_bug_workarounds); |
| 39 | 43 |
| 40 Cache::iterator it = cache_.find(params); | 44 Cache::iterator it = cache_.find(params); |
| 41 if (it != cache_.end()) | 45 if (it != cache_.end()) |
| 42 return it->second; | 46 return it->second; |
| 43 | 47 |
| 44 ShaderTranslator* translator = new ShaderTranslator(); | 48 ShaderTranslator* translator = new ShaderTranslator(); |
| 45 if (translator->Init(shader_type, shader_spec, resources, | 49 if (translator->Init(shader_type, shader_spec, resources, |
| 46 shader_output_language, driver_bug_workarounds)) { | 50 shader_output_language, driver_bug_workarounds, |
| 51 gpu_preferences_.gl_shader_interm_output)) { |
| 47 cache_[params] = translator; | 52 cache_[params] = translator; |
| 48 translator->AddDestructionObserver(this); | 53 translator->AddDestructionObserver(this); |
| 49 return translator; | 54 return translator; |
| 50 } else { | 55 } else { |
| 51 return NULL; | 56 return NULL; |
| 52 } | 57 } |
| 53 } | 58 } |
| 54 | 59 |
| 55 } // namespace gles2 | 60 } // namespace gles2 |
| 56 } // namespace gpu | 61 } // namespace gpu |
| OLD | NEW |