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

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: Style fixes, thorough tests 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 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 location_iterator = location_map.find(key);
21 if (location_iterator != location_map.end()) {
22 // already exists, erase it
23 queue.erase(location_iterator->second);
24 }
25 queue.push_front(key);
26 location_map[key] = queue.begin();
27 }
28
29 const std::string& ProgramCacheLruHelper::PeekKey() {
30 static const std::string empty_queue_response = "";
greggman 2012/07/10 21:43:30 statically initialized classes are not allowed. Ma
dmurph 2012/07/11 23:32:52 Since I'm returning a reference, I'm pretty sure t
31 if (queue.empty()) {
32 return empty_queue_response;
33 }
34 return queue.back();
35 }
36
37 void ProgramCacheLruHelper::PopKey() {
38 if (queue.empty()) {
39 return;
40 }
41 const std::string& last = queue.back();
42 location_map.erase(last);
43 queue.pop_back();
44 }
45
46 } // namespace gpu
47 } // namespace gles2
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698