The main upside is that traversal of the layer tree always only uses the children array and nothing else.
Variant B2
In the B2 variant, the mask is not part of the children array, but a separate member. This is better in that no element of the array has a special meaning just because of its array index. On the other hand, traversing all layers no longer requires reading children arrays only.
In GitLab by @viktorchlumsky on Oct 27, 2021, 11:23
Example case
Artboard:
Mask:
Layer hierarchy in editor UI:
Current state
Layers in editor UI order, everyone must hope that nothing comes between layer X and layers
maskedBy
X.Variant A - inlays as they are currently used in Rendering
Layers in drawing order, any layer can have an array of
inlays
- descendant layers.Main downside is that traversal of layer tree requires not only children of group layers but also "inlays" of all layers.
Variant B - special mask group layer type
The mask group does not represent an actual layer / group layer, but serves as a special node in the hierarchy.
Variant B1
In the B1 variant, the first child of a mask group is the mask.
The main upside is that traversal of the layer tree always only uses the
children
array and nothing else.Variant B2
In the B2 variant, the mask is not part of the children array, but a separate member. This is better in that no element of the array has a special meaning just because of its array index. On the other hand, traversing all layers no longer requires reading children arrays only.