Use correct StateSet for LayerVector compare.
Currently LayerVector compare function was using the current StateSet.
This is incorect since the LayerVector may be created with the intention
of sorting the layers by drawing state. Instead, create the LayerVector
with a specified StateSet so the compare function always uses the
correct state.
This fixes an issue where the layers were getting added and sorted by
current state z order but the caller expected the order to be by drawing
state z order.
Change-Id: I7afef556fa72f687bcfeb0a642465488cc72f40b
Fixes: 80516823
Test: No longer flicker when IME closes. Logs show correct z order.
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index 8c1199b..10b3443 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -94,6 +94,8 @@
mLastFrameNumberReceived(0),
mAutoRefresh(false),
mFreezeGeometryUpdates(false),
+ mCurrentChildren(LayerVector::StateSet::Current),
+ mDrawingChildren(LayerVector::StateSet::Drawing),
mBE{this, name.string()} {
mCurrentCrop.makeInvalid();
@@ -133,7 +135,6 @@
CompositorTiming compositorTiming;
flinger->getCompositorTiming(&compositorTiming);
mFrameEventHistory.initializeCompositorTiming(compositorTiming);
-
}
void Layer::onFirstRef() {}
@@ -1677,7 +1678,7 @@
return children;
}
- LayerVector traverse;
+ LayerVector traverse(stateSet);
for (const wp<Layer>& weakRelative : state.zOrderRelatives) {
sp<Layer> strongRelative = weakRelative.promote();
if (strongRelative != nullptr) {
@@ -1775,7 +1776,7 @@
const LayerVector& children = useDrawing ? mDrawingChildren : mCurrentChildren;
const State& state = useDrawing ? mDrawingState : mCurrentState;
- LayerVector traverse;
+ LayerVector traverse(stateSet);
for (const wp<Layer>& weakRelative : state.zOrderRelatives) {
sp<Layer> strongRelative = weakRelative.promote();
// Only add relative layers that are also descendents of the top most parent of the tree.