Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(417)

Side by Side Diff: gpu/command_buffer/service/shader_translator_cache.cc

Issue 217813004: Make ShaderTranslatorCache thread safe (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nit Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/shader_translator_cache.h ('k') | gpu/command_buffer/tests/gl_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698