From 4145919ef9853145532430c1e2e39ea53baee189 Mon Sep 17 00:00:00 2001 From: John Reck Date: Thu, 31 Oct 2019 15:04:58 -0700 Subject: [PATCH] Fix wrong surfaceRequiresRedraw check We only need to redraw if the size /changed/ not if it was the same. Also fix damageId to not use frameNumber as repeated redraws of the same frame would toggle. Bug: 143711430 Test: systrace Change-Id: I8ac4629c9ff4fd51de33d1be7aa46ccc995ba342 --- libs/hwui/TreeInfo.cpp | 1 - libs/hwui/renderthread/CanvasContext.cpp | 3 ++- libs/hwui/renderthread/CanvasContext.h | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/libs/hwui/TreeInfo.cpp b/libs/hwui/TreeInfo.cpp index dc53dd6c27c35..750f869e25517 100644 --- a/libs/hwui/TreeInfo.cpp +++ b/libs/hwui/TreeInfo.cpp @@ -24,7 +24,6 @@ TreeInfo::TreeInfo(TraversalMode mode, renderthread::CanvasContext& canvasContex : mode(mode) , prepareTextures(mode == MODE_FULL) , canvasContext(canvasContext) - , damageGenerationId(canvasContext.getFrameNumber()) , disableForceDark(canvasContext.useForceDark() ? 0 : 1) , screenSize(canvasContext.getNextFrameSize()) {} diff --git a/libs/hwui/renderthread/CanvasContext.cpp b/libs/hwui/renderthread/CanvasContext.cpp index e5c502cca09a6..4ca26c273c953 100644 --- a/libs/hwui/renderthread/CanvasContext.cpp +++ b/libs/hwui/renderthread/CanvasContext.cpp @@ -303,6 +303,7 @@ void CanvasContext::prepareTree(TreeInfo& info, int64_t* uiFrameInfo, int64_t sy info.damageAccumulator = &mDamageAccumulator; info.layerUpdateQueue = &mLayerUpdateQueue; + info.damageGenerationId = mDamageId++; info.out.canDrawThisFrame = true; mAnimationContext->startFrame(info.mode); @@ -702,7 +703,7 @@ bool CanvasContext::surfaceRequiresRedraw() { surface->query(NATIVE_WINDOW_WIDTH, &width); surface->query(NATIVE_WINDOW_HEIGHT, &height); - return width == mLastFrameWidth && height == mLastFrameHeight; + return width != mLastFrameWidth || height != mLastFrameHeight; } void CanvasContext::setRenderAheadDepth(int renderAhead) { diff --git a/libs/hwui/renderthread/CanvasContext.h b/libs/hwui/renderthread/CanvasContext.h index 6e3e43af8c6fb..b192d461da9b4 100644 --- a/libs/hwui/renderthread/CanvasContext.h +++ b/libs/hwui/renderthread/CanvasContext.h @@ -245,6 +245,7 @@ private: // Need at least 4 because we do quad buffer. Add a 5th for good measure. RingBuffer mSwapHistory; int64_t mFrameNumber = -1; + int64_t mDamageId = 0; // last vsync for a dropped frame due to stuffed queue nsecs_t mLastDropVsync = 0;