aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkScaledImageCache.h
diff options
context:
space:
mode:
authorGravatar halcanary <halcanary@google.com>2014-07-17 06:58:01 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-07-17 06:58:01 -0700
commit805ef159d197007b9529e60e5b918ee0f9d3802d (patch)
tree251ff1b8317b3a77752020252f119385e3f5b413 /src/core/SkScaledImageCache.h
parent3f376a55002c205aacacc4cb16ed745e3afbad31 (diff)
Set maximum output size for scaled-image-cache images
Accessable via: SkScaledImageCache::{G,S}etMaximumOutputSizeForHighQualityFilter Also, a unit test. BUG=389439 R=humper@google.com, tomhudson@google.com, reveman@chromium.org, vangelis@chromium.org, reed@google.com Author: halcanary@google.com Review URL: https://codereview.chromium.org/394003003
Diffstat (limited to 'src/core/SkScaledImageCache.h')
-rw-r--r--src/core/SkScaledImageCache.h35
1 files changed, 23 insertions, 12 deletions
diff --git a/src/core/SkScaledImageCache.h b/src/core/SkScaledImageCache.h
index fe072306d3..817147e3b8 100644
--- a/src/core/SkScaledImageCache.h
+++ b/src/core/SkScaledImageCache.h
@@ -60,9 +60,12 @@ public:
static void Unlock(ID*);
- static size_t GetBytesUsed();
- static size_t GetByteLimit();
- static size_t SetByteLimit(size_t newLimit);
+ static size_t GetTotalBytesUsed();
+ static size_t GetTotalByteLimit();
+ static size_t SetTotalByteLimit(size_t newLimit);
+
+ static size_t SetSingleAllocationByteLimit(size_t);
+ static size_t GetSingleAllocationByteLimit();
static SkBitmap::Allocator* GetAllocator();
@@ -76,9 +79,9 @@ public:
/**
* 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.
+ * not explicit budget, and so methods like getTotalBytesUsed()
+ * and getTotalByteLimit() will return 0, and setTotalByteLimit
+ * will ignore its argument and return 0.
*/
SkScaledImageCache(DiscardableFactory);
@@ -86,7 +89,7 @@ public:
* 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.
+ * changed at runtime with setTotalByteLimit.
*/
SkScaledImageCache(size_t byteLimit);
@@ -144,15 +147,22 @@ public:
*/
void unlock(ID*);
- size_t getBytesUsed() const { return fBytesUsed; }
- size_t getByteLimit() const { return fByteLimit; }
+ size_t getTotalBytesUsed() const { return fTotalBytesUsed; }
+ size_t getTotalByteLimit() const { return fTotalByteLimit; }
/**
+ * This is respected by SkBitmapProcState::possiblyScaleImage.
+ * 0 is no maximum at all; this is the default.
+ * setSingleAllocationByteLimit() returns the previous value.
+ */
+ size_t setSingleAllocationByteLimit(size_t maximumAllocationSize);
+ size_t getSingleAllocationByteLimit() const;
+ /**
* Set the maximum number of bytes available to this cache. If the current
* cache exceeds this new value, it will be purged to try to fit within
* this new limit.
*/
- size_t setByteLimit(size_t newLimit);
+ size_t setTotalByteLimit(size_t newLimit);
SkBitmap::Allocator* allocator() const { return fAllocator; };
@@ -175,8 +185,9 @@ private:
// the allocator is NULL or one that matches discardables
SkBitmap::Allocator* fAllocator;
- size_t fBytesUsed;
- size_t fByteLimit;
+ size_t fTotalBytesUsed;
+ size_t fTotalByteLimit;
+ size_t fSingleAllocationByteLimit;
int fCount;
Rec* findAndLock(uint32_t generationID, SkScalar sx, SkScalar sy,