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

Side by Side Diff: src/core/SkResourceCache.cpp

Issue 825263005: notify resource caches when pixelref genID goes stale (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 11 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 unified diff | Download patch
« src/core/SkResourceCache.h ('K') | « src/core/SkResourceCache.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkChecksum.h" 8 #include "SkChecksum.h"
9 #include "SkResourceCache.h" 9 #include "SkResourceCache.h"
10 #include "SkMipMap.h" 10 #include "SkMipMap.h"
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 if (!forcePurge && fTotalBytesUsed < byteLimit && fCount < countLimit) { 287 if (!forcePurge && fTotalBytesUsed < byteLimit && fCount < countLimit) {
288 break; 288 break;
289 } 289 }
290 290
291 Rec* prev = rec->fPrev; 291 Rec* prev = rec->fPrev;
292 this->remove(rec); 292 this->remove(rec);
293 rec = prev; 293 rec = prev;
294 } 294 }
295 } 295 }
296 296
297 void SkResourceCache::purgeVisitor(const void* nameSpace, VisitorProc proc, void * context) {
298 // go backwards, just like purgeAsNeeded, just to make the code similar.
299 // could iterate either direction and still be correct.
300 Rec* rec = fTail;
301 while (rec) {
302 Rec* prev = rec->fPrev;
303 if (rec->getKey().getNamespace() == nameSpace && !proc(*rec, context)) {
304 this->remove(rec);
305 }
306 rec = prev;
307 }
308 }
309
297 size_t SkResourceCache::setTotalByteLimit(size_t newLimit) { 310 size_t SkResourceCache::setTotalByteLimit(size_t newLimit) {
298 size_t prevLimit = fTotalByteLimit; 311 size_t prevLimit = fTotalByteLimit;
299 fTotalByteLimit = newLimit; 312 fTotalByteLimit = newLimit;
300 if (newLimit < prevLimit) { 313 if (newLimit < prevLimit) {
301 this->purgeAsNeeded(); 314 this->purgeAsNeeded();
302 } 315 }
303 return prevLimit; 316 return prevLimit;
304 } 317 }
305 318
306 SkCachedData* SkResourceCache::newCachedData(size_t bytes) { 319 SkCachedData* SkResourceCache::newCachedData(size_t bytes) {
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 size_t SkResourceCache::SetSingleAllocationByteLimit(size_t size) { 517 size_t SkResourceCache::SetSingleAllocationByteLimit(size_t size) {
505 SkAutoMutexAcquire am(gMutex); 518 SkAutoMutexAcquire am(gMutex);
506 return get_cache()->setSingleAllocationByteLimit(size); 519 return get_cache()->setSingleAllocationByteLimit(size);
507 } 520 }
508 521
509 size_t SkResourceCache::GetSingleAllocationByteLimit() { 522 size_t SkResourceCache::GetSingleAllocationByteLimit() {
510 SkAutoMutexAcquire am(gMutex); 523 SkAutoMutexAcquire am(gMutex);
511 return get_cache()->getSingleAllocationByteLimit(); 524 return get_cache()->getSingleAllocationByteLimit();
512 } 525 }
513 526
527 void SkResourceCache::PurgeVisitor(const void* nameSpace, VisitorProc proc, void * context) {
528 SkAutoMutexAcquire am(gMutex);
529 return get_cache()->purgeVisitor(nameSpace, proc, context);
530 }
531
514 void SkResourceCache::PurgeAll() { 532 void SkResourceCache::PurgeAll() {
515 SkAutoMutexAcquire am(gMutex); 533 SkAutoMutexAcquire am(gMutex);
516 return get_cache()->purgeAll(); 534 return get_cache()->purgeAll();
517 } 535 }
518 536
519 bool SkResourceCache::Find(const Key& key, VisitorProc visitor, void* context) { 537 bool SkResourceCache::Find(const Key& key, VisitorProc visitor, void* context) {
520 SkAutoMutexAcquire am(gMutex); 538 SkAutoMutexAcquire am(gMutex);
521 return get_cache()->find(key, visitor, context); 539 return get_cache()->find(key, visitor, context);
522 } 540 }
523 541
(...skipping 23 matching lines...) Expand all
547 } 565 }
548 566
549 size_t SkGraphics::SetResourceCacheSingleAllocationByteLimit(size_t newLimit) { 567 size_t SkGraphics::SetResourceCacheSingleAllocationByteLimit(size_t newLimit) {
550 return SkResourceCache::SetSingleAllocationByteLimit(newLimit); 568 return SkResourceCache::SetSingleAllocationByteLimit(newLimit);
551 } 569 }
552 570
553 void SkGraphics::PurgeResourceCache() { 571 void SkGraphics::PurgeResourceCache() {
554 return SkResourceCache::PurgeAll(); 572 return SkResourceCache::PurgeAll();
555 } 573 }
556 574
OLDNEW
« src/core/SkResourceCache.h ('K') | « src/core/SkResourceCache.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698