OLD | NEW |
(Empty) | |
| 1 #ifndef SkScaledImageCache_DEFINED |
| 2 #define SkScaledImageCache_DEFINED |
| 3 |
| 4 #include "SkBitmap.h" |
| 5 |
| 6 class SkScaledImageCache { |
| 7 public: |
| 8 struct ID; |
| 9 |
| 10 /** |
| 11 * Search the cache for a scaled version of original. If found, return it |
| 12 * in scaled, and return its ID pointer. Use the returned ptr to unlock |
| 13 * the cache when you are done using scaled. |
| 14 * |
| 15 * If a match is not found, scaled will be unmodifed, and NULL will be |
| 16 * returned. |
| 17 */ |
| 18 static ID* FindAndLock(const SkBitmap& original, SkScalar scaleX, |
| 19 SkScalar scaleY, SkBitmap* scaled); |
| 20 |
| 21 /** |
| 22 * To add a new (scaled) bitmap to the cache, call AddAndLock. Use the |
| 23 * returned ptr to unlock the cache when you are done using scaled. |
| 24 */ |
| 25 static ID* AddAndLock(const SkBitmap& original, SkScalar scaleX, |
| 26 SkScalar scaleY, const SkBitmap& scaled); |
| 27 |
| 28 static void Unlock(ID*); |
| 29 |
| 30 static size_t GetByteLimit(); |
| 31 static size_t SetByteLimit(size_t newLimit); |
| 32 static size_t GetBytesUsed(); |
| 33 |
| 34 SkScaledImageCache(); |
| 35 ~SkScaledImageCache(); |
| 36 |
| 37 private: |
| 38 ID* findAndLock(const SkBitmap& original, SkScalar scaleX, |
| 39 SkScalar scaleY, SkBitmap* scaled); |
| 40 ID* addAndLock(const SkBitmap& original, SkScalar scaleX, |
| 41 SkScalar scaleY, const SkBitmap& scaled); |
| 42 void unlock(ID*); |
| 43 |
| 44 struct Rec; |
| 45 Rec* fHead; |
| 46 Rec* fTail; |
| 47 |
| 48 size_t fBytesUsed; |
| 49 size_t fByteLimit; |
| 50 int fCount; |
| 51 |
| 52 void purgeAsNeeded(); |
| 53 |
| 54 // linklist management |
| 55 void moveToHead(Rec*); |
| 56 void addToHead(Rec*); |
| 57 void detach(Rec*); |
| 58 #ifdef SK_DEBUG |
| 59 void validate() const; |
| 60 #else |
| 61 void validate() const {} |
| 62 #endif |
| 63 }; |
| 64 |
| 65 #endif |
OLD | NEW |