Skip to content

Remove single view assumption in Canvas #125780

@dkwingsmt

Description

@dkwingsmt

Canvas.cc depends on the device pixel ratio of window 0 in Canvas::drawShadow:

  // Not using SafeNarrow because DPR will always be a relatively small number.
  SkScalar dpr = static_cast<float>(UIDartState::Current()
                                        ->platform_configuration()
                                        ->get_window(0)
                                        ->viewport_metrics()
                                        .device_pixel_ratio);

We need to get rid of the get_window(0) in order to support multi-view.

Analysis:
One trivial solution is to make Canvas provide a DPR or make it tied to a view. However, it's too much of a change that will only be used for this feature.

Deeper analysis shows that this DPR is just multiplied with the provided elevation:

https://github.com/flutter/engine/blob/main/impeller/display_list/dl_dispatcher.cc#L1113

Technically we could make this work today by multiplying elevation by DPR in the framework. But this breaks the API.

cc @jonahwilliams @goderbauer @loic-sharma

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: multi windowIssues related to multi window supportengineflutter/engine related. See also e: labels.r: duplicateIssue is closed as a duplicate of an existing issueteam-engineOwned by Engine teamtriaged-engineTriaged by Engine team

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions