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

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: 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"
10 #include "third_party/skia/include/core/SkGraphics.h" 11 #include "third_party/skia/include/core/SkGraphics.h"
12 #include "third_party/skia/include/core/SkGlyphCacheStats.h"
petrcermak 2015/07/28 19:40:29 nit: I think this should come before the include o
ssid 2015/07/28 20:19:11 I would expect upload to give me error. Fixed it,
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
21 class SkiaGlyphCacheDumper : public SkGlyphCacheStatsDumper {
22 public:
23 SkiaGlyphCacheDumper(
24 base::trace_event::ProcessMemoryDump* process_memory_dump);
25
26 // SkGlyphCacheStatsDumper implementation:
27 void DumpStats(const char* uniqueName, const size_t memoryUsed) override;
28
29 private:
30 base::trace_event::ProcessMemoryDump* process_memory_dump_;
31 };
32
33 SkiaGlyphCacheDumper::SkiaGlyphCacheDumper(
34 base::trace_event::ProcessMemoryDump* process_memory_dump)
35 : process_memory_dump_(process_memory_dump) {}
36
37 void SkiaGlyphCacheDumper::DumpStats(const char* uniqueName,
38 const size_t memoryUsed) {
39 auto cache_mad = process_memory_dump_->CreateAllocatorDump(
40 base::StringPrintf("%s/%s", kFontCacheDumpName, uniqueName));
41
42 cache_mad->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize,
petrcermak 2015/07/28 19:40:29 nit: I'd find this more readable if both calls had
ssid 2015/07/28 20:19:11 Hm, it was git cl format. I don't want to touch th
43 base::trace_event::MemoryAllocatorDump::kUnitsBytes,
44 memoryUsed);
45 cache_mad->AddScalar(
46 base::trace_event::MemoryAllocatorDump::kNameObjectsCount,
47 base::trace_event::MemoryAllocatorDump::kUnitsObjects, 1u);
48 }
49
50 } // namespace
51
15 // static 52 // static
16 SkiaMemoryDumpProvider* SkiaMemoryDumpProvider::GetInstance() { 53 SkiaMemoryDumpProvider* SkiaMemoryDumpProvider::GetInstance() {
17 return Singleton<SkiaMemoryDumpProvider, 54 return Singleton<SkiaMemoryDumpProvider,
18 LeakySingletonTraits<SkiaMemoryDumpProvider>>::get(); 55 LeakySingletonTraits<SkiaMemoryDumpProvider>>::get();
19 } 56 }
20 57
21 SkiaMemoryDumpProvider::SkiaMemoryDumpProvider() {} 58 SkiaMemoryDumpProvider::SkiaMemoryDumpProvider() {}
22 59
23 SkiaMemoryDumpProvider::~SkiaMemoryDumpProvider() {} 60 SkiaMemoryDumpProvider::~SkiaMemoryDumpProvider() {}
24 61
25 bool SkiaMemoryDumpProvider::OnMemoryDump( 62 bool SkiaMemoryDumpProvider::OnMemoryDump(
26 base::trace_event::ProcessMemoryDump* process_memory_dump) { 63 base::trace_event::ProcessMemoryDump* process_memory_dump) {
27 auto font_mad = 64 auto font_mad = process_memory_dump->CreateAllocatorDump(kFontCacheDumpName);
28 process_memory_dump->CreateAllocatorDump("skia/sk_font_cache"); 65 font_mad->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize,
29 font_mad->AddScalar("size", "bytes", SkGraphics::GetFontCacheUsed()); 66 base::trace_event::MemoryAllocatorDump::kUnitsBytes,
30 font_mad->AddScalar("count", "objects", SkGraphics::GetFontCacheCountUsed()); 67 SkGraphics::GetFontCacheUsed());
68 font_mad->AddScalar(base::trace_event::MemoryAllocatorDump::kNameObjectsCount,
69 base::trace_event::MemoryAllocatorDump::kUnitsObjects,
70 SkGraphics::GetFontCacheCountUsed());
71
72 SkiaGlyphCacheDumper dumper(process_memory_dump);
73 DumpSkGlyphCacheStats(&dumper);
31 74
32 auto resource_mad = 75 auto resource_mad =
33 process_memory_dump->CreateAllocatorDump("skia/sk_resource_cache"); 76 process_memory_dump->CreateAllocatorDump("skia/sk_resource_cache");
petrcermak 2015/07/28 19:40:29 nit: I'd factor this dump name out into a constant
ssid 2015/07/28 20:19:11 Done.
34 resource_mad->AddScalar("size", "bytes", 77 resource_mad->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize,
78 base::trace_event::MemoryAllocatorDump::kUnitsBytes,
35 SkResourceCache::GetTotalBytesUsed()); 79 SkResourceCache::GetTotalBytesUsed());
36 // TODO(ssid): crbug.com/503168. Add sub-allocation edges from discardable or 80 // TODO(ssid): crbug.com/503168. Add sub-allocation edges from discardable or
37 // malloc memory dumps to avoid double counting. 81 // malloc memory dumps to avoid double counting.
38 82
39 return true; 83 return true;
40 } 84 }
41 85
42 } // namespace skia 86 } // 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