[sf] avoid traversals for cursor updates and buffer udpates
In U, we have a unified way to traverse the layer
hierarchy from both new FrontEnd and legacy logic
to generate the snapshots to provide to CE.
We update CE twice, once to draw the cursor and once
for the remaining layers. In T we relied on the previous
frame's composition state to update cursor state. This
extra traversal increases the cpu usage for buffer updates.
Fix this by keeping track of the previous composition state
and expand on this to avoid all traversals when there are
only buffer updates.
Bug: 278634536
Test: simple perf and check the instruction count between T and U
Change-Id: I26989bf42aa00650ee97c3c60e7f34171c385c5c
diff --git a/services/surfaceflinger/tests/unittests/TestableSurfaceFlinger.h b/services/surfaceflinger/tests/unittests/TestableSurfaceFlinger.h
index a189c00..f135c2c 100644
--- a/services/surfaceflinger/tests/unittests/TestableSurfaceFlinger.h
+++ b/services/surfaceflinger/tests/unittests/TestableSurfaceFlinger.h
@@ -588,6 +588,7 @@
auto& mutablePhysicalDisplays() { return mFlinger->mPhysicalDisplays; }
auto& mutableDrawingState() { return mFlinger->mDrawingState; }
auto& mutableGeometryDirty() { return mFlinger->mGeometryDirty; }
+ auto& mutableVisibleRegionsDirty() { return mFlinger->mVisibleRegionsDirty; }
auto& mutableMainThreadId() { return mFlinger->mMainThreadId; }
auto& mutablePendingHotplugEvents() { return mFlinger->mPendingHotplugEvents; }
auto& mutableTexturePool() { return mFlinger->mTexturePool; }
@@ -599,6 +600,7 @@
auto& mutableHwcPhysicalDisplayIdMap() { return getHwComposer().mPhysicalDisplayIdMap; }
auto& mutablePrimaryHwcDisplayId() { return getHwComposer().mPrimaryHwcDisplayId; }
auto& mutableActiveDisplayId() { return mFlinger->mActiveDisplayId; }
+ auto& mutablePreviouslyComposedLayers() { return mFlinger->mPreviouslyComposedLayers; }
auto fromHandle(const sp<IBinder>& handle) { return LayerHandle::getLayer(handle); }