SurfaceFlinger: Select which layer state to visit
Modifies the traverseIn[Reverse]ZOrder methods to also take an enum
value specifying whether to traverse the current state or the drawing
state.
This has the effect of fixing a bug where we weren't performing
transactions on a child layer because its parent was only visiting its
drawing layers (rather than its current layers) and was thus skipping
the child, which had not yet been moved from current to drawing.
Bug: 36858924
Test: ChildLayerTest.Bug36858924 doesn't hang
Change-Id: I1959f40bc07e77864ba024511d429592a398a67a
diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h
index c01f701..1bc689d 100644
--- a/services/surfaceflinger/SurfaceFlinger.h
+++ b/services/surfaceflinger/SurfaceFlinger.h
@@ -238,11 +238,21 @@
class State {
public:
+ 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;
+ return *this;
+ }
+
+ const LayerVector::StateSet stateSet = LayerVector::StateSet::Invalid;
LayerVector layersSortedByZ;
DefaultKeyedVector< wp<IBinder>, DisplayDeviceState> displays;
- void traverseInZOrder(const std::function<void(Layer*)>& consume) const;
- void traverseInReverseZOrder(const std::function<void(Layer*)>& consume) const;
+ void traverseInZOrder(const LayerVector::Visitor& visitor) const;
+ void traverseInReverseZOrder(const LayerVector::Visitor& visitor) const;
};
/* ------------------------------------------------------------------------
@@ -577,7 +587,7 @@
// access must be protected by mStateLock
mutable Mutex mStateLock;
- State mCurrentState;
+ State mCurrentState{LayerVector::StateSet::Current};
volatile int32_t mTransactionFlags;
Condition mTransactionCV;
bool mTransactionPending;
@@ -617,7 +627,7 @@
// Can only accessed from the main thread, these members
// don't need synchronization
- State mDrawingState;
+ State mDrawingState{LayerVector::StateSet::Drawing};
bool mVisibleRegionsDirty;
#ifndef USE_HWC2
bool mHwWorkListDirty;