Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 027013d8 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add documentation for layer drawing order" into main

parents 58b0cc83 bcaffd40
Loading
Loading
Loading
Loading
+23 −0
Original line number Diff line number Diff line
@@ -17,6 +17,29 @@ maintain policies at different levels without needing to understand the entire h
This allows control to be delegated to different parts of the system - such as SystemServer,
SysUI and Apps.

### Layer Drawing Order
Layers are drawn based on an inorder traversal, treating relative parents as
direct parents. Negative z-values place layers below their parent, while
non-negative values place them above. Layers with the same z-value are drawn
in creation order (newer on top).  However, relying on creation order for
z-ordering is discouraged; use unique z-values whenever possible for better
control.

Traversal pseudo code:
```
fn traverseBottomToTop(root):
  for each child node including relative children,
    sorted by z then layer id, with z less than 0:
          traverseBottomToTop(childNode)

  visit(root)

  for each child node including relative children,
    sorted by z then layer id, with z greater than
    or equal to 0:
          traverseBottomToTop(childNode)
```

### Layer Lifecycle
Layer is created by a client. The client receives a strong binder reference to the layer
handle, which will keep the layer alive as long as the client holds the reference. The