SF: Commit created layers without using transactions
This solves a couple of issues:
1. This will remove the need to maintain a transaction
queue and a pending transaction queue. If we remove
one of the queues, we have to maintain transactions
by apply tokens and layer creation transactions will
create an order dependency between apply tokens.
2. For transaction tracing, layer creations are
tracked at the layer creation binder call. Tracking
internal layer creation transactions as well will
create an invalid state since the transaction is
a side effect not a client request.
Test: presubmit
Bug: 200284593
Change-Id: Ibfdf403dd0129801fcfb4c64229616d48f84fe9b
diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h
index 01709ab..b088535 100644
--- a/services/surfaceflinger/SurfaceFlinger.h
+++ b/services/surfaceflinger/SurfaceFlinger.h
@@ -1325,7 +1325,7 @@
std::unordered_map<DisplayId, sp<HdrLayerInfoReporter>> mHdrLayerInfoListeners
GUARDED_BY(mStateLock);
- mutable Mutex mCreatedLayersLock;
+ mutable std::mutex mCreatedLayersLock;
struct LayerCreatedState {
LayerCreatedState(const wp<Layer>& layer, const wp<Layer> parent, bool addToRoot)
: layer(layer), initialParent(parent), addToRoot(addToRoot) {}
@@ -1341,11 +1341,9 @@
// A temporay pool that store the created layers and will be added to current state in main
// thread.
- std::unordered_map<BBinder*, std::unique_ptr<LayerCreatedState>> mCreatedLayers;
- void setLayerCreatedState(const sp<IBinder>& handle, const wp<Layer>& layer,
- const wp<Layer> parent, bool addToRoot);
- auto getLayerCreatedState(const sp<IBinder>& handle);
- sp<Layer> handleLayerCreatedLocked(const sp<IBinder>& handle) REQUIRES(mStateLock);
+ std::vector<LayerCreatedState> mCreatedLayers GUARDED_BY(mCreatedLayersLock);
+ bool commitCreatedLayers();
+ void handleLayerCreatedLocked(const LayerCreatedState& state) REQUIRES(mStateLock);
std::atomic<ui::Transform::RotationFlags> mActiveDisplayTransformHint;