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

Unified Diff: src/lazy/SkLruImageCache.cpp

Issue 12378075: Provide an option in bench_pictures to count pixel ram. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Use the logger rather than debug statements. Created 7 years, 10 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 | « include/lazy/SkLruImageCache.h ('k') | tools/bench_pictures_main.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/lazy/SkLruImageCache.cpp
diff --git a/src/lazy/SkLruImageCache.cpp b/src/lazy/SkLruImageCache.cpp
index 62e29535966e8674acbe3cae3999dfeb8adca68a..6beb8a479bf59497b9ead4802aca899252ea58d6 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) {
« no previous file with comments | « include/lazy/SkLruImageCache.h ('k') | tools/bench_pictures_main.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698