OLD | NEW |
---|---|
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 SkResourceCache_DEFINED | 8 #ifndef SkResourceCache_DEFINED |
9 #define SkResourceCache_DEFINED | 9 #define SkResourceCache_DEFINED |
10 | 10 |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
91 | 91 |
92 /* | 92 /* |
93 * The following static methods are thread-safe wrappers around a global | 93 * The following static methods are thread-safe wrappers around a global |
94 * instance of this cache. | 94 * instance of this cache. |
95 */ | 95 */ |
96 | 96 |
97 static const Rec* FindAndLock(const Key& key); | 97 static const Rec* FindAndLock(const Key& key); |
98 static const Rec* AddAndLock(Rec*); | 98 static const Rec* AddAndLock(Rec*); |
99 static void Add(Rec*); | 99 static void Add(Rec*); |
100 static void Unlock(ID); | 100 static void Unlock(ID); |
101 static void Remove(ID); | |
101 | 102 |
102 static size_t GetTotalBytesUsed(); | 103 static size_t GetTotalBytesUsed(); |
103 static size_t GetTotalByteLimit(); | 104 static size_t GetTotalByteLimit(); |
104 static size_t SetTotalByteLimit(size_t newLimit); | 105 static size_t SetTotalByteLimit(size_t newLimit); |
105 | 106 |
106 static size_t SetSingleAllocationByteLimit(size_t); | 107 static size_t SetSingleAllocationByteLimit(size_t); |
107 static size_t GetSingleAllocationByteLimit(); | 108 static size_t GetSingleAllocationByteLimit(); |
108 | 109 |
109 /** | 110 /** |
110 * Use this allocator for bitmaps, so they can use ashmem when available. | 111 * Use this allocator for bitmaps, so they can use ashmem when available. |
(...skipping 22 matching lines...) Expand all Loading... | |
133 * byteLimit, purging automatically when a new image is added to the cache | 134 * byteLimit, purging automatically when a new image is added to the cache |
134 * that pushes the total bytesUsed over the limit. Note: The limit can be | 135 * that pushes the total bytesUsed over the limit. Note: The limit can be |
135 * changed at runtime with setTotalByteLimit. | 136 * changed at runtime with setTotalByteLimit. |
136 */ | 137 */ |
137 explicit SkResourceCache(size_t byteLimit); | 138 explicit SkResourceCache(size_t byteLimit); |
138 ~SkResourceCache(); | 139 ~SkResourceCache(); |
139 | 140 |
140 const Rec* findAndLock(const Key& key); | 141 const Rec* findAndLock(const Key& key); |
141 const Rec* addAndLock(Rec*); | 142 const Rec* addAndLock(Rec*); |
142 void add(Rec*); | 143 void add(Rec*); |
144 void remove(ID); | |
reed1
2014/09/11 13:40:31
(Rec*)
| |
143 | 145 |
144 /** | 146 /** |
145 * Given a non-null ID ptr returned by either findAndLock or addAndLock, | 147 * Given a non-null ID ptr returned by either findAndLock or addAndLock, |
146 * this releases the associated resources to be available to be purged | 148 * this releases the associated resources to be available to be purged |
147 * if needed. After this, the cached bitmap should no longer be | 149 * if needed. After this, the cached bitmap should no longer be |
148 * referenced by the caller. | 150 * referenced by the caller. |
149 */ | 151 */ |
150 void unlock(ID); | 152 void unlock(ID); |
151 | 153 |
152 size_t getTotalBytesUsed() const { return fTotalBytesUsed; } | 154 size_t getTotalBytesUsed() const { return fTotalBytesUsed; } |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
199 | 201 |
200 void init(); // called by constructors | 202 void init(); // called by constructors |
201 | 203 |
202 #ifdef SK_DEBUG | 204 #ifdef SK_DEBUG |
203 void validate() const; | 205 void validate() const; |
204 #else | 206 #else |
205 void validate() const {} | 207 void validate() const {} |
206 #endif | 208 #endif |
207 }; | 209 }; |
208 #endif | 210 #endif |
OLD | NEW |