| Index: src/core/SkScaledImageCache.h
|
| diff --git a/src/core/SkScaledImageCache.h b/src/core/SkScaledImageCache.h
|
| index 44ef1f8a2cb8e19369452ae191514eb0cdf3b98c..311db325be887ccddfa36b6790c0639387271786 100644
|
| --- a/src/core/SkScaledImageCache.h
|
| +++ b/src/core/SkScaledImageCache.h
|
| @@ -10,6 +10,7 @@
|
|
|
| #include "SkBitmap.h"
|
|
|
| +class SkDiscardableMemory;
|
| class SkMipMap;
|
|
|
| /**
|
| @@ -26,6 +27,12 @@ class SkScaledImageCache {
|
| public:
|
| struct ID;
|
|
|
| + /**
|
| + * Returns a locked/pinned SkDiscardableMemory instance for the specified
|
| + * number of bytes, or NULL on failure.
|
| + */
|
| + typedef SkDiscardableMemory* (*DiscardableFactory)(size_t bytes);
|
| +
|
| /*
|
| * The following static methods are thread-safe wrappers around a global
|
| * instance of this cache.
|
| @@ -57,9 +64,27 @@ public:
|
| static size_t GetByteLimit();
|
| static size_t SetByteLimit(size_t newLimit);
|
|
|
| + static SkBitmap::Allocator* GetAllocator();
|
| +
|
| ///////////////////////////////////////////////////////////////////////////
|
|
|
| + /**
|
| + * Construct the cache to call DiscardableFactory when it
|
| + * allocates memory for the pixels. In this mode, the cache has
|
| + * not explicit budget, and so methods like getBytesUsed() and
|
| + * getByteLimit() will return 0, and setByteLimit will ignore its argument
|
| + * and return 0.
|
| + */
|
| + SkScaledImageCache(DiscardableFactory);
|
| +
|
| + /**
|
| + * Construct the cache, allocating memory with malloc, and respect the
|
| + * byteLimit, purging automatically when a new image is added to the cache
|
| + * that pushes the total bytesUsed over the limit. Note: The limit can be
|
| + * changed at runtime with setByteLimit.
|
| + */
|
| SkScaledImageCache(size_t byteLimit);
|
| +
|
| ~SkScaledImageCache();
|
|
|
| /**
|
| @@ -124,6 +149,8 @@ public:
|
| */
|
| size_t setByteLimit(size_t newLimit);
|
|
|
| + SkBitmap::Allocator* allocator() const { return fAllocator; };
|
| +
|
| public:
|
| struct Rec;
|
| struct Key;
|
| @@ -134,6 +161,10 @@ private:
|
| class Hash;
|
| Hash* fHash;
|
|
|
| + DiscardableFactory fDiscardableFactory;
|
| + // the allocator is NULL or one that matches discardables
|
| + SkBitmap::Allocator* fAllocator;
|
| +
|
| size_t fBytesUsed;
|
| size_t fByteLimit;
|
| int fCount;
|
| @@ -149,6 +180,9 @@ private:
|
| void moveToHead(Rec*);
|
| void addToHead(Rec*);
|
| void detach(Rec*);
|
| +
|
| + void init(); // called by constructors
|
| +
|
| #ifdef SK_DEBUG
|
| void validate() const;
|
| #else
|
|
|