Remove legacy layer hierarchy
Legacy layer objects are now all stored in the mLegacyLayer map. They
are created on the binder thread and destroyed on the main thread.
Cloned layers do not have a legacy layer.
This change also keeps the create layer alive until main thread wakes up
to make the lifetime a bit simpler to track.
Flag: EXEMPT flag removal
Bug: 330785038
Test: presubmit
Change-Id: I4132e7a7c373c823ad914209955f7b0f55af008d
diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h
index 282c8cf..cee9160 100644
--- a/services/surfaceflinger/SurfaceFlinger.h
+++ b/services/surfaceflinger/SurfaceFlinger.h
@@ -389,11 +389,10 @@
class State {
public:
- explicit State(LayerVector::StateSet set) : stateSet(set), layersSortedByZ(set) {}
+ explicit State(LayerVector::StateSet set) : stateSet(set) {}
State& operator=(const State& other) {
// We explicitly don't copy stateSet so that, e.g., mDrawingState
// always uses the Drawing StateSet.
- layersSortedByZ = other.layersSortedByZ;
displays = other.displays;
colorMatrixChanged = other.colorMatrixChanged;
if (colorMatrixChanged) {
@@ -405,7 +404,6 @@
}
const LayerVector::StateSet stateSet = LayerVector::StateSet::Invalid;
- LayerVector layersSortedByZ;
// TODO(b/241285876): Replace deprecated DefaultKeyedVector with ftl::SmallMap.
DefaultKeyedVector<wp<IBinder>, DisplayDeviceState> displays;
@@ -425,10 +423,6 @@
mat4 colorMatrix;
ShadowSettings globalShadowSettings;
-
- void traverse(const LayerVector::Visitor& visitor) const;
- void traverseInZOrder(const LayerVector::Visitor& visitor) const;
- void traverseInReverseZOrder(const LayerVector::Visitor& visitor) const;
};
// Keeps track of pending buffers per layer handle in the transaction queue or current/drawing
@@ -847,8 +841,6 @@
status_t mirrorDisplay(DisplayId displayId, const LayerCreationArgs& args,
gui::CreateSurfaceResult& outResult);
- void markLayerPendingRemovalLocked(const sp<Layer>& layer) REQUIRES(mStateLock);
-
// add a layer to SurfaceFlinger
status_t addClientLayer(LayerCreationArgs& args, const sp<IBinder>& handle,
const sp<Layer>& layer, const wp<Layer>& parentLayer,
@@ -1202,7 +1194,6 @@
State mCurrentState{LayerVector::StateSet::Current};
std::atomic<int32_t> mTransactionFlags = 0;
std::atomic<uint32_t> mUniqueTransactionId = 1;
- SortedVector<sp<Layer>> mLayersPendingRemoval;
// Buffers that have been discarded by clients and need to be evicted from per-layer caches so
// the graphics memory can be immediately freed.
@@ -1392,13 +1383,6 @@
std::unordered_map<DisplayId, sp<HdrLayerInfoReporter>> mHdrLayerInfoListeners
GUARDED_BY(mStateLock);
- mutable std::mutex mCreatedLayersLock;
-
- // A temporay pool that store the created layers and will be added to current state in main
- // thread.
- std::vector<LayerCreatedState> mCreatedLayers GUARDED_BY(mCreatedLayersLock);
- void handleLayerCreatedLocked(const LayerCreatedState&, VsyncId) REQUIRES(mStateLock);
-
std::atomic<ui::Transform::RotationFlags> mActiveDisplayTransformHint;
// Must only be accessed on the main thread.
@@ -1439,6 +1423,8 @@
frontend::LayerHierarchyBuilder mLayerHierarchyBuilder GUARDED_BY(kMainThreadContext);
frontend::LayerSnapshotBuilder mLayerSnapshotBuilder GUARDED_BY(kMainThreadContext);
+ mutable std::mutex mCreatedLayersLock;
+ std::vector<sp<Layer>> mCreatedLayers GUARDED_BY(mCreatedLayersLock);
std::vector<std::pair<uint32_t, std::string>> mDestroyedHandles GUARDED_BY(mCreatedLayersLock);
std::vector<std::unique_ptr<frontend::RequestedLayerState>> mNewLayers
GUARDED_BY(mCreatedLayersLock);