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

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

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) 201 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 #ifndef GPU_COMMAND_BUFFER_SERVICE_PROGRAM_CACHE_LRU_HELPER_H_
6 #define GPU_COMMAND_BUFFER_SERVICE_PROGRAM_CACHE_LRU_HELPER_H_
7
8 #include <list>
9 #include <string>
10
11 #include "base/basictypes.h"
12 #include "base/hash_tables.h"
13 #include "gpu/gpu_export.h"
14 #include "net/disk_cache/hash.h"
15
16 namespace gpu {
17 namespace gles2 {
18
19 // LRU helper for the program cache, operates in O(1) time.
20 // This class uses a linked list with a hash map. Both copy their string keys,
21 // so be mindful that keys you insert will be stored again twice in memory.
22 class GPU_EXPORT ProgramCacheLruHelper {
23 public:
24 ProgramCacheLruHelper() {}
25 // clears the lru queue
26 void Clear();
27 // returns true if the lru queue is empty
28 bool IsEmpty();
29 // inserts or refreshes a key in the queue
30 void KeyUsed(const std::string& key);
31 // Peeks at the next key. Use IsEmpty() first (if the queue is empty then
32 // a static null string is returned).
33 const std::string& PeekKey();
34 // evicts the next key from the queue.
35 void PopKey();
36
37 private:
38 typedef std::list<std::string> StringList;
39 typedef base::hash_map<std::string,
40 StringList::iterator> IteratorMap;
41 StringList queue;
42 IteratorMap location_map;
43
44 DISALLOW_COPY_AND_ASSIGN(ProgramCacheLruHelper);
45 };
46
47 } // namespace gles2
48 } // namespace gpu
49
50 #endif // GPU_COMMAND_BUFFER_SERVICE_PROGRAM_CACHE_LRU_HELPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698