diff options
Diffstat (limited to 'libs/hwui/renderthread/CacheManager.cpp')
-rw-r--r-- | libs/hwui/renderthread/CacheManager.cpp | 32 |
1 files changed, 14 insertions, 18 deletions
diff --git a/libs/hwui/renderthread/CacheManager.cpp b/libs/hwui/renderthread/CacheManager.cpp index 1e5877356e8d..5047be979e41 100644 --- a/libs/hwui/renderthread/CacheManager.cpp +++ b/libs/hwui/renderthread/CacheManager.cpp @@ -61,7 +61,7 @@ CacheManager::CacheManager() SkGraphics::SetFontCacheLimit(mMaxCpuFontCacheBytes); } -void CacheManager::reset(sk_sp<GrContext> context) { +void CacheManager::reset(sk_sp<GrDirectContext> context) { if (context != mGrContext) { destroy(); } @@ -101,7 +101,8 @@ void CacheManager::trimMemory(TrimMemoryMode mode) { return; } - mGrContext->flush(); + // flush and submit all work to the gpu and wait for it to finish + mGrContext->flushAndSubmit(/*syncCpu=*/true); switch (mode) { case TrimMemoryMode::Complete: @@ -119,17 +120,13 @@ void CacheManager::trimMemory(TrimMemoryMode mode) { SkGraphics::SetFontCacheLimit(mMaxCpuFontCacheBytes); break; } - - // We must sync the cpu to make sure deletions of resources still queued up on the GPU actually - // happen. - mGrContext->flush(kSyncCpu_GrFlushFlag, 0, nullptr); } void CacheManager::trimStaleResources() { if (!mGrContext) { return; } - mGrContext->flush(); + mGrContext->flushAndSubmit(); mGrContext->purgeResourcesNotUsedInMs(std::chrono::seconds(30)); } @@ -143,7 +140,6 @@ void CacheManager::dumpMemoryUsage(String8& log, const RenderState* renderState) log.appendFormat(" Size: %.2f kB \n", SkGraphics::GetFontCacheUsed() / 1024.0f); log.appendFormat(" Glyph Count: %d \n", SkGraphics::GetFontCacheCountUsed()); - log.appendFormat("CPU Caches:\n"); std::vector<skiapipeline::ResourcePair> cpuResourceMap = { {"skia/sk_resource_cache/bitmap_", "Bitmaps"}, {"skia/sk_resource_cache/rrect-blur_", "Masks"}, @@ -152,20 +148,20 @@ void CacheManager::dumpMemoryUsage(String8& log, const RenderState* renderState) }; skiapipeline::SkiaMemoryTracer cpuTracer(cpuResourceMap, false); SkGraphics::DumpMemoryStatistics(&cpuTracer); - cpuTracer.logOutput(log); + if (cpuTracer.hasOutput()) { + log.appendFormat("CPU Caches:\n"); + cpuTracer.logOutput(log); + } - log.appendFormat("GPU Caches:\n"); skiapipeline::SkiaMemoryTracer gpuTracer("category", true); mGrContext->dumpMemoryStatistics(&gpuTracer); - gpuTracer.logOutput(log); - - log.appendFormat("Other Caches:\n"); - log.appendFormat(" Current / Maximum\n"); + if (gpuTracer.hasOutput()) { + log.appendFormat("GPU Caches:\n"); + gpuTracer.logOutput(log); + } - if (renderState) { - if (renderState->mActiveLayers.size() > 0) { - log.appendFormat(" Layer Info:\n"); - } + if (renderState && renderState->mActiveLayers.size() > 0) { + log.appendFormat("Layer Info:\n"); const char* layerType = Properties::getRenderPipelineType() == RenderPipelineType::SkiaGL ? "GlLayer" |