diff options
author | Nader Jawad <njawad@google.com> | 2021-09-08 22:17:15 -0700 |
---|---|---|
committer | Nader Jawad <njawad@google.com> | 2021-09-09 16:13:32 +0000 |
commit | f49068f09485c1d50d7398242c1caf08b6a4978f (patch) | |
tree | 2def96d5208601259449ff413ade198a62296875 | |
parent | cd9481d29abd982eb21a9e681a140685a66394ab (diff) |
Fix aggressive caching of RenderNode snapshot
Updated ImageFilter caching logic to update the snapshot
whenever the surface generation ID has changed.
Fixes: 199242895
Test: Added test to RenderNodeTests
Change-Id: I803dce35ba15a098f14dc02a479abf8b2fbae51f
-rw-r--r-- | libs/hwui/RenderNode.cpp | 9 | ||||
-rw-r--r-- | libs/hwui/RenderNode.h | 1 |
2 files changed, 7 insertions, 3 deletions
diff --git a/libs/hwui/RenderNode.cpp b/libs/hwui/RenderNode.cpp index 0c422df65881..b348a6ecaae4 100644 --- a/libs/hwui/RenderNode.cpp +++ b/libs/hwui/RenderNode.cpp @@ -341,6 +341,7 @@ std::optional<RenderNode::SnapshotResult> RenderNode::updateSnapshotIfRequired( sk_sp<SkImage> snapshot = layerSurface->makeImageSnapshot(); const auto subset = SkIRect::MakeWH(properties().getWidth(), properties().getHeight()); + uint32_t layerSurfaceGenerationId = layerSurface->generationID(); // If we don't have an ImageFilter just return the snapshot if (imageFilter == nullptr) { mSnapshotResult.snapshot = snapshot; @@ -348,9 +349,10 @@ std::optional<RenderNode::SnapshotResult> RenderNode::updateSnapshotIfRequired( mSnapshotResult.outOffset = SkIPoint::Make(0.0f, 0.0f); mImageFilterClipBounds = clipBounds; mTargetImageFilter = nullptr; - } else if (mSnapshotResult.snapshot == nullptr || - imageFilter != mTargetImageFilter.get() || - mImageFilterClipBounds != clipBounds) { + mTargetImageFilterLayerSurfaceGenerationId = 0; + } else if (mSnapshotResult.snapshot == nullptr || imageFilter != mTargetImageFilter.get() || + mImageFilterClipBounds != clipBounds || + mTargetImageFilterLayerSurfaceGenerationId != layerSurfaceGenerationId) { // Otherwise create a new snapshot with the given filter and snapshot mSnapshotResult.snapshot = snapshot->makeWithFilter(context, @@ -361,6 +363,7 @@ std::optional<RenderNode::SnapshotResult> RenderNode::updateSnapshotIfRequired( &mSnapshotResult.outOffset); mTargetImageFilter = sk_ref_sp(imageFilter); mImageFilterClipBounds = clipBounds; + mTargetImageFilterLayerSurfaceGenerationId = layerSurfaceGenerationId; } return mSnapshotResult; diff --git a/libs/hwui/RenderNode.h b/libs/hwui/RenderNode.h index 45a4f6c9c70d..da0476259b97 100644 --- a/libs/hwui/RenderNode.h +++ b/libs/hwui/RenderNode.h @@ -396,6 +396,7 @@ private: * SkImageFilter used to create the mSnapshotResult */ sk_sp<SkImageFilter> mTargetImageFilter; + uint32_t mTargetImageFilterLayerSurfaceGenerationId = 0; /** * Clip bounds used to create the mSnapshotResult |