Skip to content

Provide ui.Canvas.getCurrentMatrix and getCurrentClip #103469

@dnfield

Description

@dnfield

This would be useful when dealing with a render Object that wants to traverse the layer tree to find transformation/clip information, since the layer tree is generally shallower than the render tree. However, a RO has no way currently of determining whether its own canvas has been transformed or clipped - it can't use the describeApproximateClip or applyPaintTransform methods because it doesn't know when to stop querying parents and start querying the layer tree, and it can't jump right into the layer tree because it then misses transforms/clips applied already directly to its canvas.

AFAIU, these methods are currently implemented in SkCanvas/DisplayList, e.g. https://github.com/google/skia/blob/8d3d0bcd4b2c469d8f5272d42916d8a0554950a3/include/core/SkCanvas.h#L2127 and https://github.com/google/skia/blob/8d3d0bcd4b2c469d8f5272d42916d8a0554950a3/include/core/SkCanvas.h#L1064.

I can't find methods on DL that currently support this but it seems like it wouldn't be terribly hard to add - provided there's agreement that this would be an API worth exposing.

An alternative new API we could add in the framework would instead track when the canvas gets transforms/clips concatenated to it and provide them on something like the PaintingContext.

@goderbauer for framework input
@flar for displaylist input.

Please feel free to tell me this is a terrible idea and not worth any small performance gains we might get from it :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Issues that are less important to the Flutter projectc: new featureNothing broken; request for a new capabilityengineflutter/engine related. See also e: labels.frameworkflutter/packages/flutter repository. See also f: labels.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions