Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(158)

Unified Diff: src/core/SkScaledImageCache.h

Issue 394003003: Set maximum output size for scaled-image-cache images (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: AnotherPatchSet Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/core/SkBitmapProcState.cpp ('k') | src/core/SkScaledImageCache.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkScaledImageCache.h
diff --git a/src/core/SkScaledImageCache.h b/src/core/SkScaledImageCache.h
index fe072306d383f44eec7554724f4c3d8b94ae9fdf..817147e3b81e7bd75fc954fb029ca8854572d379 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,
« no previous file with comments | « src/core/SkBitmapProcState.cpp ('k') | src/core/SkScaledImageCache.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698