Merge "Fix aggressive caching of RenderNode snapshot" into sc-v2-dev

This commit is contained in:
Nader Jawad
2021-09-10 22:54:54 +00:00
committed by Android (Google) Code Review
2 changed files with 7 additions and 3 deletions

View File

@@ -341,6 +341,7 @@ std::optional<RenderNode::SnapshotResult> RenderNode::updateSnapshotIfRequired(
sk_sp<SkImage> snapshot = layerSurface->makeImageSnapshot(); sk_sp<SkImage> snapshot = layerSurface->makeImageSnapshot();
const auto subset = SkIRect::MakeWH(properties().getWidth(), const auto subset = SkIRect::MakeWH(properties().getWidth(),
properties().getHeight()); properties().getHeight());
uint32_t layerSurfaceGenerationId = layerSurface->generationID();
// If we don't have an ImageFilter just return the snapshot // If we don't have an ImageFilter just return the snapshot
if (imageFilter == nullptr) { if (imageFilter == nullptr) {
mSnapshotResult.snapshot = snapshot; mSnapshotResult.snapshot = snapshot;
@@ -348,9 +349,10 @@ std::optional<RenderNode::SnapshotResult> RenderNode::updateSnapshotIfRequired(
mSnapshotResult.outOffset = SkIPoint::Make(0.0f, 0.0f); mSnapshotResult.outOffset = SkIPoint::Make(0.0f, 0.0f);
mImageFilterClipBounds = clipBounds; mImageFilterClipBounds = clipBounds;
mTargetImageFilter = nullptr; mTargetImageFilter = nullptr;
} else if (mSnapshotResult.snapshot == nullptr || mTargetImageFilterLayerSurfaceGenerationId = 0;
imageFilter != mTargetImageFilter.get() || } else if (mSnapshotResult.snapshot == nullptr || imageFilter != mTargetImageFilter.get() ||
mImageFilterClipBounds != clipBounds) { mImageFilterClipBounds != clipBounds ||
mTargetImageFilterLayerSurfaceGenerationId != layerSurfaceGenerationId) {
// Otherwise create a new snapshot with the given filter and snapshot // Otherwise create a new snapshot with the given filter and snapshot
mSnapshotResult.snapshot = mSnapshotResult.snapshot =
snapshot->makeWithFilter(context, snapshot->makeWithFilter(context,
@@ -361,6 +363,7 @@ std::optional<RenderNode::SnapshotResult> RenderNode::updateSnapshotIfRequired(
&mSnapshotResult.outOffset); &mSnapshotResult.outOffset);
mTargetImageFilter = sk_ref_sp(imageFilter); mTargetImageFilter = sk_ref_sp(imageFilter);
mImageFilterClipBounds = clipBounds; mImageFilterClipBounds = clipBounds;
mTargetImageFilterLayerSurfaceGenerationId = layerSurfaceGenerationId;
} }
return mSnapshotResult; return mSnapshotResult;

View File

@@ -396,6 +396,7 @@ private:
* SkImageFilter used to create the mSnapshotResult * SkImageFilter used to create the mSnapshotResult
*/ */
sk_sp<SkImageFilter> mTargetImageFilter; sk_sp<SkImageFilter> mTargetImageFilter;
uint32_t mTargetImageFilterLayerSurfaceGenerationId = 0;
/** /**
* Clip bounds used to create the mSnapshotResult * Clip bounds used to create the mSnapshotResult