| 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 ProgramCacheLruHelper::ProgramCacheLruHelper() {} | |
| 11 ProgramCacheLruHelper::~ProgramCacheLruHelper() {} | |
| 12 | |
| 13 void ProgramCacheLruHelper::Clear() { | |
| 14 location_map.clear(); | |
| 15 queue.clear(); | |
| 16 } | |
| 17 | |
| 18 bool ProgramCacheLruHelper::IsEmpty() { | |
| 19 return queue.empty(); | |
| 20 } | |
| 21 | |
| 22 void ProgramCacheLruHelper::KeyUsed(const std::string& key) { | |
| 23 IteratorMap::iterator location_iterator = location_map.find(key); | |
| 24 if (location_iterator != location_map.end()) { | |
| 25 // already exists, erase it | |
| 26 queue.erase(location_iterator->second); | |
| 27 } | |
| 28 queue.push_front(key); | |
| 29 location_map[key] = queue.begin(); | |
| 30 } | |
| 31 | |
| 32 const std::string* ProgramCacheLruHelper::PeekKey() { | |
| 33 if (queue.empty()) { | |
| 34 return NULL; | |
| 35 } | |
| 36 return &queue.back(); | |
| 37 } | |
| 38 | |
| 39 void ProgramCacheLruHelper::PopKey() { | |
| 40 if (queue.empty()) { | |
| 41 return; | |
| 42 } | |
| 43 const std::string& last = queue.back(); | |
| 44 location_map.erase(last); | |
| 45 queue.pop_back(); | |
| 46 } | |
| 47 | |
| 48 } // namespace gpu | |
| 49 } // namespace gles2 | |
| OLD | NEW |