Skip to content

[DisplayList] Provide a method to transfer save stack state from one DisplayListBuilder to another #109563

@flar

Description

@flar

Currently, for our SkCanvas rendering, we apply rendering calls to either or both of a leaf_nodes_canvas (which is performing the actual rendering for the current under-over-inter-layer of our embedding stack) and/or an internal_nodes_canvas (which has all of the canvas objects for all of the embedding stack tied together in a multi-dispatch adapter). The latter allows us to track the transform/clip state for all of these canvas objects in parallel to avoid issues when we switch from one embedding layer to another.

A simpler implementation would be to provide a way to transfer the transform/clip/save stack from one graphics object to another, such as:

DisplayListBuilder::copyState(DisplayListBuilder& other) {
  // copy all entries from save_stack_ to other.save_stack_;
  other.transform_ = this.transform_;
  other.clip(_bounds)_ = this.clip(_bounds)_;
}

Note that since the outgoing graphics object will be retired when switching between embedding stack elements, this could also be a transfer operation that ended up with effectively restoring the source builder back to its initial state as it mirrors all of the items into the new builder. Perhaps offering both "copyState" and "move/transferState" depending on whether the caller wants to move or copy the state.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Issues that are less important to the Flutter projectengineflutter/engine related. See also e: labels.

    Type

    No type

    Projects

    Status

    ✅ Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions