Skip to content

Drawing RTree DisplayList into another RTree DisplayList ferries all of the rectangles #139323

@flar

Description

@flar

In order to compute the most accurate pixel coverage for embedded platform layers the DisplayList will include the exact RTree coverage of a DisplayList when you draw one into another - only if both are calculating an RTree (see flutter/engine#37451). In order to accomplish this exact accounting we copy all of the rectangles from the child DL's RTree into the parent DL's RTree. This involves a lot of duplication of data and the parent RTree now has many rectangles that all reference the same "rendering ID" which is redundant while traversing the tree for rendering.

The impact of this was discovered during a local Impeller profiling session and led to turning off the prepare_rtree flag for at least one Canvas in the system that wouldn't need to produce this exact pixel coverage (see flutter/engine#48422).

One thought on improving the performance of this operation would be to include the child RTrees by reference into the parent RTree. This would involve far less copying, but it would complicate the traversal. This would save storage overall and when we are using the RTree for culling we don't need to test every single sub-rectangle for the culling test, we just need to test the overall bounds of the child RTree. The only time we need to look at every sub-rectangle is collecting coverage info for the platform view, which is a relatively rare operation since many apps do not embed platform widgets.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Issues that are less important to the Flutter projectengineflutter/engine related. See also e: labels.team-engineOwned by Engine teamtriaged-engineTriaged by Engine team

    Type

    No type

    Projects

    Status

    ⚡ Performance

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions