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

Side by Side Diff: include/lazy/SkLruImageCache.h

Issue 12378075: Provide an option in bench_pictures to count pixel ram. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « gm/factory.cpp ('k') | src/lazy/SkLruImageCache.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #ifndef SkLruImageCache_DEFINED 8 #ifndef SkLruImageCache_DEFINED
9 #define SkLruImageCache_DEFINED 9 #define SkLruImageCache_DEFINED
10 10
11 #include "SkImageCache.h" 11 #include "SkImageCache.h"
12 #include "SkThread.h" 12 #include "SkThread.h"
13 #include "SkTInternalLList.h" 13 #include "SkTInternalLList.h"
14 14
15 class CachedPixels; 15 class CachedPixels;
16 16
17 /** 17 /**
18 * SkImageCache implementation that uses an LRU cache to age out old images. 18 * SkImageCache implementation that uses an LRU cache to age out old images.
19 */ 19 */
20 class SkLruImageCache : public SkImageCache { 20 class SkLruImageCache : public SkImageCache {
21 21
22 public: 22 public:
23 SkLruImageCache(size_t budget); 23 SkLruImageCache(size_t budget);
24 24
25 virtual ~SkLruImageCache(); 25 virtual ~SkLruImageCache();
26 26
27 #ifdef SK_DEBUG 27 #ifdef SK_DEBUG
28 CacheStatus getCacheStatus(intptr_t ID) const SK_OVERRIDE; 28 CacheStatus getCacheStatus(intptr_t ID) const SK_OVERRIDE;
29 #endif 29 #endif
30 30
reed1 2013/03/04 20:07:27 existing API naming we use for font cache. Maybe w
scroggo 2013/03/04 20:49:29 Done. Currently, we do not have a notion like the
31 /**
32 * Set the budget. If more bytes are used than this, the cache will free un pinned memory until
33 * under the new budget or until all unpinned memory is freed. This will ne ver free pinned
34 * memory, so the cache can potentially remain over budget. The budget is e nforced each time
35 * memory is allocated or released.
36 * 0 is a special flag for an infinite budget.
37 */
31 void setBudget(size_t newBudget); 38 void setBudget(size_t newBudget);
32 39
40 /**
41 * Return the amount of memory currently in use by the cache. Can include m emory that is no
42 * longer pinned, but has not been freed.
43 */
44 size_t getRamUsed() const { return fRamUsed; }
45
33 virtual void* allocAndPinCache(size_t bytes, intptr_t* ID) SK_OVERRIDE; 46 virtual void* allocAndPinCache(size_t bytes, intptr_t* ID) SK_OVERRIDE;
34 virtual void* pinCache(intptr_t ID) SK_OVERRIDE; 47 virtual void* pinCache(intptr_t ID) SK_OVERRIDE;
35 virtual void releaseCache(intptr_t ID) SK_OVERRIDE; 48 virtual void releaseCache(intptr_t ID) SK_OVERRIDE;
36 virtual void throwAwayCache(intptr_t ID) SK_OVERRIDE; 49 virtual void throwAwayCache(intptr_t ID) SK_OVERRIDE;
37 50
38 private: 51 private:
39 // Linked list of recently used. Head is the most recently used, and tail is the least. 52 // Linked list of recently used. Head is the most recently used, and tail is the least.
40 SkTInternalLList<CachedPixels> fLRU; 53 SkTInternalLList<CachedPixels> fLRU;
41 typedef SkTInternalLList<CachedPixels>::Iter Iter; 54 typedef SkTInternalLList<CachedPixels>::Iter Iter;
42 55
(...skipping 22 matching lines...) Expand all
65 */ 78 */
66 void purgeTilAtOrBelow(size_t limit); 79 void purgeTilAtOrBelow(size_t limit);
67 80
68 /** 81 /**
69 * Remove a set of CachedPixels. Mutex must be locked before calling. 82 * Remove a set of CachedPixels. Mutex must be locked before calling.
70 */ 83 */
71 void removePixels(CachedPixels*); 84 void removePixels(CachedPixels*);
72 }; 85 };
73 86
74 #endif // SkLruImageCache_DEFINED 87 #endif // SkLruImageCache_DEFINED
OLDNEW
« no previous file with comments | « gm/factory.cpp ('k') | src/lazy/SkLruImageCache.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698