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/LayerVector.h b/services/surfaceflinger/LayerVector.h
index 7dfa4a0..a9adb41 100644
--- a/services/surfaceflinger/LayerVector.h
+++ b/services/surfaceflinger/LayerVector.h
@@ -32,13 +32,22 @@
*/
class LayerVector : public SortedVector<sp<Layer>> {
public:
- LayerVector() = default;
+ LayerVector();
LayerVector(const LayerVector& rhs);
+ ~LayerVector() override;
+
+ enum class StateSet {
+ Invalid,
+ Current,
+ Drawing,
+ };
+
// Sorts layer by layer-stack, Z order, and finally creation order (sequence).
int do_compare(const void* lhs, const void* rhs) const override;
- void traverseInReverseZOrder(const std::function<void(Layer*)>& consume) const;
- void traverseInZOrder(const std::function<void(Layer*)>& consume) const;
+ using Visitor = std::function<void(Layer*)>;
+ void traverseInReverseZOrder(StateSet stateSet, const Visitor& visitor) const;
+ void traverseInZOrder(StateSet stateSet, const Visitor& visitor) const;
};
}