Preserve relative z layer info when moving layers offscreen

When a layer is removed from screen, by reparenting it to null, we need to
remove its relative z info as well. Otherwise, if the layer has a visible
relative parent, it will continue to be drawn.

However, there are some scenarios where it maybe useful to preserve relative z.
When a layer is temporarily moved offscreen, and the layer has children with
relative z ordered to other children, then the client logic can be made simpler
by preserving the relative z info for all the children and only removing relative
z info if its relative parent is not on the pending removal state.

Bug: 132613412

Test: atest SurfaceFlinger_test
Test: go/wm-smoke
Change-Id: Id9e2d164673c9028fb27a38ab2b3005269ad4932
diff --git a/services/surfaceflinger/Layer.h b/services/surfaceflinger/Layer.h
index bbbc5b0..5c55111 100644
--- a/services/surfaceflinger/Layer.h
+++ b/services/surfaceflinger/Layer.h
@@ -571,6 +571,17 @@
     virtual bool isBufferLatched() const { return false; }
 
     /*
+     * Remove relative z for the layer if its relative parent is not part of the
+     * provided layer tree.
+     */
+    void removeRelativeZ(const std::vector<Layer*>& layersInTree);
+
+    /*
+     * Remove from current state and mark for removal.
+     */
+    void removeFromCurrentState();
+
+    /*
      * called with the state lock from a binder thread when the layer is
      * removed from the current list to the pending removal list
      */