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() { | |
11 return Singleton<ShaderTranslatorCache>::get(); | |
12 } | |
13 | |
14 ShaderTranslatorCache::ShaderTranslatorCache() { | 10 ShaderTranslatorCache::ShaderTranslatorCache() { |
15 } | 11 } |
16 | 12 |
17 ShaderTranslatorCache::~ShaderTranslatorCache() { | 13 ShaderTranslatorCache::~ShaderTranslatorCache() { |
| 14 DCHECK(cache_.empty()); |
18 } | 15 } |
19 | 16 |
20 void ShaderTranslatorCache::OnDestruct(ShaderTranslator* translator) { | 17 void ShaderTranslatorCache::OnDestruct(ShaderTranslator* translator) { |
21 Cache::iterator it = cache_.begin(); | 18 Cache::iterator it = cache_.begin(); |
22 while (it != cache_.end()) { | 19 while (it != cache_.end()) { |
23 if (it->second == translator) { | 20 if (it->second == translator) { |
24 cache_.erase(it); | 21 cache_.erase(it); |
25 return; | 22 return; |
26 } | 23 } |
27 it++; | 24 it++; |
(...skipping 24 matching lines...) Expand all Loading... |
52 cache_[params] = translator; | 49 cache_[params] = translator; |
53 translator->AddDestructionObserver(this); | 50 translator->AddDestructionObserver(this); |
54 return translator; | 51 return translator; |
55 } else { | 52 } else { |
56 return NULL; | 53 return NULL; |
57 } | 54 } |
58 } | 55 } |
59 | 56 |
60 } // namespace gles2 | 57 } // namespace gles2 |
61 } // namespace gpu | 58 } // namespace gpu |
OLD | NEW |