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 #include "SkMessageBus.h" | 12 #include "SkMessageBus.h" |
13 #include "SkTDArray.h" | 13 #include "SkTDArray.h" |
14 | 14 |
15 class SkCachedData; | 15 class SkCachedData; |
16 class SkDiscardableMemory; | 16 class SkDiscardableMemory; |
| 17 class SkTraceMemoryDump; |
17 | 18 |
18 /** | 19 /** |
19 * Cache object for bitmaps (with possible scale in X Y as part of the key). | 20 * Cache object for bitmaps (with possible scale in X Y as part of the key). |
20 * | 21 * |
21 * Multiple caches can be instantiated, but each instance is not implicitly | 22 * Multiple caches can be instantiated, but each instance is not implicitly |
22 * thread-safe, so if a given instance is to be shared across threads, the | 23 * thread-safe, so if a given instance is to be shared across threads, the |
23 * caller must manage the access itself (e.g. via a mutex). | 24 * caller must manage the access itself (e.g. via a mutex). |
24 * | 25 * |
25 * As a convenience, a global instance is also defined, which can be safely | 26 * As a convenience, a global instance is also defined, which can be safely |
26 * access across threads via the static methods (e.g. FindAndLock, etc.). | 27 * access across threads via the static methods (e.g. FindAndLock, etc.). |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 static size_t SetTotalByteLimit(size_t newLimit); | 146 static size_t SetTotalByteLimit(size_t newLimit); |
146 | 147 |
147 static size_t SetSingleAllocationByteLimit(size_t); | 148 static size_t SetSingleAllocationByteLimit(size_t); |
148 static size_t GetSingleAllocationByteLimit(); | 149 static size_t GetSingleAllocationByteLimit(); |
149 static size_t GetEffectiveSingleAllocationByteLimit(); | 150 static size_t GetEffectiveSingleAllocationByteLimit(); |
150 | 151 |
151 static void PurgeAll(); | 152 static void PurgeAll(); |
152 | 153 |
153 static void TestDumpMemoryStatistics(); | 154 static void TestDumpMemoryStatistics(); |
154 | 155 |
| 156 /** Dump memory usage statistics of every Rec in the cache using the |
| 157 SkTraceMemoryDump interface. |
| 158 */ |
| 159 static void DumpMemoryStatistics(SkTraceMemoryDump* dump); |
| 160 |
155 /** | 161 /** |
156 * Returns the DiscardableFactory used by the global cache, or NULL. | 162 * Returns the DiscardableFactory used by the global cache, or NULL. |
157 */ | 163 */ |
158 static DiscardableFactory GetDiscardableFactory(); | 164 static DiscardableFactory GetDiscardableFactory(); |
159 | 165 |
160 /** | 166 /** |
161 * Use this allocator for bitmaps, so they can use ashmem when available. | 167 * Use this allocator for bitmaps, so they can use ashmem when available. |
162 * Returns NULL if the ResourceCache has not been initialized with a Discard
ableFactory. | 168 * Returns NULL if the ResourceCache has not been initialized with a Discard
ableFactory. |
163 */ | 169 */ |
164 static SkBitmap::Allocator* GetAllocator(); | 170 static SkBitmap::Allocator* GetAllocator(); |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 | 277 |
272 void init(); // called by constructors | 278 void init(); // called by constructors |
273 | 279 |
274 #ifdef SK_DEBUG | 280 #ifdef SK_DEBUG |
275 void validate() const; | 281 void validate() const; |
276 #else | 282 #else |
277 void validate() const {} | 283 void validate() const {} |
278 #endif | 284 #endif |
279 }; | 285 }; |
280 #endif | 286 #endif |
OLD | NEW |