Skip to content

Commit 027013d

Browse files
Treehugger RobotAndroid (Google) Code Review
authored andcommitted
Merge "Add documentation for layer drawing order" into main
2 parents 58b0cc8 + bcaffd4 commit 027013d

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

services/surfaceflinger/FrontEnd/readme.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,29 @@ maintain policies at different levels without needing to understand the entire h
1717
This allows control to be delegated to different parts of the system - such as SystemServer,
1818
SysUI and Apps.
1919

20+
### Layer Drawing Order
21+
Layers are drawn based on an inorder traversal, treating relative parents as
22+
direct parents. Negative z-values place layers below their parent, while
23+
non-negative values place them above. Layers with the same z-value are drawn
24+
in creation order (newer on top). However, relying on creation order for
25+
z-ordering is discouraged; use unique z-values whenever possible for better
26+
control.
27+
28+
Traversal pseudo code:
29+
```
30+
fn traverseBottomToTop(root):
31+
for each child node including relative children,
32+
sorted by z then layer id, with z less than 0:
33+
traverseBottomToTop(childNode)
34+
35+
visit(root)
36+
37+
for each child node including relative children,
38+
sorted by z then layer id, with z greater than
39+
or equal to 0:
40+
traverseBottomToTop(childNode)
41+
```
42+
2043
### Layer Lifecycle
2144
Layer is created by a client. The client receives a strong binder reference to the layer
2245
handle, which will keep the layer alive as long as the client holds the reference. The

0 commit comments

Comments
 (0)