aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/lazy
diff options
context:
space:
mode:
authorGravatar scroggo@google.com <scroggo@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-03-04 21:32:32 +0000
committerGravatar scroggo@google.com <scroggo@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-03-04 21:32:32 +0000
commita560d00ba5005ded8094a307ca41365bdf47cd50 (patch)
tree1b1bba4a061d8fe19785ca8ed55a3888d778e9ec /src/lazy
parent8563d3089cd18464db181c16ad90271de16ba524 (diff)
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
Diffstat (limited to 'src/lazy')
-rw-r--r--src/lazy/SkLruImageCache.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/lazy/SkLruImageCache.cpp b/src/lazy/SkLruImageCache.cpp
index 62e2953596..6beb8a479b 100644
--- a/src/lazy/SkLruImageCache.cpp
+++ b/src/lazy/SkLruImageCache.cpp
@@ -87,10 +87,12 @@ SkImageCache::CacheStatus SkLruImageCache::getCacheStatus(intptr_t ID) const {
}
#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 @@ CachedPixels* SkLruImageCache::findByID(intptr_t ID) const {
void SkLruImageCache::purgeIfNeeded() {
// Mutex is already locked.
- this->purgeTilAtOrBelow(fRamBudget);
+ if (fRamBudget > 0) {
+ this->purgeTilAtOrBelow(fRamBudget);
+ }
}
void SkLruImageCache::purgeTilAtOrBelow(size_t limit) {