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

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

Issue 10797055: gpu in-memory program cache implementation with a memory limit + lru eviction. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: nit fixes Created 8 years, 5 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
OLDNEW
(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
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/program_cache_lru_helper.h ('k') | gpu/command_buffer/service/program_cache_lru_helper_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698