Add a re-parent function to re-parent a specific child.
This is similar to reparentChildren, but the reparentChild will
only re-parent a specific child to the new parent and not all
children.
Test: Added test in Transaction_test for reparentChild.
Change-Id: I4275e0d5f1d5601b489956753c78a56d1a5d4c1c
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 6a01f30..4b079d6 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -3103,6 +3103,13 @@
// We don't trigger a traversal here because if no other state is
// changed, we don't want this to cause any more work
}
+ // Always re-parent the children that explicitly requested to get
+ // re-parented before the general re-parent of all children.
+ if (what & layer_state_t::eReparentChild) {
+ if (layer->reparentChild(s.parentHandleForChild, s.childHandle)) {
+ flags |= eTransactionNeeded|eTraversalNeeded;
+ }
+ }
if (what & layer_state_t::eReparentChildren) {
if (layer->reparentChildren(s.reparentHandle)) {
flags |= eTransactionNeeded|eTraversalNeeded;