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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 57 static ID* AddAndLock(const SkBitmap& original, SkScalar scaleX, | 57 static ID* AddAndLock(const SkBitmap& original, SkScalar scaleX, |
| 58 SkScalar scaleY, const SkBitmap& bitmap); | 58 SkScalar scaleY, const SkBitmap& bitmap); |
| 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 void SetMaximumOutputSizeForHighQualityFilter(size_t); | |
|
reed1
2014/07/16 18:38:00
What if we rename SetByteLimit to SetTotalByteLimi
| |
| 68 static size_t GetMaximumOutputSizeForHighQualityFilter(); | |
| 69 | |
| 67 static SkBitmap::Allocator* GetAllocator(); | 70 static SkBitmap::Allocator* GetAllocator(); |
| 68 | 71 |
| 69 /** | 72 /** |
| 70 * Call SkDebugf() with diagnostic information about the state of the cache | 73 * Call SkDebugf() with diagnostic information about the state of the cache |
| 71 */ | 74 */ |
| 72 static void Dump(); | 75 static void Dump(); |
| 73 | 76 |
| 74 /////////////////////////////////////////////////////////////////////////// | 77 /////////////////////////////////////////////////////////////////////////// |
| 75 | 78 |
| 76 /** | 79 /** |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 141 * this releases the associated resources to be available to be purged | 144 * this releases the associated resources to be available to be purged |
| 142 * if needed. After this, the cached bitmap should no longer be | 145 * if needed. After this, the cached bitmap should no longer be |
| 143 * referenced by the caller. | 146 * referenced by the caller. |
| 144 */ | 147 */ |
| 145 void unlock(ID*); | 148 void unlock(ID*); |
| 146 | 149 |
| 147 size_t getBytesUsed() const { return fBytesUsed; } | 150 size_t getBytesUsed() const { return fBytesUsed; } |
| 148 size_t getByteLimit() const { return fByteLimit; } | 151 size_t getByteLimit() const { return fByteLimit; } |
| 149 | 152 |
| 150 /** | 153 /** |
| 154 * This is respected by SkBitmapProcState::possiblyScaleImage. | |
| 155 * 0 is no maximum at all; this is the default. | |
| 156 */ | |
| 157 void setMaximumOutputSizeForHighQualityFilter(size_t maximumAllocationSize); | |
| 158 size_t getMaximumOutputSizeForHighQualityFilter() const; | |
| 159 /** | |
| 151 * Set the maximum number of bytes available to this cache. If the current | 160 * Set the maximum number of bytes available to this cache. If the current |
| 152 * cache exceeds this new value, it will be purged to try to fit within | 161 * cache exceeds this new value, it will be purged to try to fit within |
| 153 * this new limit. | 162 * this new limit. |
| 154 */ | 163 */ |
| 155 size_t setByteLimit(size_t newLimit); | 164 size_t setByteLimit(size_t newLimit); |
| 156 | 165 |
| 157 SkBitmap::Allocator* allocator() const { return fAllocator; }; | 166 SkBitmap::Allocator* allocator() const { return fAllocator; }; |
| 158 | 167 |
| 159 /** | 168 /** |
| 160 * Call SkDebugf() with diagnostic information about the state of the cache | 169 * Call SkDebugf() with diagnostic information about the state of the cache |
| 161 */ | 170 */ |
| 162 void dump() const; | 171 void dump() const; |
| 163 | 172 |
| 164 public: | 173 public: |
| 165 struct Rec; | 174 struct Rec; |
| 166 struct Key; | 175 struct Key; |
| 167 private: | 176 private: |
| 168 Rec* fHead; | 177 Rec* fHead; |
| 169 Rec* fTail; | 178 Rec* fTail; |
| 170 | 179 |
| 171 class Hash; | 180 class Hash; |
| 172 Hash* fHash; | 181 Hash* fHash; |
| 173 | 182 |
| 174 DiscardableFactory fDiscardableFactory; | 183 DiscardableFactory fDiscardableFactory; |
| 175 // the allocator is NULL or one that matches discardables | 184 // the allocator is NULL or one that matches discardables |
| 176 SkBitmap::Allocator* fAllocator; | 185 SkBitmap::Allocator* fAllocator; |
| 177 | 186 |
| 178 size_t fBytesUsed; | 187 size_t fBytesUsed; |
| 179 size_t fByteLimit; | 188 size_t fByteLimit; |
| 189 size_t fMaximumOutputSizeForHighQualityFilter; | |
| 180 int fCount; | 190 int fCount; |
| 181 | 191 |
| 182 Rec* findAndLock(uint32_t generationID, SkScalar sx, SkScalar sy, | 192 Rec* findAndLock(uint32_t generationID, SkScalar sx, SkScalar sy, |
| 183 const SkIRect& bounds); | 193 const SkIRect& bounds); |
| 184 Rec* findAndLock(const Key& key); | 194 Rec* findAndLock(const Key& key); |
| 185 ID* addAndLock(Rec* rec); | 195 ID* addAndLock(Rec* rec); |
| 186 | 196 |
| 187 void purgeRec(Rec*); | 197 void purgeRec(Rec*); |
| 188 void purgeAsNeeded(); | 198 void purgeAsNeeded(); |
| 189 | 199 |
| 190 // linklist management | 200 // linklist management |
| 191 void moveToHead(Rec*); | 201 void moveToHead(Rec*); |
| 192 void addToHead(Rec*); | 202 void addToHead(Rec*); |
| 193 void detach(Rec*); | 203 void detach(Rec*); |
| 194 | 204 |
| 195 void init(); // called by constructors | 205 void init(); // called by constructors |
| 196 | 206 |
| 197 #ifdef SK_DEBUG | 207 #ifdef SK_DEBUG |
| 198 void validate() const; | 208 void validate() const; |
| 199 #else | 209 #else |
| 200 void validate() const {} | 210 void validate() const {} |
| 201 #endif | 211 #endif |
| 202 }; | 212 }; |
| 203 #endif | 213 #endif |
| OLD | NEW |