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

Unified 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, 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/core/SkResourceCache.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkResourceCache.cpp
diff --git a/src/core/SkResourceCache.cpp b/src/core/SkResourceCache.cpp
index 922fc7ee0a5d9ca186b7ce80d7d473b6cdef355c..7fa98f0863a1500e4da5ea0c48f10380596e3cac 100644
--- a/src/core/SkResourceCache.cpp
+++ b/src/core/SkResourceCache.cpp
@@ -11,6 +11,7 @@
#include "SkMutex.h"
#include "SkPixelRef.h"
#include "SkResourceCache.h"
+#include "SkTraceMemoryDump.h"
#include <stddef.h>
#include <stdlib.h>
@@ -672,3 +673,19 @@ static void dump_visitor(const SkResourceCache::Rec& rec, void*) {
void SkResourceCache::TestDumpMemoryStatistics() {
VisitAll(dump_visitor, nullptr);
}
+
+static void sk_trace_dump_visitor(const SkResourceCache::Rec& rec, void* context) {
+ SkTraceMemoryDump* dump = static_cast<SkTraceMemoryDump*>(context);
+ SkString dump_name = SkStringPrintf("skia/sk_resource_cache/%s_%p", rec.getCategory(), &rec);
+ SkDiscardableMemory* discardable = rec.diagnostic_only_getDiscardable();
+ if (discardable) {
+ dump->setDiscardableMemoryBacking(dump_name.c_str(), *discardable);
+ } else {
+ dump->dumpNumericValue(dump_name.c_str(), "size", "bytes", rec.bytesUsed());
+ dump->setMemoryBacking(dump_name.c_str(), "malloc", nullptr);
+ }
+}
+
+void SkResourceCache::DumpMemoryStatistics(SkTraceMemoryDump* dump) {
+ VisitAll(sk_trace_dump_visitor, dump);
+}
« 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