| Index: gpu/command_buffer/service/program_cache_lru_helper.cc
|
| diff --git a/gpu/command_buffer/service/program_cache_lru_helper.cc b/gpu/command_buffer/service/program_cache_lru_helper.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..9401153e17da08286b26af943d0d8b23b5f6590e
|
| --- /dev/null
|
| +++ b/gpu/command_buffer/service/program_cache_lru_helper.cc
|
| @@ -0,0 +1,40 @@
|
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "program_cache_lru_helper.h"
|
| +
|
| +namespace gpu {
|
| +namespace gles2 {
|
| +
|
| +void ProgramCacheLruHelper::Clear() {
|
| + location_map.clear();
|
| + queue.clear();
|
| +}
|
| +
|
| +bool ProgramCacheLruHelper::IsEmpty() {
|
| + return queue.empty();
|
| +}
|
| +
|
| +void ProgramCacheLruHelper::KeyUsed(const std::string& key) {
|
| + IteratorMap::iterator locationIterator = location_map.find(key);
|
| + if(locationIterator != location_map.end()) {
|
| + // already exists, erase it
|
| + queue.erase(locationIterator->second);
|
| + }
|
| + queue.push_front(key);
|
| + location_map[key] = queue.begin();
|
| +}
|
| +
|
| +std::string ProgramCacheLruHelper::EvictKey() {
|
| + if(queue.empty()) {
|
| + return "";
|
| + }
|
| + const std::string last = queue.back();
|
| + queue.pop_back();
|
| + location_map.erase(last);
|
| + return last;
|
| +}
|
| +
|
| +} // namespace gpu
|
| +} // namespace gles2
|
|
|