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

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

Issue 670063004: Add SkMaskCache (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: add namespace for key in MaskCache Created 6 years, 2 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
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 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 296
297 size_t SkResourceCache::setTotalByteLimit(size_t newLimit) { 297 size_t SkResourceCache::setTotalByteLimit(size_t newLimit) {
298 size_t prevLimit = fTotalByteLimit; 298 size_t prevLimit = fTotalByteLimit;
299 fTotalByteLimit = newLimit; 299 fTotalByteLimit = newLimit;
300 if (newLimit < prevLimit) { 300 if (newLimit < prevLimit) {
301 this->purgeAsNeeded(); 301 this->purgeAsNeeded();
302 } 302 }
303 return prevLimit; 303 return prevLimit;
304 } 304 }
305 305
306 SkCachedData* SkResourceCache::newCachedData(size_t bytes) {
307 if (fDiscardableFactory) {
308 SkDiscardableMemory* dm = fDiscardableFactory(bytes);
309 return dm ? SkNEW_ARGS(SkCachedData, (bytes, dm)) : NULL;
310 } else {
311 return SkNEW_ARGS(SkCachedData, (sk_malloc_throw(bytes), bytes));
312 }
313 }
314
306 /////////////////////////////////////////////////////////////////////////////// 315 ///////////////////////////////////////////////////////////////////////////////
307 316
308 void SkResourceCache::detach(Rec* rec) { 317 void SkResourceCache::detach(Rec* rec) {
309 Rec* prev = rec->fPrev; 318 Rec* prev = rec->fPrev;
310 Rec* next = rec->fNext; 319 Rec* next = rec->fNext;
311 320
312 if (!prev) { 321 if (!prev) {
313 SkASSERT(fHead == rec); 322 SkASSERT(fHead == rec);
314 fHead = next; 323 fHead = next;
315 } else { 324 } else {
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 SkResourceCache::DiscardableFactory SkResourceCache::GetDiscardableFactory() { 484 SkResourceCache::DiscardableFactory SkResourceCache::GetDiscardableFactory() {
476 SkAutoMutexAcquire am(gMutex); 485 SkAutoMutexAcquire am(gMutex);
477 return get_cache()->discardableFactory(); 486 return get_cache()->discardableFactory();
478 } 487 }
479 488
480 SkBitmap::Allocator* SkResourceCache::GetAllocator() { 489 SkBitmap::Allocator* SkResourceCache::GetAllocator() {
481 SkAutoMutexAcquire am(gMutex); 490 SkAutoMutexAcquire am(gMutex);
482 return get_cache()->allocator(); 491 return get_cache()->allocator();
483 } 492 }
484 493
494 SkCachedData* SkResourceCache::NewCachedData(size_t bytes) {
495 SkAutoMutexAcquire am(gMutex);
496 return get_cache()->newCachedData(bytes);
497 }
498
485 void SkResourceCache::Dump() { 499 void SkResourceCache::Dump() {
486 SkAutoMutexAcquire am(gMutex); 500 SkAutoMutexAcquire am(gMutex);
487 get_cache()->dump(); 501 get_cache()->dump();
488 } 502 }
489 503
490 size_t SkResourceCache::SetSingleAllocationByteLimit(size_t size) { 504 size_t SkResourceCache::SetSingleAllocationByteLimit(size_t size) {
491 SkAutoMutexAcquire am(gMutex); 505 SkAutoMutexAcquire am(gMutex);
492 return get_cache()->setSingleAllocationByteLimit(size); 506 return get_cache()->setSingleAllocationByteLimit(size);
493 } 507 }
494 508
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 } 547 }
534 548
535 size_t SkGraphics::SetResourceCacheSingleAllocationByteLimit(size_t newLimit) { 549 size_t SkGraphics::SetResourceCacheSingleAllocationByteLimit(size_t newLimit) {
536 return SkResourceCache::SetSingleAllocationByteLimit(newLimit); 550 return SkResourceCache::SetSingleAllocationByteLimit(newLimit);
537 } 551 }
538 552
539 void SkGraphics::PurgeResourceCache() { 553 void SkGraphics::PurgeResourceCache() {
540 return SkResourceCache::PurgeAll(); 554 return SkResourceCache::PurgeAll();
541 } 555 }
542 556
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698