summaryrefslogtreecommitdiff
path: root/libs/hwui/renderthread/CacheManager.cpp
diff options
context:
space:
mode:
authorJohn Reck <jreck@google.com>2021-05-12 19:10:47 -0400
committerJohn Reck <jreck@google.com>2021-05-12 19:29:03 -0400
commit3920768c72240c11f7ff62e1a823142bb451ff82 (patch)
tree7766756c9fde387af03a34c7e43500e654782df2 /libs/hwui/renderthread/CacheManager.cpp
parent8ae0654abd92ac4da12272f0618ae0ac992a63be (diff)
More benchmark tweaks
Bug: 187718492 Test: this Change-Id: Ie0cad91e1c7d1a02704fc4b1007ba2c28cb2b3e7
Diffstat (limited to 'libs/hwui/renderthread/CacheManager.cpp')
-rw-r--r--libs/hwui/renderthread/CacheManager.cpp24
1 files changed, 20 insertions, 4 deletions
diff --git a/libs/hwui/renderthread/CacheManager.cpp b/libs/hwui/renderthread/CacheManager.cpp
index 5047be979e41..46e806081c0c 100644
--- a/libs/hwui/renderthread/CacheManager.cpp
+++ b/libs/hwui/renderthread/CacheManager.cpp
@@ -130,27 +130,43 @@ void CacheManager::trimStaleResources() {
mGrContext->purgeResourcesNotUsedInMs(std::chrono::seconds(30));
}
+void CacheManager::getMemoryUsage(size_t* cpuUsage, size_t* gpuUsage) {
+ *cpuUsage = 0;
+ *gpuUsage = 0;
+ if (!mGrContext) {
+ return;
+ }
+
+ skiapipeline::SkiaMemoryTracer cpuTracer("category", true);
+ SkGraphics::DumpMemoryStatistics(&cpuTracer);
+ *cpuUsage += cpuTracer.total();
+
+ skiapipeline::SkiaMemoryTracer gpuTracer("category", true);
+ mGrContext->dumpMemoryStatistics(&gpuTracer);
+ *gpuUsage += gpuTracer.total();
+}
+
void CacheManager::dumpMemoryUsage(String8& log, const RenderState* renderState) {
if (!mGrContext) {
log.appendFormat("No valid cache instance.\n");
return;
}
- log.appendFormat("Font Cache (CPU):\n");
- log.appendFormat(" Size: %.2f kB \n", SkGraphics::GetFontCacheUsed() / 1024.0f);
- log.appendFormat(" Glyph Count: %d \n", SkGraphics::GetFontCacheCountUsed());
-
std::vector<skiapipeline::ResourcePair> cpuResourceMap = {
{"skia/sk_resource_cache/bitmap_", "Bitmaps"},
{"skia/sk_resource_cache/rrect-blur_", "Masks"},
{"skia/sk_resource_cache/rects-blur_", "Masks"},
{"skia/sk_resource_cache/tessellated", "Shadows"},
+ {"skia/sk_glyph_cache", "Glyph Cache"},
};
skiapipeline::SkiaMemoryTracer cpuTracer(cpuResourceMap, false);
SkGraphics::DumpMemoryStatistics(&cpuTracer);
if (cpuTracer.hasOutput()) {
log.appendFormat("CPU Caches:\n");
cpuTracer.logOutput(log);
+ log.appendFormat(" Glyph Count: %d \n", SkGraphics::GetFontCacheCountUsed());
+ log.appendFormat("Total CPU memory usage:\n");
+ cpuTracer.logTotals(log);
}
skiapipeline::SkiaMemoryTracer gpuTracer("category", true);