Respect relative layer value if in tree when screenshotting.

Relative layers need to be screenshotted so the dim layer can be
captured in the correct place. However, there are other relative layers
that are not in the tree that shouldn't be part of the screenshot. This
change allows relative layer value to be handled correctly as long as the
layer it's relative to is in the tree to capture. This ensures relative
layers in the tree are captured the correct order, but also ignores any
relative layers that are not in the tree.

Change-Id: If0e0ea1417f01ad1bfe518744ae2b9827009c4c6
Fixes: 77823704
Test: Open app with dialog and go to recents. Dim is screenshotted.
Test: Open app with IME and go to recents. IME is not screenshotted.
Test: Transaction_test#DontCaptureRelativeOutsideTree, CaptureRelativeInTree
3 files changed