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

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

Issue 1313793004: [tracing] Add support for skia caches to dump memory stats (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Commit missed files. Created 5 years, 3 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/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 "SkMessageBus.h" 9 #include "SkMessageBus.h"
10 #include "SkMipMap.h" 10 #include "SkMipMap.h"
11 #include "SkMutex.h" 11 #include "SkMutex.h"
12 #include "SkPixelRef.h" 12 #include "SkPixelRef.h"
13 #include "SkResourceCache.h" 13 #include "SkResourceCache.h"
14 #include "SkTraceMemoryDump.h"
14 15
15 #include <stddef.h> 16 #include <stddef.h>
16 #include <stdlib.h> 17 #include <stdlib.h>
17 18
18 DECLARE_SKMESSAGEBUS_MESSAGE(SkResourceCache::PurgeSharedIDMessage) 19 DECLARE_SKMESSAGEBUS_MESSAGE(SkResourceCache::PurgeSharedIDMessage)
19 20
20 // This can be defined by the caller's build system 21 // This can be defined by the caller's build system
21 //#define SK_USE_DISCARDABLE_SCALEDIMAGECACHE 22 //#define SK_USE_DISCARDABLE_SCALEDIMAGECACHE
22 23
23 #ifndef SK_DISCARDABLEMEMORY_SCALEDIMAGECACHE_COUNT_LIMIT 24 #ifndef SK_DISCARDABLEMEMORY_SCALEDIMAGECACHE_COUNT_LIMIT
(...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after
665 ///////////// 666 /////////////
666 667
667 static void dump_visitor(const SkResourceCache::Rec& rec, void*) { 668 static void dump_visitor(const SkResourceCache::Rec& rec, void*) {
668 SkDebugf("RC: %12s bytes %9lu discardable %p\n", 669 SkDebugf("RC: %12s bytes %9lu discardable %p\n",
669 rec.getCategory(), rec.bytesUsed(), rec.diagnostic_only_getDiscarda ble()); 670 rec.getCategory(), rec.bytesUsed(), rec.diagnostic_only_getDiscarda ble());
670 } 671 }
671 672
672 void SkResourceCache::TestDumpMemoryStatistics() { 673 void SkResourceCache::TestDumpMemoryStatistics() {
673 VisitAll(dump_visitor, nullptr); 674 VisitAll(dump_visitor, nullptr);
674 } 675 }
676
677 static void sk_trace_dump_visitor(const SkResourceCache::Rec& rec, void* context ) {
678 SkTraceMemoryDump* dump = static_cast<SkTraceMemoryDump*>(context);
679 SkString dump_name = SkStringPrintf("skia/sk_resource_cache/%s_%p", rec.getC ategory(), &rec);
680 SkDiscardableMemory* discardable = rec.diagnostic_only_getDiscardable();
681 if (discardable) {
682 dump->setDiscardableMemoryBacking(dump_name.c_str(), *discardable);
683 } else {
684 dump->dumpNumericValue(dump_name.c_str(), "size", "bytes", rec.bytesUsed ());
685 dump->setMemoryBacking(dump_name.c_str(), "malloc", nullptr);
686 }
687 }
688
689 void SkResourceCache::DumpMemoryStatistics(SkTraceMemoryDump* dump) {
690 VisitAll(sk_trace_dump_visitor, dump);
691 }
OLDNEW
« no previous file with comments | « src/core/SkResourceCache.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698