OLD | NEW |
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 "SkMessageBus.h" | 9 #include "SkMessageBus.h" |
10 #include "SkMipMap.h" | 10 #include "SkMipMap.h" |
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
535 void SkResourceCache::checkMessages() { | 535 void SkResourceCache::checkMessages() { |
536 SkTArray<PurgeSharedIDMessage> msgs; | 536 SkTArray<PurgeSharedIDMessage> msgs; |
537 fPurgeSharedIDInbox.poll(&msgs); | 537 fPurgeSharedIDInbox.poll(&msgs); |
538 for (int i = 0; i < msgs.count(); ++i) { | 538 for (int i = 0; i < msgs.count(); ++i) { |
539 this->purgeSharedID(msgs[i].fSharedID); | 539 this->purgeSharedID(msgs[i].fSharedID); |
540 } | 540 } |
541 } | 541 } |
542 | 542 |
543 /////////////////////////////////////////////////////////////////////////////// | 543 /////////////////////////////////////////////////////////////////////////////// |
544 | 544 |
545 static SkMutex gMutex; | 545 SK_DECLARE_STATIC_MUTEX(gMutex); |
546 static SkResourceCache* gResourceCache = nullptr; | 546 static SkResourceCache* gResourceCache = nullptr; |
547 | 547 |
548 /** Must hold gMutex when calling. */ | 548 /** Must hold gMutex when calling. */ |
549 static SkResourceCache* get_cache() { | 549 static SkResourceCache* get_cache() { |
550 // gMutex is always held when this is called, so we don't need to be fancy i
n here. | 550 // gMutex is always held when this is called, so we don't need to be fancy i
n here. |
551 gMutex.assertHeld(); | 551 gMutex.assertHeld(); |
552 if (nullptr == gResourceCache) { | 552 if (nullptr == gResourceCache) { |
553 #ifdef SK_USE_DISCARDABLE_SCALEDIMAGECACHE | 553 #ifdef SK_USE_DISCARDABLE_SCALEDIMAGECACHE |
554 gResourceCache = new SkResourceCache(SkDiscardableMemory::Create); | 554 gResourceCache = new SkResourceCache(SkDiscardableMemory::Create); |
555 #else | 555 #else |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
690 dump->dumpNumericValue(dumpName.c_str(), "size", "bytes", rec.bytesUsed(
)); | 690 dump->dumpNumericValue(dumpName.c_str(), "size", "bytes", rec.bytesUsed(
)); |
691 dump->setMemoryBacking(dumpName.c_str(), "malloc", nullptr); | 691 dump->setMemoryBacking(dumpName.c_str(), "malloc", nullptr); |
692 } | 692 } |
693 } | 693 } |
694 | 694 |
695 void SkResourceCache::DumpMemoryStatistics(SkTraceMemoryDump* dump) { | 695 void SkResourceCache::DumpMemoryStatistics(SkTraceMemoryDump* dump) { |
696 // Since resource could be backed by malloc or discardable, the cache always
dumps detailed | 696 // Since resource could be backed by malloc or discardable, the cache always
dumps detailed |
697 // stats to be accurate. | 697 // stats to be accurate. |
698 VisitAll(sk_trace_dump_visitor, dump); | 698 VisitAll(sk_trace_dump_visitor, dump); |
699 } | 699 } |
OLD | NEW |