| 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 SkScaledImageCache_DEFINED | 8 #ifndef SkScaledImageCache_DEFINED |
| 9 #define SkScaledImageCache_DEFINED | 9 #define SkScaledImageCache_DEFINED |
| 10 | 10 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 */ | 68 */ |
| 69 typedef SkDiscardableMemory* (*DiscardableFactory)(size_t bytes); | 69 typedef SkDiscardableMemory* (*DiscardableFactory)(size_t bytes); |
| 70 | 70 |
| 71 /* | 71 /* |
| 72 * The following static methods are thread-safe wrappers around a global | 72 * The following static methods are thread-safe wrappers around a global |
| 73 * instance of this cache. | 73 * instance of this cache. |
| 74 */ | 74 */ |
| 75 | 75 |
| 76 static ID* FindAndLock(const Key&, SkBitmap* result); | 76 static ID* FindAndLock(const Key&, SkBitmap* result); |
| 77 static ID* AddAndLock(const Key&, const SkBitmap& result); | 77 static ID* AddAndLock(const Key&, const SkBitmap& result); |
| 78 | 78 |
| 79 static ID* FindAndLock(const Key&, const SkMipMap** result); | 79 static ID* FindAndLock(const Key&, const SkMipMap** result); |
| 80 static ID* AddAndLock(const Key&, const SkMipMap* result); | 80 static ID* AddAndLock(const Key&, const SkMipMap* result); |
| 81 | 81 |
| 82 static void Unlock(ID*); | 82 static void Unlock(ID*); |
| 83 | 83 |
| 84 static size_t GetTotalBytesUsed(); | 84 static size_t GetTotalBytesUsed(); |
| 85 static size_t GetTotalByteLimit(); | 85 static size_t GetTotalByteLimit(); |
| 86 static size_t SetTotalByteLimit(size_t newLimit); | 86 static size_t SetTotalByteLimit(size_t newLimit); |
| 87 | 87 |
| 88 static size_t SetSingleAllocationByteLimit(size_t); | 88 static size_t SetSingleAllocationByteLimit(size_t); |
| 89 static size_t GetSingleAllocationByteLimit(); | 89 static size_t GetSingleAllocationByteLimit(); |
| 90 | 90 |
| 91 static SkBitmap::Allocator* GetAllocator(); | 91 static SkBitmap::Allocator* GetAllocator(); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 121 * | 121 * |
| 122 * If a match is not found, outBitmap will be unmodifed, and NULL will be r
eturned. | 122 * If a match is not found, outBitmap will be unmodifed, and NULL will be r
eturned. |
| 123 */ | 123 */ |
| 124 ID* findAndLock(const Key& key, SkBitmap* outBitmap); | 124 ID* findAndLock(const Key& key, SkBitmap* outBitmap); |
| 125 ID* findAndLock(const Key& key, const SkMipMap** returnedMipMap); | 125 ID* findAndLock(const Key& key, const SkMipMap** returnedMipMap); |
| 126 | 126 |
| 127 /** | 127 /** |
| 128 * To add a new bitmap (or mipMap) to the cache, call | 128 * To add a new bitmap (or mipMap) to the cache, call |
| 129 * AddAndLock. Use the returned ptr to unlock the cache when you | 129 * AddAndLock. Use the returned ptr to unlock the cache when you |
| 130 * are done using scaled. | 130 * are done using scaled. |
| 131 * | |
| 132 * Use (generationID, width, and height) or (original, scaleX, | |
| 133 * scaleY) or (original) as a search key | |
| 134 */ | 131 */ |
| 135 ID* addAndLock(const Key&, const SkBitmap& bitmap); | 132 ID* addAndLock(const Key&, const SkBitmap& bitmap); |
| 136 ID* addAndLock(const Key&, const SkMipMap* mipMap); | 133 ID* addAndLock(const Key&, const SkMipMap* mipMap); |
| 137 | 134 |
| 138 /** | 135 /** |
| 139 * Given a non-null ID ptr returned by either findAndLock or addAndLock, | 136 * Given a non-null ID ptr returned by either findAndLock or addAndLock, |
| 140 * this releases the associated resources to be available to be purged | 137 * this releases the associated resources to be available to be purged |
| 141 * if needed. After this, the cached bitmap should no longer be | 138 * if needed. After this, the cached bitmap should no longer be |
| 142 * referenced by the caller. | 139 * referenced by the caller. |
| 143 */ | 140 */ |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 | 195 |
| 199 void init(); // called by constructors | 196 void init(); // called by constructors |
| 200 | 197 |
| 201 #ifdef SK_DEBUG | 198 #ifdef SK_DEBUG |
| 202 void validate() const; | 199 void validate() const; |
| 203 #else | 200 #else |
| 204 void validate() const {} | 201 void validate() const {} |
| 205 #endif | 202 #endif |
| 206 }; | 203 }; |
| 207 #endif | 204 #endif |
| OLD | NEW |