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

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

Issue 10534173: GPU Program Caching (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: memory limit + lru Created 8 years, 6 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 "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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698