diff options
author | Robert Carr <racarr@google.com> | 2021-06-11 13:59:52 -0700 |
---|---|---|
committer | Robert Carr <racarr@google.com> | 2021-06-21 21:58:09 -0700 |
commit | a70e91c90e0e88f7e36ccb47725b6109d6bb2c99 (patch) | |
tree | 4533986d86881a2fe556bf02d91c58b5da824f8a | |
parent | b552ff5e4262640cbaefa0031e8b7b61e4864268 (diff) | |
download | native-a70e91c90e0e88f7e36ccb47725b6109d6bb2c99.tar.gz |
Protect committing child list behind visible regions changed
This can be further optimized but as a first pass checking for
visible regions will improve the buffer update path. In Layer.cpp,
we need to be sure updating Z-order sets the mVisibleRegionsChanged
flag directly rather than relying on doTransaction (as this now occurs
too late after being coalesced in to handlePageFlip).
Test: Existing tests pass. simpleperf
Bug: 186200583
Change-Id: I24be38594f13e774d20a2a32ad12676a4e3c3052
-rw-r--r-- | services/surfaceflinger/Layer.cpp | 4 | ||||
-rw-r--r-- | services/surfaceflinger/SurfaceFlinger.cpp | 7 |
2 files changed, 9 insertions, 2 deletions
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp index 1b076632d8..bb1d3fc93e 100644 --- a/services/surfaceflinger/Layer.cpp +++ b/services/surfaceflinger/Layer.cpp @@ -772,6 +772,8 @@ bool Layer::setLayer(int32_t z) { mDrawingState.z = z; mDrawingState.modified = true; + mFlinger->mSomeChildrenChanged = true; + // Discard all relative layering. if (mDrawingState.zOrderRelativeOf != nullptr) { sp<Layer> strongRelative = mDrawingState.zOrderRelativeOf.promote(); @@ -822,6 +824,8 @@ bool Layer::setRelativeLayer(const sp<IBinder>& relativeToHandle, int32_t relati return false; } + mFlinger->mSomeChildrenChanged = true; + mDrawingState.sequence++; mDrawingState.modified = true; mDrawingState.z = relativeZ; diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index 467446e91c..d4605674b7 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -3224,9 +3224,12 @@ void SurfaceFlinger::commitTransactionLocked() { // clear the "changed" flags in current state mCurrentState.colorMatrixChanged = false; - for (const auto& rootLayer : mDrawingState.layersSortedByZ) { - rootLayer->commitChildList(); + if (mVisibleRegionsDirty) { + for (const auto& rootLayer : mDrawingState.layersSortedByZ) { + rootLayer->commitChildList(); + } } + // TODO(b/163019109): See if this traversal is needed at all... if (!mOffscreenLayers.empty()) { mDrawingState.traverse([&](Layer* layer) { |