From b502ad7847bdabf8aa9908b606f0448a15ece259 Mon Sep 17 00:00:00 2001 From: Nader Jawad Date: Thu, 17 Jun 2021 14:10:04 -0700 Subject: [PATCH] Improve snapshot clearing consistency Updated snapshot result to clear the internal SkImage whenever the layer changes. The previous logic did not clear out the snapshot in various use cases. Because the implementation before relied on the snapshot created with SkSurface this makes the cleanup logic consistent with SkImages created with SkImage::makeWithFilter Bug: 188450217 Test: manual testing of discord app Change-Id: I6391eb3b49794e54705bf5c6a09d2bdfd0564d05 --- libs/hwui/RenderNode.cpp | 3 +-- libs/hwui/RenderNode.h | 5 +++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/libs/hwui/RenderNode.cpp b/libs/hwui/RenderNode.cpp index 332f7e6f0eac6..44c335f6adb3d 100644 --- a/libs/hwui/RenderNode.cpp +++ b/libs/hwui/RenderNode.cpp @@ -455,8 +455,7 @@ void RenderNode::destroyLayers() { if (hasLayer()) { this->setLayerSurface(nullptr); } - mSnapshotResult.snapshot = nullptr; - mTargetImageFilter = nullptr; + if (mDisplayList) { mDisplayList.updateChildren([](RenderNode* child) { child->destroyLayers(); }); } diff --git a/libs/hwui/RenderNode.h b/libs/hwui/RenderNode.h index 8595b6e5f78ae..c770150650e2b 100644 --- a/libs/hwui/RenderNode.h +++ b/libs/hwui/RenderNode.h @@ -330,6 +330,11 @@ public: } else { mSkiaLayer.reset(); } + + // Clear out the previous snapshot and the image filter the previous + // snapshot was created with whenever the layer changes. + mSnapshotResult.snapshot = nullptr; + mTargetImageFilter = nullptr; } /**