Chromium Code Reviews| 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 661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 672 void SkResourceCache::TestDumpMemoryStatistics() { | 672 void SkResourceCache::TestDumpMemoryStatistics() { |
| 673 VisitAll(dump_visitor, nullptr); | 673 VisitAll(dump_visitor, nullptr); |
| 674 } | 674 } |
| 675 | 675 |
| 676 static void sk_trace_dump_visitor(const SkResourceCache::Rec& rec, void* context ) { | 676 static void sk_trace_dump_visitor(const SkResourceCache::Rec& rec, void* context ) { |
| 677 SkTraceMemoryDump* dump = static_cast<SkTraceMemoryDump*>(context); | 677 SkTraceMemoryDump* dump = static_cast<SkTraceMemoryDump*>(context); |
| 678 SkString dumpName = SkStringPrintf("skia/sk_resource_cache/%s_%p", rec.getCa tegory(), &rec); | 678 SkString dumpName = SkStringPrintf("skia/sk_resource_cache/%s_%p", rec.getCa tegory(), &rec); |
| 679 SkDiscardableMemory* discardable = rec.diagnostic_only_getDiscardable(); | 679 SkDiscardableMemory* discardable = rec.diagnostic_only_getDiscardable(); |
| 680 if (discardable) { | 680 if (discardable) { |
| 681 dump->setDiscardableMemoryBacking(dumpName.c_str(), *discardable); | 681 dump->setDiscardableMemoryBacking(dumpName.c_str(), *discardable); |
| 682 dump->dumpNumericValue(dumpName.c_str(), "discardable_size", "bytes", re c.bytesUsed()); | |
|
reed1
2015/09/23 13:21:29
Why is this needed? Can we not determine the size
ssid
2015/09/23 13:30:22
The system works like this:
Skia tells discardable
| |
| 682 } else { | 683 } else { |
| 683 dump->dumpNumericValue(dumpName.c_str(), "size", "bytes", rec.bytesUsed( )); | 684 dump->dumpNumericValue(dumpName.c_str(), "size", "bytes", rec.bytesUsed( )); |
| 684 dump->setMemoryBacking(dumpName.c_str(), "malloc", nullptr); | 685 dump->setMemoryBacking(dumpName.c_str(), "malloc", nullptr); |
| 685 } | 686 } |
| 686 } | 687 } |
| 687 | 688 |
| 688 void SkResourceCache::DumpMemoryStatistics(SkTraceMemoryDump* dump) { | 689 void SkResourceCache::DumpMemoryStatistics(SkTraceMemoryDump* dump) { |
| 689 // Since resource could be backed by malloc or discardable, the cache always dumps detailed | 690 // Since resource could be backed by malloc or discardable, the cache always dumps detailed |
| 690 // stats to be accurate. | 691 // stats to be accurate. |
| 691 if (dump->getRequestedDetails() & (SkTraceMemoryDump::kMemoryTotals | | 692 if (dump->getRequestedDetails() & (SkTraceMemoryDump::kMemoryTotals | |
| 692 SkTraceMemoryDump::kDiscardableDetails | SkTraceMemoryDump::kMallocD etails)) { | 693 SkTraceMemoryDump::kDiscardableDetails | SkTraceMemoryDump::kMallocD etails)) { |
| 693 VisitAll(sk_trace_dump_visitor, dump); | 694 VisitAll(sk_trace_dump_visitor, dump); |
| 694 } | 695 } |
| 695 } | 696 } |
| OLD | NEW |