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

Side by Side Diff: skia/ext/skia_memory_dump_provider.cc

Issue 1260753004: [tracing] Adding SkGlyphCache detailed statistics to skia dump provider (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@skia_v1
Patch Set: Style fixes. Created 5 years, 4 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 | « no previous file | 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 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "skia_memory_dump_provider.h" 5 #include "skia_memory_dump_provider.h"
6 6
7 #include "base/strings/stringprintf.h"
7 #include "base/trace_event/memory_allocator_dump.h" 8 #include "base/trace_event/memory_allocator_dump.h"
8 #include "base/trace_event/memory_dump_manager.h" 9 #include "base/trace_event/memory_dump_manager.h"
9 #include "base/trace_event/process_memory_dump.h" 10 #include "base/trace_event/process_memory_dump.h"
11 #include "third_party/skia/include/core/SkGlyphCacheStats.h"
10 #include "third_party/skia/include/core/SkGraphics.h" 12 #include "third_party/skia/include/core/SkGraphics.h"
11 #include "third_party/skia/src/core/SkResourceCache.h" 13 #include "third_party/skia/src/core/SkResourceCache.h"
12 14
13 namespace skia { 15 namespace skia {
14 16
17 namespace {
18
19 const char kFontCacheDumpName[] = "skia/sk_font_cache";
20 const char kResourceCacheDumpName[] = "skia/sk_resource_cache";
21
22 class SkiaGlyphCacheDumper : public SkGlyphCacheStatsDumper {
23 public:
24 SkiaGlyphCacheDumper(
25 base::trace_event::ProcessMemoryDump* process_memory_dump);
26
27 // SkGlyphCacheStatsDumper implementation:
28 void DumpStats(const char* uniqueName, const size_t memoryUsed) override;
29
30 private:
31 base::trace_event::ProcessMemoryDump* process_memory_dump_;
32 };
33
34 SkiaGlyphCacheDumper::SkiaGlyphCacheDumper(
35 base::trace_event::ProcessMemoryDump* process_memory_dump)
36 : process_memory_dump_(process_memory_dump) {}
37
38 void SkiaGlyphCacheDumper::DumpStats(const char* uniqueName,
39 const size_t memoryUsed) {
40 auto cache_mad = process_memory_dump_->CreateAllocatorDump(
41 base::StringPrintf("%s/%s", kFontCacheDumpName, uniqueName));
42
43 cache_mad->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize,
44 base::trace_event::MemoryAllocatorDump::kUnitsBytes,
45 memoryUsed);
46 cache_mad->AddScalar(
47 base::trace_event::MemoryAllocatorDump::kNameObjectsCount,
48 base::trace_event::MemoryAllocatorDump::kUnitsObjects, 1u);
49 }
50
51 } // namespace
52
15 // static 53 // static
16 SkiaMemoryDumpProvider* SkiaMemoryDumpProvider::GetInstance() { 54 SkiaMemoryDumpProvider* SkiaMemoryDumpProvider::GetInstance() {
17 return Singleton<SkiaMemoryDumpProvider, 55 return Singleton<SkiaMemoryDumpProvider,
18 LeakySingletonTraits<SkiaMemoryDumpProvider>>::get(); 56 LeakySingletonTraits<SkiaMemoryDumpProvider>>::get();
19 } 57 }
20 58
21 SkiaMemoryDumpProvider::SkiaMemoryDumpProvider() {} 59 SkiaMemoryDumpProvider::SkiaMemoryDumpProvider() {}
22 60
23 SkiaMemoryDumpProvider::~SkiaMemoryDumpProvider() {} 61 SkiaMemoryDumpProvider::~SkiaMemoryDumpProvider() {}
24 62
25 bool SkiaMemoryDumpProvider::OnMemoryDump( 63 bool SkiaMemoryDumpProvider::OnMemoryDump(
26 base::trace_event::ProcessMemoryDump* process_memory_dump) { 64 base::trace_event::ProcessMemoryDump* process_memory_dump) {
27 auto font_mad = 65 auto font_mad = process_memory_dump->CreateAllocatorDump(kFontCacheDumpName);
28 process_memory_dump->CreateAllocatorDump("skia/sk_font_cache"); 66 font_mad->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize,
29 font_mad->AddScalar("size", "bytes", SkGraphics::GetFontCacheUsed()); 67 base::trace_event::MemoryAllocatorDump::kUnitsBytes,
30 font_mad->AddScalar("count", "objects", SkGraphics::GetFontCacheCountUsed()); 68 SkGraphics::GetFontCacheUsed());
69 font_mad->AddScalar(base::trace_event::MemoryAllocatorDump::kNameObjectsCount,
70 base::trace_event::MemoryAllocatorDump::kUnitsObjects,
71 SkGraphics::GetFontCacheCountUsed());
72
73 SkiaGlyphCacheDumper dumper(process_memory_dump);
74 DumpSkGlyphCacheStats(&dumper);
31 75
32 auto resource_mad = 76 auto resource_mad =
33 process_memory_dump->CreateAllocatorDump("skia/sk_resource_cache"); 77 process_memory_dump->CreateAllocatorDump(kResourceCacheDumpName);
34 resource_mad->AddScalar("size", "bytes", 78 resource_mad->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize,
79 base::trace_event::MemoryAllocatorDump::kUnitsBytes,
35 SkResourceCache::GetTotalBytesUsed()); 80 SkResourceCache::GetTotalBytesUsed());
36 // TODO(ssid): crbug.com/503168. Add sub-allocation edges from discardable or 81 // TODO(ssid): crbug.com/503168. Add sub-allocation edges from discardable or
37 // malloc memory dumps to avoid double counting. 82 // malloc memory dumps to avoid double counting.
38 83
39 return true; 84 return true;
40 } 85 }
41 86
42 } // namespace skia 87 } // namespace skia
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698