summaryrefslogtreecommitdiff
path: root/libs/hwui/pipeline/skia/RenderNodeDrawable.cpp
diff options
context:
space:
mode:
authorNader Jawad <njawad@google.com>2021-09-27 15:44:09 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2021-09-27 15:44:09 +0000
commitc2618b3fa1fd91ccbf369a00428e89d4438e15e1 (patch)
tree6fe614e4195f017a5e500e97eb68e7807f0f3158 /libs/hwui/pipeline/skia/RenderNodeDrawable.cpp
parent716af6ff2a87e587001059645286acba62491a78 (diff)
parent69617682e463f30fec743a96302130a33d3c52e2 (diff)
Merge "Conditionally cache RenderEffect results" into sc-qpr1-dev am: 69617682e4
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15882028 Change-Id: I7a3ff706eb350073535595c1fc79f97a71e4489e
Diffstat (limited to 'libs/hwui/pipeline/skia/RenderNodeDrawable.cpp')
-rw-r--r--libs/hwui/pipeline/skia/RenderNodeDrawable.cpp36
1 files changed, 28 insertions, 8 deletions
diff --git a/libs/hwui/pipeline/skia/RenderNodeDrawable.cpp b/libs/hwui/pipeline/skia/RenderNodeDrawable.cpp
index 7556af918170..2c81c971f7a6 100644
--- a/libs/hwui/pipeline/skia/RenderNodeDrawable.cpp
+++ b/libs/hwui/pipeline/skia/RenderNodeDrawable.cpp
@@ -231,14 +231,34 @@ void RenderNodeDrawable::drawContent(SkCanvas* canvas) const {
SkASSERT(properties.effectiveLayerType() == LayerType::RenderLayer);
SkPaint paint;
layerNeedsPaint(layerProperties, alphaMultiplier, &paint);
- const auto snapshotResult = renderNode->updateSnapshotIfRequired(
- canvas->recordingContext(),
- layerProperties.getImageFilter(),
- clipBounds.roundOut()
- );
- sk_sp<SkImage> snapshotImage = snapshotResult->snapshot;
- srcBounds = snapshotResult->outSubset;
- offset = snapshotResult->outOffset;
+ sk_sp<SkImage> snapshotImage;
+ auto* imageFilter = layerProperties.getImageFilter();
+ auto recordingContext = canvas->recordingContext();
+ // On some GL vendor implementations, caching the result of
+ // getLayerSurface->makeImageSnapshot() causes a call to
+ // Fence::waitForever without a corresponding signal. This would
+ // lead to ANRs throughout the system.
+ // Instead only cache the SkImage created with the SkImageFilter
+ // for supported devices. Otherwise just create a new SkImage with
+ // the corresponding SkImageFilter each time.
+ // See b/193145089 and b/197263715
+ if (!Properties::enableRenderEffectCache) {
+ if (imageFilter) {
+ auto subset = SkIRect::MakeWH(srcBounds.width(), srcBounds.height());
+ snapshotImage = snapshotImage->makeWithFilter(recordingContext, imageFilter,
+ subset, clipBounds.roundOut(),
+ &srcBounds, &offset);
+ } else {
+ snapshotImage = renderNode->getLayerSurface()->makeImageSnapshot();
+ }
+ } else {
+ const auto snapshotResult = renderNode->updateSnapshotIfRequired(
+ recordingContext, layerProperties.getImageFilter(), clipBounds.roundOut());
+ snapshotImage = snapshotResult->snapshot;
+ srcBounds = snapshotResult->outSubset;
+ offset = snapshotResult->outOffset;
+ }
+
const auto dstBounds = SkIRect::MakeXYWH(offset.x(),
offset.y(),
srcBounds.width(),