Provide an option in bench_pictures to count pixel ram.
In SkLruImageCache, provide an option to keep all pixels, and document
the new behavior.
In gm/factory.cpp, set the budget for the Lru image cache to 1, to
retain (basically) the old behavior.
BUG=https://code.google.com/p/skia/issues/detail?id=1010
Review URL: https://codereview.chromium.org/12378075
git-svn-id: http://skia.googlecode.com/svn/trunk@7972 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/lazy/SkLruImageCache.cpp b/src/lazy/SkLruImageCache.cpp
index 62e2953..6beb8a4 100644
--- a/src/lazy/SkLruImageCache.cpp
+++ b/src/lazy/SkLruImageCache.cpp
@@ -87,10 +87,12 @@
}
#endif
-void SkLruImageCache::setBudget(size_t newBudget) {
+size_t SkLruImageCache::setImageCacheLimit(size_t newLimit) {
+ size_t oldLimit = fRamBudget;
SkAutoMutexAcquire ac(&fMutex);
- fRamBudget = newBudget;
+ fRamBudget = newLimit;
this->purgeIfNeeded();
+ return oldLimit;
}
void* SkLruImageCache::allocAndPinCache(size_t bytes, intptr_t* ID) {
@@ -168,7 +170,9 @@
void SkLruImageCache::purgeIfNeeded() {
// Mutex is already locked.
- this->purgeTilAtOrBelow(fRamBudget);
+ if (fRamBudget > 0) {
+ this->purgeTilAtOrBelow(fRamBudget);
+ }
}
void SkLruImageCache::purgeTilAtOrBelow(size_t limit) {