| 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 "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 locationIterator = location_map.find(key); |
| 21 if(locationIterator != location_map.end()) { |
| 22 // already exists, erase it |
| 23 queue.erase(locationIterator->second); |
| 24 } |
| 25 queue.push_front(key); |
| 26 location_map[key] = queue.begin(); |
| 27 } |
| 28 |
| 29 std::string ProgramCacheLruHelper::EvictKey() { |
| 30 if(queue.empty()) { |
| 31 return ""; |
| 32 } |
| 33 const std::string last = queue.back(); |
| 34 queue.pop_back(); |
| 35 location_map.erase(last); |
| 36 return last; |
| 37 } |
| 38 |
| 39 } // namespace gpu |
| 40 } // namespace gles2 |
| OLD | NEW |