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

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

Issue 1931903002: Repurpose Release_Developer BUILDTYPE and remove SK_DEVELOPER. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 7 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
« no previous file with comments | « src/core/SkGraphics.cpp ('k') | src/core/SkStream.cpp » ('j') | 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 "SkMessageBus.h" 9 #include "SkMessageBus.h"
10 #include "SkMipMap.h" 10 #include "SkMipMap.h"
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 SK_DECLARE_STATIC_MUTEX(gMutex); 545 SK_DECLARE_STATIC_MUTEX(gMutex);
546 static SkResourceCache* gResourceCache = nullptr; 546 static SkResourceCache* gResourceCache = nullptr;
547 static void cleanup_gResourceCache() {
548 // We'll clean this up in our own tests, but disable for clients.
549 // Chrome seems to have funky multi-process things going on in unit tests th at
550 // makes this unsafe to delete when the main process atexit()s.
551 // SkLazyPtr does the same sort of thing.
mtklein 2016/04/28 20:46:00 Ah, good. SkLazyPtr was deleted but this comment
552 #if SK_DEVELOPER
553 delete gResourceCache;
554 #endif
555 }
556 547
557 /** Must hold gMutex when calling. */ 548 /** Must hold gMutex when calling. */
558 static SkResourceCache* get_cache() { 549 static SkResourceCache* get_cache() {
559 // 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.
560 gMutex.assertHeld(); 551 gMutex.assertHeld();
561 if (nullptr == gResourceCache) { 552 if (nullptr == gResourceCache) {
562 #ifdef SK_USE_DISCARDABLE_SCALEDIMAGECACHE 553 #ifdef SK_USE_DISCARDABLE_SCALEDIMAGECACHE
563 gResourceCache = new SkResourceCache(SkDiscardableMemory::Create); 554 gResourceCache = new SkResourceCache(SkDiscardableMemory::Create);
564 #else 555 #else
565 gResourceCache = new SkResourceCache(SK_DEFAULT_IMAGE_CACHE_LIMIT); 556 gResourceCache = new SkResourceCache(SK_DEFAULT_IMAGE_CACHE_LIMIT);
566 #endif 557 #endif
567 atexit(cleanup_gResourceCache);
568 } 558 }
569 return gResourceCache; 559 return gResourceCache;
570 } 560 }
571 561
572 size_t SkResourceCache::GetTotalBytesUsed() { 562 size_t SkResourceCache::GetTotalBytesUsed() {
573 SkAutoMutexAcquire am(gMutex); 563 SkAutoMutexAcquire am(gMutex);
574 return get_cache()->getTotalBytesUsed(); 564 return get_cache()->getTotalBytesUsed();
575 } 565 }
576 566
577 size_t SkResourceCache::GetTotalByteLimit() { 567 size_t SkResourceCache::GetTotalByteLimit() {
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
700 dump->dumpNumericValue(dumpName.c_str(), "size", "bytes", rec.bytesUsed( )); 690 dump->dumpNumericValue(dumpName.c_str(), "size", "bytes", rec.bytesUsed( ));
701 dump->setMemoryBacking(dumpName.c_str(), "malloc", nullptr); 691 dump->setMemoryBacking(dumpName.c_str(), "malloc", nullptr);
702 } 692 }
703 } 693 }
704 694
705 void SkResourceCache::DumpMemoryStatistics(SkTraceMemoryDump* dump) { 695 void SkResourceCache::DumpMemoryStatistics(SkTraceMemoryDump* dump) {
706 // 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
707 // stats to be accurate. 697 // stats to be accurate.
708 VisitAll(sk_trace_dump_visitor, dump); 698 VisitAll(sk_trace_dump_visitor, dump);
709 } 699 }
OLDNEW
« no previous file with comments | « src/core/SkGraphics.cpp ('k') | src/core/SkStream.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698