From 6aff4814a73c0b87cd1ab5e92ef9547e4d20042c Mon Sep 17 00:00:00 2001 From: Nader Jawad Date: Wed, 9 Jun 2021 10:14:43 -0700 Subject: Refactor SkImageFilter usage to cache results. If an SkImageFilter is used, create an image snapshot with the filter applied to avoid re-computing it on each draw invocation Bug: 188450217 Test: Re-ran CTS tests Change-Id: Ib790669e14ada9d4ebbfac958d699e2b5242f2d7 --- libs/hwui/RenderNode.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'libs/hwui/RenderNode.h') diff --git a/libs/hwui/RenderNode.h b/libs/hwui/RenderNode.h index 6a0b1aafd7c7..8595b6e5f78a 100644 --- a/libs/hwui/RenderNode.h +++ b/libs/hwui/RenderNode.h @@ -345,6 +345,16 @@ public: return mSkiaLayer.get() ? mSkiaLayer->layerSurface.get() : nullptr; } + struct SnapshotResult { + sk_sp snapshot; + SkIRect outSubset; + SkIPoint outOffset; + }; + + std::optional updateSnapshotIfRequired(GrRecordingContext* context, + const SkImageFilter* imageFilter, + const SkIRect& clipBounds); + skiapipeline::SkiaLayer* getSkiaLayer() const { return mSkiaLayer.get(); } /** @@ -375,6 +385,22 @@ private: */ std::unique_ptr mSkiaLayer; + /** + * SkImageFilter used to create the mSnapshotResult + */ + sk_sp mTargetImageFilter; + + /** + * Clip bounds used to create the mSnapshotResult + */ + SkIRect mImageFilterClipBounds; + + /** + * Result of the most recent snapshot with additional metadata used to + * determine how to draw the contents + */ + SnapshotResult mSnapshotResult; + struct ClippedOutlineCache { // keys uint32_t outlineID = 0; -- cgit v1.2.3-59-g8ed1b