surfaceflinger: fix z-relative layer destruction
Layer::commitTransaction is called before Layer::onRemoved. The
removal of a layer from another layer's zOrderRelatives is not
reflected in Layer::mDrawingState until Layer::commitTransaction is
called again. As a result, we may draw a removed layer, which is
not supposed to own any HWC or GL resource.
Add Layer::onRemovedFromCurrentState that is called when a layer is
removed from mCurrentState to mLayersPendingRemoval. Move
zOrderRelative* updates from onRemoved to the new
onRemovedFromCurrentState, and set eTraversalNeeded as needed.
Also fix Layer::~Layer to restore the old behavior and destroy all
stale HWC layers just in case.
Bug:
64572777
Test: manual and AUPT
Change-Id: I546c5b4b7ecac0937fead655733402fae664331c