Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "gpu/command_buffer/service/program_cache_lru_helper.h" | |
| 6 | |
| 7 namespace gpu { | |
| 8 namespace gles2 { | |
| 9 | |
| 10 void ProgramCacheLruHelper::Clear() { | |
| 11 location_map.clear(); | |
| 12 queue.clear(); | |
| 13 } | |
| 14 | |
| 15 bool ProgramCacheLruHelper::IsEmpty() { | |
| 16 return queue.empty(); | |
| 17 } | |
| 18 | |
| 19 void ProgramCacheLruHelper::KeyUsed(const std::string& key) { | |
| 20 IteratorMap::iterator location_iterator = location_map.find(key); | |
| 21 if (location_iterator != location_map.end()) { | |
| 22 // already exists, erase it | |
| 23 queue.erase(location_iterator->second); | |
| 24 } | |
| 25 queue.push_front(key); | |
| 26 location_map[key] = queue.begin(); | |
| 27 } | |
| 28 | |
| 29 const std::string& ProgramCacheLruHelper::PeekKey() { | |
| 30 static const std::string emptyQueueResponse = ""; | |
|
greggman
2012/06/26 23:00:27
style: variables use under_score
dmurph
2012/07/04 00:01:29
Done.
| |
| 31 if (queue.empty()) { | |
| 32 return emptyQueueResponse; | |
| 33 } | |
| 34 return queue.back(); | |
| 35 } | |
| 36 | |
| 37 void ProgramCacheLruHelper::PopKey() { | |
| 38 if (queue.empty()) { | |
| 39 return; | |
| 40 } | |
| 41 const std::string& last = queue.back(); | |
| 42 location_map.erase(last); | |
| 43 queue.pop_back(); | |
| 44 } | |
| 45 | |
| 46 } // namespace gpu | |
| 47 } // namespace gles2 | |
| OLD | NEW |