diff --git a/libs/hwui/pipeline/skia/SkiaOpenGLPipeline.cpp b/libs/hwui/pipeline/skia/SkiaOpenGLPipeline.cpp index 494f14d2a75b7..7d4cf423b1a1f 100644 --- a/libs/hwui/pipeline/skia/SkiaOpenGLPipeline.cpp +++ b/libs/hwui/pipeline/skia/SkiaOpenGLPipeline.cpp @@ -95,6 +95,11 @@ bool SkiaOpenGLPipeline::draw(const Frame& frame, const SkRect& screenDirty, profileCanvas->flush(); } + // Log memory statistics + if (CC_UNLIKELY(Properties::debugLevel != kDebugDisabled)) { + dumpResourceCacheUsage(); + } + return true; } diff --git a/libs/hwui/pipeline/skia/SkiaPipeline.cpp b/libs/hwui/pipeline/skia/SkiaPipeline.cpp index 03fa266a5c205..1b50531c9a182 100644 --- a/libs/hwui/pipeline/skia/SkiaPipeline.cpp +++ b/libs/hwui/pipeline/skia/SkiaPipeline.cpp @@ -253,6 +253,20 @@ void SkiaPipeline::renderFrame(const LayerUpdateQueue& layers, const SkRect& cli canvas->flush(); } +void SkiaPipeline::dumpResourceCacheUsage() const { + int resources, maxResources; + size_t bytes, maxBytes; + mRenderThread.getGrContext()->getResourceCacheUsage(&resources, &bytes); + mRenderThread.getGrContext()->getResourceCacheLimits(&maxResources, &maxBytes); + + SkString log("Resource Cache Usage:\n"); + log.appendf("%8d items out of %d maximum items\n", resources, maxResources); + log.appendf("%8zu bytes (%.2f MB) out of %.2f MB maximum\n", + bytes, bytes * (1.0f / (1024.0f * 1024.0f)), maxBytes * (1.0f / (1024.0f * 1024.0f))); + + ALOGD("%s", log.c_str()); +} + } /* namespace skiapipeline */ } /* namespace uirenderer */ } /* namespace android */ diff --git a/libs/hwui/pipeline/skia/SkiaPipeline.h b/libs/hwui/pipeline/skia/SkiaPipeline.h index 160046af63a6e..a16fabfe31e9d 100644 --- a/libs/hwui/pipeline/skia/SkiaPipeline.h +++ b/libs/hwui/pipeline/skia/SkiaPipeline.h @@ -96,7 +96,10 @@ public: mSpotShadowAlpha = lightInfo.spotShadowAlpha; mLightCenter = lightGeometry.center; } + protected: + void dumpResourceCacheUsage() const; + renderthread::RenderThread& mRenderThread; private: diff --git a/libs/hwui/pipeline/skia/SkiaVulkanPipeline.cpp b/libs/hwui/pipeline/skia/SkiaVulkanPipeline.cpp index 8fffe91cfe396..da8f504edb7bb 100644 --- a/libs/hwui/pipeline/skia/SkiaVulkanPipeline.cpp +++ b/libs/hwui/pipeline/skia/SkiaVulkanPipeline.cpp @@ -81,6 +81,11 @@ bool SkiaVulkanPipeline::draw(const Frame& frame, const SkRect& screenDirty, profileCanvas->flush(); } + // Log memory statistics + if (CC_UNLIKELY(Properties::debugLevel != kDebugDisabled)) { + dumpResourceCacheUsage(); + } + return true; }