diff options
author | android-build-team Robot <android-build-team-robot@google.com> | 2021-06-16 01:07:40 +0000 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2021-06-16 01:07:40 +0000 |
commit | 233ce9ef453bc7b47f7ac5d0eb1d5fda0ce845ab (patch) | |
tree | 2c414c5d9ce4ab1099cd73259d912432ac526bdc /libs/hwui/renderthread/CanvasContext.cpp | |
parent | 379d80ba17a87a4302c6a177f845159880e1536d (diff) | |
parent | f34c9ede734be8bb831304bfd3a9ba22461cec6d (diff) |
Snap for 7460608 from f34c9ede734be8bb831304bfd3a9ba22461cec6d to sc-release
Change-Id: Icefa7a959e8b47c6b77e621c924eba895eab3c47
Diffstat (limited to 'libs/hwui/renderthread/CanvasContext.cpp')
-rw-r--r-- | libs/hwui/renderthread/CanvasContext.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/libs/hwui/renderthread/CanvasContext.cpp b/libs/hwui/renderthread/CanvasContext.cpp index a0d93e928876..8bfc2c14ad7c 100644 --- a/libs/hwui/renderthread/CanvasContext.cpp +++ b/libs/hwui/renderthread/CanvasContext.cpp @@ -461,6 +461,7 @@ void CanvasContext::prepareTree(TreeInfo& info, int64_t* uiFrameInfo, int64_t sy } void CanvasContext::stopDrawing() { + cleanupResources(); mRenderThread.removeFrameCallback(this); mAnimationContext->pauseAnimators(); mGenerationID++; @@ -619,10 +620,25 @@ nsecs_t CanvasContext::draw() { } } + cleanupResources(); mRenderThread.cacheManager().onFrameCompleted(); return mCurrentFrameInfo->get(FrameInfoIndex::DequeueBufferDuration); } +void CanvasContext::cleanupResources() { + auto& tracker = mJankTracker.frames(); + auto size = tracker.size(); + auto capacity = tracker.capacity(); + if (size == capacity) { + nsecs_t nowNanos = systemTime(SYSTEM_TIME_MONOTONIC); + nsecs_t frameCompleteNanos = + tracker[0].get(FrameInfoIndex::FrameCompleted); + nsecs_t frameDiffNanos = nowNanos - frameCompleteNanos; + nsecs_t cleanupMillis = ns2ms(std::max(frameDiffNanos, 10_s)); + mRenderThread.cacheManager().performDeferredCleanup(cleanupMillis); + } +} + void CanvasContext::reportMetricsWithPresentTime() { if (mFrameMetricsReporter == nullptr) { return; |