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

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

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, 4 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 #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
15 namespace gpu {
16 namespace gles2 {
17
18 // LRU helper for the program cache, operates in O(1) time.
19 // This class uses a linked list with a hash map. Both copy their string keys,
20 // so be mindful that keys you insert will be stored again twice in memory.
21 class GPU_EXPORT ProgramCacheLruHelper {
22 public:
23 ProgramCacheLruHelper();
24 ~ProgramCacheLruHelper();
25
26 // clears the lru queue
27 void Clear();
28 // returns true if the lru queue is empty
29 bool IsEmpty();
30 // inserts or refreshes a key in the queue
31 void KeyUsed(const std::string& key);
32 // Peeks at the next key. Use IsEmpty() first (if the queue is empty then
33 // null is returned).
34 const std::string* PeekKey();
35 // evicts the next key from the queue.
36 void PopKey();
37
38 private:
39 typedef std::list<std::string> StringList;
40 typedef base::hash_map<std::string,
41 StringList::iterator> IteratorMap;
42 StringList queue;
43 IteratorMap location_map;
44
45 DISALLOW_COPY_AND_ASSIGN(ProgramCacheLruHelper);
46 };
47
48 } // namespace gles2
49 } // namespace gpu
50
51 #endif // GPU_COMMAND_BUFFER_SERVICE_PROGRAM_CACHE_LRU_HELPER_H_
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/program_cache.cc ('k') | gpu/command_buffer/service/program_cache_lru_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698