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 |
11 #include "SkBitmap.h" | 11 #include "SkBitmap.h" |
12 | 12 |
| 13 class SkCachedData; |
13 class SkDiscardableMemory; | 14 class SkDiscardableMemory; |
14 class SkMipMap; | 15 class SkMipMap; |
15 | 16 |
16 /** | 17 /** |
17 * Cache object for bitmaps (with possible scale in X Y as part of the key). | 18 * Cache object for bitmaps (with possible scale in X Y as part of the key). |
18 * | 19 * |
19 * Multiple caches can be instantiated, but each instance is not implicitly | 20 * Multiple caches can be instantiated, but each instance is not implicitly |
20 * thread-safe, so if a given instance is to be shared across threads, the | 21 * thread-safe, so if a given instance is to be shared across threads, the |
21 * caller must manage the access itself (e.g. via a mutex). | 22 * caller must manage the access itself (e.g. via a mutex). |
22 * | 23 * |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 */ | 191 */ |
191 size_t setTotalByteLimit(size_t newLimit); | 192 size_t setTotalByteLimit(size_t newLimit); |
192 | 193 |
193 void purgeAll() { | 194 void purgeAll() { |
194 this->purgeAsNeeded(true); | 195 this->purgeAsNeeded(true); |
195 } | 196 } |
196 | 197 |
197 DiscardableFactory discardableFactory() const { return fDiscardableFactory;
} | 198 DiscardableFactory discardableFactory() const { return fDiscardableFactory;
} |
198 SkBitmap::Allocator* allocator() const { return fAllocator; }; | 199 SkBitmap::Allocator* allocator() const { return fAllocator; }; |
199 | 200 |
| 201 SkCachedData* newCachedData(size_t bytes); |
| 202 |
200 /** | 203 /** |
201 * Call SkDebugf() with diagnostic information about the state of the cache | 204 * Call SkDebugf() with diagnostic information about the state of the cache |
202 */ | 205 */ |
203 void dump() const; | 206 void dump() const; |
204 | 207 |
205 private: | 208 private: |
206 Rec* fHead; | 209 Rec* fHead; |
207 Rec* fTail; | 210 Rec* fTail; |
208 | 211 |
209 class Hash; | 212 class Hash; |
(...skipping 18 matching lines...) Expand all Loading... |
228 | 231 |
229 void init(); // called by constructors | 232 void init(); // called by constructors |
230 | 233 |
231 #ifdef SK_DEBUG | 234 #ifdef SK_DEBUG |
232 void validate() const; | 235 void validate() const; |
233 #else | 236 #else |
234 void validate() const {} | 237 void validate() const {} |
235 #endif | 238 #endif |
236 }; | 239 }; |
237 #endif | 240 #endif |
OLD | NEW |