Chromium Code Reviews| 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 59 static ID* AddAndLockMip(const SkBitmap& original, const SkMipMap* mipMap); | 59 static ID* AddAndLockMip(const SkBitmap& original, const SkMipMap* mipMap); |
| 60 | 60 |
| 61 static void Unlock(ID*); | 61 static void Unlock(ID*); |
| 62 | 62 |
| 63 static size_t GetBytesUsed(); | 63 static size_t GetBytesUsed(); |
| 64 static size_t GetByteLimit(); | 64 static size_t GetByteLimit(); |
| 65 static size_t SetByteLimit(size_t newLimit); | 65 static size_t SetByteLimit(size_t newLimit); |
| 66 | 66 |
| 67 static SkBitmap::Allocator* GetAllocator(); | 67 static SkBitmap::Allocator* GetAllocator(); |
| 68 | 68 |
| 69 static void Dump(); | |
| 70 | |
| 69 /////////////////////////////////////////////////////////////////////////// | 71 /////////////////////////////////////////////////////////////////////////// |
| 70 | 72 |
| 71 /** | 73 /** |
| 72 * Construct the cache to call DiscardableFactory when it | 74 * Construct the cache to call DiscardableFactory when it |
| 73 * allocates memory for the pixels. In this mode, the cache has | 75 * allocates memory for the pixels. In this mode, the cache has |
| 74 * not explicit budget, and so methods like getBytesUsed() and | 76 * not explicit budget, and so methods like getBytesUsed() and |
| 75 * getByteLimit() will return 0, and setByteLimit will ignore its argument | 77 * getByteLimit() will return 0, and setByteLimit will ignore its argument |
| 76 * and return 0. | 78 * and return 0. |
| 77 */ | 79 */ |
| 78 SkScaledImageCache(DiscardableFactory); | 80 SkScaledImageCache(DiscardableFactory); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 144 | 146 |
| 145 /** | 147 /** |
| 146 * Set the maximum number of bytes available to this cache. If the current | 148 * Set the maximum number of bytes available to this cache. If the current |
| 147 * cache exceeds this new value, it will be purged to try to fit within | 149 * cache exceeds this new value, it will be purged to try to fit within |
| 148 * this new limit. | 150 * this new limit. |
| 149 */ | 151 */ |
| 150 size_t setByteLimit(size_t newLimit); | 152 size_t setByteLimit(size_t newLimit); |
| 151 | 153 |
| 152 SkBitmap::Allocator* allocator() const { return fAllocator; }; | 154 SkBitmap::Allocator* allocator() const { return fAllocator; }; |
| 153 | 155 |
| 156 void dump() const; | |
|
scroggo
2013/12/12 20:34:55
Can you add some comments? I see "dump" and I'm no
reed1
2013/12/12 21:13:49
Not sure. SkPath has a dump() that works in releas
| |
| 157 | |
| 154 public: | 158 public: |
| 155 struct Rec; | 159 struct Rec; |
| 156 struct Key; | 160 struct Key; |
| 157 private: | 161 private: |
| 158 Rec* fHead; | 162 Rec* fHead; |
| 159 Rec* fTail; | 163 Rec* fTail; |
| 160 | 164 |
| 161 class Hash; | 165 class Hash; |
| 162 Hash* fHash; | 166 Hash* fHash; |
| 163 | 167 |
| 164 DiscardableFactory fDiscardableFactory; | 168 DiscardableFactory fDiscardableFactory; |
| 165 // the allocator is NULL or one that matches discardables | 169 // the allocator is NULL or one that matches discardables |
| 166 SkBitmap::Allocator* fAllocator; | 170 SkBitmap::Allocator* fAllocator; |
| 167 | 171 |
| 168 size_t fBytesUsed; | 172 size_t fBytesUsed; |
| 169 size_t fByteLimit; | 173 size_t fByteLimit; |
| 170 int fCount; | 174 int fCount; |
| 171 | 175 |
| 172 Rec* findAndLock(uint32_t generationID, SkScalar sx, SkScalar sy, | 176 Rec* findAndLock(uint32_t generationID, SkScalar sx, SkScalar sy, |
| 173 const SkIRect& bounds); | 177 const SkIRect& bounds); |
| 174 Rec* findAndLock(const Key& key); | 178 Rec* findAndLock(const Key& key); |
| 175 ID* addAndLock(Rec* rec); | 179 ID* addAndLock(Rec* rec); |
| 176 | 180 |
| 181 void purgeRec(Rec*); | |
| 177 void purgeAsNeeded(); | 182 void purgeAsNeeded(); |
| 178 | 183 |
| 179 // linklist management | 184 // linklist management |
| 180 void moveToHead(Rec*); | 185 void moveToHead(Rec*); |
| 181 void addToHead(Rec*); | 186 void addToHead(Rec*); |
| 182 void detach(Rec*); | 187 void detach(Rec*); |
| 183 | 188 |
| 184 void init(); // called by constructors | 189 void init(); // called by constructors |
| 185 | 190 |
| 186 #ifdef SK_DEBUG | 191 #ifdef SK_DEBUG |
| 187 void validate() const; | 192 void validate() const; |
| 188 #else | 193 #else |
| 189 void validate() const {} | 194 void validate() const {} |
| 190 #endif | 195 #endif |
| 191 }; | 196 }; |
| 192 #endif | 197 #endif |
| OLD | NEW |